From 8fa06dc6fad9d5c6280ad1801d9fdbb714b8bade Mon Sep 17 00:00:00 2001 From: Pengyu Lv Date: Fri, 1 Dec 2023 14:23:27 +0800 Subject: [PATCH 1/4] Align the case listing with case running in compat.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pengyu Lv Signed-off-by: Manuel Pégourié-Gonnard --- tests/compat.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index b608b83ae8..2b742e345c 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -135,17 +135,28 @@ print_test_case() { list_test_cases() { for MODE in $MODES; do for TYPE in $TYPES; do - for VERIFY in $VERIFIES; do + # PSK cipher suites do not allow client certificate verification. + SUB_VERIFIES=$VERIFIES + if [ "$TYPE" = "PSK" ]; then + SUB_VERIFIES="NO" + fi + for VERIFY in $SUB_VERIFIES; do VERIF=$(echo $VERIFY | tr '[:upper:]' '[:lower:]') reset_ciphersuites add_common_ciphersuites add_openssl_ciphersuites add_gnutls_ciphersuites add_mbedtls_ciphersuites + # For GnuTLS client -> Mbed TLS server, + # we need to force IPv4 by connecting to 127.0.0.1 but then auth fails + SUB_G_CIPHERS=$G_CIPHERS + if is_dtls "$MODE" && [ "X$VERIFY" = "XYES" ]; then + SUB_G_CIPHERS="" + fi print_test_case m O "$O_CIPHERS" print_test_case O m "$O_CIPHERS" print_test_case m G "$G_CIPHERS" - print_test_case G m "$G_CIPHERS" + print_test_case G m "$SUB_G_CIPHERS" print_test_case m m "$M_CIPHERS" done done From ac0b3505047d23fa3b9dab867439c1f93b556bba Mon Sep 17 00:00:00 2001 From: Pengyu Lv Date: Fri, 1 Dec 2023 14:25:40 +0800 Subject: [PATCH 2/4] Remove the workarround for G->m dtls12 tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pengyu Lv Signed-off-by: Manuel Pégourié-Gonnard --- tests/compat.sh | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 2b742e345c..92fcce39f7 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -147,16 +147,10 @@ list_test_cases() { add_openssl_ciphersuites add_gnutls_ciphersuites add_mbedtls_ciphersuites - # For GnuTLS client -> Mbed TLS server, - # we need to force IPv4 by connecting to 127.0.0.1 but then auth fails - SUB_G_CIPHERS=$G_CIPHERS - if is_dtls "$MODE" && [ "X$VERIFY" = "XYES" ]; then - SUB_G_CIPHERS="" - fi print_test_case m O "$O_CIPHERS" print_test_case O m "$O_CIPHERS" print_test_case m G "$G_CIPHERS" - print_test_case G m "$SUB_G_CIPHERS" + print_test_case G m "$G_CIPHERS" print_test_case m m "$M_CIPHERS" done done @@ -289,12 +283,6 @@ filter_ciphersuites() # Ciphersuite for GnuTLS G_CIPHERS=$( filter "$G_CIPHERS" ) fi - - # For GnuTLS client -> Mbed TLS server, - # we need to force IPv4 by connecting to 127.0.0.1 but then auth fails - if is_dtls "$MODE" && [ "X$VERIFY" = "XYES" ]; then - G_CIPHERS="" - fi } reset_ciphersuites() @@ -1298,13 +1286,7 @@ run_client() { ;; [Gg]nu*) - # need to force IPv4 with UDP, but keep localhost for auth - if is_dtls "$MODE"; then - G_HOST="127.0.0.1" - else - G_HOST="localhost" - fi - CLIENT_CMD="$GNUTLS_CLI $G_CLIENT_ARGS --priority $G_PRIO_MODE:$2 $G_HOST" + CLIENT_CMD="$GNUTLS_CLI $G_CLIENT_ARGS --priority $G_PRIO_MODE:$2 localhost" log "$CLIENT_CMD" echo "$CLIENT_CMD" > $CLI_OUT printf 'GET HTTP/1.0\r\n\r\n' | $CLIENT_CMD >> $CLI_OUT 2>&1 & From ebfcf58dc7937c779c063b208c524445450d4c42 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 20 Mar 2024 17:51:48 +0100 Subject: [PATCH 3/4] Always list TLS-RSA-WITH-NULL-SHA256, but skip conditionally with GnuTLS TLS-RSA-WITH-NULL-SHA256 is officially a cipher suite only since TLS 1.2, but Mbed TLS allows it in 1.0/1.1, and so did ancient versions of GnuTLS. This script was only considering it for GnuTLS interoperability if the running version of GnuTLS supported it with older protocol versions. Change to always considering it, and in particular always including it with --list-test-cases, but skipping it at runtime if GnuTLS doesn't support it. Signed-off-by: Gilles Peskine --- tests/compat.sh | 50 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index 92fcce39f7..e41489f7bc 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -640,24 +640,14 @@ add_gnutls_ciphersuites() ;; "RSA") - # TLS-RSA-WITH-NULL-SHA256 is a (D)TLS 1.2-only cipher suite, - # like all SHA256 cipher suites. But Mbed TLS supports it with - # (D)TLS 1.0 and 1.1 as well. So do ancient versions of GnuTLS, - # but this was considered a bug which was fixed in GnuTLS 3.4.7. - # Check the GnuTLS support list to see what the protocol version - # requirement is for that cipher suite. - if [ `minor_ver "$MODE"` -ge 3 ] || { - [ `minor_ver "$MODE"` -gt 0 ] && - $GNUTLS_CLI --list | grep -q '^TLS_RSA_NULL_SHA256.*0$' - } - then - M_CIPHERS="$M_CIPHERS \ + # Not actually supported with all GnuTLS versions. See + # GNUTLS_HAS_TLS1_RSA_NULL_SHA256= below. + M_CIPHERS="$M_CIPHERS \ TLS-RSA-WITH-NULL-SHA256 \ " - G_CIPHERS="$G_CIPHERS \ + G_CIPHERS="$G_CIPHERS \ +RSA:+NULL:+SHA256 \ " - fi if [ `minor_ver "$MODE"` -ge 3 ] then M_CIPHERS="$M_CIPHERS \ @@ -929,6 +919,23 @@ o_check_ciphersuite() fi } +# g_check_ciphersuite CIPHER_SUITE_NAME +g_check_ciphersuite() +{ + set -x + if [ -z "$GNUTLS_HAS_TLS1_RSA_NULL_SHA256" ]; then + case "$MODE" in + tls1|tls1_1|dtls1) + case "$1" in + TLS-RSA-WITH-NULL-SHA256|+RSA:+NULL:+SHA256) + SKIP_NEXT="YES";; + esac;; + esac + fi + set +x +} + + setup_arguments() { O_MODE="" @@ -1415,6 +1422,19 @@ for PEER in $PEERS; do esac done +case " $PEERS " in *\ [Gg]nu*) + GNUTLS_HAS_TLS1_RSA_NULL_SHA256= + # TLS-RSA-WITH-NULL-SHA256 is a (D)TLS 1.2-only cipher suite, + # like all SHA256 cipher suites. But Mbed TLS supports it with + # (D)TLS 1.0 and 1.1 as well. So do ancient versions of GnuTLS, + # but this was considered a bug which was fixed in GnuTLS 3.4.7. + # Check the GnuTLS support list to see what the protocol version + # requirement is for that cipher suite. + if $GNUTLS_CLI --list | grep -q '^TLS_RSA_NULL_SHA256.*0$'; then + GNUTLS_HAS_TLS1_RSA_NULL_SHA256=YES + fi +esac + # Pick a "unique" port in the range 10000-19999. PORT="0000$$" PORT="1$(echo $PORT | tail -c 5)" @@ -1504,6 +1524,7 @@ for MODE in $MODES; do if [ "X" != "X$M_CIPHERS" ]; then start_server "GnuTLS" for i in $M_CIPHERS; do + g_check_ciphersuite "$i" run_client mbedTLS $i done stop_server @@ -1512,6 +1533,7 @@ for MODE in $MODES; do if [ "X" != "X$G_CIPHERS" ]; then start_server "mbedTLS" for i in $G_CIPHERS; do + g_check_ciphersuite "$i" run_client GnuTLS $i done stop_server From 09ed985beef3ca16c22fcfff17ec7f4d89ed2619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 21 Mar 2024 11:07:14 +0100 Subject: [PATCH 4/4] Remove debugging code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- tests/compat.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/compat.sh b/tests/compat.sh index e41489f7bc..c2ea8821df 100755 --- a/tests/compat.sh +++ b/tests/compat.sh @@ -922,7 +922,6 @@ o_check_ciphersuite() # g_check_ciphersuite CIPHER_SUITE_NAME g_check_ciphersuite() { - set -x if [ -z "$GNUTLS_HAS_TLS1_RSA_NULL_SHA256" ]; then case "$MODE" in tls1|tls1_1|dtls1) @@ -932,7 +931,6 @@ g_check_ciphersuite() esac;; esac fi - set +x }