1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00

Styling and refactoring

Signed-off-by: Archana <archana.madhavan@silabs.com>
This commit is contained in:
Archana
2021-09-10 06:22:44 +05:30
parent 9a2b6ff8f2
commit 9d17bf4215
6 changed files with 53 additions and 49 deletions

View File

@ -1991,18 +1991,6 @@ exit:
}
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
psa_key_slot_t *target )
{
psa_status_t status = psa_copy_key_material_into_slot( target,
source->key.data,
source->key.bytes );
if( status != PSA_SUCCESS )
return( status );
return( PSA_SUCCESS );
}
psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
const psa_key_attributes_t *specified_attributes,
mbedtls_svc_key_id_t *target_key )
@ -2027,13 +2015,13 @@ 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.
/* The target key type and number of bits have been validated by
* psa_validate_optional_attributes() to be either equal to zero or
* equal to the ones of the source key. So it is safe to inherit
* them from the source key now."
* */
actual_attributes.core.bits = source_slot->attr.bits;
actual_attributes.core.type = source_slot->attr.type;
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,
@ -2050,7 +2038,7 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
PSA_KEY_LIFETIME_GET_LOCATION( source_slot->attr.lifetime ) )
{
/*
* If the source and target keys are stored across different locations,
* If the source and target keys are stored in different locations,
* the source key would need to be exported as plaintext and re-imported
* in the other location. This has security implications which have not
* been fully mapped. For now, this can be achieved through
@ -2087,7 +2075,9 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
}
else
{
status = psa_copy_key_material( source_slot, target_slot );
status = psa_copy_key_material_into_slot( target_slot,
source_slot->key.data,
source_slot->key.bytes );
if( status != PSA_SUCCESS )
goto exit;
}

View File

@ -785,7 +785,7 @@ psa_status_t psa_driver_wrapper_get_builtin_key(
psa_status_t psa_driver_wrapper_copy_key(
psa_key_attributes_t *attributes,
const uint8_t *source_key, size_t source_key_size,
const uint8_t *source_key, size_t source_key_length,
uint8_t *target_key_buffer, size_t target_key_buffer_size,
size_t *target_key_buffer_length )
{
@ -793,13 +793,24 @@ psa_status_t psa_driver_wrapper_copy_key(
psa_key_location_t location =
PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
const psa_drv_se_t *drv;
psa_drv_se_context_t *drv_context;
if( psa_get_se_driver( attributes->core.lifetime, &drv, &drv_context ) )
{
/* Copying to a secure element is not implemented yet. */
return( PSA_ERROR_NOT_SUPPORTED );
}
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
switch( location )
{
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
#if defined(PSA_CRYPTO_DRIVER_TEST)
case PSA_CRYPTO_TEST_DRIVER_LOCATION:
return( mbedtls_test_opaque_copy_key( attributes, source_key,
source_key_size,
source_key_length,
target_key_buffer,
target_key_buffer_size,
target_key_buffer_length) );
@ -807,7 +818,7 @@ psa_status_t psa_driver_wrapper_copy_key(
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
default:
(void)source_key;
(void)source_key_size;
(void)source_key_length;
(void)target_key_buffer;
(void)target_key_buffer_size;
(void)target_key_buffer_length;

View File

@ -102,7 +102,7 @@ psa_status_t psa_driver_wrapper_get_builtin_key(
psa_status_t psa_driver_wrapper_copy_key(
psa_key_attributes_t *attributes,
const uint8_t *source_key, size_t source_key_size,
const uint8_t *source_key, size_t source_key_length,
uint8_t *target_key_buffer, size_t target_key_buffer_size,
size_t *target_key_buffer_length );
/*