From 3da3c0a0009dca7abd26c387d1754f8c56a431e6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 30 Jan 2024 10:22:29 +0100 Subject: [PATCH] Always call psa_crypto_init when testing mbedtls_pk_get_psa_attributes mbedtls_pk_get_psa_attributes() actually works without having initialized the PSA subsystem, because it doesn't call any non-client PSA API functions. But the function is only useful in conjunction with the PSA API: it's meant to be followed by importing a key with the resulting attributes. We don't advertize it to work without an up-and-running PSA subsystem, and there's no need to test it without an up-and-running PSA subsystem as we were (accidentally) doing. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_pk.function | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index 23a7b2523..225ead484 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -1711,7 +1711,7 @@ void pk_get_psa_attributes(int pk_type, int from_pair, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_usage_t usage = usage_arg; - MD_OR_USE_PSA_INIT(); + PSA_INIT(); psa_key_type_t expected_psa_type = 0; if (!pk_setup_for_type(pk_type, from_pair, &pk, &expected_psa_type)) { @@ -1772,7 +1772,7 @@ void pk_get_psa_attributes(int pk_type, int from_pair, exit: mbedtls_pk_free(&pk); psa_reset_key_attributes(&attributes); - MD_OR_USE_PSA_DONE(); + PSA_DONE(); } /* END_CASE */ @@ -1786,7 +1786,7 @@ void pk_rsa_v21_get_psa_attributes(int md_type, int from_pair, psa_key_usage_t usage = usage_arg; psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; - MD_OR_USE_PSA_INIT(); + PSA_INIT(); psa_key_type_t expected_psa_type = 0; if (!pk_setup_for_type(MBEDTLS_PK_RSA, from_pair, &pk, &expected_psa_type)) { @@ -1833,7 +1833,7 @@ void pk_rsa_v21_get_psa_attributes(int md_type, int from_pair, exit: mbedtls_pk_free(&pk); psa_reset_key_attributes(&attributes); - MD_OR_USE_PSA_DONE(); + PSA_DONE(); } /* END_CASE */ @@ -1847,7 +1847,7 @@ void pk_get_psa_attributes_fail(int pk_type, int from_pair, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_key_usage_t usage = usage_arg; - MD_OR_USE_PSA_INIT(); + PSA_INIT(); psa_key_type_t expected_psa_type; if (!pk_setup_for_type(pk_type, from_pair, &pk, &expected_psa_type)) { @@ -1860,7 +1860,7 @@ void pk_get_psa_attributes_fail(int pk_type, int from_pair, exit: mbedtls_pk_free(&pk); psa_reset_key_attributes(&attributes); - MD_OR_USE_PSA_DONE(); + PSA_DONE(); } /* END_CASE */