Crypto: psa_aead_verify()/finish() can have NULL pointer outputs
The psa_aead_verify() and psa_aead_finish() APIs can have cases
where the output pointers for plaintext and ciphertext are NULL
or zero-length hence need to be handled accordingly by the
interface as the IPC framework would result in error in these
cases.
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
Change-Id: Ic1885d130c8e7eae1a928623153a93a43b280292
diff --git a/interface/src/tfm_crypto_func_api.c b/interface/src/tfm_crypto_func_api.c
index 2b033d4..fea3edc 100644
--- a/interface/src/tfm_crypto_func_api.c
+++ b/interface/src/tfm_crypto_func_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -1059,15 +1059,15 @@
};
psa_outvec out_vec[] = {
{.base = &(operation->handle), .len = sizeof(uint32_t)},
- {.base = ciphertext, .len = ciphertext_size},
{.base = tag, .len = tag_size},
+ {.base = ciphertext, .len = ciphertext_size}
};
status = API_DISPATCH(tfm_crypto_aead_finish,
TFM_CRYPTO_AEAD_FINISH);
- *ciphertext_length = out_vec[1].len;
- *tag_length = out_vec[2].len;
+ *ciphertext_length = out_vec[2].len;
+ *tag_length = out_vec[1].len;
return status;
}