Skip to content

Commit 760efdf

Browse files
committed
Fix from review
1 parent a2c5197 commit 760efdf

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19544,42 +19544,52 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_eax_test(void)
1954419544

1954519545
/* Direct incremental-API coverage: wc_AesEaxDecryptFinal must also
1954619546
* reject authInSz of zero and below WOLFSSL_MIN_AUTH_TAG_SZ. The
19547-
* one-shot API above is a separate code path. */
19547+
* one-shot API above is a separate code path. Heap-allocate the
19548+
* AesEax context to keep stack usage within Linux kernel limits. */
1954819549
{
19549-
AesEax eax;
19550-
XMEMSET(&eax, 0, sizeof(eax));
19551-
ret = wc_AesEaxInit(&eax,
19550+
AesEax *eax = (AesEax *)XMALLOC(sizeof(*eax), HEAP_HINT,
19551+
DYNAMIC_TYPE_TMP_BUFFER);
19552+
if (eax == NULL) {
19553+
return WC_TEST_RET_ENC_NC;
19554+
}
19555+
XMEMSET(eax, 0, sizeof(*eax));
19556+
ret = wc_AesEaxInit(eax,
1955219557
vectors[0].key, (word32)vectors[0].key_length,
1955319558
vectors[0].iv, (word32)vectors[0].iv_length,
1955419559
vectors[0].aad,
1955519560
(word32)vectors[0].aad_length);
1955619561
if (ret != 0) {
19562+
XFREE(eax, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
1955719563
return WC_TEST_RET_ENC_EC(ret);
1955819564
}
1955919565

19560-
ret = wc_AesEaxDecryptFinal(&eax, zero_tag, 0);
19566+
ret = wc_AesEaxDecryptFinal(eax, zero_tag, 0);
1956119567
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19562-
wc_AesEaxFree(&eax);
19568+
wc_AesEaxFree(eax);
19569+
XFREE(eax, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
1956319570
return WC_TEST_RET_ENC_EC(ret);
1956419571
}
1956519572

1956619573
#if WOLFSSL_MIN_AUTH_TAG_SZ > 1
19567-
ret = wc_AesEaxDecryptFinal(&eax, zero_tag,
19574+
ret = wc_AesEaxDecryptFinal(eax, zero_tag,
1956819575
WOLFSSL_MIN_AUTH_TAG_SZ - 1);
1956919576
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19570-
wc_AesEaxFree(&eax);
19577+
wc_AesEaxFree(eax);
19578+
XFREE(eax, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
1957119579
return WC_TEST_RET_ENC_EC(ret);
1957219580
}
1957319581
#endif
1957419582

1957519583
/* Upper bound: authInSz > WC_AES_BLOCK_SIZE must be rejected. */
19576-
ret = wc_AesEaxDecryptFinal(&eax, zero_tag, WC_AES_BLOCK_SIZE + 1);
19584+
ret = wc_AesEaxDecryptFinal(eax, zero_tag, WC_AES_BLOCK_SIZE + 1);
1957719585
if (ret != WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
19578-
wc_AesEaxFree(&eax);
19586+
wc_AesEaxFree(eax);
19587+
XFREE(eax, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
1957919588
return WC_TEST_RET_ENC_EC(ret);
1958019589
}
1958119590

19582-
wc_AesEaxFree(&eax);
19591+
wc_AesEaxFree(eax);
19592+
XFREE(eax, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
1958319593
}
1958419594
}
1958519595
#endif /* WOLFSSL_MIN_AUTH_TAG_SZ > 0 */

0 commit comments

Comments
 (0)