From 7544195a449acc70cafc2a3bddf4c95667310898 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 14:12:16 +0200 Subject: [PATCH 01/12] Remove echo FORCE SKIP This was probably an artifact from testing the cmdline_compat-stuff. Currently only pollutes the output. --- tests/ssl-opt.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index a6ad765e7..2d93ca344 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -656,7 +656,6 @@ check_cmdline_force_version_compat() { SKIP_NEXT="YES" elif ( [ "$__ARG" = "tls1_2" ] || [ "$__ARG" = "dtls1_2" ] ) && \ ( [ "$__VAL_MIN" != "3" ] || [ "$__VAL_MAX" != "3" ] ); then - echo "FORCE SKIP" SKIP_NEXT="YES" fi From 5b944b5793bd4c968a1e1cfc75edeffaa9d7dbe3 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 10:30:10 +0200 Subject: [PATCH 02/12] define MBEDTLS_FS_IO This is needed for the tests using certificate-files. --- configs/baremetal_test.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/baremetal_test.h b/configs/baremetal_test.h index 33b51673d..7a0377708 100644 --- a/configs/baremetal_test.h +++ b/configs/baremetal_test.h @@ -43,6 +43,9 @@ /* Use Mbed TLS' timer implementation for Linux. */ #define MBEDTLS_TIMING_C +/* Needed for certificates in ssl_opt.sh */ +#define MBEDTLS_FS_IO + #undef MBEDTLS_NO_PLATFORM_ENTROPY #undef MBEDTLS_ENTROPY_MAX_SOURCES From ff434c2ef3ffbac9421eec4a6b77d243d7ee63ae Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Fri, 25 Oct 2019 12:21:54 +0300 Subject: [PATCH 03/12] Add test for enforcing extended master secret Only add test when both are enforcing. This is configured in baremetal.h and is checked in the check_cmdline_compat, would render other cases with baremetal.h to skipped. --- tests/ssl-opt.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 2d93ca344..5c09e18e7 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -2375,6 +2375,17 @@ run_test "Extended Master Secret: client enabled, server SSLv3" \ -C "session hash for extended master secret" \ -S "session hash for extended master secret" +run_test "Extended Master Secret: both enabled, both enforcing, DTLS" \ + "$P_SRV dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \ + "$P_CLI dtls=1 debug_level=3 extended_ms=1 enforce_extended_master_secret=1" \ + 0 \ + -c "client hello, adding extended_master_secret extension" \ + -s "found extended master secret extension" \ + -s "server hello, adding extended master secret extension" \ + -c "found extended_master_secret extension" \ + -c "session hash for extended master secret" \ + -s "session hash for extended master secret" + # Tests for FALLBACK_SCSV run_test "Fallback SCSV: default" \ From c5118b7664f85e221917a6eddc4c532576e0d940 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 10:30:58 +0200 Subject: [PATCH 04/12] Add a new keyUsage test for p256 using DTLS --- tests/ssl-opt.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 5c09e18e7..d0fcfeb04 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -4835,6 +4835,12 @@ run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \ 0 \ -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-" +run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA p256" \ + "$P_SRV dtls=1 key_file=data_files/server11.key.der \ + crt_file=data_files/server11.crt.der" \ + "$P_CLI dtls=1 ca_file=data_files/test-ca3.crt.der" \ + 0 \ + -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-" run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \ "$P_SRV key_file=data_files/server5.key \ From 0ed68089ee9e97858b74db30920405b3202663b9 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 14:10:59 +0200 Subject: [PATCH 05/12] Add test for small client packet Enable testing with ECDHE-ECDSA with DTLS --- tests/ssl-opt.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index d0fcfeb04..4d3904195 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -5657,6 +5657,13 @@ run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \ 0 \ -s "Read from client: 1 bytes read" +run_test "Small client packet DTLS, ECDHE-ECDSA" \ + "$P_SRV dtls=1" \ + "$P_CLI dtls=1 request_size=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ + 0 \ + -s "Read from client: 1 bytes read" + # Tests for small server packets requires_config_enabled MBEDTLS_SSL_PROTO_SSL3 From c40184b44aa54e1ff3fa9781ad27c1ab9819306e Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 14:16:12 +0200 Subject: [PATCH 06/12] Add test for small server packet To allow testing with ECDHE-ECDSA with DTLS --- tests/ssl-opt.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 4d3904195..6faf61a0f 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -5945,6 +5945,13 @@ run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \ 0 \ -c "Read from server: 1 bytes read" +run_test "Small server packet DTLS, ECDHE-ECDSA" \ + "$P_SRV dtls=1 response_size=1" \ + "$P_CLI dtls=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ + 0 \ + -c "Read from server: 1 bytes read" + # A test for extensions in SSLv3 requires_config_enabled MBEDTLS_SSL_PROTO_SSL3 From d3428051349eeb0af3348ac25805245a82a4855a Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 14:36:37 +0200 Subject: [PATCH 07/12] Added Forced ECC ciphersuite with CCM tests --- tests/ssl-opt.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 6faf61a0f..999275305 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -6987,6 +6987,30 @@ run_test "Force an ECC ciphersuite in the server side" \ -c "found supported_point_formats extension" \ -s "server hello, supported_point_formats extension" +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CCM_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +run_test "Force an ECC ciphersuite with CCM in the client side" \ + "$P_SRV dtls=1 debug_level=3" \ + "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ + 0 \ + -c "client hello, adding supported_elliptic_curves extension" \ + -c "client hello, adding supported_point_formats extension" \ + -s "found supported elliptic curves extension" \ + -s "found supported point formats extension" + +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CCM_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +run_test "Force an ECC ciphersuite with CCM in the server side" \ + "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ + "$P_CLI dtls=1 debug_level=3" \ + 0 \ + -c "found supported_point_formats extension" \ + -s "server hello, supported_point_formats extension" + # Tests for DTLS HelloVerifyRequest run_test "DTLS cookie: enabled" \ From b514cd3626eeb5741b62cd18808e837fa3559796 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 28 Oct 2019 14:37:51 +0200 Subject: [PATCH 08/12] Remove dependency to MBEDTLS_ERROR_C The test is already checking for return value No need to check for MBEDTLS_ERROR_C -dependent print --- tests/ssl-opt.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 999275305..94bd495b3 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -7035,7 +7035,6 @@ run_test "DTLS cookie: disabled" \ -S "hello verification requested" \ -S "SSL - The requested feature is not available" -requires_config_enabled MBEDTLS_ERROR_C run_test "DTLS cookie: default (failing)" \ "$P_SRV dtls=1 debug_level=2 cookies=-1" \ "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \ @@ -7044,8 +7043,7 @@ run_test "DTLS cookie: default (failing)" \ -S "cookie verification passed" \ -S "cookie verification skipped" \ -C "received hello verify request" \ - -S "hello verification requested" \ - -s "SSL - The requested feature is not available" + -S "hello verification requested" requires_ipv6 run_test "DTLS cookie: enabled, IPv6" \ From 6f54fe72f26d84a4598b5a29516f962b8851168b Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Tue, 29 Oct 2019 15:15:58 +0200 Subject: [PATCH 09/12] Add a bad version of server11 certificate The certificate has a corrupted public key and signature. Generating it through Makefile isn't trivial and since it is a corrupted certificate, that shouldn't be accepted, there shouldn't be a need to generate it again anyway. --- tests/data_files/Readme-x509.txt | 1 + tests/data_files/server11-bad.crt.der | Bin 0 -> 435 bytes 2 files changed, 1 insertion(+) create mode 100644 tests/data_files/server11-bad.crt.der diff --git a/tests/data_files/Readme-x509.txt b/tests/data_files/Readme-x509.txt index 388865be5..850237a84 100644 --- a/tests/data_files/Readme-x509.txt +++ b/tests/data_files/Readme-x509.txt @@ -107,6 +107,7 @@ List of certificates: _int3_int-ca2_ca.crt: S10 + I3 + I2 + 1 _int3_spurious_int-ca2.crt: S10 + I3 + I1(spurious) + I2 - server11.crt: 3 E, secp256r1 curve + -bad.crt.der: S11 with corrupted public key and signature Certificate revocation lists ---------------------------- diff --git a/tests/data_files/server11-bad.crt.der b/tests/data_files/server11-bad.crt.der new file mode 100644 index 0000000000000000000000000000000000000000..0a782a76614e00c296c15c603fb0f7a375662d31 GIT binary patch literal 435 zcmXqLVq9;~#2B=InTe5!iILHOhmAw4&EuRc3o{cdgMqc7lz{{rb0`Zlk6=h@afyPn zqe5_Ma)FVlS&^ZkfB_#!j*ExgHz_qG#3$I0+kg`!!Y0fV>TMt=&TC)@h6W%ICC+PX zU}$6vM5dOemQe=AhC&7c5W_ih@{<#DGV+T{2pJk_Ak4-Nb|DiZ)Tzvj?95IKEXN=D zcKp70?0*8!!^0&@e#%>~om;YW!xn2<(f>CWtSN}?+`<(WcXpau-OQTfQ>=f+u8`ur z9M`bN=jHSs?x@@kXBYb#c!QlUE6l=Vz+fN?beb$5ix`WDa-6N)ZBCc4DNXq*D|crx zt8xC`WFQZcR%Vef5Ni@DWOV_2bNdhPeQfaeNAs3FPh$zb5dq{z_w{$nNY zW{V&`--3nrG{SD*aeTQ!;=$$r4`SD+sc*690V?Tvw0QLg&d$&4P8M%8JHISD Date: Tue, 29 Oct 2019 15:16:40 +0200 Subject: [PATCH 10/12] Add authentication tests for baremetal config --- tests/ssl-opt.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 94bd495b3..b18d64c67 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -3787,6 +3787,25 @@ run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsuppo -c "! Certificate verification flags"\ -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check +requires_config_enabled MBEDTLS_USE_TINYCRYPT +run_test "Authentication: DTLS server ECDH p256v1, client required, server goodcert" \ + "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \ + crt_file=data_files/server11.crt.der" \ + "$P_CLI dtls=1 debug_level=3 auth_mode=required" \ + 0 \ + -C "bad certificate (EC key curve)"\ + -C "! Certificate verification flags"\ + -C "! mbedtls_ssl_handshake returned" + +requires_config_enabled MBEDTLS_USE_TINYCRYPT +run_test "Authentication: DTLS server ECDH p256v1, client required, server badcert" \ + "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \ + crt_file=data_files/server11-bad.crt.der" \ + "$P_CLI dtls=1 debug_level=3 auth_mode=required" \ + 1 \ + -c "! Certificate verification flags"\ + -c "! mbedtls_ssl_handshake returned" + run_test "Authentication: server badcert, client none" \ "$P_SRV crt_file=data_files/server5-badsign.crt \ key_file=data_files/server5.key" \ From 77c4fcc96e45648588cd7b9483df3ae6ce518479 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Wed, 30 Oct 2019 14:44:05 +0200 Subject: [PATCH 11/12] Use DER encoded keys with tinycrypt PEM and BASE64 aren't used with baremetal config by default and using DER encoded key enables the test without enabling PEM and BASE64. --- tests/data_files/ec_256_pub.der | Bin 0 -> 91 bytes tests/suites/test_suite_pk.data | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tests/data_files/ec_256_pub.der diff --git a/tests/data_files/ec_256_pub.der b/tests/data_files/ec_256_pub.der new file mode 100644 index 0000000000000000000000000000000000000000..2ba259538d55d60a1d89a19c3a558e19c0997886 GIT binary patch literal 91 zcmXqrG!SNE*J|@PXUoLM#sOw9GqN)~F|d>urRFz!TTZIH`tW0g{F;2uSvD~XH#`mw tZ1(2Z7RMc~I^pd4{<6u5dp>)eKPVT+?$@HW_a4i>yi`k9mucenTmg74BDw$o literal 0 HcmV?d00001 diff --git a/tests/suites/test_suite_pk.data b/tests/suites/test_suite_pk.data index 5bdbea05c..c8f4d70d6 100644 --- a/tests/suites/test_suite_pk.data +++ b/tests/suites/test_suite_pk.data @@ -154,7 +154,7 @@ mbedtls_pk_check_pair:"data_files/ec_256_pub.pem":"data_files/server5.key":MBEDT Check pair #2 (EC, bad, TinyCrypt) depends_on:MBEDTLS_USE_TINYCRYPT -mbedtls_pk_check_pair:"data_files/ec_256_pub.pem":"data_files/server5.key":MBEDTLS_ERR_PK_BAD_INPUT_DATA +mbedtls_pk_check_pair:"data_files/ec_256_pub.der":"data_files/server5.key.der":MBEDTLS_ERR_PK_BAD_INPUT_DATA Check pair #3 (RSA, OK) depends_on:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 From 2e2fa5e352ee01b2d03d0123cb0e6a5cb8245770 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Wed, 30 Oct 2019 15:08:26 +0200 Subject: [PATCH 12/12] Adress review comments --- tests/ssl-opt.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index b18d64c67..cd0b03119 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -3788,7 +3788,7 @@ run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsuppo -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check requires_config_enabled MBEDTLS_USE_TINYCRYPT -run_test "Authentication: DTLS server ECDH p256v1, client required, server goodcert" \ +run_test "Authentication: DTLS server ECDH p256, client required, server goodcert" \ "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \ crt_file=data_files/server11.crt.der" \ "$P_CLI dtls=1 debug_level=3 auth_mode=required" \ @@ -3798,7 +3798,7 @@ run_test "Authentication: DTLS server ECDH p256v1, client required, server go -C "! mbedtls_ssl_handshake returned" requires_config_enabled MBEDTLS_USE_TINYCRYPT -run_test "Authentication: DTLS server ECDH p256v1, client required, server badcert" \ +run_test "Authentication: DTLS server ECDH p256, client required, server badcert" \ "$P_SRV dtls=1 debug_level=1 key_file=data_files/server11.key.der \ crt_file=data_files/server11-bad.crt.der" \ "$P_CLI dtls=1 debug_level=3 auth_mode=required" \ @@ -7006,10 +7006,7 @@ run_test "Force an ECC ciphersuite in the server side" \ -c "found supported_point_formats extension" \ -s "server hello, supported_point_formats extension" -requires_config_enabled MBEDTLS_AES_C -requires_config_enabled MBEDTLS_CCM_C -requires_config_enabled MBEDTLS_SHA256_C -requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 run_test "Force an ECC ciphersuite with CCM in the client side" \ "$P_SRV dtls=1 debug_level=3" \ "$P_CLI dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ @@ -7019,10 +7016,7 @@ run_test "Force an ECC ciphersuite with CCM in the client side" \ -s "found supported elliptic curves extension" \ -s "found supported point formats extension" -requires_config_enabled MBEDTLS_AES_C -requires_config_enabled MBEDTLS_CCM_C -requires_config_enabled MBEDTLS_SHA256_C -requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +requires_ciphersuite_enabled TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 run_test "Force an ECC ciphersuite with CCM in the server side" \ "$P_SRV dtls=1 debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \ "$P_CLI dtls=1 debug_level=3" \