Skip to content

Commit

Permalink
Add PSA interruptible key generation get num ops API
Browse files Browse the repository at this point in the history
Signed-off-by: Waleed Elmelegy <[email protected]>
  • Loading branch information
waleed-elmelegy-arm committed Nov 18, 2024
1 parent e0dac22 commit 6e1e3ca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tf-psa-crypto/core/psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -8121,8 +8121,7 @@ static psa_status_t psa_generate_key_iop_abort_internal(
uint32_t psa_generate_key_iop_get_num_ops(
psa_generate_key_iop_t *operation)
{
(void) operation;
return 0;
return operation->num_ops;
}

psa_status_t psa_generate_key_iop_setup(
Expand Down Expand Up @@ -8197,6 +8196,8 @@ psa_status_t psa_generate_key_iop_complete(
goto exit;
}

operation->num_ops = mbedtls_psa_generate_key_get_num_ops(&operation->ctx);

status = psa_import_key(&operation->attributes,
key_data + (sizeof(key_data) - key_len),
key_len,
Expand Down
17 changes: 17 additions & 0 deletions tf-psa-crypto/core/psa_crypto_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,23 @@ psa_status_t psa_generate_key_internal(const psa_key_attributes_t *attributes,
size_t key_buffer_size,
size_t *key_buffer_length);


/**
* \brief Get the total number of ops that a key generation operation has taken
* Since it's start.
*
* \note The signature of this function is that of a PSA driver
* generate_key_get_num_ops entry point. This function behaves as an
* generate_key_get_num_ops entry point as defined in the PSA driver
* interface specification for transparent drivers.
*
* \param[in] operation The \c mbedtls_psa_generate_key_iop_t to use.
* This must be initialized first.
* \return Total number of operations.
*/
uint32_t mbedtls_psa_generate_key_get_num_ops(
mbedtls_psa_generate_key_iop_t *operation);

/**
* \brief Setup a new interruptible key generation operation.
*
Expand Down
6 changes: 6 additions & 0 deletions tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ psa_status_t mbedtls_psa_key_agreement_ecdh(

#if defined(MBEDTLS_ECP_RESTARTABLE)

uint32_t mbedtls_psa_generate_key_get_num_ops(
mbedtls_psa_generate_key_iop_t *operation)
{
return operation->num_ops;
}

psa_status_t mbedtls_psa_generate_key_iop_setup(
mbedtls_psa_generate_key_iop_t *operation,
const psa_key_attributes_t *attributes)
Expand Down

0 comments on commit 6e1e3ca

Please sign in to comment.