Abort AEAD operation if client provided buffer is too small
To enable PSA Arch test c258 to pass, handling is added in the
PSA API client adaptor for AEAD (psa_aead.c) to abort an AEAD
operation if an update operation is performed but the client
provided buffer for the output is too small.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: Iec86215b9a71b53e5eb93f53f924aa84cb708098
diff --git a/components/service/crypto/client/psa/psa_aead.c b/components/service/crypto/client/psa/psa_aead.c
index 559eb6a..c820d22 100644
--- a/components/service/crypto/client/psa/psa_aead.c
+++ b/components/service/crypto/client/psa/psa_aead.c
@@ -74,10 +74,22 @@
size_t output_size,
size_t *output_length)
{
- return crypto_caller_aead_update(&psa_crypto_client_instance.base,
+ psa_status_t status = crypto_caller_aead_update(&psa_crypto_client_instance.base,
operation->handle,
input, input_length,
output, output_size, output_length);
+
+ /*
+ * If too small a buffer has been provided for the output, the operation
+ * state will have been updated but the result can't be put anywhere. This
+ * is an unrecoveral condition so abort the operation.
+ */
+ if (status == PSA_ERROR_BUFFER_TOO_SMALL) {
+
+ psa_aead_abort(operation);
+ }
+
+ return status;
}
psa_status_t psa_aead_finish(psa_aead_operation_t *operation,