mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-06-02 20:30:20 +00:00
Apply review feedback
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
98435ddf84
commit
ac3434fc19
|
@ -2325,8 +2325,6 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
if( psa_key_lifetime_is_external( psa_get_key_lifetime( attributes ) ) )
|
|
||||||
{
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||||
if( driver != NULL )
|
if( driver != NULL )
|
||||||
{
|
{
|
||||||
|
@ -2355,6 +2353,7 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||||
|
if( psa_key_lifetime_is_external( psa_get_key_lifetime( attributes ) ) )
|
||||||
{
|
{
|
||||||
/* Importing a key with external lifetime through the driver wrapper
|
/* Importing a key with external lifetime through the driver wrapper
|
||||||
* interface is not yet supported. Return as if this was an invalid
|
* interface is not yet supported. Return as if this was an invalid
|
||||||
|
@ -2362,7 +2361,6 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
|
||||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = psa_import_key_into_slot( slot, data, data_length );
|
status = psa_import_key_into_slot( slot, data, data_length );
|
||||||
|
|
|
@ -247,9 +247,9 @@ static psa_status_t psa_load_persistent_key_into_slot( psa_key_slot_t *slot )
|
||||||
if( status != PSA_SUCCESS )
|
if( status != PSA_SUCCESS )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
if( psa_key_lifetime_is_external( slot->attr.lifetime ) )
|
|
||||||
{
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||||
|
/* Special handling is required for loading keys associated with a
|
||||||
|
* dynamically registered SE interface. */
|
||||||
const psa_drv_se_t *drv;
|
const psa_drv_se_t *drv;
|
||||||
psa_drv_se_context_t *drv_context;
|
psa_drv_se_context_t *drv_context;
|
||||||
if( psa_get_se_driver( slot->attr.lifetime, &drv, &drv_context ) )
|
if( psa_get_se_driver( slot->attr.lifetime, &drv, &drv_context ) )
|
||||||
|
@ -263,14 +263,12 @@ static psa_status_t psa_load_persistent_key_into_slot( psa_key_slot_t *slot )
|
||||||
data = (psa_se_key_data_storage_t *) key_data;
|
data = (psa_se_key_data_storage_t *) key_data;
|
||||||
memcpy( &slot->data.se.slot_number, &data->slot_number,
|
memcpy( &slot->data.se.slot_number, &data->slot_number,
|
||||||
sizeof( slot->data.se.slot_number ) );
|
sizeof( slot->data.se.slot_number ) );
|
||||||
|
|
||||||
|
status = PSA_SUCCESS;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||||
{
|
|
||||||
/* A key that is successfully loaded from storage with an
|
|
||||||
* external lifetime, but doesn't belong to an SE driver,
|
|
||||||
* must be a PSA driver-associated key which we can just
|
|
||||||
* load like an internal key. */
|
|
||||||
if ( key_data == NULL )
|
if ( key_data == NULL )
|
||||||
{
|
{
|
||||||
status = PSA_ERROR_STORAGE_FAILURE;
|
status = PSA_ERROR_STORAGE_FAILURE;
|
||||||
|
@ -278,12 +276,6 @@ static psa_status_t psa_load_persistent_key_into_slot( psa_key_slot_t *slot )
|
||||||
}
|
}
|
||||||
|
|
||||||
status = psa_copy_key_material_into_slot( slot, key_data, key_data_length );
|
status = psa_copy_key_material_into_slot( slot, key_data, key_data_length );
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = psa_copy_key_material_into_slot( slot, key_data, key_data_length );
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
psa_free_persistent_key_data( key_data, key_data_length );
|
psa_free_persistent_key_data( key_data, key_data_length );
|
||||||
|
@ -360,31 +352,26 @@ psa_status_t psa_validate_key_location( psa_key_lifetime_t lifetime,
|
||||||
if ( psa_key_lifetime_is_external( lifetime ) )
|
if ( psa_key_lifetime_is_external( lifetime ) )
|
||||||
{
|
{
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
|
||||||
|
/* Check whether a driver is registered against this lifetime */
|
||||||
psa_se_drv_table_entry_t *driver = psa_get_se_driver_entry( lifetime );
|
psa_se_drv_table_entry_t *driver = psa_get_se_driver_entry( lifetime );
|
||||||
if( driver == NULL )
|
if( driver != NULL )
|
||||||
{
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
|
|
||||||
/* Key location for external keys gets checked by the wrapper */
|
|
||||||
return( PSA_SUCCESS );
|
|
||||||
#else
|
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (p_drv != NULL)
|
if (p_drv != NULL)
|
||||||
*p_drv = driver;
|
*p_drv = driver;
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
}
|
}
|
||||||
#else
|
#else /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||||
(void) p_drv;
|
(void) p_drv;
|
||||||
|
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
|
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
|
||||||
/* Key location for external keys gets checked by the wrapper */
|
/* Key location for external keys gets checked by the wrapper */
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
#else
|
#else /* MBEDTLS_PSA_CRYPTO_DRIVERS */
|
||||||
|
/* No support for external lifetimes at all, or dynamic interface
|
||||||
|
* did not find driver for requested lifetime. */
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||||
#endif
|
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS */
|
||||||
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Local/internal keys are always valid */
|
/* Local/internal keys are always valid */
|
||||||
|
|
Loading…
Reference in a new issue