Skip to content

Commit 66be51c

Browse files
If starting a transaction fails, wipe the transaction data
Nothing has been saved to disk yet, but there is stale data in psa_crypto_transaction. This stale data should not be reused, but do wipe it to reduce the risk of it mattering somehow in the future.
1 parent 2ea06fd commit 66be51c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/psa_crypto.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ psa_status_t psa_destroy_key( psa_key_handle_t handle )
993993
status = psa_crypto_save_transaction( );
994994
if( status != PSA_SUCCESS )
995995
{
996+
(void) psa_crypto_stop_transaction( );
996997
/* TOnogrepDO: destroy what can be destroyed anyway */
997998
return( status );
998999
}
@@ -1484,7 +1485,10 @@ static psa_status_t psa_start_key_creation(
14841485
psa_crypto_transaction.key.id = slot->persistent_storage_id;
14851486
status = psa_crypto_save_transaction( );
14861487
if( status != PSA_SUCCESS )
1488+
{
1489+
(void) psa_crypto_stop_transaction( );
14871490
return( status );
1491+
}
14881492
}
14891493
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
14901494

0 commit comments

Comments
 (0)