From 232ab25bcd264c6d4973f41a6854f7d69fdc0468 Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Mon, 20 Nov 2023 12:39:38 +0000 Subject: [PATCH] Change psa_crypto_copy_output error code When we are copying output, it makes sense to return PSA_ERROR_BUFFER_TOO_SMALL since the buffer we are copying to is a user output buffer. Signed-off-by: David Horstmann --- library/psa_crypto.c | 4 ++-- tests/suites/test_suite_psa_crypto_memory.data | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 0679368df1..b3bb394a25 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -5558,7 +5558,7 @@ psa_status_t psa_crypto_copy_input(const uint8_t *input, size_t input_len, * \param[out] output_len Length of the user-supplied output buffer. * \return #PSA_SUCCESS, if the buffer was successfully * copied. - * \return #PSA_ERROR_CORRUPTION_DETECTED, if the + * \return #PSA_ERROR_BUFFER_TOO_SMALL, if the * user-supplied output buffer is too small to * hold the contents of the local buffer. */ @@ -5567,7 +5567,7 @@ psa_status_t psa_crypto_copy_output(const uint8_t *output_copy, size_t output_co uint8_t *output, size_t output_len) { if (output_len < output_copy_len) { - return PSA_ERROR_CORRUPTION_DETECTED; + return PSA_ERROR_BUFFER_TOO_SMALL; } if (output_copy_len > 0) { diff --git a/tests/suites/test_suite_psa_crypto_memory.data b/tests/suites/test_suite_psa_crypto_memory.data index 357d3423d3..94fb407f9b 100644 --- a/tests/suites/test_suite_psa_crypto_memory.data +++ b/tests/suites/test_suite_psa_crypto_memory.data @@ -20,7 +20,7 @@ PSA output buffer copy: output buffer larger than required copy_output:10:20:PSA_SUCCESS PSA output buffer copy: output buffer too small -copy_output:20:10:PSA_ERROR_CORRUPTION_DETECTED +copy_output:20:10:PSA_ERROR_BUFFER_TOO_SMALL PSA output buffer copy: zero-length source buffer copy_output:0:10:PSA_SUCCESS