PK: return helpful error on API misuse

This makes test_suite_pk pass again, but beyond that I think it's the
right thing to do.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard
2026-02-12 10:07:57 +01:00
parent 210c613361
commit 00fd34ef18

View File

@@ -967,6 +967,13 @@ static int copy_from_psa(mbedtls_svc_key_id_t key_id,
if (exp_key == NULL) {
return MBEDTLS_ERR_PK_ALLOC_FAILED;
}
#else
/* In case we're passed non-ECC key (API misuse), return a sensible error
* now. Otherwise we might get BUFFER_TOO_SMALL when exporting below, which
* is unlikely to be helpful to the user as the buffer is internal. */
if (!PSA_KEY_TYPE_IS_ECC(key_type)) {
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
}
#endif
if (public_only) {