From 689a05df0b9170ae6bbbd6a012d5c4d46758986c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 2 Jun 2026 09:35:51 +0200 Subject: [PATCH] pk: test RSA decrypt with buffer too small 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_pk.function | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index 9bfbb37bc9..6d397f096d 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -1546,6 +1546,12 @@ void pk_rsa_decrypt_test_vec(data_t *cipher, int mod, int padding, int md_alg, if (ret == 0) { TEST_ASSERT(olen == clear->len); TEST_ASSERT(memcmp(output, clear->x, olen) == 0); + + /* Try again with an output buffer that's too small */ + TEST_EQUAL(mbedtls_pk_decrypt(&pk, cipher->x, cipher->len, + output, &olen, clear->len - 1, + mbedtls_test_rnd_pseudo_rand, &rnd_info), + MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE); } exit: