mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2024-12-26 18:20:21 +00:00
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>
This commit is contained in:
parent
0843214dee
commit
e330e58bd7
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user