Handle zeroed attributes key bits and type in copy
The target attributes for key copy could have key bits and type zeroed. If so, they need to be overwritten/ inherited from the source key. This is now forcefully overwritten after validating the optional attributes. As a result assigning attributes type and bits after copy are no longer necessary. Signed-off-by: Archana <archana.madhavan@silabs.com>
This commit is contained in:
parent
449608bc61
commit
374fe5b8d2
1 changed files with 11 additions and 3 deletions
|
@ -2000,9 +2000,6 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
|
|||
if( status != PSA_SUCCESS )
|
||||
return( status );
|
||||
|
||||
target->attr.type = source->attr.type;
|
||||
target->attr.bits = source->attr.bits;
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
|
@ -2030,6 +2027,15 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
|
|||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
/* The actual attributes that we received from the user could have
|
||||
* zero values for key bits and type.These optional attributes
|
||||
* have been validated and so it is safe to inherit these
|
||||
* from the source key.
|
||||
* */
|
||||
actual_attributes.core.bits = source_slot->attr.bits;
|
||||
actual_attributes.core.type = source_slot->attr.type;
|
||||
|
||||
|
||||
status = psa_restrict_key_policy( source_slot->attr.type,
|
||||
&actual_attributes.core.policy,
|
||||
&source_slot->attr.policy );
|
||||
|
@ -2065,9 +2071,11 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
|
|||
&storage_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
status = psa_allocate_buffer_to_slot( target_slot, storage_size );
|
||||
if( status != PSA_SUCCESS )
|
||||
goto exit;
|
||||
|
||||
status = psa_driver_wrapper_copy_key( &actual_attributes,
|
||||
source_slot->key.data,
|
||||
source_slot->key.bytes,
|
||||
|
|
Loading…
Reference in a new issue