From 9516cc4e70e41d6cb6e13791b8177598a8808aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 11 Jun 2026 10:40:11 +0200 Subject: [PATCH] psa: test buffer too small for RSA decrypt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- tests/suites/test_suite_psa_crypto.function | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index c73aa9ad86..090d18d9a3 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -8776,6 +8776,16 @@ void asymmetric_encrypt_decrypt(int key_type_arg, TEST_MEMORY_COMPARE(input_data->x, input_data->len, output2, output2_length); + /* Try again with an output buffer that's one byte too small */ + if (output2_size != 0) { + TEST_EQUAL(PSA_ERROR_BUFFER_TOO_SMALL, + psa_asymmetric_decrypt(key, alg, + output, output_length, + label->x, label->len, + output2, output2_size - 1, + &output2_length)); + } + exit: /* * Key attributes may have been returned by psa_get_key_attributes() @@ -8857,6 +8867,17 @@ void asymmetric_decrypt(int key_type_arg, output, output_length); } + /* Try again with an output buffer that's one byte too small */ + if (output_size != 0) { + TEST_EQUAL(PSA_ERROR_BUFFER_TOO_SMALL, + psa_asymmetric_decrypt(key, alg, + input_data->x, input_data->len, + label->x, label->len, + output, + output_size - 1, + &output_length)); + } + exit: psa_reset_key_attributes(&attributes); psa_destroy_key(key);