File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -148,17 +148,23 @@ psa_status_t psa_load_se_persistent_data(
148
148
{
149
149
psa_status_t status ;
150
150
psa_storage_uid_t uid ;
151
+ size_t length ;
151
152
152
153
status = psa_get_se_driver_its_file_uid ( driver , & uid );
153
154
if ( status != PSA_SUCCESS )
154
155
return ( status );
155
156
157
+ /* Read the amount of persistent data that the driver requests.
158
+ * If the data in storage is larger, it is truncated. If the data
159
+ * in storage is smaller, silently keep what is already at the end
160
+ * of the output buffer. */
156
161
/* psa_get_se_driver_its_file_uid ensures that the size_t
157
162
* persistent_data_size is in range, but compilers don't know that,
158
163
* so cast to reassure them. */
159
164
return ( psa_its_get ( uid , 0 ,
160
165
(uint32_t ) driver -> internal .persistent_data_size ,
161
- driver -> internal .persistent_data ) );
166
+ driver -> internal .persistent_data ,
167
+ & length ) );
162
168
}
163
169
164
170
psa_status_t psa_save_se_persistent_data (
Original file line number Diff line number Diff line change @@ -437,9 +437,16 @@ psa_status_t psa_crypto_save_transaction( void )
437
437
438
438
psa_status_t psa_crypto_load_transaction ( void )
439
439
{
440
- return ( psa_its_get ( PSA_CRYPTO_ITS_TRANSACTION_UID , 0 ,
441
- sizeof ( psa_crypto_transaction ),
442
- & psa_crypto_transaction ) );
440
+ psa_status_t status ;
441
+ size_t length ;
442
+ status = psa_its_get ( PSA_CRYPTO_ITS_TRANSACTION_UID , 0 ,
443
+ sizeof ( psa_crypto_transaction ),
444
+ & psa_crypto_transaction , & length );
445
+ if ( status != PSA_SUCCESS )
446
+ return ( status );
447
+ if ( length != sizeof ( psa_crypto_transaction ) )
448
+ return ( PSA_ERROR_STORAGE_FAILURE );
449
+ return ( PSA_SUCCESS );
443
450
}
444
451
445
452
psa_status_t psa_crypto_stop_transaction ( void )
You can’t perform that action at this time.
0 commit comments