mirror of
https://github.com/espressif/mbedtls.git
synced 2026-07-29 15:47:47 +00:00
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 <[email protected]>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user