From e2a9b6a3b56fa6c55afecefb3dde3d84a0b7a7d6 Mon Sep 17 00:00:00 2001 From: Waleed Elmelegy Date: Wed, 20 Nov 2024 11:52:59 +0000 Subject: [PATCH] Add internal iop export public-key setup API Signed-off-by: Waleed Elmelegy --- .../drivers/builtin/src/psa_crypto_ecp.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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 b2764b064..a3ceb01c7 100644 --- a/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c +++ b/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c @@ -654,6 +654,31 @@ psa_status_t mbedtls_psa_ecp_generate_key_iop_abort( return PSA_SUCCESS; } +psa_status_t mbedtls_psa_ecp_export_public_key_iop_setup( + mbedtls_psa_export_public_key_iop_operation_t *operation, + uint8_t *private_key, + size_t private_key_len, + const psa_key_attributes_t *private_key_attributes) +{ + psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; + + status = mbedtls_psa_ecp_load_representation( + psa_get_key_type(private_key_attributes), + psa_get_key_bits(private_key_attributes), + private_key, + private_key_len, + &operation->key); + if (status != PSA_SUCCESS) { + goto exit; + } + + mbedtls_ecp_restart_init(&operation->restart_ctx); + operation->num_ops = 0; + +exit: + return status; +} + #endif /****************************************************************/ /* Interruptible ECC Key Agreement */