Fix ChaCha20-Poly1305 Final() to allow empty plaintext and AAD#10046
Open
MarkAtwood wants to merge 1 commit intowolfSSL:masterfrom
Open
Fix ChaCha20-Poly1305 Final() to allow empty plaintext and AAD#10046MarkAtwood wants to merge 1 commit intowolfSSL:masterfrom
MarkAtwood wants to merge 1 commit intowolfSSL:masterfrom
Conversation
dgarske
requested changes
Mar 23, 2026
Contributor
dgarske
left a comment
There was a problem hiding this comment.
Many of the CI tests are failing now:
ChaCha20-Poly1305 AEAD test failed!
error L=10590 code=0 (ok)
[fiducial line numbers: 11340 31712 53140 66641]
Exiting main with return code: -1
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the ChaCha20-Poly1305 streaming finalization logic to permit generating an authentication tag when both plaintext and AAD are empty, aligning behavior with RFC 8439 and fixing the reported BAD_STATE_E error path.
Changes:
- Allow
wc_ChaCha20Poly1305_Final()to accept theCHACHA20_POLY1305_STATE_READYstate (no prior AAD/data updates). - Preserve existing state validation for AAD and DATA states while continuing to reject other invalid states.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10046
Scan targets checked: wolfcrypt-bugs, wolfcrypt-src
No new issues found in the changed files. ✅
ChaCha20-Poly1305 Final() rejected the READY state (no data or AAD provided), though RFC 8439 §2.8 explicitly permits empty plaintext and produces a well-defined authentication tag. RSA-OAEP rejected zero-length plaintexts at both encrypt and decrypt. RFC 8017 §7.1.1 permits empty messages; OpenSSL and BoringSSL both accept them. Found via Wycheproof test vectors.
74a8154 to
1edcdc0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wc_ChaCha20Poly1305_Final()rejectedCHACHA20_POLY1305_STATE_READYwithBAD_STATE_E, which occurs when neitherUpdateAadnorUpdateDatahas been called (both AAD and plaintext are empty)wc_ChaCha20Poly1305_Encrypt/Decryptfunctions which call through itFixes #10040
Test plan
🤖 Generated with Claude Code