Skip to content

Commit 9d29e66

Browse files
committed
Fix from review
1 parent c60ffbd commit 9d29e66

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19525,6 +19525,62 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_eax_test(void)
1952519525
return WC_TEST_RET_ENC_EC(ret);
1952619526
}
1952719527
#endif
19528+
19529+
/* Upper bound: authTagSz > WC_AES_BLOCK_SIZE must be rejected.
19530+
* Pins the '>' operator in the validation against mutation to '>='
19531+
* and prevents an over-read of the caller-supplied tag buffer. */
19532+
ret = wc_AesEaxDecryptAuth(vectors[0].key,
19533+
(word32)vectors[0].key_length,
19534+
zero_pt,
19535+
zero_ct, (word32)sizeof(zero_ct),
19536+
vectors[0].iv,
19537+
(word32)vectors[0].iv_length,
19538+
zero_tag, WC_AES_BLOCK_SIZE + 1,
19539+
vectors[0].aad,
19540+
(word32)vectors[0].aad_length);
19541+
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19542+
return WC_TEST_RET_ENC_EC(ret);
19543+
}
19544+
19545+
/* Direct incremental-API coverage: wc_AesEaxDecryptFinal must also
19546+
* reject authInSz of zero and below WOLFSSL_MIN_AUTH_TAG_SZ. The
19547+
* one-shot API above is a separate code path. */
19548+
{
19549+
AesEax eax;
19550+
XMEMSET(&eax, 0, sizeof(eax));
19551+
ret = wc_AesEaxInit(&eax,
19552+
vectors[0].key, (word32)vectors[0].key_length,
19553+
vectors[0].iv, (word32)vectors[0].iv_length,
19554+
vectors[0].aad,
19555+
(word32)vectors[0].aad_length);
19556+
if (ret != 0) {
19557+
return WC_TEST_RET_ENC_EC(ret);
19558+
}
19559+
19560+
ret = wc_AesEaxDecryptFinal(&eax, zero_tag, 0);
19561+
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19562+
wc_AesEaxFree(&eax);
19563+
return WC_TEST_RET_ENC_EC(ret);
19564+
}
19565+
19566+
#if WOLFSSL_MIN_AUTH_TAG_SZ > 1
19567+
ret = wc_AesEaxDecryptFinal(&eax, zero_tag,
19568+
WOLFSSL_MIN_AUTH_TAG_SZ - 1);
19569+
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19570+
wc_AesEaxFree(&eax);
19571+
return WC_TEST_RET_ENC_EC(ret);
19572+
}
19573+
#endif
19574+
19575+
/* Upper bound: authInSz > WC_AES_BLOCK_SIZE must be rejected. */
19576+
ret = wc_AesEaxDecryptFinal(&eax, zero_tag, WC_AES_BLOCK_SIZE + 1);
19577+
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19578+
wc_AesEaxFree(&eax);
19579+
return WC_TEST_RET_ENC_EC(ret);
19580+
}
19581+
19582+
wc_AesEaxFree(&eax);
19583+
}
1952819584
}
1952919585
#endif /* WOLFSSL_MIN_AUTH_TAG_SZ > 0 */
1953019586

0 commit comments

Comments
 (0)