From 18df1c560a86e75d181963956699511aa5fdd6b0 Mon Sep 17 00:00:00 2001 From: Waleed Elmelegy Date: Wed, 30 Oct 2024 16:41:04 +0000 Subject: [PATCH] Refactor and improve interuptible key agreement builtin implementation - rename psa_driver_wrapper_key_agreement_xxx to psa_driver_wrapper_key_agreement_iop_xxx. - reorganise the paraemters of psa_driver_wrapper_key_agreement_setup Signed-off-by: Waleed Elmelegy --- tf-psa-crypto/core/psa_crypto_core.h | 14 ++++++------- .../drivers/builtin/src/psa_crypto_ecp.c | 20 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tf-psa-crypto/core/psa_crypto_core.h b/tf-psa-crypto/core/psa_crypto_core.h index c23b0b209c..ea30bf1d5e 100644 --- a/tf-psa-crypto/core/psa_crypto_core.h +++ b/tf-psa-crypto/core/psa_crypto_core.h @@ -702,7 +702,7 @@ psa_status_t psa_key_agreement_raw_builtin( /** * \brief Get the total number of ops that a key agreement operation has taken - * Since its start. + * since its start. * * \note The signature of this function is that of a PSA driver * key_agreement_get_num_ops entry point. This function behaves as an @@ -714,7 +714,7 @@ psa_status_t psa_key_agreement_raw_builtin( * * \return Total number of operations. */ -uint32_t mbedtls_psa_key_agreement_get_num_ops( +uint32_t mbedtls_psa_key_agreement_iop_get_num_ops( mbedtls_psa_key_agreement_interruptible_operation_t *operation); /** @@ -748,13 +748,13 @@ uint32_t mbedtls_psa_key_agreement_get_num_ops( * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * There was insufficient memory to load the key representation. */ -psa_status_t mbedtls_psa_key_agreement_setup( +psa_status_t mbedtls_psa_key_agreement_iop_setup( mbedtls_psa_key_agreement_interruptible_operation_t *operation, + const psa_key_attributes_t *private_key_attributes, const uint8_t *private_key_buffer, size_t private_key_buffer_len, const uint8_t *peer_key, - size_t peer_key_length, - const psa_key_attributes_t *attributes); + size_t peer_key_length); /** * \brief Continue and eventually complete a key agreement operation. @@ -780,7 +780,7 @@ psa_status_t mbedtls_psa_key_agreement_setup( * \retval #PSA_ERROR_BUFFER_TOO_SMALL * \p shared_secret_size is too small */ -psa_status_t mbedtls_psa_key_agreement_complete( +psa_status_t mbedtls_psa_key_agreement_iop_complete( mbedtls_psa_key_agreement_interruptible_operation_t *operation, uint8_t *shared_secret, size_t shared_secret_size, @@ -800,7 +800,7 @@ psa_status_t mbedtls_psa_key_agreement_complete( * \retval #PSA_SUCCESS * The operation was aborted successfully. */ -psa_status_t mbedtls_psa_key_agreement_abort( +psa_status_t mbedtls_psa_key_agreement_iop_abort( mbedtls_psa_key_agreement_interruptible_operation_t *operation); diff --git a/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c b/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c index 949bf3b296..57b10c9f50 100644 --- a/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c +++ b/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c @@ -632,19 +632,19 @@ psa_status_t mbedtls_psa_generate_key_iop_abort( #if defined(MBEDTLS_PSA_BUILTIN_ALG_ECDH) && defined(MBEDTLS_ECP_RESTARTABLE) -uint32_t mbedtls_psa_key_agreement_get_num_ops( +uint32_t mbedtls_psa_key_agreement_iop_get_num_ops( mbedtls_psa_key_agreement_interruptible_operation_t *operation) { return operation->num_ops; } -psa_status_t mbedtls_psa_key_agreement_setup( +psa_status_t mbedtls_psa_key_agreement_iop_setup( mbedtls_psa_key_agreement_interruptible_operation_t *operation, + const psa_key_attributes_t *private_key_attributes, const uint8_t *private_key_buffer, size_t private_key_buffer_len, const uint8_t *peer_key, - size_t peer_key_length, - const psa_key_attributes_t *attributes) + size_t peer_key_length) { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; mbedtls_ecp_keypair *our_key = NULL; @@ -658,8 +658,8 @@ psa_status_t mbedtls_psa_key_agreement_setup( operation->num_ops = 0; status = mbedtls_psa_ecp_load_representation( - psa_get_key_type(attributes), - psa_get_key_bits(attributes), + psa_get_key_type(private_key_attributes), + psa_get_key_bits(private_key_attributes), private_key_buffer, private_key_buffer_len, &our_key); @@ -678,8 +678,8 @@ psa_status_t mbedtls_psa_key_agreement_setup( our_key = NULL; status = mbedtls_psa_ecp_load_representation( - PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(psa_get_key_type(attributes)), - psa_get_key_bits(attributes), + PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(psa_get_key_type(private_key_attributes)), + psa_get_key_bits(private_key_attributes), peer_key, peer_key_length, &their_key); @@ -705,7 +705,7 @@ exit: return status; } -psa_status_t mbedtls_psa_key_agreement_complete( +psa_status_t mbedtls_psa_key_agreement_iop_complete( mbedtls_psa_key_agreement_interruptible_operation_t *operation, uint8_t *shared_secret, size_t shared_secret_size, @@ -726,7 +726,7 @@ psa_status_t mbedtls_psa_key_agreement_complete( return status; } -psa_status_t mbedtls_psa_key_agreement_abort( +psa_status_t mbedtls_psa_key_agreement_iop_abort( mbedtls_psa_key_agreement_interruptible_operation_t *operation) { operation->num_ops = 0;