Skip to content

Commit 60450a4

Browse files
Improve comments
1 parent 725f22a commit 60450a4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

library/psa_crypto.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,8 @@ static psa_status_t psa_get_key_from_slot( psa_key_handle_t handle,
876876
* A transparent key is a key for which the key material is directly
877877
* available, as opposed to a key in a secure element.
878878
*
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.
881881
*/
882882
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
883883
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 )
981981
driver = psa_get_se_driver_entry( slot->lifetime );
982982
if( driver != NULL )
983983
{
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. */
984989
psa_crypto_prepare_transaction( PSA_CRYPTO_TRANSACTION_DESTROY_KEY );
985990
psa_crypto_transaction.key.lifetime = slot->lifetime;
986991
psa_crypto_transaction.key.slot = slot->data.se.slot_number;
@@ -1454,9 +1459,18 @@ static psa_status_t psa_start_key_creation(
14541459
slot->type = attributes->type;
14551460

14561461
#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,
14601474
* we can roll back to a state where the key doesn't exist. */
14611475
if( *p_drv != NULL )
14621476
{

0 commit comments

Comments
 (0)