Repository navigation
Allow setAuthTag() after update() for GCM Decipheriv - #8392
Merged
Merged
Conversation
A node:crypto GCM Decipheriv threw "No auth tag provided" from update() unless setAuthTag() had been called first. Node only needs the tag before final() for GCM, so streaming decryption, where the tag arrives last, failed. ssh2's aes*-gcm@openssh.com does this, so GCM SSH connections from a Worker failed on the first encrypted packet. In this patch: - update() passes the auth tag to BoringSSL only if it has already been set. final() already passes it when update() didn't, and still throws "No auth tag provided" if it was never set. - CCM still requires the tag before any data, since that mode checks it during update(). This only lets a call order that used to throw work as it does in Node, so it has no compatibility flag. chacha20-poly1305 goes through the one-shot EVP_AEAD path and still needs the tag before its single update(). Fixes #8123
There was a problem hiding this comment.
✅ Approved — Small, well-scoped fix that matches Node's GCM behaviour. CCM keeps its early tag check, final() still requires a tag, and tests cover the new call orders.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
No issues found.
update(): passes the auth tag only if it has been set. Without one, CCM still throwsNo auth tag provided, and GCM goes ahead.final(): passes the tag ifupdate()didn't, and throwsNo auth tag providedif no tag was ever set.- Tests: they cover the late-tag, wrong-tag and missing-tag cases for the AES-GCM variants.
📝 Documentation: ✅ LGTM
No documentation issues. The new code comment accurately describes the CCM and GCM tag requirements.
Reviewed commit: 4107c4a8
jasnell
approved these changes
Nov 12, 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.
A
node:cryptoGCMDecipherivthrewNo auth tag providedfromupdate()unlesssetAuthTag()had been called first. Node only needs the tag beforefinal()for GCM, so streaming decryption, where the tag arrives last, failed. ssh2'saes*-gcm@openssh.comdoes this, so GCM SSH connections from a Worker failed on the first encrypted packet. Fixes #8123.In this patch:
update()passes the auth tag to BoringSSL only if it has already been set.final()already passes it whenupdate()didn't, and still throwsNo auth tag providedif it was never set.update().update(ct), thensetAuthTag(tag), thenfinal()No auth tag providedNo auth tag providedfinal()throwsAuthentication failedupdate(ct), thenfinal()with no tagNo auth tag providedfinal()throwsNo auth tag providedThis only lets a call order that used to throw work as it does in Node, so it has no compatibility flag. chacha20-poly1305 goes through the one-shot EVP_AEAD path and still needs the tag before its single
update().