Commit 68d8029
Fix ChaCha20-Poly1305 and XChaCha20-Poly1305 one-shot APIs to allow empty plaintext
Three functions rejected zero-length plaintext with BAD_FUNC_ARG:
1. wc_ChaCha20Poly1305_Decrypt: required outPlaintext != NULL even
when inCiphertextLen is 0. RFC 8439 Section 2.8 permits empty
plaintext (authentication-only mode).
2. wc_ChaCha20Poly1305_UpdateData: required inData/outData != NULL
unconditionally, and called wc_Chacha_Process with NULL pointers
even when dataLen is 0 (which also rejects NULL).
3. wc_XChaCha20Poly1305_crypt_oneshot: required dst != NULL even
when dst_len is 0.
Fix: gate all NULL checks and processing calls on the respective
length being > 0. Also guard the ForceZero error cleanup in the
one-shot decrypt path, which would pass NULL to ForceZero on error
with zero-length plaintext.
Note: the streaming API Final() fix for empty plaintext was merged
upstream separately (PR #10040). This commit fixes the one-shot and
UpdateData paths that the streaming fix did not cover.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Found via Wycheproof test vectors.1 parent c4c71ee commit 68d8029
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
122 | | - | |
| 124 | + | |
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
| |||
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
232 | | - | |
| 234 | + | |
| 235 | + | |
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
| |||
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
252 | | - | |
| 255 | + | |
253 | 256 | | |
254 | 257 | | |
255 | 258 | | |
| |||
401 | 404 | | |
402 | 405 | | |
403 | 406 | | |
404 | | - | |
| 407 | + | |
405 | 408 | | |
406 | 409 | | |
407 | 410 | | |
| |||
0 commit comments