mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-06-24 01:41:35 +03:00
Implement psa_generate_key_custom
Implement `psa_generate_key_custom()` and `psa_key_derivation_output_key_custom()`. These functions replace `psa_generate_key_ext()` and `psa_key_derivation_output_key_ext()`. They have the same functionality, but a slightly different interface: the `ext` functions use a structure with a flexible array member to pass variable-length data, while the `custom` functions use a separate parameter. Keep the `ext` functions for backward compatibility with Mbed TLS 3.6.0. But make them a thin wrapper around the new `custom` functions. Duplicate the test code and data. The test cases have to be duplicated anyway, and the test functions are individually more readable this way. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -731,7 +731,8 @@ static inline psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
|
||||
|
||||
static inline psa_status_t psa_driver_wrapper_generate_key(
|
||||
const psa_key_attributes_t *attributes,
|
||||
const psa_key_production_parameters_t *params, size_t params_data_length,
|
||||
const psa_custom_key_parameters_t *custom,
|
||||
const uint8_t *custom_data, size_t custom_data_length,
|
||||
uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
|
||||
{
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
@ -740,7 +741,7 @@ static inline psa_status_t psa_driver_wrapper_generate_key(
|
||||
|
||||
#if defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE)
|
||||
int is_default_production =
|
||||
psa_key_production_parameters_are_default(params, params_data_length);
|
||||
psa_key_production_parameters_are_default(custom, custom_data_length);
|
||||
if( location != PSA_KEY_LOCATION_LOCAL_STORAGE && !is_default_production )
|
||||
{
|
||||
/* We don't support passing custom production parameters
|
||||
@ -811,7 +812,7 @@ static inline psa_status_t psa_driver_wrapper_generate_key(
|
||||
|
||||
/* Software fallback */
|
||||
status = psa_generate_key_internal(
|
||||
attributes, params, params_data_length,
|
||||
attributes, custom, custom_data, custom_data_length,
|
||||
key_buffer, key_buffer_size, key_buffer_length );
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user