Copy input and output in psa_cipher_encrypt()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 60c81a5..55adfa7 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3563,6 +3563,20 @@
uint8_t local_iv[PSA_CIPHER_IV_MAX_SIZE];
size_t default_iv_length = 0;
+ psa_crypto_local_input_t local_input = PSA_CRYPTO_LOCAL_INPUT_INIT;
+ status = psa_crypto_local_input_alloc(input, input_length, &local_input);
+ if (status != PSA_SUCCESS) {
+ goto exit;
+ }
+ input = local_input.buffer;
+
+ psa_crypto_local_output_t local_output = PSA_CRYPTO_LOCAL_OUTPUT_INIT;
+ status = psa_crypto_local_output_alloc(output, output_size, &local_output);
+ if (status != PSA_SUCCESS) {
+ goto exit;
+ }
+ output = local_output.buffer;
+
if (!PSA_ALG_IS_CIPHER(alg)) {
status = PSA_ERROR_INVALID_ARGUMENT;
goto exit;
@@ -3618,6 +3632,9 @@
*output_length = 0;
}
+ psa_crypto_local_input_free(&local_input);
+ psa_crypto_local_output_free(&local_output);
+
return status;
}