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 <waleed.elmelegy@arm.com>
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 a793404..6be0f60 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 @@
}
/* 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 @@
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 @@
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);
}