mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Make psa_fail_key_creation thread safe
Hold the mutex for the entirety of the call. We need the mutex for the wipe, also hold it for aborting driver transactions as this may have side effects. We can't use the macros here as this function returns void. Signed-off-by: Ryan Everett <ryan.everett@arm.com>
This commit is contained in:
@ -1891,6 +1891,10 @@ static void psa_fail_key_creation(psa_key_slot_t *slot,
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
mbedtls_mutex_lock(&mbedtls_threading_key_slot_mutex);
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||
/* TODO: If the key has already been created in the secure
|
||||
* element, and the failure happened later (when saving metadata
|
||||
@ -1909,6 +1913,10 @@ static void psa_fail_key_creation(psa_key_slot_t *slot,
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||
|
||||
psa_wipe_key_slot(slot);
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
mbedtls_mutex_unlock(&mbedtls_threading_key_slot_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Validate optional attributes during key creation.
|
||||
|
Reference in New Issue
Block a user