Skip to content

Commit f64a416

Browse files
Add regression test for authTagSz validation
1 parent 0a05129 commit f64a416

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

wolfcrypt/test/test.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18056,6 +18056,21 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aesgcm_test(void)
1805618056
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
1805718057
#endif
1805818058

18059+
/* Regression test: wc_AesGcmDecryptFinal must reject authTagSz below
18060+
* WOLFSSL_MIN_AUTH_TAG_SZ, consistent with wc_AesGcmDecrypt and
18061+
* wc_AesGcmEncryptFinal. */
18062+
#if defined(HAVE_AES_DECRYPT) && WOLFSSL_MIN_AUTH_TAG_SZ > 1
18063+
ret = wc_AesGcmDecryptInit(enc, k1, sizeof(k1), iv1, sizeof(iv1));
18064+
if (ret != 0)
18065+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
18066+
ret = wc_AesGcmDecryptUpdate(enc, resultP, c1, sizeof(c1), a, sizeof(a));
18067+
if (ret != 0)
18068+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
18069+
ret = wc_AesGcmDecryptFinal(enc, t1, WOLFSSL_MIN_AUTH_TAG_SZ - 1);
18070+
if (ret != BAD_FUNC_ARG)
18071+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
18072+
#endif /* HAVE_AES_DECRYPT && WOLFSSL_MIN_AUTH_TAG_SZ > 1 */
18073+
1805918074
/* alen is the size to pass in with each update. */
1806018075
for (alen = 1; alen < WC_AES_BLOCK_SIZE + 1; alen++) {
1806118076
ret = wc_AesGcmEncryptInit(enc, k1, sizeof(k1), iv1, sizeof(iv1));

0 commit comments

Comments
 (0)