From e330e58bd7efca051bd7f2536efba59771c50653 Mon Sep 17 00:00:00 2001 From: Waleed Elmelegy Date: Mon, 9 Dec 2024 18:04:05 +0000 Subject: [PATCH] Improve iop export public-key testing * Improve wording of comments. * Zeroize buffer before doing iop testing to avoid comparing with previous values in case they are not overwritten. * Remove redundant testing. Signed-off-by: Waleed Elmelegy --- .../tests/suites/test_suite_psa_crypto.function | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tf-psa-crypto/tests/suites/test_suite_psa_crypto.function b/tf-psa-crypto/tests/suites/test_suite_psa_crypto.function index a793404ece..6be0f60c11 100644 --- a/tf-psa-crypto/tests/suites/test_suite_psa_crypto.function +++ b/tf-psa-crypto/tests/suites/test_suite_psa_crypto.function @@ -1929,7 +1929,7 @@ void import_export_public_key(data_t *data, } /* Adjust expected_status for interruptible export public-key. - * Interruptible export public-key is only supported for ECC key pairs and even + * Interruptible export public-key is only supported for ECC keys and even * for those only when MBEDTLS_ECP_RESTARTABLE is on. */ if ((PSA_KEY_TYPE_IS_KEY_PAIR(type) || PSA_KEY_TYPE_IS_PUBLIC_KEY(type)) && @@ -1953,6 +1953,8 @@ void import_export_public_key(data_t *data, expected_export_status = PSA_ERROR_BAD_STATE; } + memset(exported, 0, export_size); + do { status = psa_export_public_key_iop_complete(&export_key_operation, exported, @@ -1962,16 +1964,6 @@ void import_export_public_key(data_t *data, TEST_EQUAL(status, expected_export_status); if (status == PSA_SUCCESS) { - psa_key_type_t public_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type); - size_t bits; - PSA_ASSERT(psa_get_key_attributes(key, &attributes)); - bits = psa_get_key_bits(&attributes); - TEST_LE_U(expected_public_key->len, - PSA_EXPORT_KEY_OUTPUT_SIZE(public_type, bits)); - TEST_LE_U(expected_public_key->len, - PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(public_type, bits)); - TEST_LE_U(expected_public_key->len, - PSA_EXPORT_PUBLIC_KEY_MAX_SIZE); TEST_MEMORY_COMPARE(expected_public_key->x, expected_public_key->len, exported, exported_length); }