From 5603efd525f43865a42f0653048f7a0aebb11115 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Mon, 26 Sep 2022 10:49:16 -0400 Subject: [PATCH] Improve readability and formatting Also use a sizeof instead of a constant for zeroization, as requested in review. Signed-off-by: Andrzej Kurek --- library/psa_crypto.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 663b645bbb..0b21eb083d 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -4355,7 +4355,7 @@ psa_status_t psa_key_derivation_abort( psa_key_derivation_operation_t *operation if( kdf_alg == PSA_ALG_TLS12_ECJPAKE_TO_PMS ) { mbedtls_platform_zeroize( operation->ctx.tls12_ecjpake_to_pms.data, - PSA_TLS12_ECJPAKE_TO_PMS_DATA_SIZE ); + sizeof( operation->ctx.tls12_ecjpake_to_pms.data ) ); } else #endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_ECJPAKE_TO_PMS) */ @@ -4647,7 +4647,7 @@ static psa_status_t psa_key_derivation_tls12_ecjpake_to_pms_read( size_t output_length ) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - size_t output_size; + size_t output_size = 0; if( output_length != 32 ) return ( PSA_ERROR_INVALID_ARGUMENT ); @@ -5578,7 +5578,9 @@ static psa_status_t psa_tls12_ecjpake_to_pms_input( { if( data_length != PSA_TLS12_ECJPAKE_TO_PMS_INPUT_SIZE || step != PSA_KEY_DERIVATION_INPUT_SECRET ) + { return( PSA_ERROR_INVALID_ARGUMENT ); + } /* Check if the passed point is in an uncompressed form */ if( data[0] != 0x04 )