From 82d34ccf476c3ff3cb5fe8e5f8f0426a533d024d Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 3 Nov 2021 08:51:56 +0000 Subject: [PATCH 01/14] Add signature scheme rsa pss Signed-off-by: XiaokangQian --- library/ssl_tls.c | 6 ++++++ library/ssl_tls13_generic.c | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 48a6369b7a..4ada5369b0 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6370,6 +6370,12 @@ static uint16_t ssl_preset_default_sig_algs[] = { MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512, #endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP521R1_ENABLED */ #endif /* MBEDTLS_ECDSA_C */ + + /* RSA algorithms */ +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256, +#endif + MBEDTLS_TLS13_SIG_NONE }; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 12ef4d58c8..6b7a6f84af 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -320,6 +320,11 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, unsigned char verify_hash[MBEDTLS_MD_MAX_SIZE]; size_t verify_hash_len; + void const *opts_ptr = NULL; +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + mbedtls_pk_rsassa_pss_options opts; +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ + /* * struct { * SignatureScheme algorithm; @@ -368,6 +373,13 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, md_alg = MBEDTLS_MD_SHA512; sig_alg = MBEDTLS_PK_ECDSA; break; +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + case MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256: + MBEDTLS_SSL_DEBUG_MSG( 4, ( "Certificate Verify: using RSA" ) ); + md_alg = MBEDTLS_MD_SHA256; + sig_alg = MBEDTLS_PK_RSASSA_PSS; + break; +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ default: MBEDTLS_SSL_DEBUG_MSG( 1, ( "Certificate Verify: Unknown signature algorithm." ) ); goto error; @@ -426,8 +438,21 @@ static int ssl_tls13_parse_certificate_verify( mbedtls_ssl_context *ssl, } MBEDTLS_SSL_DEBUG_BUF( 3, "verify hash", verify_hash, verify_hash_len ); +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + if( sig_alg == MBEDTLS_PK_RSASSA_PSS ) + { + const mbedtls_md_info_t* md_info; + opts.mgf1_hash_id = md_alg; + if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL ) + { + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + opts.expected_salt_len = mbedtls_md_get_size( md_info ); + opts_ptr = (const void*) &opts; + } +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ - if( ( ret = mbedtls_pk_verify_ext( sig_alg, NULL, + if( ( ret = mbedtls_pk_verify_ext( sig_alg, opts_ptr, &ssl->session_negotiate->peer_cert->pk, md_alg, verify_hash, verify_hash_len, p, signature_len ) ) == 0 ) From d940e641edbbf0787cd1bbe2b415ae59cfd04670 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 11 Nov 2021 10:22:08 +0000 Subject: [PATCH 02/14] Add test script for RSA signature Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 1ac34dae77..56d8d61fbb 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8835,6 +8835,36 @@ run_test "TLS1.3: minimal feature sets - openssl" \ -c "<= parse finished message" \ -c "HTTP/1.0 200 ok" +requires_openssl_tls1_3 +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_disabled MBEDTLS_USE_PSA_CRYPTO +run_test "TLS1.3: Test client hello msg work - openssl" \ + "$O_NEXT_SRV -tls1_3 -msg -no_middlebox" \ + "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=secp256r1" \ + 1 \ + -c "SSL - The requested feature is not available" \ + -s "ServerHello" \ + -c "tls1_3 client state: 0" \ + -c "tls1_3 client state: 2" \ + -c "tls1_3 client state: 19" \ + -c "tls1_3 client state: 5" \ + -c "tls1_3 client state: 3" \ + -c "tls1_3 client state: 9" \ + -c "tls1_3 client state: 13" \ + -c "tls1_3 client state: 7" \ + -c "tls1_3 client state: 20" \ + -c "tls1_3 client state: 11" \ + -c "tls1_3 client state: 14" \ + -c "tls1_3 client state: 15" \ + -c "<= ssl_tls1_3_process_server_hello" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -c "=> ssl_tls1_3_process_server_hello" \ + -c "<= parse encrypted extensions" \ + -c "Certificate verification flags clear" \ + -c "=> parse certificate verify" \ + -c "<= parse certificate verify" \ + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" + requires_gnutls_tls1_3 requires_gnutls_next_no_ticket requires_gnutls_next_disable_tls13_compat From 4b82ca1b7050efe092a0dd70605f658bc8acd6b6 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Thu, 18 Nov 2021 08:27:17 +0000 Subject: [PATCH 03/14] Refine test code and test scripts Change client test code to support rsa pss signatures Add test cases for rsa pss signature in ssl-opt.sh Signed-off-by: XiaokangQian --- library/ssl_tls.c | 6 ++++ programs/ssl/ssl_client2.c | 22 +++++++++++++ tests/ssl-opt.sh | 63 ++++++++++++++++++++++++++++++++------ 3 files changed, 81 insertions(+), 10 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 4ada5369b0..91cc5b61b9 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -6389,6 +6389,12 @@ static uint16_t ssl_preset_suiteb_sig_algs[] = { MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384, #endif /* MBEDTLS_SHA512_C && MBEDTLS_ECP_DP_SECP384R1_ENABLED */ #endif /* MBEDTLS_ECDSA_C */ + + /* RSA algorithms */ +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256, +#endif + MBEDTLS_TLS13_SIG_NONE }; #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index cb299b159e..462b8f6240 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -567,6 +567,24 @@ static int my_verify( void *data, mbedtls_x509_crt *crt, } #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_ECP_C) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) +static uint16_t ssl_tls13_sig_algs_for_test[] = { +#if defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256, +#endif +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384, +#endif +#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512, +#endif +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256, +#endif + MBEDTLS_TLS13_SIG_NONE +}; +#endif /* MBEDTLS_ECP_C && MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) int report_cid_usage( mbedtls_ssl_context *ssl, const char *additional_description ) @@ -1731,6 +1749,10 @@ int main( int argc, char *argv[] ) memset( peer_crt_info, 0, sizeof( peer_crt_info ) ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) + mbedtls_ssl_conf_sig_algs( &conf, ssl_tls13_sig_algs_for_test ); +#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ + #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) if( opt.cid_enabled == 1 || opt.cid_enabled_renego == 1 ) { diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 56d8d61fbb..dbe9771936 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -62,6 +62,7 @@ guess_config_name() { : ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key" +O_SRV_RSA="$OPENSSL_CMD s_server -www -cert data_files/server2.crt -key data_files/server2.key" O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client" G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt" @@ -87,6 +88,7 @@ fi if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" + G_NEXT_SRV_RSA="$GNUTLS_NEXT_SERV --x509certfile data_files/server2.crt --x509keyfile data_files/server2.key" else G_NEXT_SRV=false fi @@ -264,7 +266,7 @@ requires_config_value_equals() { # Space-separated list of ciphersuites supported by this build of # Mbed TLS. P_CIPHERSUITES=" $($P_CLI --help 2>/dev/null | - grep TLS- | + grep 'TLS-\|TLS1-3' | tr -s ' \n' ' ')" requires_ciphersuite_enabled() { case $P_CIPHERSUITES in @@ -1405,6 +1407,7 @@ P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT" P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT" P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}" O_SRV="$O_SRV -accept $SRV_PORT" +O_SRV_RSA="$O_SRV_RSA -accept $SRV_PORT" O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT" G_SRV="$G_SRV -p $SRV_PORT" G_CLI="$G_CLI -p +SRV_PORT" @@ -1421,6 +1424,7 @@ fi if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT" + G_NEXT_SRV_RSA="$G_NEXT_SRV_RSA -p $SRV_PORT" fi if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then @@ -8835,12 +8839,13 @@ run_test "TLS1.3: minimal feature sets - openssl" \ -c "<= parse finished message" \ -c "HTTP/1.0 200 ok" -requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL -requires_config_disabled MBEDTLS_USE_PSA_CRYPTO -run_test "TLS1.3: Test client hello msg work - openssl" \ - "$O_NEXT_SRV -tls1_3 -msg -no_middlebox" \ - "$P_CLI debug_level=3 min_version=tls1_3 max_version=tls1_3 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=secp256r1" \ +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT +run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ + "$O_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ + "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ 1 \ -c "SSL - The requested feature is not available" \ -s "ServerHello" \ @@ -8851,19 +8856,20 @@ run_test "TLS1.3: Test client hello msg work - openssl" \ -c "tls1_3 client state: 3" \ -c "tls1_3 client state: 9" \ -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 7" \ - -c "tls1_3 client state: 20" \ -c "tls1_3 client state: 11" \ -c "tls1_3 client state: 14" \ -c "tls1_3 client state: 15" \ -c "<= ssl_tls1_3_process_server_hello" \ - -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -c "ECDH curve: x25519" \ -c "=> ssl_tls1_3_process_server_hello" \ -c "<= parse encrypted extensions" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -c "Certificate Verify: Signature algorithm ( 0804 )" \ -c "Certificate verification flags clear" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ - -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ + -c "<= parse finished message" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8897,6 +8903,43 @@ run_test "TLS1.3: minimal feature sets - gnutls" \ -c "<= parse finished message" \ -c "HTTP/1.0 200 OK" +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +requires_config_enabled MBEDTLS_DEBUG_C +requires_config_enabled MBEDTLS_SSL_CLI_C +requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT +requires_gnutls_next +run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ + "$G_NEXT_SRV_RSA --disable-client-cert --priority=NORMAL:+CIPHER-ALL:+SHA256:+GROUP-SECP256R1:+ECDHE-ECDSA:+AEAD:+SIGN-RSA-PSS-RSAE-SHA256:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ + "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ + 1 \ + -c "SSL - The requested feature is not available" \ + -c "tls1_3 client state: 0" \ + -c "tls1_3 client state: 2" \ + -c "tls1_3 client state: 19" \ + -c "tls1_3 client state: 5" \ + -c "tls1_3 client state: 3" \ + -c "tls1_3 client state: 9" \ + -c "tls1_3 client state: 13" \ + -c "tls1_3 client state: 11" \ + -c "tls1_3 client state: 14" \ + -c "tls1_3 client state: 15" \ + -c "<= ssl_tls1_3_process_server_hello" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -s "Ephemeral EC Diffie-Hellman parameters" \ + -s "Version: TLS1.3" \ + -s "Cipher: AES-128-GCM" \ + -S "Client Signature:" \ + -s "Server Signature: RSA-PSS-RSAE-SHA256" \ + -c "ECDH curve: x25519" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ + -c "Certificate Verify: Signature algorithm ( 0804 )" \ + -c "=> ssl_tls1_3_process_server_hello" \ + -c "<= parse encrypted extensions" \ + -c "Certificate verification flags clear" \ + -c "=> parse certificate verify" \ + -c "<= parse certificate verify" \ + -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ + -c "<= parse finished message" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From d15018972c604dd2d49932ddb49e2adb5ad4a4f8 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 22 Nov 2021 04:06:52 +0000 Subject: [PATCH 04/14] Change script to solve G_NEXT_SRV_RSA not set issue Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index dbe9771936..8d72c4edad 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -91,6 +91,7 @@ if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then G_NEXT_SRV_RSA="$GNUTLS_NEXT_SERV --x509certfile data_files/server2.crt --x509keyfile data_files/server2.key" else G_NEXT_SRV=false + G_NEXT_SRV_RSA=false fi if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then From 22dd68c2b576f9b212489b58b724c41589e494dc Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 22 Nov 2021 05:54:50 +0000 Subject: [PATCH 05/14] Rebase code and run through the whole test flow Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 8d72c4edad..a8721f3e80 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8847,8 +8847,7 @@ requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$O_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ - 1 \ - -c "SSL - The requested feature is not available" \ + 0 \ -s "ServerHello" \ -c "tls1_3 client state: 0" \ -c "tls1_3 client state: 2" \ @@ -8870,7 +8869,8 @@ run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ - -c "<= parse finished message" + -c "<= parse finished message" \ + -c "HTTP/1.0 200 ok" requires_gnutls_tls1_3 requires_gnutls_next_no_ticket @@ -8912,8 +8912,7 @@ requires_gnutls_next run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$G_NEXT_SRV_RSA --disable-client-cert --priority=NORMAL:+CIPHER-ALL:+SHA256:+GROUP-SECP256R1:+ECDHE-ECDSA:+AEAD:+SIGN-RSA-PSS-RSAE-SHA256:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ - 1 \ - -c "SSL - The requested feature is not available" \ + 0 \ -c "tls1_3 client state: 0" \ -c "tls1_3 client state: 2" \ -c "tls1_3 client state: 19" \ @@ -8940,7 +8939,8 @@ run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ -c "=> parse certificate verify" \ -c "<= parse certificate verify" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ - -c "<= parse finished message" + -c "<= parse finished message" \ + -c "HTTP/1.0 200 OK" # Test heap memory usage after handshake requires_config_enabled MBEDTLS_MEMORY_DEBUG From 3887ab5bcc07644121ecd8eea89c4a2efe29c62b Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 22 Nov 2021 07:14:39 +0000 Subject: [PATCH 06/14] Use O_NEXT_SRV to support ciphersuite option Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index a8721f3e80..f9ec847cf4 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -62,7 +62,6 @@ guess_config_name() { : ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key" -O_SRV_RSA="$OPENSSL_CMD s_server -www -cert data_files/server2.crt -key data_files/server2.key" O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client" G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt" @@ -80,9 +79,11 @@ fi if [ -n "${OPENSSL_NEXT:-}" ]; then O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key" + O_NEXT_SRV_RSA="$OPENSSL_NEXT s_server -www -cert data_files/server2.crt -key data_files/server2.key" O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client" else O_NEXT_SRV=false + O_NEXT_SRV_RSA=false O_NEXT_CLI=false fi @@ -1408,7 +1409,6 @@ P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT" P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT" P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}" O_SRV="$O_SRV -accept $SRV_PORT" -O_SRV_RSA="$O_SRV_RSA -accept $SRV_PORT" O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT" G_SRV="$G_SRV -p $SRV_PORT" G_CLI="$G_CLI -p +SRV_PORT" @@ -1420,6 +1420,7 @@ fi if [ -n "${OPENSSL_NEXT:-}" ]; then O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT" + O_NEXT_SRV_RSA="$O_NEXT_SRV -accept $SRV_PORT" O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT" fi @@ -8840,12 +8841,13 @@ run_test "TLS1.3: minimal feature sets - openssl" \ -c "<= parse finished message" \ -c "HTTP/1.0 200 ok" +requires_openssl_tls1_3 requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_enabled MBEDTLS_DEBUG_C requires_config_enabled MBEDTLS_SSL_CLI_C requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ - "$O_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ + "$O_NEXT_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ 0 \ -s "ServerHello" \ From bdf26de3844af5fbd0eca3266242fcc002df1c63 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Mon, 22 Nov 2021 09:52:56 +0000 Subject: [PATCH 07/14] Fix test failure and remove useless code Signed-off-by: XiaokangQian --- programs/ssl/ssl_client2.c | 22 ---------------------- tests/ssl-opt.sh | 37 +------------------------------------ 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 462b8f6240..cb299b159e 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -567,24 +567,6 @@ static int my_verify( void *data, mbedtls_x509_crt *crt, } #endif /* MBEDTLS_X509_CRT_PARSE_C */ -#if defined(MBEDTLS_ECP_C) && defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) -static uint16_t ssl_tls13_sig_algs_for_test[] = { -#if defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - MBEDTLS_TLS13_SIG_ECDSA_SECP256R1_SHA256, -#endif -#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - MBEDTLS_TLS13_SIG_ECDSA_SECP384R1_SHA384, -#endif -#if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) - MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512, -#endif -#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) - MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256, -#endif - MBEDTLS_TLS13_SIG_NONE -}; -#endif /* MBEDTLS_ECP_C && MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ - #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) int report_cid_usage( mbedtls_ssl_context *ssl, const char *additional_description ) @@ -1749,10 +1731,6 @@ int main( int argc, char *argv[] ) memset( peer_crt_info, 0, sizeof( peer_crt_info ) ); #endif /* MBEDTLS_X509_CRT_PARSE_C */ -#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL) && defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) - mbedtls_ssl_conf_sig_algs( &conf, ssl_tls13_sig_algs_for_test ); -#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL && MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */ - #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) if( opt.cid_enabled == 1 || opt.cid_enabled_renego == 1 ) { diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index f9ec847cf4..c964167ff7 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -1420,7 +1420,7 @@ fi if [ -n "${OPENSSL_NEXT:-}" ]; then O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT" - O_NEXT_SRV_RSA="$O_NEXT_SRV -accept $SRV_PORT" + O_NEXT_SRV_RSA="$O_NEXT_SRV_RSA -accept $SRV_PORT" O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT" fi @@ -8850,28 +8850,10 @@ run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$O_NEXT_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ 0 \ - -s "ServerHello" \ - -c "tls1_3 client state: 0" \ - -c "tls1_3 client state: 2" \ - -c "tls1_3 client state: 19" \ - -c "tls1_3 client state: 5" \ - -c "tls1_3 client state: 3" \ - -c "tls1_3 client state: 9" \ - -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 11" \ - -c "tls1_3 client state: 14" \ - -c "tls1_3 client state: 15" \ - -c "<= ssl_tls1_3_process_server_hello" \ -c "ECDH curve: x25519" \ - -c "=> ssl_tls1_3_process_server_hello" \ - -c "<= parse encrypted extensions" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "Certificate Verify: Signature algorithm ( 0804 )" \ - -c "Certificate verification flags clear" \ - -c "=> parse certificate verify" \ - -c "<= parse certificate verify" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ - -c "<= parse finished message" \ -c "HTTP/1.0 200 ok" requires_gnutls_tls1_3 @@ -8915,17 +8897,6 @@ run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$G_NEXT_SRV_RSA --disable-client-cert --priority=NORMAL:+CIPHER-ALL:+SHA256:+GROUP-SECP256R1:+ECDHE-ECDSA:+AEAD:+SIGN-RSA-PSS-RSAE-SHA256:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ 0 \ - -c "tls1_3 client state: 0" \ - -c "tls1_3 client state: 2" \ - -c "tls1_3 client state: 19" \ - -c "tls1_3 client state: 5" \ - -c "tls1_3 client state: 3" \ - -c "tls1_3 client state: 9" \ - -c "tls1_3 client state: 13" \ - -c "tls1_3 client state: 11" \ - -c "tls1_3 client state: 14" \ - -c "tls1_3 client state: 15" \ - -c "<= ssl_tls1_3_process_server_hello" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -s "Ephemeral EC Diffie-Hellman parameters" \ -s "Version: TLS1.3" \ @@ -8935,13 +8906,7 @@ run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ -c "ECDH curve: x25519" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "Certificate Verify: Signature algorithm ( 0804 )" \ - -c "=> ssl_tls1_3_process_server_hello" \ - -c "<= parse encrypted extensions" \ - -c "Certificate verification flags clear" \ - -c "=> parse certificate verify" \ - -c "<= parse certificate verify" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ - -c "<= parse finished message" \ -c "HTTP/1.0 200 OK" # Test heap memory usage after handshake From a27b3526bfb618953355a519e98931aa97dc1f95 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 23 Nov 2021 02:27:07 +0000 Subject: [PATCH 08/14] Disable PSA_CRYPTO in tls1.3 tests Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index c964167ff7..6ca663eb39 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8846,6 +8846,7 @@ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_enabled MBEDTLS_DEBUG_C requires_config_enabled MBEDTLS_SSL_CLI_C requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT +requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$O_NEXT_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ @@ -8888,10 +8889,13 @@ run_test "TLS1.3: minimal feature sets - gnutls" \ -c "<= parse finished message" \ -c "HTTP/1.0 200 OK" +requires_gnutls_next_no_ticket +requires_gnutls_next_disable_tls13_compat requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL requires_config_enabled MBEDTLS_DEBUG_C requires_config_enabled MBEDTLS_SSL_CLI_C requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT +requires_config_disabled MBEDTLS_USE_PSA_CRYPTO requires_gnutls_next run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$G_NEXT_SRV_RSA --disable-client-cert --priority=NORMAL:+CIPHER-ALL:+SHA256:+GROUP-SECP256R1:+ECDHE-ECDSA:+AEAD:+SIGN-RSA-PSS-RSAE-SHA256:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ From f977e9af6da5a36947e305a8cc8f381e3eadc411 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 23 Nov 2021 07:19:23 +0000 Subject: [PATCH 09/14] Add componet test and rsa signature options Signed-off-by: XiaokangQian --- programs/ssl/ssl_client2.c | 5 +++++ tests/scripts/all.sh | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index cb299b159e..b945364464 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1534,6 +1534,10 @@ int main( int argc, char *argv[] ) { sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512; } + else if( strcmp( q, "rsa_pkcs1_sha256" ) == 0 ) + { + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_RSA_PKCS1_SHA1; + } else { mbedtls_printf( "unknown signature algorithm %s\n", q ); @@ -1541,6 +1545,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( "ecdsa_secp256r1_sha256 " ); mbedtls_printf( "ecdsa_secp384r1_sha384 " ); mbedtls_printf( "ecdsa_secp521r1_sha512 " ); + mbedtls_printf( "rsa_pkcs1_sha256 " ); mbedtls_printf( "\n" ); goto exit; } diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 241b1b6d0a..00c7f8821d 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2610,6 +2610,22 @@ component_test_tls13_experimental_with_everest () { if_build_succeeded tests/ssl-opt.sh } +component_test_tls13_experimental_with_rsa () { + msg "default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with rsa" + scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + scripts/config.py unset MBEDTLS_SSL_USE_MPS + scripts/config.py unset MBEDTLS_SSL_SRV_C + scripts/config.py set MBEDTLS_SSL_CLI_C + scripts/config.py set MBEDTLS_RSA_C + scripts/config.py set MBEDTLS_X509_RSASSA_PSS_SUPPORT + cmake CC=gcc CMAKE_BUILD_TYPE=ASanDbg . + make + msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with rsa" + make test + msg "ssl-opt.sh (TLS 1.3 experimental)" + if_build_succeeded tests/ssl-opt.sh -f "TLS 1.3" +} + component_build_mingw () { msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs From 07c554748ae3a395067eadf5d9400bd9de32eedb Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 23 Nov 2021 08:30:14 +0000 Subject: [PATCH 10/14] Change cert file to server2-sha256.crt Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 6ca663eb39..a562f49f22 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -79,7 +79,7 @@ fi if [ -n "${OPENSSL_NEXT:-}" ]; then O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key" - O_NEXT_SRV_RSA="$OPENSSL_NEXT s_server -www -cert data_files/server2.crt -key data_files/server2.key" + O_NEXT_SRV_RSA="$OPENSSL_NEXT s_server -www -cert data_files/server2-sha256.crt -key data_files/server2.key" O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client" else O_NEXT_SRV=false @@ -89,7 +89,7 @@ fi if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" - G_NEXT_SRV_RSA="$GNUTLS_NEXT_SERV --x509certfile data_files/server2.crt --x509keyfile data_files/server2.key" + G_NEXT_SRV_RSA="$GNUTLS_NEXT_SERV --x509certfile data_files/server2-sha256.crt --x509keyfile data_files/server2.key" else G_NEXT_SRV=false G_NEXT_SRV_RSA=false From ff5f6c8bb0f13214a44f444f7760343f0d42bcaf Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 23 Nov 2021 08:49:51 +0000 Subject: [PATCH 11/14] Refine test code and test scripts Signed-off-by: XiaokangQian --- programs/ssl/ssl_client2.c | 10 +++++++--- tests/scripts/all.sh | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index b945364464..401f078d9d 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1534,10 +1534,12 @@ int main( int argc, char *argv[] ) { sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512; } - else if( strcmp( q, "rsa_pkcs1_sha256" ) == 0 ) +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + else if( strcmp( q, "rsa_pss_rsae_sha256" ) == 0 ) { - sig_alg_list[i++] = MBEDTLS_TLS13_SIG_RSA_PKCS1_SHA1; + sig_alg_list[i++] = MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256; } +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ else { mbedtls_printf( "unknown signature algorithm %s\n", q ); @@ -1545,7 +1547,9 @@ int main( int argc, char *argv[] ) mbedtls_printf( "ecdsa_secp256r1_sha256 " ); mbedtls_printf( "ecdsa_secp384r1_sha384 " ); mbedtls_printf( "ecdsa_secp521r1_sha512 " ); - mbedtls_printf( "rsa_pkcs1_sha256 " ); +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + mbedtls_printf( "rsa_pss_rsae_sha256 " ); +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ mbedtls_printf( "\n" ); goto exit; } diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 00c7f8821d..6318d4d086 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2613,8 +2613,6 @@ component_test_tls13_experimental_with_everest () { component_test_tls13_experimental_with_rsa () { msg "default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with rsa" scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL - scripts/config.py unset MBEDTLS_SSL_USE_MPS - scripts/config.py unset MBEDTLS_SSL_SRV_C scripts/config.py set MBEDTLS_SSL_CLI_C scripts/config.py set MBEDTLS_RSA_C scripts/config.py set MBEDTLS_X509_RSASSA_PSS_SUPPORT From 25476a48b9a414d99b4e6a5296be63b607d53455 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 23 Nov 2021 14:01:21 +0000 Subject: [PATCH 12/14] Change code based on review Remove useless component in all.sh Remove use server logs in ssh-opt.sh Remove useless guards in ssl_client2.c Signed-off-by: XiaokangQian --- programs/ssl/ssl_client2.c | 4 ---- tests/scripts/all.sh | 14 -------------- tests/ssl-opt.sh | 13 +++---------- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 401f078d9d..204b9754aa 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1534,12 +1534,10 @@ int main( int argc, char *argv[] ) { sig_alg_list[i++] = MBEDTLS_TLS13_SIG_ECDSA_SECP521R1_SHA512; } -#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) else if( strcmp( q, "rsa_pss_rsae_sha256" ) == 0 ) { sig_alg_list[i++] = MBEDTLS_TLS13_SIG_RSA_PSS_RSAE_SHA256; } -#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ else { mbedtls_printf( "unknown signature algorithm %s\n", q ); @@ -1547,9 +1545,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( "ecdsa_secp256r1_sha256 " ); mbedtls_printf( "ecdsa_secp384r1_sha384 " ); mbedtls_printf( "ecdsa_secp521r1_sha512 " ); -#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) mbedtls_printf( "rsa_pss_rsae_sha256 " ); -#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ mbedtls_printf( "\n" ); goto exit; } diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 6318d4d086..241b1b6d0a 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2610,20 +2610,6 @@ component_test_tls13_experimental_with_everest () { if_build_succeeded tests/ssl-opt.sh } -component_test_tls13_experimental_with_rsa () { - msg "default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with rsa" - scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL - scripts/config.py set MBEDTLS_SSL_CLI_C - scripts/config.py set MBEDTLS_RSA_C - scripts/config.py set MBEDTLS_X509_RSASSA_PSS_SUPPORT - cmake CC=gcc CMAKE_BUILD_TYPE=ASanDbg . - make - msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled, with rsa" - make test - msg "ssl-opt.sh (TLS 1.3 experimental)" - if_build_succeeded tests/ssl-opt.sh -f "TLS 1.3" -} - component_build_mingw () { msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index a562f49f22..a1e469db9d 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -78,7 +78,7 @@ else fi if [ -n "${OPENSSL_NEXT:-}" ]; then - O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key" + O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server7.crt -key data_files/server7.key" O_NEXT_SRV_RSA="$OPENSSL_NEXT s_server -www -cert data_files/server2-sha256.crt -key data_files/server2.key" O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client" else @@ -8849,7 +8849,7 @@ requires_config_enabled MBEDTLS_X509_RSASSA_PSS_SUPPORT requires_config_disabled MBEDTLS_USE_PSA_CRYPTO run_test "TLS 1.3 m->O AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$O_NEXT_SRV_RSA -ciphersuites TLS_AES_128_GCM_SHA256 -tls1_3 -msg -no_middlebox -num_tickets 0" \ - "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ + "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256 allow_sha1=0" \ 0 \ -c "ECDH curve: x25519" \ -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ @@ -8899,16 +8899,9 @@ requires_config_disabled MBEDTLS_USE_PSA_CRYPTO requires_gnutls_next run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$G_NEXT_SRV_RSA --disable-client-cert --priority=NORMAL:+CIPHER-ALL:+SHA256:+GROUP-SECP256R1:+ECDHE-ECDSA:+AEAD:+SIGN-RSA-PSS-RSAE-SHA256:-VERS-ALL:+VERS-TLS1.3:%NO_TICKETS:%DISABLE_TLS13_COMPAT_MODE" \ - "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256" \ + "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256 allow_sha1=0" \ 0 \ - -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ - -s "Ephemeral EC Diffie-Hellman parameters" \ - -s "Version: TLS1.3" \ - -s "Cipher: AES-128-GCM" \ - -S "Client Signature:" \ - -s "Server Signature: RSA-PSS-RSAE-SHA256" \ -c "ECDH curve: x25519" \ - -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "Certificate Verify: Signature algorithm ( 0804 )" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ -c "HTTP/1.0 200 OK" From f9fca8a791e0a80ccef4dda2783fba9609bb756a Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Tue, 23 Nov 2021 23:21:27 +0000 Subject: [PATCH 13/14] Add back cipher suite information in ssh-opt.sh Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index a1e469db9d..6bf333f5eb 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -8902,6 +8902,7 @@ run_test "TLS 1.3 m->G AES_128_GCM_SHA256 , RSA_PSS_RSAE_SHA256" \ "$P_CLI debug_level=4 force_version=tls1_3 server_name=localhost force_ciphersuite=TLS1-3-AES-128-GCM-SHA256 allow_sha1=0" \ 0 \ -c "ECDH curve: x25519" \ + -c "server hello, chosen ciphersuite: ( 1301 ) - TLS1-3-AES-128-GCM-SHA256" \ -c "Certificate Verify: Signature algorithm ( 0804 )" \ -c "mbedtls_ssl_tls13_process_certificate_verify() returned 0" \ -c "HTTP/1.0 200 OK" From 30f556059a53280a4679a0325ea273f87d7251b1 Mon Sep 17 00:00:00 2001 From: XiaokangQian Date: Wed, 24 Nov 2021 01:54:50 +0000 Subject: [PATCH 14/14] Reverse the cert file Signed-off-by: XiaokangQian --- tests/ssl-opt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 6bf333f5eb..d43d66260e 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -78,7 +78,7 @@ else fi if [ -n "${OPENSSL_NEXT:-}" ]; then - O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server7.crt -key data_files/server7.key" + O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key" O_NEXT_SRV_RSA="$OPENSSL_NEXT s_server -www -cert data_files/server2-sha256.crt -key data_files/server2.key" O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client" else