Fix ChaCha20-Poly1305 Final() to allow empty plaintext and AAD#10046
Fix ChaCha20-Poly1305 Final() to allow empty plaintext and AAD#10046MarkAtwood wants to merge 2 commits intowolfSSL:masterfrom
Conversation
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
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. ✅
1edcdc0 to
4c49ea4
Compare
wc_ChaCha20Poly1305_Final() rejected CHACHA20_POLY1305_STATE_READY, blocking use when no data or AAD was ever provided. RFC 8439 §2.8 permits empty plaintext and produces a well-defined authentication tag. Found via Wycheproof test vectors.
4c49ea4 to
5e899a1
Compare
|
/cc @wolfSSL-Fenrir-bot please review |
|
Replace the READY-state BAD_STATE_E assertion (which the fix renders obsolete) with a positive Wycheproof tc2 test: empty plaintext + empty AAD through the streaming API must produce the correct authentication tag per RFC 8439 Section 2.8.
|
Fixed the CI failure: the existing bad-state test at line 10987 manually set Replaced it with a positive test using Wycheproof tc2 (key/iv/tag from the test corpus): calls |
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