Merge contexts for session cache

parent ae319149
......@@ -23,6 +23,8 @@ API Changes
mbedtls_ctr_drbg_init() -> mbedtls_ctr_drbg_init(_buf)()
* mbedtls_ssl_set_ca_chain() lost its last argument (peer_cn), now set
using mbedtls_ssl_set_hostname().
* mbedtls_ssl_set_session_cached() changed prototype (only one context
pointer, parameters reordered).
* mbedtls_memory_bufer_alloc_init() now returns void
* In the threading layer, mbedtls_mutex_init() and mbedtls_mutex_free() now
return void.
......
......@@ -807,10 +807,9 @@ typedef struct
/** Callback to retrieve a session from the cache */
int (*f_get_cache)(void *, mbedtls_ssl_session *);
void *p_get_cache; /*!< context for cache retrieval */
/** Callback to store a session into the cache */
int (*f_set_cache)(void *, const mbedtls_ssl_session *);
void *p_set_cache; /*!< context for cache store */
void *p_cache; /*!< context for cache callbacks */
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
/** Callback for setting cert according to SNI extension */
......@@ -1482,14 +1481,14 @@ void mbedtls_ssl_set_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min,
* successfully cached, return 1 otherwise.
*
* \param conf SSL configuration
* \param p_cache parmater (context) for both callbacks
* \param f_get_cache session get callback
* \param p_get_cache session get parameter
* \param f_set_cache session set callback
* \param p_set_cache session set parameter
*/
void mbedtls_ssl_set_session_cache( mbedtls_ssl_config *conf,
int (*f_get_cache)(void *, mbedtls_ssl_session *), void *p_get_cache,
int (*f_set_cache)(void *, const mbedtls_ssl_session *), void *p_set_cache );
void *p_cache,
int (*f_get_cache)(void *, mbedtls_ssl_session *),
int (*f_set_cache)(void *, const mbedtls_ssl_session *) );
#endif /* MBEDTLS_SSL_SRV_C */
#if defined(MBEDTLS_SSL_CLI_C)
......
......@@ -2475,7 +2475,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
#endif
ssl->session_negotiate->length != 0 &&
ssl->conf->f_get_cache != NULL &&
ssl->conf->f_get_cache( ssl->conf->p_get_cache, ssl->session_negotiate ) == 0 )
ssl->conf->f_get_cache( ssl->conf->p_cache, ssl->session_negotiate ) == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from cache" ) );
ssl->handshake->resume = 1;
......
......@@ -4575,7 +4575,7 @@ void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl )
ssl->session->length != 0 &&
resume == 0 )
{
if( ssl->conf->f_set_cache( ssl->conf->p_set_cache, ssl->session ) != 0 )
if( ssl->conf->f_set_cache( ssl->conf->p_cache, ssl->session ) != 0 )
MBEDTLS_SSL_DEBUG_MSG( 1, ( "cache did not store session" ) );
}
......@@ -5245,13 +5245,13 @@ void mbedtls_ssl_set_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout )
#if defined(MBEDTLS_SSL_SRV_C)
void mbedtls_ssl_set_session_cache( mbedtls_ssl_config *conf,
int (*f_get_cache)(void *, mbedtls_ssl_session *), void *p_get_cache,
int (*f_set_cache)(void *, const mbedtls_ssl_session *), void *p_set_cache )
void *p_cache,
int (*f_get_cache)(void *, mbedtls_ssl_session *),
int (*f_set_cache)(void *, const mbedtls_ssl_session *) )
{
conf->p_cache = p_cache;
conf->f_get_cache = f_get_cache;
conf->p_get_cache = p_get_cache;
conf->f_set_cache = f_set_cache;
conf->p_set_cache = p_set_cache;
}
#endif /* MBEDTLS_SSL_SRV_C */
......
......@@ -210,9 +210,9 @@ int main( void )
mbedtls_ssl_set_dbg( &conf, my_debug, stdout );
#if defined(MBEDTLS_SSL_CACHE_C)
mbedtls_ssl_set_session_cache( &conf,
mbedtls_ssl_cache_get, &cache,
mbedtls_ssl_cache_set, &cache );
mbedtls_ssl_set_session_cache( &conf, &cache,
mbedtls_ssl_cache_get,
mbedtls_ssl_cache_set );
#endif
mbedtls_ssl_set_ca_chain( &conf, srvcert.next, NULL );
......
......@@ -209,9 +209,9 @@ int main( void )
mbedtls_ssl_set_dbg( &conf, my_debug, stdout );
#if defined(MBEDTLS_SSL_CACHE_C)
mbedtls_ssl_set_session_cache( &conf,
mbedtls_ssl_cache_get, &cache,
mbedtls_ssl_cache_set, &cache );
mbedtls_ssl_set_session_cache( &conf, &cache,
mbedtls_ssl_cache_get,
mbedtls_ssl_cache_set );
#endif
mbedtls_ssl_set_ca_chain( &conf, srvcert.next, NULL );
......
......@@ -1584,9 +1584,9 @@ int main( int argc, char *argv[] )
if( opt.cache_timeout != -1 )
mbedtls_ssl_cache_set_timeout( &cache, opt.cache_timeout );
mbedtls_ssl_set_session_cache( &conf,
mbedtls_ssl_cache_get, &cache,
mbedtls_ssl_cache_set, &cache );
mbedtls_ssl_set_session_cache( &conf, &cache,
mbedtls_ssl_cache_get,
mbedtls_ssl_cache_set );
#endif
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment