Skip to content

fix: AES-EAX allow empty plaintext#10251

Open
MarkAtwood wants to merge 1 commit intowolfSSL:masterfrom
MarkAtwood:fix/aes-eax-empty-plaintext
Open

fix: AES-EAX allow empty plaintext#10251
MarkAtwood wants to merge 1 commit intowolfSSL:masterfrom
MarkAtwood:fix/aes-eax-empty-plaintext

Conversation

@MarkAtwood
Copy link
Copy Markdown

Summary

wc_AesEaxEncryptAuth, wc_AesEaxDecryptAuth, wc_AesEaxEncryptUpdate, and wc_AesEaxDecryptUpdate unconditionally required non-NULL out/in/authIn pointers, returning BAD_FUNC_ARG even when the corresponding length was 0.

EAX mode with empty plaintext is a valid authentication-only operation (OMAC over nonce and AAD only), permitted by the EAX specification (Bellare, Rogaway, Wagner 2004) and exercised by Wycheproof test vectors.

Fix: gate NULL pointer checks on the corresponding length being > 0. In the incremental Update functions, skip the AES-CTR and CMAC ciphertext update when inSz is 0 to avoid passing NULL to wc_AesCtrEncrypt.

Found via Wycheproof test vectors.

Test plan

  • Wycheproof AES-EAX vectors with empty plaintext pass
  • Existing AES-EAX tests unaffected

/cc @wolfSSL-Fenrir-bot please review

The one-shot wc_AesEaxEncryptAuth/wc_AesEaxDecryptAuth and the
incremental wc_AesEaxEncryptUpdate/wc_AesEaxDecryptUpdate functions
unconditionally required non-NULL out/in/authIn pointers, returning
BAD_FUNC_ARG even when the corresponding length was 0.

EAX mode with empty plaintext is a valid authentication-only operation
that produces just an authentication tag (OMAC over nonce and AAD).
This is permitted by the EAX specification (Bellare, Rogaway, Wagner
2004) and exercised by Wycheproof test vectors.

Fix: gate NULL pointer checks on the corresponding length being > 0.
In the incremental Update functions, skip the AES-CTR and CMAC
ciphertext update when inSz is 0 to avoid passing NULL to
wc_AesCtrEncrypt (which also rejects NULL unconditionally).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 17, 2026 21:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates AES-EAX one-shot and incremental APIs to support authentication-only operations by allowing NULL plaintext/ciphertext pointers when the corresponding length is 0 (as permitted by the EAX spec and required by Wycheproof vectors).

Changes:

  • Relax NULL pointer checks in wc_AesEaxEncryptAuth / wc_AesEaxDecryptAuth when inSz == 0 and/or authInSz == 0.
  • In wc_AesEaxEncryptUpdate / wc_AesEaxDecryptUpdate, skip CTR and ciphertext-CMAC updates when inSz == 0 to avoid calling wc_AesCtrEncrypt with NULL pointers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfcrypt/src/aes.c
int ret;

if (eax == NULL || out == NULL || in == NULL) {
if (eax == NULL || (inSz > 0 && (out == NULL || in == NULL))) {
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wc_AesEaxEncryptUpdate still doesn't validate authIn when authInSz > 0. If the function later CMAC-updates AAD when authInSz is non-zero, passing authIn == NULL will result in a NULL dereference. Fix by extending the argument validation to also require authIn != NULL when authInSz > 0 (mirroring the one-shot Auth functions).

Suggested change
if (eax == NULL || (inSz > 0 && (out == NULL || in == NULL))) {
if (eax == NULL || (inSz > 0 && (out == NULL || in == NULL)) ||
(authInSz > 0 && authIn == NULL)) {

Copilot uses AI. Check for mistakes.
Comment thread wolfcrypt/src/aes.c
int ret;

if (eax == NULL || out == NULL || in == NULL) {
if (eax == NULL || (inSz > 0 && (out == NULL || in == NULL))) {
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wc_AesEaxDecryptUpdate has the same gap as EncryptUpdate: there is no guard ensuring authIn != NULL when authInSz > 0. If the function proceeds to CMAC-update AAD for non-zero authInSz, this can crash. Add a length-gated NULL check for authIn in the argument validation.

Suggested change
if (eax == NULL || (inSz > 0 && (out == NULL || in == NULL))) {
if (eax == NULL || (inSz > 0 && (out == NULL || in == NULL)) ||
(authInSz > 0 && authIn == NULL)) {

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants