Skip to content

Implement crypto/internal/backend outside of the standard library#2362

Merged
qmuntal merged 9 commits into
microsoft/mainfrom
dev/qmuntal/extractbackend
Jun 11, 2026
Merged

Implement crypto/internal/backend outside of the standard library#2362
qmuntal merged 9 commits into
microsoft/mainfrom
dev/qmuntal/extractbackend

Conversation

@qmuntal

@qmuntal qmuntal commented Jun 11, 2026

Copy link
Copy Markdown
Member

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.patch loses 2500 lines of code, and that's the real win, given that all these lines were real code.

@qmuntal qmuntal marked this pull request as ready for review June 11, 2026 12:38
@qmuntal qmuntal requested a review from a team as a code owner June 11, 2026 12:38
Copilot AI review requested due to automatic review settings June 11, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/cryptobackend tree 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

Comment thread cryptobackend/internal/fips140state/requirefips_nosystemcrypto.go
Comment thread cryptobackend/backend_linux.go
Comment thread cryptobackend/backend_windows.go
Comment thread cryptobackend/backend_darwin.go
Comment thread cryptobackend/backend_test.go

@gdams gdams left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this!

@qmuntal qmuntal merged commit d7a6bb3 into microsoft/main Jun 11, 2026
54 checks passed
@qmuntal qmuntal deleted the dev/qmuntal/extractbackend branch June 11, 2026 14:05
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.

3 participants