Repository navigation
cryptobackend/chacha20poly1305: reject FIPS 140-only mode in New - #2722
Merged
Quim Muntal (qmuntal) merged 1 commit intoNov 13, 2026
Merged
Conversation
Check fips140.Enforced() once in the common New, before choosing between the native backend and the Go fallback, instead of repeating the check in each platform's newBackend. The policy no longer depends on which backend is compiled in or on what Supports() reports. The returned error is unchanged, so behavior is the same as before. Regenerate the vendored copy in the vendor patch. Updates #2489. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change centralizing ChaCha20-Poly1305’s FIPS 140-only rejection in the shared constructor.
No open issues 🎉
What changed in this PR
Centralizes ChaCha20-Poly1305’s FIPS 140-only rejection in the common cryptobackend.New constructor, supporting #2489’s consolidation of crypto behavior in the backend layer.
Changes:
- Checks FIPS 140-only mode before selecting the native backend or Go fallback, and documents this behavior.
- Removes duplicate checks and unused imports from the three platform implementations.
- Synchronizes the vendored code and patch index metadata.
Patches are happy!
| File | Description |
|---|---|
patches/index.json |
Updates the vendor patch hash and index entries. |
patches/0002-Vendor-external-dependencies.patch |
Mirrors the constructor and platform changes in vendored code. |
cryptobackend/chacha20poly1305/chacha20poly1305.go |
Adds and documents the shared FIPS 140-only guard. |
cryptobackend/chacha20poly1305/chacha20poly1305_windows.go |
Removes the duplicate Windows guard and unused imports. |
cryptobackend/chacha20poly1305/chacha20poly1305_openssl.go |
Removes the duplicate OpenSSL guard and unused imports. |
cryptobackend/chacha20poly1305/chacha20poly1305_darwin.go |
Removes the duplicate Darwin guard and unused imports. |
Review effort: Balanced
Quim Muntal (qmuntal)
enabled auto-merge
November 13, 2026 09:58
George Adams (gdams)
approved these changes
Nov 13, 2026
Quim Muntal (qmuntal)
deleted the
dev/qmuntal/chacha20poly1305-fips-only
branch
November 13, 2026 12:05
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.
Move the FIPS 140-only rejection for ChaCha20-Poly1305 into the common
Newincryptobackend/chacha20poly1305, before the native-backend/Go-fallback selection.Previously each platform
newBackend(openssl, windows, darwin) repeated the check, and the Go fallback relied on x/crypto's own. There is now a single check that does not depend on which backend is compiled in or on whatSupports()reports.There is no behavior change: the error is the same on every path.
Changes
chacha20poly1305.go: return the FIPS 140-only error whenfips140.Enforced(), ahead ofbackend.Enabled && Supports().chacha20poly1305_{openssl,windows,darwin}.go: drop the duplicated check and the now-unused imports.go mod vendorand folded it into0002-Vendor-external-dependencies.patch(pluspatches/index.json) usinggit go-patch rebaseandextract. No other patch changes.Testing
No new tests: the existing
TestFIPS140Onlyincrypto/internal/fips140onlyalready asserts that HPKE ChaCha20-Poly1305Seal/Openfail underfips140=only.cryptobackend:go test ./...with system Go and with the built toolchain (CNG).go vetof the vendored package andcrypto/hpkefor linux/{amd64,arm64}, darwin/{arm64,amd64}, windows/amd64 and freebsd/amd64, plus the nobackend build (MS_GO_NOSYSTEMCRYPTO=1).go test -short crypto/hpke crypto/tls crypto/internal/fips140only, andTestFIPS140Onlyrun withGODEBUG=fips140=only.go test go/builddependency tests, with and withoutMS_GO_NOSYSTEMCRYPTO=1.eng/_utilpatchchecktest. Applying the patch series to the submodule base reproduces the tested tree.The OpenSSL path could only be compile-checked locally (cross-vet); CI covers it at runtime.
Updates #2489.