@@ -55,8 +55,13 @@ extern "C" {
55
55
typedef struct {
56
56
/** A read-only pointer to the driver's persistent data.
57
57
*
58
- * The PSA Cryptography core saves the persistent data from one
59
- * session to the next.
58
+ * Drivers typically use this persistent data to keep track of
59
+ * which slot numbers are available. This is only a guideline:
60
+ * drivers may use the persistent data for any purpose, keeping
61
+ * in mind the restrictions on when the persistent data is saved
62
+ * to storage: the persistent data is only saved after calling
63
+ * certain functions that receive a writable pointer to the
64
+ * persistent data.
60
65
*
61
66
* The core allocates a memory buffer for the persistent data.
62
67
* The pointer is guaranteed to be suitably aligned for any data type,
@@ -74,7 +79,23 @@ typedef struct {
74
79
*
75
80
* This pointer is to read-only data. Only a few driver functions are
76
81
* allowed to modify the persistent data. These functions receive a
77
- * writable pointer.
82
+ * writable pointer. These functions are:
83
+ * - psa_drv_se_t::p_init
84
+ * - psa_drv_se_key_management_t::p_allocate
85
+ * - psa_drv_se_key_management_t::p_destroy
86
+ *
87
+ * The PSA Cryptography core saves the persistent data from one
88
+ * session to the next. It does this before returning from API functions
89
+ * that call a driver method that is allowed to modify the persistent
90
+ * data, specifically:
91
+ * - psa_crypto_init() causes a call to psa_drv_se_t::p_init, and may call
92
+ * psa_drv_se_key_management_t::p_destroy to complete an action
93
+ * that was interrupted by a power failure.
94
+ * - Key creation functions cause a call to
95
+ * psa_drv_se_key_management_t::p_allocate, and may cause a call to
96
+ * psa_drv_se_key_management_t::p_destroy in case an error occurs.
97
+ * - psa_destroy_key() causes a call to
98
+ * psa_drv_se_key_management_t::p_destroy.
78
99
*/
79
100
const void * const persistent_data ;
80
101
@@ -1118,7 +1139,14 @@ typedef struct {
1118
1139
*/
1119
1140
uint32_t hal_version ;
1120
1141
1121
- /** The size of the driver's persistent data in bytes. */
1142
+ /** The size of the driver's persistent data in bytes.
1143
+ *
1144
+ * This can be 0 if the driver does not need persistent data.
1145
+ *
1146
+ * See the documentation of psa_drv_se_context_t::persistent_data
1147
+ * for more information about why and how a driver can use
1148
+ * persistent data.
1149
+ */
1122
1150
size_t persistent_data_size ;
1123
1151
1124
1152
/** The driver initialization function.
0 commit comments