mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-02 07:51:10 +00:00
Take advantage of psa_core_key_attributes_t internally: key loading
This commit is contained in:
parent
4ed0e6f11a
commit
2431859dc7
|
@ -120,37 +120,31 @@ psa_status_t psa_internal_allocate_key_slot( psa_key_handle_t *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
|
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
|
||||||
static psa_status_t psa_load_persistent_key_into_slot( psa_key_slot_t *p_slot )
|
static psa_status_t psa_load_persistent_key_into_slot( psa_key_slot_t *slot )
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_SUCCESS;
|
psa_status_t status = PSA_SUCCESS;
|
||||||
uint8_t *key_data = NULL;
|
uint8_t *key_data = NULL;
|
||||||
size_t key_data_length = 0;
|
size_t key_data_length = 0;
|
||||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
|
||||||
|
|
||||||
psa_set_key_id( &attributes, p_slot->attr.id );
|
status = psa_load_persistent_key( &slot->attr,
|
||||||
status = psa_load_persistent_key( &attributes.core,
|
|
||||||
&key_data, &key_data_length );
|
&key_data, &key_data_length );
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
p_slot->attr.lifetime = psa_get_key_lifetime( &attributes );
|
|
||||||
p_slot->attr.type = psa_get_key_type( &attributes );
|
|
||||||
p_slot->attr.policy = attributes.core.policy;
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||||
if( psa_key_lifetime_is_external( p_slot->attr.lifetime ) )
|
if( psa_key_lifetime_is_external( slot->attr.lifetime ) )
|
||||||
{
|
{
|
||||||
if( key_data_length != sizeof( p_slot->data.se ) )
|
if( key_data_length != sizeof( slot->data.se ) )
|
||||||
{
|
{
|
||||||
status = PSA_ERROR_STORAGE_FAILURE;
|
status = PSA_ERROR_STORAGE_FAILURE;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
memcpy( &p_slot->data.se, key_data, sizeof( p_slot->data.se ) );
|
memcpy( &slot->data.se, key_data, sizeof( slot->data.se ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||||
{
|
{
|
||||||
status = psa_import_key_into_slot( p_slot,
|
status = psa_import_key_into_slot( slot, key_data, key_data_length );
|
||||||
key_data, key_data_length );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
Loading…
Reference in a new issue