Add config MBEDTLS_SSL_SESSION_CACHE

Add configuration option MBEDTLS_SSL_SESSION_CACHE to control
enabling/disabling of the cache based session resumption.
This commit is contained in:
Jarno Lamsa 2019-06-18 13:07:17 +03:00 committed by Manuel Pégourié-Gonnard
parent 4e24c449e2
commit 7be14065e2
9 changed files with 40 additions and 12 deletions

View file

@ -7273,7 +7273,9 @@ static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl )
void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl )
{
#if defined(MBEDTLS_SSL_SESSION_CACHE)
int resume = ssl->handshake->resume;
#endif /* MBEDTLS_SSL_SESSION_CACHE */
MBEDTLS_SSL_DEBUG_MSG( 3, ( "=> handshake wrapup" ) );
@ -7302,6 +7304,7 @@ void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl )
ssl->session = ssl->session_negotiate;
ssl->session_negotiate = NULL;
#if defined(MBEDTLS_SSL_SESSION_CACHE)
/*
* Add cache entry
*/
@ -7312,6 +7315,7 @@ void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl )
if( ssl->conf->f_set_cache( ssl->conf->p_cache, ssl->session ) != 0 )
MBEDTLS_SSL_DEBUG_MSG( 1, ( "cache did not store session" ) );
}
#endif /* MBEDTLS_SSL_SESSION_CACHE */
#if defined(MBEDTLS_SSL_PROTO_DTLS)
if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) &&
@ -8152,7 +8156,7 @@ void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *ssl,
ssl_set_timer( ssl, 0 );
}
#if defined(MBEDTLS_SSL_SRV_C)
#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_SESSION_CACHE)
void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf,
void *p_cache,
int (*f_get_cache)(void *, mbedtls_ssl_session *),
@ -8162,9 +8166,9 @@ void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf,
conf->f_get_cache = f_get_cache;
conf->f_set_cache = f_set_cache;
}
#endif /* MBEDTLS_SSL_SRV_C */
#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_SESSION_CACHE */
#if defined(MBEDTLS_SSL_CLI_C)
#if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_SSL_SESSION_CACHE)
int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session )
{
int ret;
@ -8185,7 +8189,7 @@ int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session
return( 0 );
}
#endif /* MBEDTLS_SSL_CLI_C */
#endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_SSL_SESSION_CACHE */
void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf,
const int *ciphersuites )