Skip to content

Reject zero-length AEAD authentication tags - #58

Merged
Coralesoft merged 1 commit into
mainfrom
fix/aead-zero-tag-validation
Jul 16, 2026
Merged

Reject zero-length AEAD authentication tags#58
Coralesoft merged 1 commit into
mainfrom
fix/aead-zero-tag-validation

Conversation

@Coralesoft

Copy link
Copy Markdown
Collaborator

AEAD APIs accepted zero-length authentication tags. EncryptAndAuthenticate produced no tag, while DecryptAndVerify could report tampered ciphertext as authentic.

This affected GCM, EAX, CCM, ChaCha20-Poly1305, and XChaCha20-Poly1305 through both the one-shot APIs and authenticated filters. Reported upstream as weidai11/cryptopp#1364.

What changed

  • Reject a zero tag size in AuthenticatedSymmetricCipherBase::TruncatedFinal.
  • Cover all five algorithms and both GCM filter paths.
  • Add one-byte truncation and full-tag tamper controls.

The one-shot APIs process the message before finalisation, so output buffers may already contain ciphertext or unauthenticated plaintext when the exception is thrown. Callers must discard that output.

Defaults are unchanged. A filter truncatedDigestSize of -1 still selects the full tag.

GCM, EAX, CCM, ChaCha20-Poly1305, and XChaCha20-Poly1305 accepted a zero tag size through EncryptAndAuthenticate, DecryptAndVerify, and the authenticated filters, and verification with a zero-length tag reported tampered ciphertext as authentic. Reject zero in AuthenticatedSymmetricCipherBase::TruncatedFinal, which all five algorithms and both filter paths reach during finalisation.

Add rejection tests for each algorithm and the GCM filters, a one-byte truncation control, and a full-tag tamper control. Reported upstream as weidai11/cryptopp issue 1364.
@Coralesoft Coralesoft self-assigned this Jul 16, 2026
@Coralesoft
Coralesoft merged commit 209c852 into main Jul 16, 2026
47 checks passed
@Coralesoft
Coralesoft deleted the fix/aead-zero-tag-validation branch July 16, 2026 10:30
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.

1 participant