From dff21d3429449bcc89d3980a38bcbaa83545168f Mon Sep 17 00:00:00 2001 From: Przemek Stekiel Date: Tue, 14 Feb 2023 20:09:10 +0100 Subject: [PATCH] Move jpake role check to psa_pake_complete_inputs() Signed-off-by: Przemek Stekiel --- library/psa_crypto.c | 6 ++++++ library/psa_crypto_pake.c | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9c12863f0f..0fd0eff888 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -7483,6 +7483,12 @@ static psa_status_t psa_pake_complete_inputs( return PSA_ERROR_BAD_STATE; } + if (operation->alg == PSA_ALG_JPAKE && + inputs.role != PSA_PAKE_ROLE_CLIENT && + inputs.role != PSA_PAKE_ROLE_SERVER) { + return PSA_ERROR_NOT_SUPPORTED; + } + /* Clear driver context */ mbedtls_platform_zeroize(&operation->data, sizeof(operation->data)); diff --git a/library/psa_crypto_pake.c b/library/psa_crypto_pake.c index 2d84f570b9..382f0214a4 100644 --- a/library/psa_crypto_pake.c +++ b/library/psa_crypto_pake.c @@ -221,13 +221,6 @@ psa_status_t mbedtls_psa_pake_setup(mbedtls_psa_pake_operation_t *operation, return PSA_ERROR_NOT_SUPPORTED; } - if (role != PSA_PAKE_ROLE_CLIENT && - role != PSA_PAKE_ROLE_SERVER) { - return PSA_ERROR_NOT_SUPPORTED; - } - - - operation->password = mbedtls_calloc(1, password_len); if (operation->password == NULL) { status = PSA_ERROR_INSUFFICIENT_MEMORY;