From cb818205a6a7340fd5b2baaf679bf24ec4f1912d Mon Sep 17 00:00:00 2001 From: Joshua Siegel Date: Tue, 21 Dec 2021 16:31:42 -0500 Subject: [PATCH] Add tests for new 0-RTT API --- library/ssl_tls13_generic.c | 3 +- library/ssl_tls13_server.c | 2 +- programs/ssl/ssl_client2.c | 72 +++++++++++-- tests/ssl-opt.sh | 207 +++++++++++++++++++++++++++++++++++- 4 files changed, 271 insertions(+), 13 deletions(-) diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 8ec624b743db..4186730bf6c9 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -2480,8 +2480,7 @@ int mbedtls_ssl_write_early_data_ext( mbedtls_ssl_context *ssl, if( ( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_EARLY_DATA ) == 0 ) return( 0 ); - if( ssl->conf->tls13_kex_modes != - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK || + if( !mbedtls_ssl_conf_tls13_some_psk_enabled( ssl ) || ssl->conf->early_data_enabled == MBEDTLS_SSL_EARLY_DATA_DISABLED ) { MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write early_data extension" ) ); diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c index 13fa3bb20ef0..f0776d37e27c 100644 --- a/library/ssl_tls13_server.c +++ b/library/ssl_tls13_server.c @@ -1916,7 +1916,7 @@ static int ssl_early_data_fetch( mbedtls_ssl_context *ssl, } *buf = ssl->in_msg; - *buflen = ssl->in_hslen; + *buflen = ssl->in_msglen; cleanup: diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 4723268bba0e..64e961e2b1ec 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -61,6 +61,7 @@ int main( void ) #define DFL_KEY_PWD "" #define DFL_PSK "" #define DFL_EARLY_DATA MBEDTLS_SSL_EARLY_DATA_DISABLED +#define DFL_EARLY_DATA_API MBEDTLS_SSL_EARLY_DATA_OLD_API #define DFL_PSK_OPAQUE 0 #define DFL_PSK_IDENTITY "Client_identity" #define DFL_ECJPAKE_PW NULL @@ -366,8 +367,12 @@ int main( void ) #define USAGE_EARLY_DATA \ " early_data=%%d default: 0 (disabled)\n" \ " options: 0 (disabled), 1 (enabled)\n" +#define USAGE_EARLY_DATA_API \ + " early_data_api=%%d default: 0 (old api)\n" \ + " options: 0 (old api), 1 (new api)\n" #else #define USAGE_EARLY_DATA "" +#define USAGE_EARLY_DATA_API "" #endif /* MBEDTLS_ZERO_RTT && MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_ECP_C) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) @@ -446,6 +451,7 @@ int main( void ) USAGE_CURVES \ USAGE_SIG_ALGS \ USAGE_EARLY_DATA \ + USAGE_EARLY_DATA_API \ USAGE_NAMED_GROUP \ USAGE_DHMLEN \ "\n" @@ -559,6 +565,7 @@ struct options const char *named_groups_string; /* list of named groups */ const char *key_share_named_groups_string; /* list of named groups */ int early_data; /* support for early data */ + int early_data_api; /* old or new 0-RTT API */ int query_config_mode; /* whether to read config */ int use_srtp; /* Support SRTP */ int force_srtp_profile; /* SRTP protection profile to use or all */ @@ -918,6 +925,7 @@ int main( int argc, char *argv[] ) opt.psk = DFL_PSK; opt.sig_algs = DFL_SIG_ALGS; opt.early_data = DFL_EARLY_DATA; + opt.early_data_api = DFL_EARLY_DATA_API; #if defined(MBEDTLS_USE_PSA_CRYPTO) opt.psk_opaque = DFL_PSK_OPAQUE; #endif @@ -1210,6 +1218,19 @@ int main( int argc, char *argv[] ) default: goto usage; } } + else if( strcmp( p, "early_data_api" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: + opt.early_data_api = MBEDTLS_SSL_EARLY_DATA_OLD_API; + break; + case 1: + opt.early_data_api = MBEDTLS_SSL_EARLY_DATA_NEW_API; + break; + default: goto usage; + } + } #endif /* MBEDTLS_ZERO_RTT */ #if defined(MBEDTLS_ECP_C) @@ -2200,8 +2221,9 @@ int main( int argc, char *argv[] ) opt.max_version ); #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && defined(MBEDTLS_ZERO_RTT) - mbedtls_ssl_conf_early_data( &conf, opt.early_data, 0, MBEDTLS_SSL_EARLY_DATA_OLD_API, NULL ); - mbedtls_ssl_set_early_data( &ssl, (const unsigned char*) early_data, + mbedtls_ssl_conf_early_data( &conf, opt.early_data, 0, opt.early_data_api, NULL ); + if( opt.early_data_api == MBEDTLS_SSL_EARLY_DATA_OLD_API ) + mbedtls_ssl_set_early_data( &ssl, (const unsigned char*) early_data, strlen( early_data ) ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && MBEDTLS_ZERO_RTT */ @@ -3272,7 +3294,8 @@ int main( int argc, char *argv[] ) #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && defined(MBEDTLS_ZERO_RTT) - mbedtls_ssl_set_early_data( &ssl, (const unsigned char*) early_data, + if( opt.early_data_api == MBEDTLS_SSL_EARLY_DATA_OLD_API ) + mbedtls_ssl_set_early_data( &ssl, (const unsigned char*) early_data, strlen( early_data ) ); #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && MBEDTLS_ZERO_RTT */ @@ -3298,9 +3321,44 @@ int main( int argc, char *argv[] ) goto exit; } - while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) - { - if( ret != MBEDTLS_ERR_SSL_WANT_READ && +#if defined(MBEDTLS_ZERO_RTT) + char early_buf[256]; + int early_count = 0; +#endif + do { +#if defined(MBEDTLS_ZERO_RTT) + if( ( opt.early_data_api == MBEDTLS_SSL_EARLY_DATA_NEW_API ) && + ( mbedtls_ssl_get_early_data_state( &ssl ) == MBEDTLS_SSL_EARLY_DATA_STATE_ENABLED || + mbedtls_ssl_get_early_data_state( &ssl ) == MBEDTLS_SSL_EARLY_DATA_STATE_ON ) ) + { + int early_written = 0; + int early_len = mbedtls_snprintf( early_buf, sizeof( early_buf ), "early data test %d", early_count ); // strlen(early_data); + do { + ret = mbedtls_ssl_write_early_data( &ssl, (const unsigned char*) early_buf + early_written, early_len - early_written ); + if( ret < 0 && + ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE && + ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) + { + mbedtls_printf( " failed\n ! mbedtls_ssl_write_early_data returned -0x%x\n\n", + (unsigned int) -ret ); + goto exit; + } + + if( ret < 0 ) + continue; + + early_written += ret; + } while ( early_written < early_len ); + + early_buf[ret] = '\0'; + mbedtls_printf( " %zu bytes early data sent: %s\n", ret, early_buf ); + early_count++; + } +#endif + ret = mbedtls_ssl_handshake( &ssl ); + if( ret < 0 && + ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) { @@ -3308,7 +3366,7 @@ int main( int argc, char *argv[] ) (unsigned int) -ret ); goto exit; } - } + } while ( ret != 0 ); mbedtls_printf( " ok\n" ); diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index cfb1b6d23665..52650d0dc7bc 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -831,6 +831,17 @@ find_in_both() { fi } +find_in_both_same_count() { + srv_count=$(sed -n -e "$1" "$2" | sort | uniq -c); + cli_count=$(sed -n -e "$1" "$3" | sort | uniq -c); + + if [ "$srv_count" = "$cli_count" ]; then + return 0; + else + return 1; + fi +} + SKIP_HANDSHAKE_CHECK="NO" skip_handshake_stage_check() { SKIP_HANDSHAKE_CHECK="YES" @@ -2392,6 +2403,104 @@ run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ECDHE-ECDSA, client tries early -c "Ciphersuite is TLS1-3-AES-256-GCM-SHA384" \ -c "early data status = 0" +# early data new api +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data new api" \ + "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c" \ + "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 tls13_kex_modes=psk early_data=1 early_data_api=1 psk=010203 psk_identity=0a0b0c" \ + 0 \ + -s "found early_data extension" \ + -s "Derive Early Secret with 'ext binder'" \ + -c "client hello, adding early_data extension" \ + -c "Protocol is TLSv1.3" \ + -c "Ciphersuite is TLS1-3-AES-256-GCM-SHA384" \ + -c "Derive Early Secret with 'ext binder'" \ + -c "<= write EndOfEarlyData" \ + -s "<= parse early data" \ + -s "<= parse end_of_early_data" + +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-128-CCM-SHA256, ext PSK, early data new api" \ + "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c" \ + "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-128-CCM-SHA256 tls13_kex_modes=psk early_data=1 early_data_api=1 psk=010203 psk_identity=0a0b0c" \ + 0 \ + -s "found early_data extension" \ + -s "Derive Early Secret with 'ext binder'" \ + -c "client hello, adding early_data extension" \ + -c "Protocol is TLSv1.3" \ + -c "Ciphersuite is TLS1-3-AES-128-CCM-SHA256" \ + -c "Derive Early Secret with 'ext binder'" \ + -c "<= write EndOfEarlyData" \ + -s "<= parse early data" \ + -s "<= parse end_of_early_data" + +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-128-GCM-SHA256, ext PSK, early data new api" \ + "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c" \ + "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-128-GCM-SHA256 tls13_kex_modes=psk early_data=1 early_data_api=1 psk=010203 psk_identity=0a0b0c" \ + 0 \ + -s "found early_data extension" \ + -s "Derive Early Secret with 'ext binder'" \ + -c "client hello, adding early_data extension" \ + -c "Protocol is TLSv1.3" \ + -c "Ciphersuite is TLS1-3-AES-128-GCM-SHA256" \ + -c "Derive Early Secret with 'ext binder'" \ + -c "<= write EndOfEarlyData" \ + -s "<= parse early data" \ + -s "<= parse end_of_early_data" + +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-128-CCM-8-SHA256, ext PSK, early data new api" \ + "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c" \ + "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-128-CCM-8-SHA256 tls13_kex_modes=psk early_data=1 early_data_api=1 psk=010203 psk_identity=0a0b0c" \ + 0 \ + -s "found early_data extension" \ + -s "Derive Early Secret with 'ext binder'" \ + -c "client hello, adding early_data extension" \ + -c "Protocol is TLSv1.3" \ + -c "Ciphersuite is TLS1-3-AES-128-CCM-8-SHA256" \ + -c "Derive Early Secret with 'ext binder'" \ + -c "<= write EndOfEarlyData" \ + -s "<= parse early data" \ + -s "<= parse end_of_early_data" + +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ECDHE-ECDSA, client tries early data new api without PSK, and falls back to 1-RTT" \ + "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key \ + nbio=2 debug_level=4 force_version=tls1_3" \ + "$P_CLI nbio=2 debug_level=4 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 early_data=1 early_data_api=1" \ + 0 \ + -s "Protocol is TLSv1.3" \ + -c "<= skip write early_data extension" \ + -c "Protocol is TLSv1.3" \ + -c "Ciphersuite is TLS1-3-AES-256-GCM-SHA384" \ + -c "early data status = 0" + requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_enabled MBEDTLS_DEBUG_C requires_config_enabled MBEDTLS_SSL_SRV_C @@ -2443,7 +2552,7 @@ run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data status - no "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 psk=010203 psk_identity=0a0b0c" \ "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 psk=010203 psk_identity=0a0b0c" \ 0 \ - -c "early data status = 0" \ + -c "early data status = 0" \ # test early data status - rejected requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL @@ -2456,7 +2565,7 @@ run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data status - re "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 early_data=0 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c" \ "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 tls13_kex_modes=psk early_data=1 psk=010203 psk_identity=0a0b0c" \ 0 \ - -c "early data status = 1" \ + -c "early data status = 1" \ # test early data status - accepted requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL @@ -2468,7 +2577,81 @@ run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data status - ac "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c" \ "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 tls13_kex_modes=psk early_data=1 psk=010203 psk_identity=0a0b0c" \ 0 \ - -c "early data status = 2" \ + -c "early data status = 2" \ + +# test new early data status - not sent +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data new api status - not sent" \ + "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 psk=010203 psk_identity=0a0b0c" \ + "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 psk=010203 psk_identity=0a0b0c early_data_api=1" \ + 0 \ + -c "early data status = 0" \ + +# test new early data status - accepted +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data new api status - accepted" \ + "$P_SRV nbio=2 debug_level=5 force_version=tls1_3 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c early_data=-1" \ + "$P_CLI nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 tls13_kex_modes=psk psk=010203 psk_identity=0a0b0c early_data=1 early_data_api=1" \ + 0 \ + -c "early data status = 2" \ + +# test new early data status with resumption - rejected +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data new api status with resumption - rejected" \ + "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key nbio=2 debug_level=5 force_version=tls1_3 early_data=0 tickets=1" \ + "$P_CLI crt_file=data_files/cli2.crt key_file=data_files/cli2.key server_name=localhost nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 reconnect=1 tickets=1 early_data=1 early_data_api=1 auth_mode=required" \ + 0 \ + -c "early data status, reconnect = 1" \ + -s "<= parse new session ticket" \ + -s "<= skip write early_data extension" \ + -c "early data rejected by server" \ + -c "skip EndOfEarlyData, server rejected" + +# test new early data status with resumption - not sent +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data new api status with resumption - not sent" \ + "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tickets=1" \ + "$P_CLI crt_file=data_files/cli2.crt key_file=data_files/cli2.key server_name=localhost nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 reconnect=1 tickets=1 early_data=0 early_data_api=1 auth_mode=required" \ + 0 \ + -c "early data status, reconnect = 0" \ + -s "<= parse new session ticket" + +# test new early data with resumption and multiple sends: +# find_in_both_same_count will verify the count, size, and content +# matches for all early data sent and received +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_SRV_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_ZERO_RTT +requires_config_disabled MBEDTLS_SSL_USE_MPS +run_test "TLS 1.3, TLS1-3-AES-256-GCM-SHA384, ext PSK, early data new api multiple sends" \ + "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key nbio=2 debug_level=5 force_version=tls1_3 early_data=-1 tickets=1" \ + "$P_CLI crt_file=data_files/cli2.crt key_file=data_files/cli2.key server_name=localhost nbio=2 debug_level=5 force_version=tls1_3 force_ciphersuite=TLS1-3-AES-256-GCM-SHA384 reconnect=1 tickets=1 early_data=1 early_data_api=1 auth_mode=required" \ + 0 \ + -c "early data status, reconnect = 2" \ + -s "<= parse new session ticket" \ + -g "find_in_both_same_count 's/^\(.*bytes early data\).*\(:.*\)$/\1\2/p'" requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_enabled MBEDTLS_DEBUG_C @@ -2526,6 +2709,24 @@ run_test "TLS 1.3, TLS1-3-AES-128-GCM-SHA256, reject early data, OpenSSL serv -c "skip EndOfEarlyData, server rejected" \ -c "early data status, reconnect = 1" +# Test OpenSSL server with resumption and reject early data new api +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_disabled MBEDTLS_SSL_USE_MPS +requires_openssl_with_tls1_3 +run_test "TLS 1.3, TLS1-3-AES-128-GCM-SHA256, reject early data new api, OpenSSL server" \ + "$O_SRV" \ + "$P_CLI debug_level=5 force_version=tls1_3 server_name=localhost \ + force_ciphersuite=TLS1-3-AES-128-GCM-SHA256 reconnect=1 tickets=1 \ + early_data=1 early_data_api=1" \ + 0 \ + -c "=> prepare early data" \ + -c "=> mbedtls_ssl_tls1_3_generate_early_data_keys" \ + -c "=> write early_data" \ + -c "skip EndOfEarlyData, server rejected" \ + -c "early data status, reconnect = 1" + requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_enabled MBEDTLS_DEBUG_C requires_config_enabled MBEDTLS_SSL_SRV_C