1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Code style improvements

Signed-off-by: Archana <archana.madhavan@silabs.com>
This commit is contained in:
Archana
2021-09-08 15:36:05 +05:30
parent 8a180368fb
commit 449608bc61
6 changed files with 107 additions and 107 deletions

View File

@ -431,7 +431,7 @@ mbedtls_ecp_group_id mbedtls_ecc_group_of_psa( psa_ecc_family_t curve,
* defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY) */
psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type,
size_t bits )
size_t bits )
{
/* Check that the bit size is acceptable for the key type */
switch( type )
@ -558,7 +558,8 @@ psa_status_t psa_import_key_into_slot(
{
*bits = PSA_BYTES_TO_BITS( data_length );
status = psa_validate_unstructured_key_bit_size( attributes->core.type, *bits );
status = psa_validate_unstructured_key_bit_size( attributes->core.type,
*bits );
if( status != PSA_SUCCESS )
return( status );
@ -1892,7 +1893,7 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
if( data_length == 0 )
return( PSA_ERROR_INVALID_ARGUMENT );
/* Ensure that the bytes-to-bits conversion hasn't overflown. */
/* Ensure that the bytes-to-bits conversion cannot overflow. */
if( data_length > SIZE_MAX / 8 )
return( PSA_ERROR_NOT_SUPPORTED );
@ -1902,15 +1903,15 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
goto exit;
/* In the case of a transparent key or an opaque key stored in local
* storage( thus not in the case of the old-style secure element interface
* (MBEDTLS_PSA_CRYPTO_SE_C)),we have to allocate a buffer to hold the
* imported key material. */
* storage ( thus not in the case of importing a key in a secure element
* with storage ( MBEDTLS_PSA_CRYPTO_SE_C ) ),we have to allocate a
* buffer to hold the imported key material. */
if( slot->key.data == NULL )
{
if( psa_key_lifetime_is_external( attributes->core.lifetime ) )
{
status = psa_driver_wrapper_get_key_buffer_size_from_key_data( attributes, data,
data_length , &storage_size );
status = psa_driver_wrapper_get_key_buffer_size_from_key_data(
attributes, data, data_length, &storage_size );
if( status != PSA_SUCCESS )
goto exit;
}
@ -2046,7 +2047,7 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
* If the source and target keys are stored across 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 acheived through
* been fully mapped. For now, this can be achieved through
* appropriate API invocations from the application, if needed.
* */
status = PSA_ERROR_NOT_SUPPORTED;
@ -2054,14 +2055,14 @@ psa_status_t psa_copy_key( mbedtls_svc_key_id_t source_key,
}
/*
* When the source and target keys are within the same location,
* - For transparent keys it is a blind copy sans any driver invocation,
* - For transparent keys it is a blind copy without any driver invocation,
* - For opaque keys this translates to an invocation of the drivers'
* copy_key entry point through the dispatch layer.
* */
if( psa_key_lifetime_is_external( actual_attributes.core.lifetime ) )
{
status = psa_driver_wrapper_get_key_buffer_size( &actual_attributes,
&storage_size );
&storage_size );
if( status != PSA_SUCCESS )
goto exit;
status = psa_allocate_buffer_to_slot( target_slot, storage_size );
@ -4197,7 +4198,8 @@ static psa_status_t psa_generate_derived_key_internal(
if( psa_key_lifetime_is_external( attributes.core.lifetime ) )
{
status = psa_driver_wrapper_get_key_buffer_size( &attributes, &storage_size );
status = psa_driver_wrapper_get_key_buffer_size( &attributes,
&storage_size );
if( status != PSA_SUCCESS )
goto exit;
}
@ -5193,9 +5195,9 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes,
goto exit;
/* In the case of a transparent key or an opaque key stored in local
* storage( thus not in the case of the old-style secure element interface
* (MBEDTLS_PSA_CRYPTO_SE_C)),we have to allocate a buffer to hold the
* imported key material. */
* storage ( thus not in the case of generating a key in a secure element
* with storage ( MBEDTLS_PSA_CRYPTO_SE_C ) ),we have to allocate a
* buffer to hold the generated key material. */
if( slot->key.data == NULL )
{
if ( PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime ) ==

View File

@ -546,5 +546,5 @@ psa_status_t psa_verify_hash_builtin(
* the two is not supported.
*/
psa_status_t psa_validate_unstructured_key_bit_size( psa_key_type_t type,
size_t bits );
size_t bits );
#endif /* PSA_CRYPTO_CORE_H */

View File

@ -380,10 +380,9 @@ psa_status_t psa_driver_wrapper_verify_hash(
}
}
/** calculate the key buffer size required to store the key material of a key
/** Calculate the key buffer size required to store the key material of a key
* associated with an opaque driver from input key data.
*
*
* \param[in] attributes The key attributes
* \param[in] data The input key data.
* \param[in] data_length The input data length.
@ -399,7 +398,8 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
size_t data_length,
size_t *key_buffer_size )
{
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
psa_key_location_t location =
PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
psa_key_type_t key_type = attributes->core.type;
*key_buffer_size = 0;
@ -459,7 +459,8 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size(
return( PSA_SUCCESS );
}
#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
*key_buffer_size = mbedtls_test_opaque_size_function( key_type, key_bits );
*key_buffer_size = mbedtls_test_opaque_size_function( key_type,
key_bits );
return( ( *key_buffer_size != 0 ) ?
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
#endif /* PSA_CRYPTO_DRIVER_TEST */
@ -785,20 +786,12 @@ 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,
uint8_t *target_key_buffer, size_t target_buffer_size, size_t *key_length )
uint8_t *target_key_buffer, size_t target_key_buffer_size,
size_t *target_key_buffer_length )
{
psa_status_t status = PSA_ERROR_INVALID_ARGUMENT;
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 */
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
psa_key_location_t location =
PSA_KEY_LIFETIME_GET_LOCATION( attributes->core.lifetime );
switch( location )
{
@ -808,16 +801,16 @@ psa_status_t psa_driver_wrapper_copy_key(
return( mbedtls_test_opaque_copy_key( attributes, source_key,
source_key_size,
target_key_buffer,
target_buffer_size,
key_length ) );
target_key_buffer_size,
target_key_buffer_length) );
#endif /* PSA_CRYPTO_DRIVER_TEST */
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
default:
(void)source_key;
(void)source_key_size;
(void)target_key_buffer;
(void)target_buffer_size;
(void)key_length;
(void)target_key_buffer_size;
(void)target_key_buffer_length;
status = PSA_ERROR_INVALID_ARGUMENT;
}
return( status );

View File

@ -103,7 +103,8 @@ 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,
uint8_t *target_key_buffer, size_t target_buffer_size, size_t *key_length );
uint8_t *target_key_buffer, size_t target_key_buffer_size,
size_t *target_key_buffer_length );
/*
* Cipher functions
*/