mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-06 06:55:11 +00:00
Get a builtin key's attributes in order to correctly get its size
Leverage the fact that the get_builtin_key entrypoint returns a key's attributes, such that a proper size for the builtin key's buffer can be calculated through the driver's get_key_buffer_size hook. Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
7ddee7f7c5
commit
ce48702448
2 changed files with 20 additions and 4 deletions
|
|
@ -343,9 +343,6 @@ psa_status_t test_opaque_get_builtin_key(
|
|||
psa_key_attributes_t *attributes,
|
||||
uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
|
||||
{
|
||||
if( key_buffer_size < sizeof( psa_drv_slot_number_t ) )
|
||||
return( PSA_ERROR_BUFFER_TOO_SMALL );
|
||||
|
||||
switch( slot_number )
|
||||
{
|
||||
case PSA_CRYPTO_TEST_DRIVER_BUILTIN_AES_KEY_SLOT:
|
||||
|
|
@ -358,6 +355,9 @@ psa_status_t test_opaque_get_builtin_key(
|
|||
PSA_KEY_USAGE_EXPORT );
|
||||
psa_set_key_algorithm( attributes, PSA_ALG_CTR );
|
||||
|
||||
if( key_buffer_size < sizeof( psa_drv_slot_number_t ) )
|
||||
return( PSA_ERROR_BUFFER_TOO_SMALL );
|
||||
|
||||
*( (psa_drv_slot_number_t*) key_buffer ) =
|
||||
PSA_CRYPTO_TEST_DRIVER_BUILTIN_AES_KEY_SLOT;
|
||||
*key_buffer_length = sizeof( psa_drv_slot_number_t );
|
||||
|
|
@ -375,6 +375,9 @@ psa_status_t test_opaque_get_builtin_key(
|
|||
psa_set_key_algorithm(
|
||||
attributes, PSA_ALG_ECDSA( PSA_ALG_ANY_HASH ) );
|
||||
|
||||
if( key_buffer_size < sizeof( psa_drv_slot_number_t ) )
|
||||
return( PSA_ERROR_BUFFER_TOO_SMALL );
|
||||
|
||||
*( (psa_drv_slot_number_t*) key_buffer ) =
|
||||
PSA_CRYPTO_TEST_DRIVER_BUILTIN_ECDSA_KEY_SLOT;
|
||||
*key_buffer_length = sizeof( psa_drv_slot_number_t );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue