From 53d991e655b9141aad6d719629521606f312907e Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 12 Jul 2018 01:14:59 +0200 Subject: [PATCH] generate_key: rename \p parameters to \p extra \p parameters is a confusing name for a function parameter. Rename it to \p extra. --- include/psa/crypto.h | 15 ++++++++------- library/psa_crypto.c | 14 +++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/psa/crypto.h b/include/psa/crypto.h index c2144fb497..ff85924aa0 100644 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -2415,21 +2415,22 @@ psa_status_t psa_generate_random(uint8_t *output, * be unoccupied. * \param type Key type (a \c PSA_KEY_TYPE_XXX value). * \param bits Key size in bits. - * \param[in] parameters Extra parameters for key generation. The + * \param[in] extra Extra parameters for key generation. The * interpretation of this parameter depends on * \c type. All types support \c NULL to use * the default parameters specified below. - * \param parameters_size Size of the buffer that \p parameters - * points to, in bytes. + * \param extra_size Size of the buffer that \p extra + * points to, in bytes. Note that if \p extra is + * \c NULL then \p extra_size must be zero. * * For any symmetric key type (a type such that - * #PSA_KEY_TYPE_IS_ASYMMETRIC(\p type) is false), \c parameters must be + * #PSA_KEY_TYPE_IS_ASYMMETRIC(\p type) is false), \p extra must be * \c NULL. For asymmetric key types defined by this specification, * the parameter type and the default parameters are defined by the * table below. For vendor-defined key types, the vendor documentation * shall define the parameter type and the default parameters. * - * Type | Parameter type | Meaning | Parameters used if `parameters == NULL` + * Type | Parameter type | Meaning | Parameters used if `extra == NULL` * ---- | -------------- | ------- | --------------------------------------- * `PSA_KEY_TYPE_RSA_KEYPAIR` | `unsigned int` | Public exponent | 65537 * @@ -2445,8 +2446,8 @@ psa_status_t psa_generate_random(uint8_t *output, psa_status_t psa_generate_key(psa_key_slot_t key, psa_key_type_t type, size_t bits, - const void *parameters, - size_t parameters_size); + const void *extra, + size_t extra_size); /**@}*/ diff --git a/library/psa_crypto.c b/library/psa_crypto.c index fce9e3c821..a256ad7ee2 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2964,13 +2964,13 @@ psa_status_t psa_generate_random( uint8_t *output, psa_status_t psa_generate_key( psa_key_slot_t key, psa_key_type_t type, size_t bits, - const void *parameters, - size_t parameters_size ) + const void *extra, + size_t extra_size ) { key_slot_t *slot; psa_status_t status; - if( parameters == NULL && parameters_size != 0 ) + if( extra == NULL && extra_size != 0 ) return( PSA_ERROR_INVALID_ARGUMENT ); status = psa_get_empty_key_slot( key, &slot ); @@ -3010,10 +3010,10 @@ psa_status_t psa_generate_key( psa_key_slot_t key, int exponent = 65537; if( bits > PSA_VENDOR_RSA_MAX_KEY_BITS ) return( PSA_ERROR_NOT_SUPPORTED ); - if( parameters != NULL ) + if( extra != NULL ) { - const unsigned *p = parameters; - if( parameters_size != sizeof( *p ) ) + const unsigned *p = extra; + if( extra_size != sizeof( *p ) ) return( PSA_ERROR_INVALID_ARGUMENT ); if( *p > INT_MAX ) return( PSA_ERROR_INVALID_ARGUMENT ); @@ -3048,7 +3048,7 @@ psa_status_t psa_generate_key( psa_key_slot_t key, mbedtls_ecp_curve_info_from_grp_id( grp_id ); mbedtls_ecp_keypair *ecp; int ret; - if( parameters != NULL ) + if( extra != NULL ) return( PSA_ERROR_NOT_SUPPORTED ); if( grp_id == MBEDTLS_ECP_DP_NONE || curve_info == NULL ) return( PSA_ERROR_NOT_SUPPORTED );