From e496c6273ee4e59c8508156094cc0a1854268e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 5 Jul 2022 13:11:13 +0200 Subject: [PATCH] Sort out MD dependencies in RSA tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When MD is only used to compute a size, use md_internal.h instead. When it's actually used to compute a hash, mark the test function as depending on it. This is probably suboptimal in the long run, and we might want to either adapt the code so that it can use PSA Crypto instead, or just pre-compute the hash in the test data. Signed-off-by: Manuel Pégourié-Gonnard --- tests/suites/test_suite_pk.function | 9 ++++----- tests/suites/test_suite_pkcs1_v15.function | 4 ++-- tests/suites/test_suite_rsa.function | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index f7ef421b5..78338d77f 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -475,7 +475,7 @@ void mbedtls_pk_check_pair( char * pub_file, char * prv_file, int ret ) } /* END_CASE */ -/* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ +/* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_MD_C */ void pk_rsa_verify_test_vec( data_t * message_str, int digest, int mod, int radix_N, char * input_N, int radix_E, char * input_E, data_t * result_str, @@ -526,7 +526,7 @@ exit: } /* END_CASE */ -/* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ +/* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_MD_C */ void pk_rsa_verify_ext_test_vec( data_t * message_str, int digest, int mod, int radix_N, char * input_N, int radix_E, char * input_E, @@ -1365,7 +1365,6 @@ void pk_psa_wrap_sign_ext( int pk_type, int parameter, int key_pk_type, int md_a psa_algorithm_t psa_md_alg = mbedtls_psa_translate_md( md_alg ); psa_algorithm_t psa_alg; size_t hash_len = PSA_HASH_LENGTH( psa_md_alg ); - const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); void const *options = NULL; mbedtls_pk_rsassa_pss_options rsassa_pss_options; int ret; @@ -1417,8 +1416,8 @@ void pk_psa_wrap_sign_ext( int pk_type, int parameter, int key_pk_type, int md_a if( key_pk_type == MBEDTLS_PK_RSASSA_PSS ) { rsassa_pss_options.mgf1_hash_id = md_alg; - TEST_ASSERT( md_info != NULL ); - rsassa_pss_options.expected_salt_len = mbedtls_md_get_size( md_info ); + TEST_ASSERT( hash_len != 0 ); + rsassa_pss_options.expected_salt_len = hash_len; options = (const void*) &rsassa_pss_options; } TEST_EQUAL( mbedtls_pk_verify_ext( key_pk_type, options, &pk, md_alg, diff --git a/tests/suites/test_suite_pkcs1_v15.function b/tests/suites/test_suite_pkcs1_v15.function index 6f859d5da..00da29443 100644 --- a/tests/suites/test_suite_pkcs1_v15.function +++ b/tests/suites/test_suite_pkcs1_v15.function @@ -261,7 +261,7 @@ exit: } /* END_CASE */ -/* BEGIN_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_MD_C */ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, char * input_N, int radix_E, char * input_E, int digest, int hash, @@ -320,7 +320,7 @@ exit: } /* END_CASE */ -/* BEGIN_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_MD_C */ void pkcs1_rsassa_v15_verify( int mod, int radix_N, char * input_N, int radix_E, char * input_E, int digest, int hash, data_t * message_str, char * salt, diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function index f5f515908..dbd4b53e7 100644 --- a/tests/suites/test_suite_rsa.function +++ b/tests/suites/test_suite_rsa.function @@ -76,7 +76,7 @@ void rsa_init_free( int reinit ) } /* END_CASE */ -/* BEGIN_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_MD_C */ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode, int digest, int mod, int radix_P, char * input_P, int radix_Q, char * input_Q, int radix_N, @@ -131,7 +131,7 @@ exit: } /* END_CASE */ -/* BEGIN_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_MD_C */ void mbedtls_rsa_pkcs1_verify( data_t * message_str, int padding_mode, int digest, int mod, int radix_N, char * input_N, int radix_E, char * input_E,