Skip to content

Commit 2792c35

Browse files
Improve documentation of transaction storage
1 parent f9bb29e commit 2792c35

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

library/psa_crypto_storage.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ psa_status_t psa_parse_key_data_from_storage( const uint8_t *storage_data,
206206
typedef uint16_t psa_crypto_transaction_type_t;
207207

208208
/** No transaction is in progress.
209+
*
210+
* This has the value 0, so zero-initialization sets a transaction's type to
211+
* this value.
209212
*/
210213
#define PSA_CRYPTO_TRANSACTION_NONE ( (psa_crypto_transaction_type_t) 0x0000 )
211214

@@ -244,16 +247,22 @@ typedef uint16_t psa_crypto_transaction_type_t;
244247
* -# Fill in the type-specific fields of #psa_crypto_transaction.
245248
* -# Call psa_crypto_save_transaction() to start the transaction. This
246249
* saves the transaction data to internal storage.
250+
* -# Perform the work of the transaction by modifying files, contacting
251+
* external entities, or whatever needs doing. Note that the transaction
252+
* may be interrupted by a power failure, so you need to have a way
253+
* recover from interruptions either by undoing what has been done
254+
* so far or by resuming where you left off.
247255
* -# If there are intermediate stages in the transaction, update
248256
* the fields of #psa_crypto_transaction and call
249257
* psa_crypto_save_transaction() again when each stage is reached.
250-
* -# When the transaction is over, whether it has been committed or aborted,
251-
* call psa_crypto_stop_transaction() to remove the transaction data in
252-
* storage and in memory.
258+
* -# When the transaction is over, call psa_crypto_stop_transaction() to
259+
* remove the transaction data in storage and in memory.
253260
*
254261
* If the system crashes while a transaction is in progress, psa_crypto_init()
255262
* calls psa_crypto_load_transaction() and takes care of completing or
256-
* rewinding the transaction.
263+
* rewinding the transaction. This is done in psa_crypto_recover_transaction()
264+
* in psa_crypto.c. If you add a new type of transactions, be
265+
* sure to add code for it in psa_crypto_recover_transaction().
257266
*/
258267
typedef union
259268
{
@@ -328,8 +337,10 @@ psa_status_t psa_crypto_load_transaction( void );
328337

329338
/** Indicate that the current transaction is finished.
330339
*
331-
* Call this function at the very end of transaction processing, whether
332-
* the transaction has been committed or aborted.
340+
* Call this function at the very end of transaction processing.
341+
* This function does not "commit" or "abort" the transaction: the storage
342+
* subsystem has no concept of "commit" and "abort", just saving and
343+
* removing the transaction information in storage.
333344
*
334345
* This function erases the transaction data in storage (if any) and
335346
* resets the transaction data in memory.

0 commit comments

Comments
 (0)