From 8f2a3f9563f83baafe9fa97aa91c0073d6f88837 Mon Sep 17 00:00:00 2001 From: Aidan Garske Date: Tue, 7 Apr 2026 13:05:30 -0700 Subject: [PATCH] F-2203 - Add negative test for ECC ECIES HMAC authentication tag verification --- wolfcrypt/test/test.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index ac724e28da..f0f74aeeea 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -39039,6 +39039,15 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_test_buffers(void) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done); if (XMEMCMP(plain, in, inLen)) ERROR_OUT(WC_TEST_RET_ENC_NC, done); + + /* Negative test: corrupt HMAC tag in encrypted msg, expect + * HASH_TYPE_E from wc_ecc_decrypt. */ + out[x - 1] ^= 0x01; + y = sizeof(plain); + ret = wc_ecc_decrypt(servKey, tmpKey, out, x, plain, &y, NULL); + if (ret != WC_NO_ERR_TRACE(HASH_TYPE_E)) + ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done); + ret = 0; /* reset ret for following tests */ } #endif