Rename psa_internal_allocate_key_slot to psa_get_empty_key_slot

This function no longer modifies anything, so it doesn't actually
allocate the slot. Now, it just returns the empty key slot, and it's
up to the caller to cause the slot to be in use (or not).
This commit is contained in:
Gilles Peskine 2019-08-07 18:19:59 +02:00
parent 094dac1d12
commit edbed5670a
3 changed files with 6 additions and 6 deletions

View File

@ -1546,7 +1546,7 @@ static psa_status_t psa_start_key_creation(
if( status != PSA_SUCCESS )
return( status );
status = psa_internal_allocate_key_slot( handle, p_slot );
status = psa_get_empty_key_slot( handle, p_slot );
if( status != PSA_SUCCESS )
return( status );
slot = *p_slot;
@ -1562,7 +1562,7 @@ static psa_status_t psa_start_key_creation(
/* Erase external-only flags from the internal copy. To access
* external-only flags, query `attributes`. Thanks to the check
* in psa_validate_key_attributes(), this leaves the dual-use
* flags and any internal flag that psa_internal_allocate_key_slot()
* flags and any internal flag that psa_get_empty_key_slot()
* may have set. */
slot->attr.flags &= ~MBEDTLS_PSA_KA_MASK_EXTERNAL_ONLY;

View File

@ -102,7 +102,7 @@ void psa_wipe_all_key_slots( void )
global_data.key_slots_initialized = 0;
}
psa_status_t psa_internal_allocate_key_slot( psa_key_handle_t *handle,
psa_status_t psa_get_empty_key_slot( psa_key_handle_t *handle,
psa_key_slot_t **p_slot )
{
if( ! global_data.key_slots_initialized )
@ -228,7 +228,7 @@ psa_status_t psa_open_key( psa_key_file_id_t id, psa_key_handle_t *handle )
if( status != PSA_SUCCESS )
return( status );
status = psa_internal_allocate_key_slot( handle, &slot );
status = psa_get_empty_key_slot( handle, &slot );
if( status != PSA_SUCCESS )
return( status );

View File

@ -71,7 +71,7 @@ void psa_wipe_all_key_slots( void );
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
* \retval #PSA_ERROR_BAD_STATE
*/
psa_status_t psa_internal_allocate_key_slot( psa_key_handle_t *handle,
psa_status_t psa_get_empty_key_slot( psa_key_handle_t *handle,
psa_key_slot_t **p_slot );
/** Test whether a lifetime designates a key in an external cryptoprocessor.