Skip to content

Commit 7873339

Browse files
committed
[nrf toup] don't try to find volatile/builtin keys from wrong sources
When not finding a given key in memory, the implementation would try to find it from the persistent keys regardless of the actual key type (volatile/builtin/persistent). Don't try to find inexistent volatile/builtin keys from persistent ones. In addition to the calls being superflous, the problem that was happening here is that the ITS implementation (Secure Storage subsystem) returns `PSA_ERROR_INVALID_ARGUMENT` because the ID is not in the persistent key range, and because it doesn't return `PSA_ERROR_DOES_NOT_EXIST` then the wrong error code is propagated back to the caller. `toup` as the issue has been communicated to Mbed TLS and should be fixed there. See: - Mbed-TLS/TF-PSA-Crypto#488 - Mbed-TLS/TF-PSA-Crypto#492 Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
1 parent 180fa1b commit 7873339

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/psa_crypto_slot_management.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@ static psa_status_t psa_load_persistent_key_into_slot(psa_key_slot_t *slot)
685685
uint8_t *key_data = NULL;
686686
size_t key_data_length = 0;
687687

688+
if (!psa_is_valid_key_id(slot->attr.id, 0)) {
689+
return PSA_ERROR_DOES_NOT_EXIST;
690+
}
691+
688692
#if defined(MBEDTLS_PSA_STATIC_KEY_SLOTS) /* !!OM */
689693
key_data = slot->key.data;
690694
status = psa_load_persistent_key_static(&slot->attr,

0 commit comments

Comments
 (0)