From 03d62b1958419903c766850294dbec8270e6f309 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 18 Jul 2024 19:31:57 +0100 Subject: [PATCH] Add psa_key_agreement_iop_t structs and docs Signed-off-by: Paul Elliott --- tf-psa-crypto/include/psa/crypto.h | 42 +++++++++++++++++++++++ tf-psa-crypto/include/psa/crypto_struct.h | 34 ++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/tf-psa-crypto/include/psa/crypto.h b/tf-psa-crypto/include/psa/crypto.h index 3525da221f..7a48e3eff0 100644 --- a/tf-psa-crypto/include/psa/crypto.h +++ b/tf-psa-crypto/include/psa/crypto.h @@ -4810,6 +4810,48 @@ psa_status_t psa_verify_hash_abort( psa_verify_hash_interruptible_operation_t *operation); +/**@}*/ + +/**@}*/ + +/** + * \defgroup interruptible_key_agreement Interruptible Key Agreement + * @{ + */ + +/** + * The type of the state data structure for interruptible key agreement + * operations. + * + * Before calling any function on an interruptible key agreement object, the + * application must initialize it by any of the following means: + * - Set the structure to all-bits-zero, for example: + * \code + * psa_key_agreement_iop_t operation; + * memset(&operation, 0, sizeof(operation)); + * \endcode + * - Initialize the structure to logical zero values, for example: + * \code + * psa_key_agreement_iop_t operation = {0}; + * \endcode + * - Initialize the structure to the initializer #PSA_KEY_AGREEMENT_IOP_INIT, + * for example: + * - \code + * psa_key_agreement_iop_t operation = PSA_KEY_AGREEMENT_IOP_INIT; + * \endcode + * - Assign the result of the function psa_key_agreement_iop_init() to the + * structure, for example: + * \code + * psa_key_agreement_iop_t operation; + * operation = psa_key_agreement_iop_init(); + * \endcode + * + * This is an implementation-defined \c struct. Applications should not + * make any assumptions about the content of this structure. + * Implementation details can change in future versions without notice. + */ +typedef struct psa_key_agreement_iop_s psa_key_agreement_iop_t; + /**@}*/ #ifdef __cplusplus diff --git a/tf-psa-crypto/include/psa/crypto_struct.h b/tf-psa-crypto/include/psa/crypto_struct.h index 3913551aa8..4a6c9fe7bb 100644 --- a/tf-psa-crypto/include/psa/crypto_struct.h +++ b/tf-psa-crypto/include/psa/crypto_struct.h @@ -494,6 +494,40 @@ psa_verify_hash_interruptible_operation_init(void) return v; } +/** + * \brief The context for PSA interruptible key agreement. + */ +struct psa_key_agreement_iop_s { +#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C) + mbedtls_psa_client_handle_t handle; +#else + /** + * Unique ID indicating which driver got assigned to do the + * operation. Since driver contexts are driver-specific, swapping + * drivers halfway through the operation is not supported. + * ID values are auto-generated in psa_crypto_driver_wrappers.h + * ID value zero means the context is not valid or not assigned to + * any driver (i.e. none of the driver contexts are active). + */ + unsigned int MBEDTLS_PRIVATE(id); + +#endif +}; + +#if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C) +#define PSA_KEY_AGREEMENT_IOP_INIT { 0 } +#else +#define PSA_KEY_AGREEMENT_IOP_INIT { 0 } +#endif + +static inline struct psa_key_agreement_iop_s +psa_key_agreement_iop_init(void) +{ + const struct psa_key_agreement_iop_s v = PSA_KEY_AGREEMENT_IOP_INIT; + + return v; +} + #ifdef __cplusplus } #endif