From 932ffb7ab21fb026c91742f933baf1e05cde8bbb Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Mon, 15 Feb 2021 12:14:32 +0100 Subject: [PATCH] Return NOT_SUPPORTED according to the API contract "retval = PSA_ERROR_NOT_SUPPORTED if alg is not supported" Signed-off-by: Steven Cooreman --- library/psa_crypto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7f12bcb4f..b94c114b1 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -5165,7 +5165,7 @@ psa_status_t psa_key_derivation_output_key( const psa_key_attributes_t *attribut /* Key derivation */ /****************************************************************/ -#ifdef AT_LEAST_ONE_BUILTIN_KDF +#if defined(AT_LEAST_ONE_BUILTIN_KDF) static psa_status_t psa_key_derivation_setup_kdf( psa_key_derivation_operation_t *operation, psa_algorithm_t kdf_alg ) @@ -5224,17 +5224,23 @@ psa_status_t psa_key_derivation_setup( psa_key_derivation_operation_t *operation if( PSA_ALG_IS_RAW_KEY_AGREEMENT( alg ) ) return( PSA_ERROR_INVALID_ARGUMENT ); -#ifdef AT_LEAST_ONE_BUILTIN_KDF else if( PSA_ALG_IS_KEY_AGREEMENT( alg ) ) { +#if defined(AT_LEAST_ONE_BUILTIN_KDF) psa_algorithm_t kdf_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF( alg ); status = psa_key_derivation_setup_kdf( operation, kdf_alg ); +#else + return( PSA_ERROR_NOT_SUPPORTED ); +#endif /* AT_LEAST_ONE_BUILTIN_KDF */ } else if( PSA_ALG_IS_KEY_DERIVATION( alg ) ) { +#if defined(AT_LEAST_ONE_BUILTIN_KDF) status = psa_key_derivation_setup_kdf( operation, alg ); +#else + return( PSA_ERROR_NOT_SUPPORTED ); +#endif /* AT_LEAST_ONE_BUILTIN_KDF */ } -#endif else return( PSA_ERROR_INVALID_ARGUMENT );