diff --git a/ChangeLog b/ChangeLog index e3c335e23..515b19eca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,24 +38,12 @@ Features ServerHello. * Add new configuration option MBEDTLS_SSL_PROTO_NO_TLS that enables code size savings in configurations where only DTLS is used. - -API Changes - * Add a new X.509 API call `mbedtls_x509_parse_der_nocopy()`. - See the Features section for more information. - * Allow to opt in to the removal the API mbedtls_ssl_get_peer_cert() - for the benefit of saving RAM, by disabling the new compile-time - option MBEDTLS_SSL_KEEP_PEER_CERTIFICATE (enabled by default for - API stability). Disabling this option makes mbedtls_ssl_get_peer_cert() - always return NULL, and removes the peer_cert field from the - mbedtls_ssl_session structure which otherwise stores the peer's - certificate. - * Add a new compile-time option `MBEDTLS_X509_ON_DEMAND_PARSING`, - disabled by default, which allows to parse and cache X.509 CRTs - on demand only, at the benefit of lower RAM usage. Enabling - this option breaks the structure API of X.509 in that most - fields of `mbedtls_x509_crt` are removed, but it keeps the - X.509 function API. See the API changes section as well as - the documentation in `config.h` for more information. + * Add new configuration option MBEDTLS_SSL_NO_SESSION_CACHE that enables + code size savings in configurations where cache-based session resumption is + not used. + * Add new configuration option MBEDTLS_SSL_NO_SESSION_RESUMPTION that + enables code size savings in configurations where no form of session + resumption is used. Bugfix * Server's RSA certificate in certs.c was SHA-1 signed. In the default @@ -105,6 +93,24 @@ Changes improve clarity. Fixes #2258. * Replace multiple uses of MD2 by SHA-256 in X.509 test suite. Fixes #821. +API Changes + * Add a new X.509 API call `mbedtls_x509_parse_der_nocopy()`. + See the Features section for more information. + * Allow to opt in to the removal the API mbedtls_ssl_get_peer_cert() + for the benefit of saving RAM, by disabling the new compile-time + option MBEDTLS_SSL_KEEP_PEER_CERTIFICATE (enabled by default for + API stability). Disabling this option makes mbedtls_ssl_get_peer_cert() + always return NULL, and removes the peer_cert field from the + mbedtls_ssl_session structure which otherwise stores the peer's + certificate. + * Add a new compile-time option `MBEDTLS_X509_ON_DEMAND_PARSING`, + disabled by default, which allows to parse and cache X.509 CRTs + on demand only, at the benefit of lower RAM usage. Enabling + this option breaks the structure API of X.509 in that most + fields of `mbedtls_x509_crt` are removed, but it keeps the + X.509 function API. See the API changes section as well as + the documentation in `config.h` for more information. + = mbed TLS 2.16.1 branch released 2019-03-19 Features diff --git a/configs/baremetal.h b/configs/baremetal.h index 12fa136dc..60b7f0aeb 100644 --- a/configs/baremetal.h +++ b/configs/baremetal.h @@ -71,6 +71,8 @@ #define MBEDTLS_SSL_TLS_C #define MBEDTLS_SSL_PROTO_TLS1_2 #define MBEDTLS_SSL_EXTENDED_MASTER_SECRET +#define MBEDTLS_SSL_NO_SESSION_CACHE +#define MBEDTLS_SSL_NO_SESSION_RESUMPTION #define MBEDTLS_SSL_COOKIE_C #define MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_PROTO_NO_TLS diff --git a/include/mbedtls/check_config.h b/include/mbedtls/check_config.h index 88f47011b..86f11ed3b 100644 --- a/include/mbedtls/check_config.h +++ b/include/mbedtls/check_config.h @@ -671,6 +671,16 @@ #error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" #endif +#if defined(MBEDTLS_SSL_SESSION_TICKETS) && \ + defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) +#error "MBEDTLS_SSL_SESSION_TICKETS cannot be defined with MBEDTLS_SSL_NO_SESSION_RESUMPTION" +#endif + +#if !defined(MBEDTLS_SSL_NO_SESSION_CACHE) && \ + defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) +#error "MBEDTLS_SSL_NO_SESSION_CACHE needs to be defined with MBEDTLS_SSL_NO_SESSION_RESUMPTION" +#endif + #if defined(MBEDTLS_THREADING_PTHREAD) #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) #error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites" diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h index 796b0bb2c..a1c6fde7b 100644 --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h @@ -1278,8 +1278,8 @@ * which allows to identify DTLS connections across changes * in the underlying transport. * - * Setting this option enables the SSL APIs `mbedtls_ssl_set_cid()`, - * `mbedtls_ssl_get_peer_cid()` and `mbedtls_ssl_conf_cid()`. + * Setting this option enables the SSL APIs mbedtls_ssl_set_cid(), + * mbedtls_ssl_get_peer_cid() and mbedtls_ssl_conf_cid(). * See the corresponding documentation for more information. * * \warning The Connection ID extension is still in draft state. @@ -1664,10 +1664,63 @@ * tickets, including authenticated encryption and key management. Example * callbacks are provided by MBEDTLS_SSL_TICKET_C. * - * Comment this macro to disable support for SSL session tickets + * Requires: !MBEDTLS_SSL_NO_SESSION_RESUMPTION + * + * Comment this macro to disable support for SSL session tickets. */ #define MBEDTLS_SSL_SESSION_TICKETS +/** + * \def MBEDTLS_SSL_NO_SESSION_CACHE + * + * Disable support for cache based session resumption. This is useful to + * reduce code size in configurations where cache-based session resumption is + * not used. + * + * This option is only about the server-side support of the session caches. + * Client will only need !MBEDTLS_SSL_NO_SESSION_RESUMPTION to support + * cache based session resumption. + * + * Server-side, you also need to provide callbacks for storing and reading + * sessions from cache. Example callbacks are provided by MBEDTLS_SSL_CACHE_C. + * + * If MBEDTLS_SSL_NO_SESSION_RESUMPTION is defined, this needs to be defined + * as well. + * + * Uncomment this macro to disable support for SSL session cache. + */ +//#define MBEDTLS_SSL_NO_SESSION_CACHE + +/** + * \def MBEDTLS_SSL_NO_SESSION_RESUMPTION + * + * Disable support for session resumption. This is useful to reduce code size + * in configurations where no form of session resumption is used. + * + * \note Session resumption is part of the TLS standard, disabling this + * option means that the full implementation of the standard is no longer + * used. This shouldn't cause any interoperability issues as the standard + * mandates that peers who want to resume a session need to be prepared to + * fall back to a full handshake. + * + * When this flag is enabled, following needs to be true: + * MBEDTLS_SSL_NO_SESSION_CACHE enabled + * MBEDTLS_SSL_SESSION_TICKETS disabled + * + * Client-side, this is enough to enable support for cache-based session + * resumption (as defined by the TLS standard); for ticket-based resumption + * you'll also need to enable MBEDTLS_SSL_SESSION_TICKETS. + * + * Server-side, this option is only useful in conjunction with at least + * one of !MBEDTLS_SSL_NO_SESSION_CACHE or MBEDTLS_SSL_SESSION_TICKETS. + * Each one of these additionally requires an implementation of the cache + * or tickets, examples of which are provided by MBEDTLS_SSL_CACHE_C + * and MBEDTLS_SSL_TICKET_C respectively. + * + * Uncomment this macro to disable support for SSL session resumption. + */ +//#define MBEDTLS_SSL_NO_SESSION_RESUMPTION + /** * \def MBEDTLS_SSL_EXPORT_KEYS * diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index b51708970..517eb4e77 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -906,11 +906,13 @@ struct mbedtls_ssl_config int (*f_rng)(void *, unsigned char *, size_t); void *p_rng; /*!< context for the RNG function */ +#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) /** Callback to retrieve a session from the cache */ int (*f_get_cache)(void *, mbedtls_ssl_session *); /** Callback to store a session into the cache */ int (*f_set_cache)(void *, const mbedtls_ssl_session *); void *p_cache; /*!< context for cache callbacks */ +#endif /* MBEDTLS_SSL_SRV_C && !MBEDTLS_SSL_NO_SESSION_CACHE */ #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) /** Callback for setting cert according to SNI extension */ @@ -2129,7 +2131,7 @@ void mbedtls_ssl_set_datagram_packing( mbedtls_ssl_context *ssl, void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ -#if defined(MBEDTLS_SSL_SRV_C) +#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) /** * \brief Set the session cache callbacks (server-side only) * If not set, no session resuming is done (except if session @@ -2171,9 +2173,9 @@ void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf, 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 */ +#endif /* MBEDTLS_SSL_SRV_C && !MBEDTLS_SSL_NO_SESSION_CACHE */ -#if defined(MBEDTLS_SSL_CLI_C) +#if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) /** * \brief Request resumption of session (client-side only) * Session data is copied from presented session structure. @@ -2189,7 +2191,7 @@ void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf, * \sa mbedtls_ssl_get_session() */ int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session ); -#endif /* MBEDTLS_SSL_CLI_C */ +#endif /* MBEDTLS_SSL_CLI_C && !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ /** * \brief Load serialized session data into a session structure. diff --git a/include/mbedtls/ssl_internal.h b/include/mbedtls/ssl_internal.h index 7009c4f8b..8803e8322 100644 --- a/include/mbedtls/ssl_internal.h +++ b/include/mbedtls/ssl_internal.h @@ -509,7 +509,9 @@ struct mbedtls_ssl_handshake_params unsigned char premaster[MBEDTLS_PREMASTER_SIZE]; /*!< premaster secret */ +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) int resume; /*!< session resume indicator*/ +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ int max_major_ver; /*!< max. major version client*/ int max_minor_ver; /*!< max. minor version client*/ int cli_exts; /*!< client extension presence*/ @@ -1080,6 +1082,33 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context *ssl, mbedtls_record *rec ); +/* + * Accessor functions for optional fields of various structures + */ + +static inline int mbedtls_ssl_handshake_get_resume( + const mbedtls_ssl_handshake_params *handshake ) +{ +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) + return( handshake->resume ); +#else + (void) handshake; + return( 0 ); +#endif +} + +static inline int mbedtls_ssl_get_renego_status( + const mbedtls_ssl_context *ssl ) +{ +#if defined(MBEDTLS_SSL_RENEGOTIATION) + return( ssl->renego_status ); +#else + (void) ssl; + return( MBEDTLS_SSL_INITIAL_HANDSHAKE ); +#endif +} + + /* * Getter functions for fields in mbedtls_ssl_config which may * be fixed at compile time via one of MBEDTLS_SSL_SSL_CONF_XXX. diff --git a/library/ssl_cli.c b/library/ssl_cli.c index 0f75b1c32..80a6da27c 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -828,9 +828,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_NO_RNG ); } -#if defined(MBEDTLS_SSL_RENEGOTIATION) - if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) -#endif + if( mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE ) { ssl->major_ver = ssl->conf->min_major_ver; ssl->minor_ver = ssl->conf->min_minor_ver; @@ -882,36 +880,40 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) * .. . .. extensions length (2 bytes) * .. . .. extensions */ - n = ssl->session_negotiate->id_len; - if( n < 16 || n > 32 || -#if defined(MBEDTLS_SSL_RENEGOTIATION) - ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE || -#endif - ssl->handshake->resume == 0 ) + /* + * We'll write a session of non-zero length if resumption was requested + * by the user, we're not renegotiating, and the session ID is of + * appropriate length. Otherwise make the length 0 (for now, see next code + * block for behaviour with tickets). + */ + if( mbedtls_ssl_handshake_get_resume( ssl->handshake ) == 0 || + mbedtls_ssl_get_renego_status( ssl ) != MBEDTLS_SSL_INITIAL_HANDSHAKE || + ssl->session_negotiate->id_len < 16 || + ssl->session_negotiate->id_len > 32 ) { n = 0; } + else + { + n = ssl->session_negotiate->id_len; + } #if defined(MBEDTLS_SSL_SESSION_TICKETS) /* * RFC 5077 section 3.4: "When presenting a ticket, the client MAY * generate and include a Session ID in the TLS ClientHello." */ -#if defined(MBEDTLS_SSL_RENEGOTIATION) - if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) -#endif + if( mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE && + ssl->session_negotiate->ticket != NULL && + ssl->session_negotiate->ticket_len != 0 ) { - if( ssl->session_negotiate->ticket != NULL && - ssl->session_negotiate->ticket_len != 0 ) - { - ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id, 32 ); + ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->session_negotiate->id, 32 ); - if( ret != 0 ) - return( ret ); + if( ret != 0 ) + return( ret ); - ssl->session_negotiate->id_len = n = 32; - } + ssl->session_negotiate->id_len = n = 32; } #endif /* MBEDTLS_SSL_SESSION_TICKETS */ @@ -985,9 +987,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) /* * Add TLS_EMPTY_RENEGOTIATION_INFO_SCSV */ -#if defined(MBEDTLS_SSL_RENEGOTIATION) - if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) -#endif + if( mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding EMPTY_RENEGOTIATION_INFO_SCSV" ) ); *p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO >> 8 ); @@ -1797,28 +1797,30 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) /* * Check if the session can be resumed + * + * We're only resuming a session if it was requested (handshake->resume + * already set to 1 by mbedtls_ssl_set_session()), and further conditions + * are satisfied (not renegotiating, ID and ciphersuite match, etc). + * + * Update handshake->resume to the value it will keep for the rest of the + * handshake, and that will be used to determine the relative order + * client/server last flights, as well as in handshake_wrapup(). */ - if( ssl->handshake->resume == 0 || n == 0 || -#if defined(MBEDTLS_SSL_RENEGOTIATION) - ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE || -#endif +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) + if( n == 0 || + mbedtls_ssl_get_renego_status( ssl ) != MBEDTLS_SSL_INITIAL_HANDSHAKE || ssl->session_negotiate->ciphersuite != i || ssl->session_negotiate->compression != comp || ssl->session_negotiate->id_len != n || memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 ) { - ssl->state++; ssl->handshake->resume = 0; -#if defined(MBEDTLS_HAVE_TIME) - ssl->session_negotiate->start = mbedtls_time( NULL ); -#endif - ssl->session_negotiate->ciphersuite = i; - ssl->session_negotiate->compression = comp; - ssl->session_negotiate->id_len = n; - memcpy( ssl->session_negotiate->id, buf + 35, n ); } - else +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ + + if( mbedtls_ssl_handshake_get_resume( ssl->handshake ) == 1 ) { + /* Resume a session */ ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) @@ -1829,9 +1831,21 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) return( ret ); } } + else + { + /* Start a new session */ + ssl->state++; +#if defined(MBEDTLS_HAVE_TIME) + ssl->session_negotiate->start = mbedtls_time( NULL ); +#endif + ssl->session_negotiate->ciphersuite = i; + ssl->session_negotiate->compression = comp; + ssl->session_negotiate->id_len = n; + memcpy( ssl->session_negotiate->id, buf + 35, n ); + } MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", - ssl->handshake->resume ? "a" : "no" ) ); + mbedtls_ssl_handshake_get_resume( ssl->handshake ) ? "a" : "no" ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %04x", i ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: %d", buf[37 + n] ) ); diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 94b4d7333..a69e8b46f 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1341,16 +1341,12 @@ read_record_header: * otherwise read it ourselves manually in order to support SSLv2 * ClientHello, which doesn't use the same record layer format. */ -#if defined(MBEDTLS_SSL_RENEGOTIATION) - if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE ) -#endif + if( mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE && + ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 ) { - if( ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 ) - { - /* No alert on a read error. */ - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); - return( ret ); - } + /* No alert on a read error. */ + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret ); + return( ret ); } buf = ssl->in_hdr; @@ -1405,11 +1401,8 @@ read_record_header: /* For DTLS if this is the initial handshake, remember the client sequence * number to use it in our next message (RFC 6347 4.2.1) */ #if defined(MBEDTLS_SSL_PROTO_DTLS) - if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) -#if defined(MBEDTLS_SSL_RENEGOTIATION) - && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE -#endif - ) + if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) && + mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE ) { /* Epoch should be 0 for initial handshakes */ if( ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0 ) @@ -1670,11 +1663,8 @@ read_record_header: buf + cookie_offset + 1, cookie_len ); #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) - if( ssl->conf->f_cookie_check != NULL -#if defined(MBEDTLS_SSL_RENEGOTIATION) - && ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE -#endif - ) + if( ssl->conf->f_cookie_check != NULL && + mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE ) { if( ssl->conf->f_cookie_check( ssl->conf->p_cookie, buf + cookie_offset + 1, cookie_len, @@ -2691,15 +2681,14 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 6, 32 ); +#if !defined(MBEDTLS_SSL_NO_SESSION_CACHE) /* * Resume is 0 by default, see ssl_handshake_init(). * It may be already set to 1 by ssl_parse_session_ticket_ext(). * If not, try looking up session ID in our cache. */ - if( ssl->handshake->resume == 0 && -#if defined(MBEDTLS_SSL_RENEGOTIATION) - ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE && -#endif + if( mbedtls_ssl_handshake_get_resume( ssl->handshake ) == 0 && + mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE && ssl->session_negotiate->id_len != 0 && ssl->conf->f_get_cache != NULL && ssl->conf->f_get_cache( ssl->conf->p_cache, ssl->session_negotiate ) == 0 ) @@ -2707,8 +2696,25 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from cache" ) ); ssl->handshake->resume = 1; } +#endif /* !MBEDTLS_SSL_NO_SESSION_CACHE */ - if( ssl->handshake->resume == 0 ) +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) + if( mbedtls_ssl_handshake_get_resume( ssl->handshake ) == 1 ) + { + /* + * Resuming a session + */ + n = ssl->session_negotiate->id_len; + ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; + + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); + return( ret ); + } + } + else +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ { /* * New session, create a new session id, @@ -2735,20 +2741,6 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) return( ret ); } } - else - { - /* - * Resuming a session - */ - n = ssl->session_negotiate->id_len; - ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC; - - if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); - return( ret ); - } - } /* * 38 . 38 session id length @@ -2765,7 +2757,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) ); MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 39, n ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", - ssl->handshake->resume ? "a" : "no" ) ); + mbedtls_ssl_handshake_get_resume( ssl->handshake ) ? "a" : "no" ) ); *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite >> 8 ); *p++ = (unsigned char)( ssl->session_negotiate->ciphersuite ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 4c1a5c52a..79204a77f 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -1263,11 +1263,13 @@ static int ssl_compute_master( mbedtls_ssl_handshake_params *handshake, (void) ssl; #endif +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) if( handshake->resume != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) ); return( 0 ); } +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ MBEDTLS_SSL_DEBUG_BUF( 3, "premaster secret", handshake->premaster, handshake->pmslen ); @@ -7285,8 +7287,6 @@ static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl ) void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ) { - int resume = ssl->handshake->resume; - MBEDTLS_SSL_DEBUG_MSG( 3, ( "=> handshake wrapup" ) ); #if defined(MBEDTLS_SSL_RENEGOTIATION) @@ -7314,16 +7314,18 @@ void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl ) ssl->session = ssl->session_negotiate; ssl->session_negotiate = NULL; +#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) /* * Add cache entry */ if( ssl->conf->f_set_cache != NULL && ssl->session->id_len != 0 && - resume == 0 ) + ssl->handshake->resume == 0 ) { 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_SRV_C && !MBEDTLS_SSL_NO_SESSION_CACHE */ #if defined(MBEDTLS_SSL_PROTO_DTLS) if( MBEDTLS_SSL_TRANSPORT_IS_DTLS( ssl->conf->transport ) && @@ -7372,6 +7374,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_FINISHED; +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) /* * In case of session resuming, invert the client and server * ChangeCipherSpec messages order. @@ -7388,6 +7391,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) #endif } else +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ ssl->state++; /* @@ -7528,6 +7532,7 @@ int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ) memcpy( ssl->peer_verify_data, buf, hash_len ); #endif +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) if( ssl->handshake->resume != 0 ) { #if defined(MBEDTLS_SSL_CLI_C) @@ -7540,6 +7545,7 @@ int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ) #endif } else +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ ssl->state++; #if defined(MBEDTLS_SSL_PROTO_DTLS) @@ -8164,7 +8170,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_NO_SESSION_CACHE) void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf, void *p_cache, int (*f_get_cache)(void *, mbedtls_ssl_session *), @@ -8174,9 +8180,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_NO_SESSION_CACHE */ -#if defined(MBEDTLS_SSL_CLI_C) +#if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session ) { int ret; @@ -8197,7 +8203,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_NO_SESSION_RESUMPTION */ void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf, const int *ciphersuites ) diff --git a/library/version_features.c b/library/version_features.c index 8d3f2adb0..c0b102dd2 100644 --- a/library/version_features.c +++ b/library/version_features.c @@ -513,6 +513,12 @@ static const char *features[] = { #if defined(MBEDTLS_SSL_SESSION_TICKETS) "MBEDTLS_SSL_SESSION_TICKETS", #endif /* MBEDTLS_SSL_SESSION_TICKETS */ +#if defined(MBEDTLS_SSL_NO_SESSION_CACHE) + "MBEDTLS_SSL_NO_SESSION_CACHE", +#endif /* MBEDTLS_SSL_NO_SESSION_CACHE */ +#if defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) + "MBEDTLS_SSL_NO_SESSION_RESUMPTION", +#endif /* MBEDTLS_SSL_NO_SESSION_RESUMPTION */ #if defined(MBEDTLS_SSL_EXPORT_KEYS) "MBEDTLS_SSL_EXPORT_KEYS", #endif /* MBEDTLS_SSL_EXPORT_KEYS */ diff --git a/programs/ssl/dtls_server.c b/programs/ssl/dtls_server.c index dd21fbf47..6566baef5 100644 --- a/programs/ssl/dtls_server.c +++ b/programs/ssl/dtls_server.c @@ -236,11 +236,11 @@ int main( void ) mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); -#if defined(MBEDTLS_SSL_CACHE_C) +#if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) mbedtls_ssl_conf_session_cache( &conf, &cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set ); -#endif +#endif /* MBEDTLS_SSL_CACHE_C && !MBEDTLS_SSL_NO_SESSION_CACHE */ mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) diff --git a/programs/ssl/query_config.c b/programs/ssl/query_config.c index e62341d49..8e6ef23ee 100644 --- a/programs/ssl/query_config.c +++ b/programs/ssl/query_config.c @@ -1410,6 +1410,22 @@ int query_config( const char *config ) } #endif /* MBEDTLS_SSL_SESSION_TICKETS */ +#if defined(MBEDTLS_SSL_NO_SESSION_CACHE) + if( strcmp( "MBEDTLS_SSL_NO_SESSION_CACHE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_NO_SESSION_CACHE ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_NO_SESSION_CACHE */ + +#if defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) + if( strcmp( "MBEDTLS_SSL_NO_SESSION_RESUMPTION", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_NO_SESSION_RESUMPTION ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_NO_SESSION_RESUMPTION */ + #if defined(MBEDTLS_SSL_EXPORT_KEYS) if( strcmp( "MBEDTLS_SSL_EXPORT_KEYS", config ) == 0 ) { diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 982857659..dd194f316 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -2545,12 +2545,14 @@ reconnect: } } +#if !defined(MBEDTLS_SSL_NO_SESSION_RESUMPTION) if( ( ret = mbedtls_ssl_set_session( &ssl, &saved_session ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ssl_set_session returned -0x%x\n\n", -ret ); goto exit; } +#endif /* !MBEDTLS_SSL_NO_SESSION_RESUMPTION */ if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port, diff --git a/programs/ssl/ssl_server.c b/programs/ssl/ssl_server.c index 97918562a..5052435fa 100644 --- a/programs/ssl/ssl_server.c +++ b/programs/ssl/ssl_server.c @@ -224,11 +224,11 @@ int main( void ) mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); -#if defined(MBEDTLS_SSL_CACHE_C) +#if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) mbedtls_ssl_conf_session_cache( &conf, &cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set ); -#endif +#endif /* MBEDTLS_SSL_CACHE_C && !MBEDTLS_SSL_NO_SESSION_CACHE */ mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 8534dc235..cd2fa93e7 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -2542,9 +2542,11 @@ int main( int argc, char *argv[] ) if( opt.cache_timeout != -1 ) mbedtls_ssl_cache_set_timeout( &cache, opt.cache_timeout ); +#if !defined(MBEDTLS_SSL_NO_SESSION_CACHE) mbedtls_ssl_conf_session_cache( &conf, &cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set ); +#endif /* !MBEDTLS_SSL_NO_SESSION_CACHE */ #endif #if defined(MBEDTLS_SSL_SESSION_TICKETS) diff --git a/scripts/config.pl b/scripts/config.pl index c10a3b316..1c7c736c6 100755 --- a/scripts/config.pl +++ b/scripts/config.pl @@ -32,6 +32,8 @@ # MBEDTLS_REMOVE_3DES_CIPHERSUITES # MBEDTLS_SSL_HW_RECORD_ACCEL # MBEDTLS_SSL_PROTO_NO_DTLS +# MBEDTLS_SSL_NO_SESSION_CACHE +# MBEDTLS_SSL_NO_SESSION_RESUMPTION # MBEDTLS_RSA_NO_CRT # MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 # MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION @@ -95,6 +97,8 @@ MBEDTLS_REMOVE_ARC4_CIPHERSUITES MBEDTLS_REMOVE_3DES_CIPHERSUITES MBEDTLS_SSL_HW_RECORD_ACCEL MBEDTLS_SSL_PROTO_NO_TLS +MBEDTLS_SSL_NO_SESSION_CACHE +MBEDTLS_SSL_NO_SESSION_RESUMPTION MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION MBEDTLS_X509_REMOVE_INFO diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 7ae1bc5c0..996616a9c 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -682,6 +682,21 @@ component_test_rsa_no_crt () { if_build_succeeded tests/compat.sh -t RSA } +component_test_no_resumption () { + msg "build: Default + MBEDTLS_SSL_NO_SESSION_RESUMPTION (ASan build)" # ~ 6 min + scripts/config.pl unset MBEDTLS_SSL_SESSION_TICKETS + scripts/config.pl set MBEDTLS_SSL_NO_SESSION_CACHE + scripts/config.pl set MBEDTLS_SSL_NO_SESSION_RESUMPTION + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + + msg "test: MBEDTLS_SSL_NO_SESSION_RESUMPTION - main suites (inc. selftests) (ASan build)" # ~ 50s + make test + + msg "test: MBEDTLS_SSL_NO_SESSION_RESUMPTION - ssl-opt.sh (ASan build)" # ~ 6 min + if_build_succeeded tests/ssl-opt.sh +} + component_test_small_ssl_out_content_len () { msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 7bcba2438..d35b9bfc7 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -2130,6 +2130,9 @@ run_test "Fallback SCSV: end of list" \ -s "inapropriate fallback" ## Here the expected response is a valid ServerHello prefix, up to the random. +## Due to the way the clienthello was generated, this currently needs the +## server to have support for session tickets. +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS requires_openssl_with_fallback_scsv run_test "Fallback SCSV: not in list" \ "$P_SRV debug_level=2" \ @@ -2206,6 +2209,8 @@ run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \ # Tests for Session Tickets +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets: basic" \ "$P_SRV debug_level=3 tickets=1" \ "$P_CLI debug_level=3 tickets=1 reconnect=1" \ @@ -2220,6 +2225,8 @@ run_test "Session resume using tickets: basic" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets: cache disabled" \ "$P_SRV debug_level=3 tickets=1 cache_max=0" \ "$P_CLI debug_level=3 tickets=1 reconnect=1" \ @@ -2234,6 +2241,8 @@ run_test "Session resume using tickets: cache disabled" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets: timeout" \ "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \ "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \ @@ -2248,6 +2257,8 @@ run_test "Session resume using tickets: timeout" \ -S "a session has been resumed" \ -C "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets: session copy" \ "$P_SRV debug_level=3 tickets=1 cache_max=0" \ "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \ @@ -2262,6 +2273,8 @@ run_test "Session resume using tickets: session copy" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets: openssl server" \ "$O_SRV" \ "$P_CLI debug_level=3 tickets=1 reconnect=1" \ @@ -2271,6 +2284,8 @@ run_test "Session resume using tickets: openssl server" \ -c "parse new session ticket" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets: openssl client" \ "$P_SRV debug_level=3 tickets=1" \ "( $O_CLI -sess_out $SESSION; \ @@ -2285,6 +2300,8 @@ run_test "Session resume using tickets: openssl client" \ # Tests for Session Tickets with DTLS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets, DTLS: basic" \ "$P_SRV debug_level=3 dtls=1 tickets=1" \ "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \ @@ -2299,6 +2316,8 @@ run_test "Session resume using tickets, DTLS: basic" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets, DTLS: cache disabled" \ "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \ "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1" \ @@ -2313,6 +2332,8 @@ run_test "Session resume using tickets, DTLS: cache disabled" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets, DTLS: timeout" \ "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \ "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_delay=2" \ @@ -2327,6 +2348,8 @@ run_test "Session resume using tickets, DTLS: timeout" \ -S "a session has been resumed" \ -C "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets, DTLS: session copy" \ "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \ "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 reco_mode=0" \ @@ -2341,6 +2364,8 @@ run_test "Session resume using tickets, DTLS: session copy" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets, DTLS: openssl server" \ "$O_SRV -dtls1" \ "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \ @@ -2350,6 +2375,8 @@ run_test "Session resume using tickets, DTLS: openssl server" \ -c "parse new session ticket" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "Session resume using tickets, DTLS: openssl client" \ "$P_SRV dtls=1 debug_level=3 tickets=1" \ "( $O_CLI -dtls1 -sess_out $SESSION; \ @@ -2364,6 +2391,9 @@ run_test "Session resume using tickets, DTLS: openssl client" \ # Tests for Session Resume based on session-ID and cache +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: tickets enabled on client" \ "$P_SRV debug_level=3 tickets=0" \ "$P_CLI debug_level=3 tickets=1 reconnect=1" \ @@ -2378,6 +2408,9 @@ run_test "Session resume using cache: tickets enabled on client" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: tickets enabled on server" \ "$P_SRV debug_level=3 tickets=1" \ "$P_CLI debug_level=3 tickets=0 reconnect=1" \ @@ -2392,6 +2425,8 @@ run_test "Session resume using cache: tickets enabled on server" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: cache_max=0" \ "$P_SRV debug_level=3 tickets=0 cache_max=0" \ "$P_CLI debug_level=3 tickets=0 reconnect=1" \ @@ -2401,6 +2436,8 @@ run_test "Session resume using cache: cache_max=0" \ -S "a session has been resumed" \ -C "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: cache_max=1" \ "$P_SRV debug_level=3 tickets=0 cache_max=1" \ "$P_CLI debug_level=3 tickets=0 reconnect=1" \ @@ -2410,6 +2447,8 @@ run_test "Session resume using cache: cache_max=1" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: timeout > delay" \ "$P_SRV debug_level=3 tickets=0" \ "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \ @@ -2419,6 +2458,8 @@ run_test "Session resume using cache: timeout > delay" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: timeout < delay" \ "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \ "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \ @@ -2428,6 +2469,8 @@ run_test "Session resume using cache: timeout < delay" \ -S "a session has been resumed" \ -C "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: no timeout" \ "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \ "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \ @@ -2437,6 +2480,8 @@ run_test "Session resume using cache: no timeout" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: session copy" \ "$P_SRV debug_level=3 tickets=0" \ "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \ @@ -2446,6 +2491,8 @@ run_test "Session resume using cache: session copy" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: openssl client" \ "$P_SRV debug_level=3 tickets=0" \ "( $O_CLI -sess_out $SESSION; \ @@ -2458,6 +2505,8 @@ run_test "Session resume using cache: openssl client" \ -S "session successfully restored from ticket" \ -s "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache: openssl server" \ "$O_SRV" \ "$P_CLI debug_level=3 tickets=0 reconnect=1" \ @@ -2468,6 +2517,9 @@ run_test "Session resume using cache: openssl server" \ # Tests for Session Resume based on session-ID and cache, DTLS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: tickets enabled on client" \ "$P_SRV dtls=1 debug_level=3 tickets=0" \ "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \ @@ -2482,6 +2534,9 @@ run_test "Session resume using cache, DTLS: tickets enabled on client" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: tickets enabled on server" \ "$P_SRV dtls=1 debug_level=3 tickets=1" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \ @@ -2496,6 +2551,8 @@ run_test "Session resume using cache, DTLS: tickets enabled on server" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: cache_max=0" \ "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \ @@ -2505,6 +2562,8 @@ run_test "Session resume using cache, DTLS: cache_max=0" \ -S "a session has been resumed" \ -C "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: cache_max=1" \ "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \ @@ -2514,6 +2573,8 @@ run_test "Session resume using cache, DTLS: cache_max=1" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: timeout > delay" \ "$P_SRV dtls=1 debug_level=3 tickets=0" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=0" \ @@ -2523,6 +2584,8 @@ run_test "Session resume using cache, DTLS: timeout > delay" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: timeout < delay" \ "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \ @@ -2532,6 +2595,8 @@ run_test "Session resume using cache, DTLS: timeout < delay" \ -S "a session has been resumed" \ -C "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: no timeout" \ "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_delay=2" \ @@ -2541,6 +2606,8 @@ run_test "Session resume using cache, DTLS: no timeout" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: session copy" \ "$P_SRV dtls=1 debug_level=3 tickets=0" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 reco_mode=0" \ @@ -2550,6 +2617,8 @@ run_test "Session resume using cache, DTLS: session copy" \ -s "a session has been resumed" \ -c "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: openssl client" \ "$P_SRV dtls=1 debug_level=3 tickets=0" \ "( $O_CLI -dtls1 -sess_out $SESSION; \ @@ -2562,6 +2631,8 @@ run_test "Session resume using cache, DTLS: openssl client" \ -S "session successfully restored from ticket" \ -s "a session has been resumed" +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "Session resume using cache, DTLS: openssl server" \ "$O_SRV -dtls1" \ "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \ @@ -7864,6 +7935,8 @@ run_test "DTLS reordering: Buffer out-of-order handshake message on server" \ -S "Injecting buffered CCS message" \ -S "Remember CCS message" +# This needs session tickets; otherwise CCS is the first message in its flight +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS run_test "DTLS reordering: Buffer out-of-order CCS message on client"\ -p "$P_PXY delay_srv=NewSessionTicket" \ "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ @@ -8006,6 +8079,9 @@ run_test "DTLS proxy: 3d, max handshake, nbio" \ -c "HTTP/1.0 200 OK" client_needs_more_time 4 +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "DTLS proxy: 3d, min handshake, resumption" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ @@ -8020,6 +8096,9 @@ run_test "DTLS proxy: 3d, min handshake, resumption" \ -c "HTTP/1.0 200 OK" client_needs_more_time 4 +requires_config_disabled MBEDTLS_SSL_NO_SESSION_RESUMPTION +requires_config_enabled MBEDTLS_SSL_SESSION_TICKETS +requires_config_disabled MBEDTLS_SSL_NO_SESSION_CACHE run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \