From 20a4ade3f5157855f712eaf5dac9a9f5f11fdff3 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 3 Jun 2019 14:27:03 +0100 Subject: [PATCH] Add test cases exercising successful verification of MD2/MD4/MD5 CRT --- tests/suites/test_suite_x509parse.data | 12 ++++++++++++ tests/suites/test_suite_x509parse.function | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/tests/suites/test_suite_x509parse.data b/tests/suites/test_suite_x509parse.data index 886858e21..b0dd8fba5 100644 --- a/tests/suites/test_suite_x509parse.data +++ b/tests/suites/test_suite_x509parse.data @@ -539,6 +539,18 @@ X509 Certificate verification #13 (Valid Cert MD5 Digest, MD5 forbidden) depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"compat":"NULL" +X509 Certificate verification #12 (Valid Cert MD2 Digest, MD2 allowed) +depends_on:MBEDTLS_MD2_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md2.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"all":"NULL" + +X509 Certificate verification #12 (Valid Cert MD4 Digest, MD4 allowed) +depends_on:MBEDTLS_MD4_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md4.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"all":"NULL" + +X509 Certificate verification #13 (Valid Cert MD5 Digest, MD5 allowed) +depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"all":"NULL" + X509 Certificate verification #14 (Valid Cert SHA1 Digest explicitly allowed in profile) depends_on:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL" diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function index b4e980210..85ff41df2 100644 --- a/tests/suites/test_suite_x509parse.function +++ b/tests/suites/test_suite_x509parse.function @@ -15,6 +15,15 @@ than the current threshold 19. To test larger values, please \ adapt the script tests/data_files/dir-max/long.sh." #endif +/* Test-only profile allowing all digests, PK algorithms, and curves. */ +const mbedtls_x509_crt_profile profile_all = +{ + 0xFFFFFFFF, /* Any MD */ + 0xFFFFFFFF, /* Any PK alg */ + 0xFFFFFFFF, /* Any curve */ + 1024, +}; + /* Profile for backward compatibility. Allows SHA-1, unlike the default profile. */ const mbedtls_x509_crt_profile compat_profile = @@ -531,6 +540,8 @@ void x509_verify( char *crt_file, char *ca_file, char *crl_file, profile = &mbedtls_x509_crt_profile_suiteb; else if( strcmp( profile_str, "compat" ) == 0 ) profile = &compat_profile; + else if( strcmp( profile_str, "all" ) == 0 ) + profile = &profile_all; else TEST_ASSERT( "Unknown algorithm profile" == 0 );