Skip to content

Commit 8b66389

Browse files
Adjust secure element code to the new ITS interface
1 parent 72c8c5b commit 8b66389

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

library/psa_crypto_se.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,23 @@ psa_status_t psa_load_se_persistent_data(
148148
{
149149
psa_status_t status;
150150
psa_storage_uid_t uid;
151+
size_t length;
151152

152153
status = psa_get_se_driver_its_file_uid( driver, &uid );
153154
if( status != PSA_SUCCESS )
154155
return( status );
155156

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. */
156161
/* psa_get_se_driver_its_file_uid ensures that the size_t
157162
* persistent_data_size is in range, but compilers don't know that,
158163
* so cast to reassure them. */
159164
return( psa_its_get( uid, 0,
160165
(uint32_t) driver->internal.persistent_data_size,
161-
driver->internal.persistent_data ) );
166+
driver->internal.persistent_data,
167+
&length ) );
162168
}
163169

164170
psa_status_t psa_save_se_persistent_data(

library/psa_crypto_storage.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,16 @@ psa_status_t psa_crypto_save_transaction( void )
437437

438438
psa_status_t psa_crypto_load_transaction( void )
439439
{
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 );
443450
}
444451

445452
psa_status_t psa_crypto_stop_transaction( void )

0 commit comments

Comments
 (0)