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 ddc834f..36c5f75 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -4346,6 +4346,20 @@
size_t default_iv_length = 0;
psa_key_attributes_t attributes;
+ 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;
@@ -4401,6 +4415,9 @@
*output_length = 0;
}
+ psa_crypto_local_input_free(&local_input);
+ psa_crypto_local_output_free(&local_output);
+
return status;
}