From 3d4966a5cbfbaffb18a131ea84d8e0ddb0b1cb55 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Tue, 13 Sep 2022 14:54:15 +0200 Subject: [PATCH] Move possible input/output steps check inside PSA_ALG_JPAKE handling Signed-off-by: Neil Armstrong --- library/psa_crypto_pake.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/psa_crypto_pake.c b/library/psa_crypto_pake.c index 83fcb4117..73b01624f 100644 --- a/library/psa_crypto_pake.c +++ b/library/psa_crypto_pake.c @@ -399,17 +399,17 @@ psa_status_t psa_pake_output( psa_pake_operation_t *operation, operation->state == PSA_PAKE_STATE_INVALID ) return( PSA_ERROR_BAD_STATE ); - if( step != PSA_PAKE_STEP_KEY_SHARE && - step != PSA_PAKE_STEP_ZK_PUBLIC && - step != PSA_PAKE_STEP_ZK_PROOF ) - return( PSA_ERROR_INVALID_ARGUMENT ); - if( output == NULL || output_size == 0 || output_length == NULL ) return( PSA_ERROR_INVALID_ARGUMENT ); #if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE) if( operation->alg == PSA_ALG_JPAKE ) { + if( step != PSA_PAKE_STEP_KEY_SHARE && + step != PSA_PAKE_STEP_ZK_PUBLIC && + step != PSA_PAKE_STEP_ZK_PROOF ) + return( PSA_ERROR_INVALID_ARGUMENT ); + if( operation->state == PSA_PAKE_STATE_SETUP ) { status = psa_pake_ecjpake_setup( operation ); if( status != PSA_SUCCESS ) @@ -598,17 +598,17 @@ psa_status_t psa_pake_input( psa_pake_operation_t *operation, operation->state == PSA_PAKE_STATE_INVALID ) return( PSA_ERROR_BAD_STATE ); - if( step != PSA_PAKE_STEP_KEY_SHARE && - step != PSA_PAKE_STEP_ZK_PUBLIC && - step != PSA_PAKE_STEP_ZK_PROOF ) - return( PSA_ERROR_INVALID_ARGUMENT ); - if( input == NULL || input_length == 0 ) return( PSA_ERROR_INVALID_ARGUMENT ); #if defined(MBEDTLS_PSA_BUILTIN_ALG_JPAKE) if( operation->alg == PSA_ALG_JPAKE ) { + if( step != PSA_PAKE_STEP_KEY_SHARE && + step != PSA_PAKE_STEP_ZK_PUBLIC && + step != PSA_PAKE_STEP_ZK_PROOF ) + return( PSA_ERROR_INVALID_ARGUMENT ); + if( operation->state == PSA_PAKE_STATE_SETUP ) { status = psa_pake_ecjpake_setup( operation );