Add buffer copying to psa_aead_set_nonce()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 87c7cac..b58758c 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -4938,11 +4938,14 @@
/* Set the nonce for a multipart authenticated encryption or decryption
operation.*/
psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation,
- const uint8_t *nonce,
+ const uint8_t *nonce_external,
size_t nonce_length)
{
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
+ LOCAL_INPUT_DECLARE(nonce_external, nonce);
+ LOCAL_INPUT_ALLOC(nonce_external, nonce_length, nonce);
+
if (operation->id == 0) {
status = PSA_ERROR_BAD_STATE;
goto exit;
@@ -4969,6 +4972,8 @@
psa_aead_abort(operation);
}
+ LOCAL_INPUT_FREE(nonce_external, nonce);
+
return status;
}