1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

SE keys: allocate a slot before creating the key

This commit is contained in:
Gilles Peskine
2019-07-12 23:46:04 +02:00
parent 73167e128f
commit cbaff467ef
3 changed files with 68 additions and 0 deletions

View File

@ -130,6 +130,35 @@ psa_status_t psa_save_se_persistent_data(
return( PSA_SUCCESS );
}
psa_status_t psa_find_se_slot_for_key(
const psa_key_attributes_t *attributes,
psa_se_drv_table_entry_t *driver,
psa_key_slot_number_t *slot_number )
{
psa_status_t status;
psa_drv_se_allocate_key_t p_allocate = NULL;
/* If the lifetime is wrong, it's a bug in the library. */
if( driver->lifetime != attributes->lifetime )
return( PSA_ERROR_CORRUPTION_DETECTED );
/* If the driver doesn't support key creation in any way, give up now. */
if( driver->methods->key_management == NULL )
return( PSA_ERROR_NOT_SUPPORTED );
p_allocate = driver->methods->key_management->p_allocate;
/* If the driver doesn't tell us how to allocate a slot, that's
* not supported for the time being. */
if( p_allocate == NULL )
return( PSA_ERROR_NOT_SUPPORTED );
status = ( *p_allocate )( &driver->context,
driver->internal.persistent_data,
attributes,
slot_number );
return( status );
}
/****************************************************************/