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.
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 92c9668..b2fc26e 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -993,6 +993,7 @@
status = psa_crypto_save_transaction( );
if( status != PSA_SUCCESS )
{
+ (void) psa_crypto_stop_transaction( );
/* TOnogrepDO: destroy what can be destroyed anyway */
return( status );
}
@@ -1484,7 +1485,10 @@
psa_crypto_transaction.key.id = slot->persistent_storage_id;
status = psa_crypto_save_transaction( );
if( status != PSA_SUCCESS )
+ {
+ (void) psa_crypto_stop_transaction( );
return( status );
+ }
}
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */