]> Cypherpunks repositories - gostls13.git/commit
crypto/internal/fips140/aes/gcm: add more GCM nonce modes
authorFilippo Valsorda <filippo@golang.org>
Mon, 24 Nov 2025 12:35:15 +0000 (13:35 +0100)
committerGopher Robot <gobot@golang.org>
Wed, 26 Nov 2025 02:07:13 +0000 (18:07 -0800)
commit272df5f6ba94018dac2b7d384e92115b795fe241
treeece3de9a88fdf5ab1003ce55e437247afda33f25
parent1768cb40b838a36f9bdcbe5381f2e086483f22f5
crypto/internal/fips140/aes/gcm: add more GCM nonce modes

First, this adds a GCM mode for QUIC, and a generic TLS 1.3/QUIC-like
XOR'd counter mode. QUIC constructs nonces exactly like TLS 1.3, but the
counter does not reset to zero on a key update, so the mask must be
provided explicitly (or we will panic well before running out of
counters because the wrong value is XOR'd out). See the analysis at
https://github.com/quic-go/quic-go/issues/5077#issuecomment-3570352683
for the details of QUIC and FIPS 140-3 compliance (including a
workaround for the key update issue).

Second, this coalesces all the compliance modes around two schemes:
fixed || counter, and fixed XOR counter. The former is used in TLS 1.2
and SSH, and the latter is used in TLS 1.3 and QUIC.

This would not be a backwards compatible change if these were public
APIs, but we only need different versions of the FIPS 140-3 module to be
source-compatible with the standard library, and the callers of these
NewGCMFor* functions only care that the return value implements
cipher.AEAD, at least for now.

This exposes no new public APIs, but lets us get started validating
these functions in v2.0.0 of the FIPS 140-3 module.

Updates #73110

Change-Id: I3d86cf8a3c4a96caf361c29f0db5f9706a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/723760
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/crypto/cipher/gcm_fips140v2.0_test.go [new file with mode: 0644]
src/crypto/cipher/gcm_test.go
src/crypto/internal/fips140/aes/gcm/gcm_nonces.go