raw_key_agreement_with_self: check output consistency

In `mbedtls_test_psa_raw_key_agreement_with_self()`, we may use up to three
key agreement methods: `psa_raw_key_agreement()`, `psa_key_agreement()`, and
the interruptible interface. Check that all three have the same output.

Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
Gilles Peskine
2025-01-22 12:33:40 +01:00
parent f522114db3
commit 82b5b92bf8
+15 -5
View File
@@ -782,13 +782,14 @@ psa_status_t mbedtls_test_psa_raw_key_agreement_with_self(
TEST_CALLOC(exported, exported_size);
status = psa_export_key(shared_secret_id, exported, exported_size, &exported_length);
if (key_destroyable && status == PSA_ERROR_INVALID_HANDLE) {
/* The key has been destroyed. */
status = PSA_SUCCESS;
} else {
PSA_ASSERT(status);
TEST_MEMORY_COMPARE(exported, exported_length,
output, output_length);
}
PSA_ASSERT(status);
}
#if defined(MBEDTLS_ECP_RESTARTABLE) && defined(MBEDTLS_PSA_BUILTIN_ALG_ECDH)
@@ -825,9 +826,18 @@ psa_status_t mbedtls_test_psa_raw_key_agreement_with_self(
if (key_destroyable && status == PSA_ERROR_INVALID_HANDLE) {
/* The key has been destroyed. */
status = PSA_SUCCESS;
} else {
PSA_ASSERT(status);
status = psa_export_key(shared_secret_id, exported, exported_size, &exported_length);
if (key_destroyable && status == PSA_ERROR_INVALID_HANDLE) {
/* The key has been destroyed. */
status = PSA_SUCCESS;
} else {
PSA_ASSERT(status);
TEST_MEMORY_COMPARE(exported, exported_length,
output, output_length);
}
}
PSA_ASSERT(status);
}
} else {
TEST_EQUAL(psa_key_agreement_iop_setup(&iop_operation, key, public_key,