Switch storage functions over to psa_core_key_attributes_t
diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c
index 4113fb7..55fd65a 100644
--- a/library/psa_crypto_storage.c
+++ b/library/psa_crypto_storage.c
@@ -264,7 +264,7 @@
void psa_format_key_data_for_storage( const uint8_t *data,
const size_t data_length,
- const psa_key_attributes_t *attributes,
+ const psa_core_key_attributes_t *attr,
uint8_t *storage_data )
{
psa_persistent_key_storage_format *storage_format =
@@ -272,11 +272,11 @@
memcpy( storage_format->magic, PSA_KEY_STORAGE_MAGIC_HEADER, PSA_KEY_STORAGE_MAGIC_HEADER_LENGTH );
PUT_UINT32_LE( 0, storage_format->version, 0 );
- PUT_UINT32_LE( psa_get_key_lifetime( attributes ), storage_format->lifetime, 0 );
- PUT_UINT32_LE( psa_get_key_type( attributes ), storage_format->type, 0 );
- PUT_UINT32_LE( psa_get_key_usage_flags( attributes ), storage_format->policy, 0 );
- PUT_UINT32_LE( psa_get_key_algorithm( attributes ), storage_format->policy, sizeof( uint32_t ) );
- PUT_UINT32_LE( psa_get_key_enrollment_algorithm( attributes ), storage_format->policy, 2 * sizeof( uint32_t ) );
+ PUT_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
+ PUT_UINT32_LE( attr->type, storage_format->type, 0 );
+ PUT_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
+ PUT_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
+ PUT_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
PUT_UINT32_LE( data_length, storage_format->data_len, 0 );
memcpy( storage_format->key_data, data, data_length );
}
@@ -293,7 +293,7 @@
size_t storage_data_length,
uint8_t **key_data,
size_t *key_data_length,
- psa_key_attributes_t *attributes )
+ psa_core_key_attributes_t *attr )
{
psa_status_t status;
const psa_persistent_key_storage_format *storage_format =
@@ -328,16 +328,16 @@
memcpy( *key_data, storage_format->key_data, *key_data_length );
}
- GET_UINT32_LE( attributes->core.lifetime, storage_format->lifetime, 0 );
- GET_UINT32_LE( attributes->core.type, storage_format->type, 0 );
- GET_UINT32_LE( attributes->core.policy.usage, storage_format->policy, 0 );
- GET_UINT32_LE( attributes->core.policy.alg, storage_format->policy, sizeof( uint32_t ) );
- GET_UINT32_LE( attributes->core.policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
+ GET_UINT32_LE( attr->lifetime, storage_format->lifetime, 0 );
+ GET_UINT32_LE( attr->type, storage_format->type, 0 );
+ GET_UINT32_LE( attr->policy.usage, storage_format->policy, 0 );
+ GET_UINT32_LE( attr->policy.alg, storage_format->policy, sizeof( uint32_t ) );
+ GET_UINT32_LE( attr->policy.alg2, storage_format->policy, 2 * sizeof( uint32_t ) );
return( PSA_SUCCESS );
}
-psa_status_t psa_save_persistent_key( const psa_key_attributes_t *attributes,
+psa_status_t psa_save_persistent_key( const psa_core_key_attributes_t *attr,
const uint8_t *data,
const size_t data_length )
{
@@ -353,10 +353,9 @@
if( storage_data == NULL )
return( PSA_ERROR_INSUFFICIENT_MEMORY );
- psa_format_key_data_for_storage( data, data_length, attributes,
- storage_data );
+ psa_format_key_data_for_storage( data, data_length, attr, storage_data );
- status = psa_crypto_storage_store( psa_get_key_id( attributes ),
+ status = psa_crypto_storage_store( attr->id,
storage_data, storage_data_length );
mbedtls_free( storage_data );
@@ -373,14 +372,14 @@
mbedtls_free( key_data );
}
-psa_status_t psa_load_persistent_key( psa_key_attributes_t *attributes,
+psa_status_t psa_load_persistent_key( psa_core_key_attributes_t *attr,
uint8_t **data,
size_t *data_length )
{
psa_status_t status = PSA_SUCCESS;
uint8_t *loaded_data;
size_t storage_data_length = 0;
- psa_key_id_t key = psa_get_key_id( attributes );
+ psa_key_id_t key = attr->id;
status = psa_crypto_storage_get_data_length( key, &storage_data_length );
if( status != PSA_SUCCESS )
@@ -396,7 +395,7 @@
goto exit;
status = psa_parse_key_data_from_storage( loaded_data, storage_data_length,
- data, data_length, attributes );
+ data, data_length, attr );
exit:
mbedtls_free( loaded_data );