Skip to content

Restructure cryptobackend packages#2366

Merged
qmuntal merged 3 commits into
microsoft/mainfrom
dev/qmuntal/cryptobackend-packages
Jun 12, 2026
Merged

Restructure cryptobackend packages#2366
qmuntal merged 3 commits into
microsoft/mainfrom
dev/qmuntal/cryptobackend-packages

Conversation

@qmuntal

@qmuntal qmuntal commented Jun 12, 2026

Copy link
Copy Markdown
Member

Goal

Restructure the cryptobackend layout and symbols so that they are more similar to the crypto/internal/fips140 packages. This is an important step towards leaving the Boringcrypto APIs behind.

Summary

  • Restructure cryptobackend into per-algorithm packages and slim the root backend API
  • Update stdlib integrations and vendored backend package list to use the package-specific APIs
  • Add focused GitHub Actions workflows for patch application and Go tests in cryptobackend / eng/_util

Validation

  • pwsh eng/run.ps1 submodule-refresh -shallow
  • go test ./... in cryptobackend
  • go test go/build -run TestDependencies in go/src
  • go test -run=^$ crypto/internal/fips140only crypto/hmac crypto/hkdf crypto/pbkdf2 crypto/ecdsa crypto/rsa in go/src
  • go test ./... in eng/_util

Copilot AI review requested due to automatic review settings June 12, 2026 08:37
@qmuntal qmuntal requested a review from a team as a code owner June 12, 2026 08:37
@qmuntal qmuntal marked this pull request as draft June 12, 2026 08:41

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

This PR restructures github.com/microsoft/go/cryptobackend into per-algorithm subpackages (e.g., aes, rsa, sha*, tls12, tls13) and trims the root backend package down to primarily enablement/FIPS gating, then updates integrations and CI workflows accordingly.

Changes:

  • Split the cryptobackend surface area into algorithm-focused subpackages with platform-specific implementations and nobackend stubs.
  • Update the TLS Microsoft policy patch to use package-specific capability checks (e.g., cryptobackend/ecdh, cryptobackend/mlkem) instead of the root API.
  • Add a dedicated patch-apply workflow and change the main test workflow to run Go tests for cryptobackend and eng/_util.

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 per-algorithm cryptobackend subpackages.
cryptobackend/README.md Documents the new algorithm subpackage shape and intent.
cryptobackend/nobackend.go Slims root package !systemcrypto stub to only enablement/FIPS gating.
cryptobackend/backend_linux.go Slims root Linux backend to enablement/FIPS gating only.
cryptobackend/backend_windows.go Slims root Windows backend to enablement/FIPS gating only.
cryptobackend/backend_darwin.go Slims root Darwin backend to enablement/FIPS gating only.
cryptobackend/backend_msgostd.go Wires stdlib-only FIPS approved-hash hook to the new cryptobackend/hash package.
cryptobackend/backend_test.go Adds tests enforcing subpackages import the root backend package.
cryptobackend/bbig/init.go Ensures the bbig subpackage triggers root backend init when imported.
cryptobackend/hash/hash_linux.go Adds Linux implementation for approved-hash checks.
cryptobackend/hash/hash_windows.go Adds Windows implementation for approved-hash checks.
cryptobackend/hash/hash_darwin.go Adds Darwin implementation for approved-hash checks.
cryptobackend/hash/nobackend.go Adds !systemcrypto stub for approved-hash checks.
cryptobackend/aes/aes_linux.go Adds Linux AES block backend.
cryptobackend/aes/aes_windows.go Adds Windows AES block backend.
cryptobackend/aes/aes_darwin.go Adds Darwin AES block backend.
cryptobackend/aes/nobackend.go Adds !systemcrypto AES stub.
cryptobackend/aes/init.go Ensures AES subpackage triggers root backend init.
cryptobackend/aes/gcm/gcm_linux.go Adds Linux GCM (TLS/TLS13) backend.
cryptobackend/aes/gcm/gcm_windows.go Adds Windows GCM (TLS/TLS13) backend.
cryptobackend/aes/gcm/gcm_darwin.go Adds Darwin GCM (TLS/TLS13) backend.
cryptobackend/aes/gcm/nobackend.go Adds !systemcrypto GCM stub.
cryptobackend/aes/gcm/init.go Ensures GCM subpackage triggers root backend init.
cryptobackend/chacha20poly1305/chacha20poly1305_linux.go Adds Linux ChaCha20-Poly1305 backend with FIPS-only gating.
cryptobackend/chacha20poly1305/chacha20poly1305_windows.go Adds Windows ChaCha20-Poly1305 backend with FIPS-only gating.
cryptobackend/chacha20poly1305/chacha20poly1305_darwin.go Adds Darwin ChaCha20-Poly1305 backend with FIPS-only gating.
cryptobackend/chacha20poly1305/nobackend.go Adds !systemcrypto ChaCha20-Poly1305 stub.
cryptobackend/chacha20poly1305/init.go Ensures ChaCha20-Poly1305 subpackage triggers root backend init.
cryptobackend/des/des_linux.go Adds Linux DES/3DES backend.
cryptobackend/des/des_windows.go Adds Windows DES/3DES backend.
cryptobackend/des/des_darwin.go Adds Darwin DES/3DES backend.
cryptobackend/des/nobackend.go Adds !systemcrypto DES/3DES stub.
cryptobackend/des/init.go Ensures DES subpackage triggers root backend init.
cryptobackend/rc4/rc4_linux.go Adds Linux RC4 backend.
cryptobackend/rc4/rc4_windows.go Adds Windows RC4 backend.
cryptobackend/rc4/rc4_darwin.go Adds Darwin RC4 backend.
cryptobackend/rc4/nobackend.go Adds !systemcrypto RC4 stub.
cryptobackend/rc4/init.go Ensures RC4 subpackage triggers root backend init.
cryptobackend/drbg/rand_linux.go Adds Linux DRBG/random reader wrapper.
cryptobackend/drbg/rand_windows.go Adds Windows DRBG/random reader wrapper.
cryptobackend/drbg/rand_darwin.go Adds Darwin DRBG/random reader wrapper.
cryptobackend/drbg/nobackend.go Adds !systemcrypto DRBG stub.
cryptobackend/drbg/init.go Ensures DRBG subpackage triggers root backend init.
cryptobackend/hmac/hmac_linux.go Adds Linux HMAC backend.
cryptobackend/hmac/hmac_windows.go Adds Windows HMAC backend.
cryptobackend/hmac/hmac_darwin.go Adds Darwin HMAC backend.
cryptobackend/hmac/nobackend.go Adds !systemcrypto HMAC stub.
cryptobackend/hmac/init.go Ensures HMAC subpackage triggers root backend init.
cryptobackend/hkdf/hkdf.go Adds shared HKDF composition helper.
cryptobackend/hkdf/hkdf_linux.go Adds Linux HKDF backend.
cryptobackend/hkdf/hkdf_windows.go Adds Windows HKDF backend.
cryptobackend/hkdf/hkdf_darwin.go Adds Darwin HKDF backend.
cryptobackend/hkdf/nobackend.go Adds !systemcrypto HKDF stub.
cryptobackend/hkdf/init.go Ensures HKDF subpackage triggers root backend init.
cryptobackend/pbkdf2/pbkdf2_linux.go Adds Linux PBKDF2 backend.
cryptobackend/pbkdf2/pbkdf2_windows.go Adds Windows PBKDF2 backend.
cryptobackend/pbkdf2/pbkdf2_darwin.go Adds Darwin PBKDF2 backend.
cryptobackend/pbkdf2/nobackend.go Adds !systemcrypto PBKDF2 stub.
cryptobackend/pbkdf2/init.go Ensures PBKDF2 subpackage triggers root backend init.
cryptobackend/md5/md5_linux.go Adds Linux MD5 backend.
cryptobackend/md5/md5_windows.go Adds Windows MD5 backend.
cryptobackend/md5/md5_darwin.go Adds Darwin MD5 backend.
cryptobackend/md5/nobackend.go Adds !systemcrypto MD5 stub.
cryptobackend/md5/init.go Ensures MD5 subpackage triggers root backend init.
cryptobackend/sha1/sha1_linux.go Adds Linux SHA-1 backend.
cryptobackend/sha1/sha1_windows.go Adds Windows SHA-1 backend.
cryptobackend/sha1/sha1_darwin.go Adds Darwin SHA-1 backend.
cryptobackend/sha1/nobackend.go Adds !systemcrypto SHA-1 stub.
cryptobackend/sha1/init.go Ensures SHA-1 subpackage triggers root backend init.
cryptobackend/sha256/sha256_linux.go Adds Linux SHA-224/SHA-256 backend.
cryptobackend/sha256/sha256_windows.go Adds Windows SHA-256 backend (with SHA-224 unsupported).
cryptobackend/sha256/sha256_darwin.go Adds Darwin SHA-256 backend (with SHA-224 unsupported).
cryptobackend/sha256/nobackend.go Adds !systemcrypto SHA-256/SHA-224 stub.
cryptobackend/sha256/init.go Ensures SHA-256 subpackage triggers root backend init.
cryptobackend/sha512/sha512_linux.go Adds Linux SHA-384/SHA-512 and SHA-512/224,/256 backend.
cryptobackend/sha512/sha512_windows.go Adds Windows SHA-384/SHA-512 backend (with /224,/256 unsupported).
cryptobackend/sha512/sha512_darwin.go Adds Darwin SHA-384/SHA-512 backend (with /224,/256 unsupported).
cryptobackend/sha512/nobackend.go Adds !systemcrypto SHA-512 family stub.
cryptobackend/sha512/init.go Ensures SHA-512 subpackage triggers root backend init.
cryptobackend/sha3/sha3_linux.go Adds Linux SHA-3/SHAKE/CSHAKE backend.
cryptobackend/sha3/sha3_windows.go Adds Windows SHA-3/SHAKE backend (with SHA3-224 unsupported).
cryptobackend/sha3/sha3_darwin.go Adds Darwin SHA-3 backend with partial SHAKE support.
cryptobackend/sha3/nobackend.go Adds !systemcrypto SHA-3/SHAKE stub types and functions.
cryptobackend/sha3/init.go Ensures SHA-3 subpackage triggers root backend init.
cryptobackend/ecdh/ecdh_linux.go Adds Linux ECDH backend.
cryptobackend/ecdh/ecdh_windows.go Adds Windows ECDH backend.
cryptobackend/ecdh/ecdh_darwin.go Adds Darwin ECDH backend.
cryptobackend/ecdh/nobackend.go Adds !systemcrypto ECDH stub.
cryptobackend/ecdh/init.go Ensures ECDH subpackage triggers root backend init.
cryptobackend/ecdsa/ecdsa_linux.go Adds Linux ECDSA backend.
cryptobackend/ecdsa/ecdsa_windows.go Adds Windows ECDSA backend (with stdlib signature marshal/unmarshal glue).
cryptobackend/ecdsa/ecdsa_darwin.go Adds Darwin ECDSA backend.
cryptobackend/ecdsa/nobackend.go Adds !systemcrypto ECDSA stub.
cryptobackend/ecdsa/init.go Ensures ECDSA subpackage triggers root backend init.
cryptobackend/rsa/rsa_linux.go Adds Linux RSA backend with FIPS-dependent key-size constraints.
cryptobackend/rsa/rsa_windows.go Adds Windows RSA backend.
cryptobackend/rsa/rsa_darwin.go Adds Darwin RSA backend with stdlib key encode/decode glue.
cryptobackend/rsa/nobackend.go Adds !systemcrypto RSA stub.
cryptobackend/rsa/init.go Ensures RSA subpackage triggers root backend init.
cryptobackend/rsa/rsa_test.go Adds RSA support tests for the new RSA subpackage API.
cryptobackend/dsa/dsa_linux.go Adds Linux DSA backend.
cryptobackend/dsa/dsa_windows.go Adds Windows DSA backend.
cryptobackend/dsa/dsa_darwin.go Adds Darwin DSA stubs (unsupported).
cryptobackend/dsa/nobackend.go Adds !systemcrypto DSA stub.
cryptobackend/dsa/init.go Ensures DSA subpackage triggers root backend init.
cryptobackend/ed25519/ed25519_linux.go Adds Linux Ed25519 backend.
cryptobackend/ed25519/ed25519_windows.go Adds Windows Ed25519 stubs (unsupported).
cryptobackend/ed25519/ed25519_darwin.go Adds Darwin Ed25519 backend.
cryptobackend/ed25519/nobackend.go Adds !systemcrypto Ed25519 stub.
cryptobackend/ed25519/init.go Ensures Ed25519 subpackage triggers root backend init.
cryptobackend/mlkem/mlkem_linux.go Adds Linux ML-KEM backend.
cryptobackend/mlkem/mlkem_windows.go Adds Windows ML-KEM backend.
cryptobackend/mlkem/mlkem_darwin.go Adds Darwin ML-KEM backend.
cryptobackend/mlkem/nobackend.go Adds !systemcrypto ML-KEM stub.
cryptobackend/mlkem/init.go Ensures ML-KEM subpackage triggers root backend init.
cryptobackend/mldsa/mldsa_linux.go Adds Linux ML-DSA backend.
cryptobackend/mldsa/mldsa_windows.go Adds Windows ML-DSA backend.
cryptobackend/mldsa/mldsa_darwin.go Adds Darwin ML-DSA backend with partial parameter support.
cryptobackend/mldsa/nobackend.go Adds !systemcrypto ML-DSA stub.
cryptobackend/mldsa/init.go Ensures ML-DSA subpackage triggers root backend init.
cryptobackend/tls12/tls12_linux.go Adds Linux TLS 1.2 PRF backend.
cryptobackend/tls12/tls12_windows.go Adds Windows TLS 1.2 PRF backend.
cryptobackend/tls12/tls12_darwin.go Adds Darwin TLS 1.2 PRF stubs (unsupported).
cryptobackend/tls12/nobackend.go Adds !systemcrypto TLS 1.2 PRF stub.
cryptobackend/tls12/init.go Ensures TLS 1.2 subpackage triggers root backend init.
cryptobackend/tls13/tls13_linux.go Adds Linux TLS 1.3 KDF backend.
cryptobackend/tls13/tls13_windows.go Adds Windows TLS 1.3 KDF stubs (unsupported).
cryptobackend/tls13/tls13_darwin.go Adds Darwin TLS 1.3 KDF stubs (unsupported).
cryptobackend/tls13/nobackend.go Adds !systemcrypto TLS 1.3 KDF stub.
cryptobackend/tls13/init.go Ensures TLS 1.3 subpackage triggers root backend init.
.github/workflows/test.yml Reworks CI to run go test for cryptobackend and eng/_util.
.github/workflows/patch-apply.yml Adds dedicated workflow to verify patches apply cleanly.

Copilot's findings

  • Files reviewed: 132/134 changed files
  • Comments generated: 9

Comment thread cryptobackend/chacha20poly1305/chacha20poly1305_linux.go
Comment thread cryptobackend/chacha20poly1305/chacha20poly1305_darwin.go
Comment thread cryptobackend/sha256/sha256_windows.go Outdated
Comment thread cryptobackend/sha512/sha512_windows.go Outdated
Comment thread cryptobackend/sha512/sha512_windows.go Outdated
Comment thread cryptobackend/sha3/sha3_windows.go Outdated
Comment thread cryptobackend/sha3/sha3_windows.go Outdated
Comment thread .github/workflows/test.yml
Comment thread .github/workflows/test.yml
@qmuntal qmuntal force-pushed the dev/qmuntal/cryptobackend-packages branch from 7a8c7b4 to e087292 Compare June 12, 2026 08:56
@qmuntal qmuntal force-pushed the dev/qmuntal/cryptobackend-packages branch from e087292 to 1cfaeb3 Compare June 12, 2026 09:02
@qmuntal qmuntal marked this pull request as ready for review June 12, 2026 11:26
@qmuntal qmuntal enabled auto-merge June 12, 2026 12:03
@qmuntal qmuntal merged commit 4557c5b into microsoft/main Jun 12, 2026
56 checks passed
@qmuntal qmuntal deleted the dev/qmuntal/cryptobackend-packages branch June 12, 2026 12:47
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