From 9df74beea71a29c22a8eef5ec3f641945d5f8048 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Sat, 5 Dec 2020 19:15:23 +0100 Subject: [PATCH] psa: driver wrapper: Rename and export get_key_buffer_size Rename and export get_key_buffer_size to be able to call it from psa_crypto.c to compute the size of buffers to contain keys generated by an opaque driver without storage. Signed-off-by: Ronald Cron --- library/psa_crypto_driver_wrappers.c | 9 +++++---- library/psa_crypto_driver_wrappers.h | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index 07888f1de2..e0c86cf751 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -238,7 +238,6 @@ psa_status_t psa_driver_wrapper_verify_hash( psa_key_slot_t *slot, #endif /* PSA_CRYPTO_DRIVER_PRESENT */ } -#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) /** Get the key buffer size for the key material of a generated key in the * case of an opaque driver without storage. * @@ -254,7 +253,7 @@ psa_status_t psa_driver_wrapper_verify_hash( psa_key_slot_t *slot, * The type and/or the size in bits of the key or the combination of * the two is not supported. */ -static psa_status_t get_key_buffer_size( +psa_status_t psa_driver_wrapper_get_key_buffer_size( const psa_key_attributes_t *attributes, size_t *key_buffer_size ) { @@ -301,10 +300,11 @@ static psa_status_t get_key_buffer_size( #endif /* PSA_CRYPTO_DRIVER_TEST */ default: + (void)key_type; + (void)key_bits; return( PSA_ERROR_NOT_SUPPORTED ); } } -#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */ psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attributes, psa_key_slot_t *slot ) @@ -350,7 +350,8 @@ psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attrib } else { - status = get_key_buffer_size( attributes, &export_size ); + status = psa_driver_wrapper_get_key_buffer_size( attributes, + &export_size ); if( status != PSA_SUCCESS ) return( status ); } diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h index 27d8b64eac..b9bb53e21b 100644 --- a/library/psa_crypto_driver_wrappers.h +++ b/library/psa_crypto_driver_wrappers.h @@ -63,6 +63,10 @@ psa_status_t psa_driver_wrapper_export_public_key( const uint8_t *key_buffer, size_t key_buffer_size, uint8_t *data, size_t data_size, size_t *data_length ); +psa_status_t psa_driver_wrapper_get_key_buffer_size( + const psa_key_attributes_t *attributes, + size_t *key_buffer_size ); + psa_status_t psa_driver_wrapper_generate_key( const psa_key_attributes_t *attributes, psa_key_slot_t *slot );