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 <waleed.elmelegy@arm.com>
diff --git a/tf-psa-crypto/core/psa_crypto_core.h b/tf-psa-crypto/core/psa_crypto_core.h
index c23b0b2..ea30bf1 100644
--- a/tf-psa-crypto/core/psa_crypto_core.h
+++ b/tf-psa-crypto/core/psa_crypto_core.h
@@ -702,7 +702,7 @@
/**
* \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 @@
*
* \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 @@
* \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 @@
* \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 @@
* \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 949bf3b..57b10c9 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 @@
#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 @@
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 @@
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 @@
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 @@
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;