From 26909f348f142aa9be55e5a6c4725821956b1eec Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Wed, 31 Aug 2022 15:10:50 -0400 Subject: [PATCH] Add PSA initialization and teardown to tests using pkcs5 If PSA is defined and there is no MD - an initialization is required. Signed-off-by: Andrzej Kurek --- tests/suites/test_suite_pkcs5.function | 5 +++++ tests/suites/test_suite_pkparse.function | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/tests/suites/test_suite_pkcs5.function b/tests/suites/test_suite_pkcs5.function index d00d94fbbf..e2347ccd57 100644 --- a/tests/suites/test_suite_pkcs5.function +++ b/tests/suites/test_suite_pkcs5.function @@ -14,12 +14,14 @@ void pbkdf2_hmac( int hash, data_t * pw_str, data_t * salt_str, { unsigned char key[100]; + PSA_INIT(); TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac_ext( hash, pw_str->x, pw_str->len, salt_str->x, salt_str->len, it_cnt, key_len, key ) == 0 ); TEST_ASSERT( mbedtls_test_hexcmp( key, result_key_string->x, key_len, result_key_string->len ) == 0 ); + PSA_DONE(); } /* END_CASE */ @@ -31,6 +33,8 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw, mbedtls_asn1_buf params; unsigned char *my_out = NULL; + PSA_INIT(); + params.tag = params_tag; params.p = params_hex->x; params.len = params_hex->len; @@ -46,6 +50,7 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw, exit: mbedtls_free( my_out ); + PSA_DONE(); } /* END_CASE */ diff --git a/tests/suites/test_suite_pkparse.function b/tests/suites/test_suite_pkparse.function index 0a7798836d..1e003b9b5e 100644 --- a/tests/suites/test_suite_pkparse.function +++ b/tests/suites/test_suite_pkparse.function @@ -17,6 +17,7 @@ void pk_parse_keyfile_rsa( char * key_file, char * password, int result ) int res; char *pwd = password; + PSA_INIT(); mbedtls_pk_init( &ctx ); if( strcmp( pwd, "NULL" ) == 0 ) @@ -37,6 +38,7 @@ void pk_parse_keyfile_rsa( char * key_file, char * password, int result ) exit: mbedtls_pk_free( &ctx ); + PSA_DONE(); } /* END_CASE */ @@ -46,6 +48,7 @@ void pk_parse_public_keyfile_rsa( char * key_file, int result ) mbedtls_pk_context ctx; int res; + PSA_INIT(); mbedtls_pk_init( &ctx ); res = mbedtls_pk_parse_public_keyfile( &ctx, key_file ); @@ -62,6 +65,7 @@ void pk_parse_public_keyfile_rsa( char * key_file, int result ) exit: mbedtls_pk_free( &ctx ); + PSA_DONE(); } /* END_CASE */