From dfa14cbbcd00dab45c87f71e86f90864bf252835 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Wed, 8 Nov 2023 14:33:05 +0000 Subject: [PATCH] Add function prototypes for psa_crypto_output fns Signed-off-by: David Horstmann --- library/psa_crypto_core.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/library/psa_crypto_core.h b/library/psa_crypto_core.h index a53824ec3e..f3f7dfba01 100644 --- a/library/psa_crypto_core.h +++ b/library/psa_crypto_core.h @@ -911,4 +911,43 @@ psa_status_t psa_crypto_input_copy_alloc(const uint8_t *input, size_t input_len, */ void psa_crypto_input_copy_free(psa_crypto_input_copy_t *input_copy); +typedef struct psa_crypto_output_copy_s { + uint8_t *original; + uint8_t *buffer; + size_t len; +} psa_crypto_output_copy_t; + +/** Allocate a local copy of an output buffer. + * + * \note This does not copy any data from the original + * output buffer but only allocates a buffer + * whose contents will be copied back to the + * original in a future call to + * psa_crypto_output_copy_free(). + * + * \param[in] output Pointer to output buffer. + * \param[in] output_len Length of the output buffer. + * \param[out] output_copy Pointer to a psa_crypto_output_copy_t struct to + * populate with the output copy. + * \return #PSA_SUCCESS, if the buffer was successfully + * copied. + * \return #PSA_ERROR_INSUFFICIENT_MEMORY, if a copy of + * the buffer cannot be allocated. + */ +psa_status_t psa_crypto_output_copy_alloc(uint8_t *output, size_t output_len, + psa_crypto_output_copy_t *output_copy); + +/** Copy from a local copy of an output buffer back to the original, then + * free the local copy. + * + * \param[in] output_copy Pointer to a psa_crypto_output_copy_t struct + * populated by a previous call to + * psa_crypto_output_copy_alloc(). + * \return #PSA_SUCCESS, if the output copy was + * successfully copied back to the original. + * \return #PSA_ERROR_CORRUPTION_DETECTED, if the output + * could not be copied back to the original. + */ +psa_status_t psa_crypto_output_copy_free(psa_crypto_output_copy_t *output_copy); + #endif /* PSA_CRYPTO_CORE_H */