Implement crypto/internal/backend outside of the standard library#2362
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Moves the system crypto backend implementation out of crypto/internal/* and into a standalone module (github.com/microsoft/go/cryptobackend) that is vendored into GOROOT/src/vendor, reducing patch churn and making backend changes easier to review.
Changes:
- Introduces the new
cryptobackend/module (backend shims, FIPS state detection, OpenSSL init helper, tests) and wires it into the build via vendoring. - Updates the vendor patch to include the vendored
github.com/microsoft/go/cryptobackendtree and adjusts dependency tracking (src/crypto/deps_ignore.go,src/go.mod,modules.txt, etc.). - Updates TLS-related patching and repository guidance/docs to use the new backend import path.
Patches are happy!
Show a summary per file
| File | Description |
|---|---|
| patches/0010-Align-TLS-settings-with-Microsoft-policies.patch | Updates TLS policy patch to use the externalized backend and related toggles. |
| patches/0001-Vendor-external-dependencies.patch | Vendors the new github.com/microsoft/go/cryptobackend package and updates std module deps accordingly. |
| eng/_util/internal/patchcheck/vendoronly.go | Adjusts vendor-only path allowlist for moved deps ignore file. |
| cryptobackend/stub.s | Stub assembly file to satisfy tooling/link expectations for runtime_arg0. |
| cryptobackend/README.md | Documents how/why cryptobackend is vendored and the stdlib-only import exceptions. |
| cryptobackend/nobackend.go | Non-systemcrypto stubs for the backend package. |
| cryptobackend/internal/opensslsetup/stub.go | Placeholder package file for OpenSSL setup support. |
| cryptobackend/internal/opensslsetup/opensslsetup_linux.go | Linux OpenSSL library discovery/initialization helper. |
| cryptobackend/internal/opensslsetup/opensslsetup_linux_test.go | Unit tests for OpenSSL library selection logic. |
| cryptobackend/internal/fips140state/systemfips_windows.go | Windows system FIPS detection. |
| cryptobackend/internal/fips140state/systemfips_linux.go | Linux system/kernel/OpenSSL FIPS detection. |
| cryptobackend/internal/fips140state/systemfips_darwin.go | Darwin system FIPS detection stub. |
| cryptobackend/internal/fips140state/state.go | Core FIPS enablement detection and backend checks. |
| cryptobackend/internal/fips140state/state_test.go | Tests for FIPS detection logic. |
| cryptobackend/internal/fips140state/state_nomsgostd.go | Non-stdlib build behavior for reading GODEBUG setting. |
| cryptobackend/internal/fips140state/state_msgostd.go | Stdlib-only behavior for reading GODEBUG setting. |
| cryptobackend/internal/fips140state/skipfipscheck_on.go | Build-tag hook to skip FIPS checks. |
| cryptobackend/internal/fips140state/skipfipscheck_off.go | Default behavior when skip tag is not set. |
| cryptobackend/internal/fips140state/requirefips_nosystemcrypto.go | requirefips handling when systemcrypto isn’t enabled. |
| cryptobackend/internal/fips140state/nosystemcrypto.go | System FIPS detection stub when systemcrypto is off. |
| cryptobackend/internal/fips140state/norequirefips.go | Default requirefips flag state. |
| cryptobackend/internal/fips140state/isrequirefips.go | requirefips flag state under build tag. |
| cryptobackend/go.sum | Module sums for backend dependencies. |
| cryptobackend/go.mod | Declares the standalone github.com/microsoft/go/cryptobackend module. |
| cryptobackend/fips140/fips140.go | Public shim API for querying FIPS enablement. |
| cryptobackend/common.go | Shared helpers (FIPS check plumbing, unreachable guards). |
| cryptobackend/bbig/big.go | Non-systemcrypto stub bbig API. |
| cryptobackend/bbig/big_windows.go | Windows bbig wiring for systemcrypto builds. |
| cryptobackend/bbig/big_linux.go | Linux bbig wiring for systemcrypto builds. |
| cryptobackend/bbig/big_darwin.go | Darwin bbig wiring for systemcrypto builds. |
| cryptobackend/backend_windows.go | Windows backend implementation wiring (CNG). |
| cryptobackend/backend_windows_msgostd.go | Stdlib-only Windows glue (msgostd) for backend integration. |
| cryptobackend/backend_test.go | Tests for backend helper behavior. |
| cryptobackend/backend_linux.go | Linux backend implementation wiring (OpenSSL). |
| cryptobackend/backend_darwin.go | Darwin backend implementation wiring (CryptoKit/CommonCrypto). |
| .vscode/settings.json | Adds VS Code Go environment/debug defaults for this repo. |
| .github/instructions/patch-consistency.instructions.md | Updates patch consistency guidance for moved deps ignore path. |
| .github/copilot-instructions.md | Updates repository Copilot guidance to use the new backend import path. |
Copilot's findings
- Files reviewed: 37/40 changed files
- Comments generated: 5
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.
The crypto backend layer can be moved outside of the standard library. This way the patch files are smaller and changes in the backend will be easier to review. That is, the cryptobackend package is now regular source code.
Note that this PR adds 2500 lines of code, but all of the additions are in
patches/0001-Vendor-external-dependencies.patch, which is automatically generated by copying the external dependencies, like now the cryptobackend package. On the other hand,patches/0002-Add-crypto-backends.patchloses 2500 lines of code, and that's the real win, given that all these lines were real code.