@@ -876,8 +876,8 @@ static psa_status_t psa_get_key_from_slot( psa_key_handle_t handle,
876
876
* A transparent key is a key for which the key material is directly
877
877
* available, as opposed to a key in a secure element.
878
878
*
879
- * This is a temporary function until secure element support is
880
- * fully implemented.
879
+ * This is a temporary function to use instead of psa_get_key_from_slot()
880
+ * until secure element support is fully implemented.
881
881
*/
882
882
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
883
883
static psa_status_t psa_get_transparent_key ( psa_key_handle_t handle ,
@@ -981,6 +981,11 @@ psa_status_t psa_destroy_key( psa_key_handle_t handle )
981
981
driver = psa_get_se_driver_entry ( slot -> lifetime );
982
982
if ( driver != NULL )
983
983
{
984
+ /* For a key in a secure element, we need to do three things:
985
+ * remove the key file in internal storage, destroy the
986
+ * key inside the secure element, and update the driver's
987
+ * persistent data. Start a transaction that will encompass these
988
+ * three actions. */
984
989
psa_crypto_prepare_transaction ( PSA_CRYPTO_TRANSACTION_DESTROY_KEY );
985
990
psa_crypto_transaction .key .lifetime = slot -> lifetime ;
986
991
psa_crypto_transaction .key .slot = slot -> data .se .slot_number ;
@@ -1454,9 +1459,18 @@ static psa_status_t psa_start_key_creation(
1454
1459
slot -> type = attributes -> type ;
1455
1460
1456
1461
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
1457
- /* Find a slot number for the new key. Save the slot number in
1458
- * persistent storage, but do not yet save the driver's persistent
1459
- * state, so that if the power fails during the key creation process,
1462
+ /* For a key in a secure element, we need to do three things:
1463
+ * create the key file in internal storage, create the
1464
+ * key inside the secure element, and update the driver's
1465
+ * persistent data. Start a transaction that will encompass these
1466
+ * three actions. */
1467
+ /* The first thing to do is to find a slot number for the new key.
1468
+ * We save the slot number in persistent storage as part of the
1469
+ * transaction data. It will be needed to recover if the power
1470
+ * fails during the key creation process, to clean up on the secure
1471
+ * element side after restarting. Obtaining a slot number from the
1472
+ * secure element driver updates its persistent state, but we do not yet
1473
+ * save the driver's persistent state, so that if the power fails,
1460
1474
* we can roll back to a state where the key doesn't exist. */
1461
1475
if ( * p_drv != NULL )
1462
1476
{
0 commit comments