Fix missing tag_size entry for sm4-128-gcm causing zero tag for chacha20/xchacha20 AEAD ciphers#3044
Open
Copilot wants to merge 2 commits into
Open
Fix missing tag_size entry for sm4-128-gcm causing zero tag for chacha20/xchacha20 AEAD ciphers#3044Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
… in AEAD cipher table PR #2424 review comment fix: supported_aead_ciphers_tag_size was not updated when sm4-128-gcm was added, causing chacha20-ietf-poly1305 and xchacha20-ietf-poly1305 to receive a zero tag size, breaking AEAD encryption/decryption.
Copilot
AI
changed the title
[WIP] Fix code based on review comment
Fix missing tag_size entry for sm4-128-gcm causing zero tag for chacha20/xchacha20 AEAD ciphers
Jun 28, 2026
madeye
approved these changes
Jun 28, 2026
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.
When
sm4-128-gcmwas inserted at index 3 in the AEAD cipher tables andAEAD_CIPHER_NUMwas bumped,supported_aead_ciphers_tag_sizewas left with only 4 entries. With 5 ciphers but 4 tag-size entries,chacha20-ietf-poly1305(now index 4) andxchacha20-ietf-poly1305(index 5) silently got a zero tag size — breaking authentication tag append/verify for those ciphers entirely.Changes
src/aead.h—AEAD_CIPHER_NUM4→5 (5→6 with xchacha)src/aead.c#define SM4128GCM 3; renumberCHACHA20POLY1305IETFto 4,XCHACHA20POLY1305IETFto 5"sm4-128-gcm"/"SM4-128-GCM"to name tablessupported_aead_ciphers_tag_size— add missing entry so all 5 slots are populated:SM4128GCMcase to encrypt/decrypt switchessrc/stream.h—STREAM_CIPHER_NUM21→23src/stream.c— AddSM4_128_CBC(index 13) andSM4_128_CTR(index 14); shift existing defines; populate mbedTLS name, nonce, and key size arrayssrc/utils.c— Add SM4 ciphers tousage()output