From 8f9dca1063a7513299cd079d5fca1a8efc702d49 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 19 Dec 2025 14:58:52 +0100 Subject: [PATCH 1/2] support more RSA algorithms on Windows and update support matrix --- eng/_util/cmd/updatecryptodocs/docs.go | 25 +- eng/doc/CrossPlatformCryptography.md | 43 +- .../0001-Vendor-external-dependencies.patch | 555 ++++++++++++++---- 3 files changed, 483 insertions(+), 140 deletions(-) diff --git a/eng/_util/cmd/updatecryptodocs/docs.go b/eng/_util/cmd/updatecryptodocs/docs.go index 154e1862735..6df15ced431 100644 --- a/eng/_util/cmd/updatecryptodocs/docs.go +++ b/eng/_util/cmd/updatecryptodocs/docs.go @@ -300,10 +300,11 @@ var doc = Document{ }, { Name: "OAEP (SHA-3)", + Notes: []string{ + "Supports only hash algorithms that are [supported as standalone hash functions](#hash-and-message-authentication-algorithms).", + }, Platforms: Platforms{ - Windows: PlatformStatus{Supported: NotSupported}, - Linux: PlatformStatus{Supported: NotSupported}, - MacOS: PlatformStatus{Supported: NotSupported}, + MacOS: PlatformStatus{Supported: NotSupported}, }, }, { @@ -352,9 +353,11 @@ var doc = Document{ }, { Name: "PSS (SHA-3)", + Notes: []string{ + "Supports only hash algorithms that are [supported as standalone hash functions](#hash-and-message-authentication-algorithms).", + }, Platforms: Platforms{ - Windows: PlatformStatus{Supported: NotSupported}, - Linux: PlatformStatus{Supported: NotSupported}, + Windows: PlatformStatus{MinGoVersion: "1.26"}, MacOS: PlatformStatus{Supported: NotSupported}, }, }, @@ -367,14 +370,6 @@ var doc = Document{ MacOS: PlatformStatus{Supported: NotSupported}, }, }, - { - Name: "PKCS1v15 Signature (MD4)", - Platforms: Platforms{ - Windows: PlatformStatus{Supported: NotSupported}, - Linux: PlatformStatus{MinGoVersion: "1.24"}, - MacOS: PlatformStatus{Supported: NotSupported}, - }, - }, { Name: "PKCS1v15 Signature (MD5)", Platforms: Platforms{ @@ -399,8 +394,8 @@ var doc = Document{ { Name: "PKCS1v15 Signature (SHA-3)", Platforms: Platforms{ - Windows: PlatformStatus{Supported: NotSupported}, - Linux: PlatformStatus{Supported: NotSupported}, + Windows: PlatformStatus{MinVersion: "11 (24H2)", MinGoVersion: "1.26"}, + Linux: PlatformStatus{MinVersion: "1.1.1"}, MacOS: PlatformStatus{Supported: NotSupported}, }, }, diff --git a/eng/doc/CrossPlatformCryptography.md b/eng/doc/CrossPlatformCryptography.md index 89defe307a1..ccae5df8626 100644 --- a/eng/doc/CrossPlatformCryptography.md +++ b/eng/doc/CrossPlatformCryptography.md @@ -156,24 +156,23 @@ Please refer to the documentation of the underlying cryptographic library for th Operations that require random numbers (rand io.Reader) only support [rand.Reader](https://pkg.go.dev/crypto/rand#Reader). -| Padding Mode | Windows | Linux | macOS | -| -------------------------------------- | -------------- | -------------- | -------------- | -| OAEP (MD5) | ✔️ | ✔️ | ✔️1 | -| OAEP (SHA-1) | ✔️ | ✔️ | ✔️1 | -| OAEP (SHA-2)2 | ✔️ | ✔️ | ✔️1 | -| OAEP (SHA-3) | ❌️ | ❌️ | ❌️ | -| PSS (MD5) | ✔️3 | ✔️ | ❌️ | -| PSS (SHA-1) | ✔️3 | ✔️ | ✔️4 | -| PSS (SHA-2)2 | ✔️3 | ✔️ | ✔️4 | -| PSS (SHA-3) | ❌️ | ❌️ | ❌️ | -| PKCS1v15 Signature (Unhashed) | ✔️ | ✔️ | ✔️ | -| PKCS1v15 Signature (RIPMED160) | ❌️ | ✔️5 | ❌️ | -| PKCS1v15 Signature (MD4) | ❌️ | ✔️5 | ❌️ | -| PKCS1v15 Signature (MD5) | ✔️ | ✔️ | ❌️ | -| PKCS1v15 Signature (MD5-SHA1) | ✔️5 | ✔️5 | ❌️ | -| PKCS1v15 Signature (SHA-1) | ✔️ | ✔️ | ✔️ | -| PKCS1v15 Signature (SHA-2)2 | ✔️ | ✔️ | ✔️ | -| PKCS1v15 Signature (SHA-3) | ❌️ | ❌️ | ❌️ | +| Padding Mode | Windows | Linux | macOS | +| -------------------------------------- | ---------------- | -------------- | -------------- | +| OAEP (MD5) | ✔️ | ✔️ | ✔️1 | +| OAEP (SHA-1) | ✔️ | ✔️ | ✔️1 | +| OAEP (SHA-2)2 | ✔️ | ✔️ | ✔️1 | +| OAEP (SHA-3)2 | ✔️ | ✔️ | ❌️ | +| PSS (MD5) | ✔️3 | ✔️ | ❌️ | +| PSS (SHA-1) | ✔️3 | ✔️ | ✔️4 | +| PSS (SHA-2)2 | ✔️3 | ✔️ | ✔️4 | +| PSS (SHA-3)2 | ✔️5 | ✔️ | ❌️ | +| PKCS1v15 Signature (Unhashed) | ✔️ | ✔️ | ✔️ | +| PKCS1v15 Signature (RIPMED160) | ❌️ | ✔️6 | ❌️ | +| PKCS1v15 Signature (MD5) | ✔️ | ✔️ | ❌️ | +| PKCS1v15 Signature (MD5-SHA1) | ✔️6 | ✔️6 | ❌️ | +| PKCS1v15 Signature (SHA-1) | ✔️ | ✔️ | ✔️ | +| PKCS1v15 Signature (SHA-2)2 | ✔️ | ✔️ | ✔️ | +| PKCS1v15 Signature (SHA-3) | ✔️5,7 | ✔️8 | ❌️ | 1macOS doesn't support passing a custom label to OAEP functions. @@ -183,7 +182,13 @@ Operations that require random numbers (rand io.Reader) only support [rand.Reade 4Custom salt lengths are not supported. PSS always uses the [`rsa.PSSSaltLengthEqualsHash`](https://pkg.go.dev/crypto/rsa#pkg-constants). -5Available starting in the Microsoft build of Go 1.24. +5Available starting in the Microsoft build of Go 1.26. + +6Available starting in the Microsoft build of Go 1.24. + +7Requires Windows 11 (24H2) or later. + +8Requires OpenSSL 1.1.1 or later. ### ECDSA diff --git a/patches/0001-Vendor-external-dependencies.patch b/patches/0001-Vendor-external-dependencies.patch index a5831ef27ef..b1548338728 100644 --- a/patches/0001-Vendor-external-dependencies.patch +++ b/patches/0001-Vendor-external-dependencies.patch @@ -54,7 +54,7 @@ Use a 'go' that was recently built by the current branch to ensure stable result .../github.com/golang-fips/openssl/v2/ecdh.go | 343 +++ .../golang-fips/openssl/v2/ecdsa.go | 222 ++ .../golang-fips/openssl/v2/ed25519.go | 210 ++ - .../github.com/golang-fips/openssl/v2/evp.go | 600 +++++ + .../github.com/golang-fips/openssl/v2/evp.go | 620 +++++ .../github.com/golang-fips/openssl/v2/hash.go | 502 ++++ .../golang-fips/openssl/v2/hashclone.go | 14 + .../golang-fips/openssl/v2/hashclone_go125.go | 9 + @@ -125,7 +125,7 @@ Use a 'go' that was recently built by the current branch to ensure stable result .../openssl/v2/providersymcrypt.go | 338 +++ .../github.com/golang-fips/openssl/v2/rand.go | 21 + .../github.com/golang-fips/openssl/v2/rc4.go | 68 + - .../github.com/golang-fips/openssl/v2/rsa.go | 401 +++ + .../github.com/golang-fips/openssl/v2/rsa.go | 716 +++++ .../golang-fips/openssl/v2/tls1prf.go | 158 ++ .../github.com/golang-fips/openssl/v2/zaes.go | 86 + .../microsoft/go-crypto-darwin/LICENSE | 21 + @@ -236,7 +236,7 @@ Use a 'go' that was recently built by the current branch to ensure stable result .../go-crypto-winnative/cng/pbkdf2.go | 70 + .../microsoft/go-crypto-winnative/cng/rand.go | 28 + .../microsoft/go-crypto-winnative/cng/rc4.go | 65 + - .../microsoft/go-crypto-winnative/cng/rsa.go | 396 +++ + .../microsoft/go-crypto-winnative/cng/rsa.go | 404 +++ .../microsoft/go-crypto-winnative/cng/sha3.go | 203 ++ .../go-crypto-winnative/cng/tls1prf.go | 89 + .../internal/bcrypt/bcrypt_windows.go | 414 +++ @@ -245,7 +245,7 @@ Use a 'go' that was recently built by the current branch to ensure stable result .../internal/subtle/aliasing.go | 32 + .../internal/sysdll/sys_windows.go | 55 + src/vendor/modules.txt | 23 + - 237 files changed, 31035 insertions(+), 7 deletions(-) + 237 files changed, 31378 insertions(+), 7 deletions(-) create mode 100644 src/cmd/internal/telemetry/counter/deps_ignore.go create mode 100644 src/cmd/vendor/github.com/microsoft/go-infra/telemetry/LICENSE create mode 100644 src/cmd/vendor/github.com/microsoft/go-infra/telemetry/README.md @@ -2136,7 +2136,7 @@ index 00000000000000..ae4055d2d71303 +// that are used by the backend package. This allows to track +// their versions in a single patch file. diff --git a/src/go.mod b/src/go.mod -index efc07451b53448..6ef9b5fbcb1146 100644 +index efc07451b53448..ab7ea4a4b915d9 100644 --- a/src/go.mod +++ b/src/go.mod @@ -11,3 +11,9 @@ require ( @@ -2145,21 +2145,21 @@ index efc07451b53448..6ef9b5fbcb1146 100644 ) + +require ( -+ github.com/golang-fips/openssl/v2 v2.0.4-0.20251218145113-52cddb05a262 ++ github.com/golang-fips/openssl/v2 v2.0.4-0.20251219133548-db44f2109b85 + github.com/microsoft/go-crypto-darwin v0.0.3-0.20251218120905-3dc2f5f6b182 -+ github.com/microsoft/go-crypto-winnative v0.0.0-20251218121426-ba94af8d2bb8 ++ github.com/microsoft/go-crypto-winnative v0.0.0-20251219091053-f9796ee5d078 +) diff --git a/src/go.sum b/src/go.sum -index b6b841b44d8e38..ed947ea7d43b5f 100644 +index b6b841b44d8e38..104fcfc902e896 100644 --- a/src/go.sum +++ b/src/go.sum @@ -1,3 +1,9 @@ -+github.com/golang-fips/openssl/v2 v2.0.4-0.20251218145113-52cddb05a262 h1:fNRFo5bregvphPwnGSPrC0IyGZf6agmeFByo6c88s7E= -+github.com/golang-fips/openssl/v2 v2.0.4-0.20251218145113-52cddb05a262/go.mod h1:EtVnMfLGkB4pihGOH+tXEV0WlXxewWdT1n3GLJEHvpw= ++github.com/golang-fips/openssl/v2 v2.0.4-0.20251219133548-db44f2109b85 h1:/IDnd+d+KhBvHD60Jpd1fuTW5S2FbdCfhJVL+w+ecZM= ++github.com/golang-fips/openssl/v2 v2.0.4-0.20251219133548-db44f2109b85/go.mod h1:EtVnMfLGkB4pihGOH+tXEV0WlXxewWdT1n3GLJEHvpw= +github.com/microsoft/go-crypto-darwin v0.0.3-0.20251218120905-3dc2f5f6b182 h1:yeHGQpq1zuXcbMG18BPOTENjfYEgqB7ZEUYC/0eM2Lw= +github.com/microsoft/go-crypto-darwin v0.0.3-0.20251218120905-3dc2f5f6b182/go.mod h1:MTii5PQwRlfUjYpGoF8CPLGwXSHTbLHGRN9FVNML5N0= -+github.com/microsoft/go-crypto-winnative v0.0.0-20251218121426-ba94af8d2bb8 h1:lG7y5IdfKZcZI1PWkWTN1W0vpOfFmFHQCjDzx4atIWA= -+github.com/microsoft/go-crypto-winnative v0.0.0-20251218121426-ba94af8d2bb8/go.mod h1:gD686525Li/blRSYwSzFJ6/LJQVFJp7Y0MKp+dmqFbc= ++github.com/microsoft/go-crypto-winnative v0.0.0-20251219091053-f9796ee5d078 h1:9M+LVr3rtPCD7xgX/xGFWEsyWdvTA/djZUHh2AyXTB4= ++github.com/microsoft/go-crypto-winnative v0.0.0-20251219091053-f9796ee5d078/go.mod h1:gD686525Li/blRSYwSzFJ6/LJQVFJp7Y0MKp+dmqFbc= golang.org/x/crypto v0.46.1-0.20251210140736-7dacc380ba00 h1:JgcPM1rzpSOZS8y69FQvnY0xN0ciHlpQqwTXJcuZIA4= golang.org/x/crypto v0.46.1-0.20251210140736-7dacc380ba00/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= golang.org/x/net v0.47.1-0.20251128220604-7c360367ab7e h1:PAAT9cIDvIAIRQVz2txQvUFRt3jOlhiO84ihd8XMGlg= @@ -5133,10 +5133,10 @@ index 00000000000000..6413f3e42b4adb +} diff --git a/src/vendor/github.com/golang-fips/openssl/v2/evp.go b/src/vendor/github.com/golang-fips/openssl/v2/evp.go new file mode 100644 -index 00000000000000..1f70c904dc237f +index 00000000000000..56fae101c4feb4 --- /dev/null +++ b/src/vendor/github.com/golang-fips/openssl/v2/evp.go -@@ -0,0 +1,600 @@ +@@ -0,0 +1,620 @@ +//go:build !cmd_go_bootstrap && (cgo || goexperiment.ms_nocgo_opensslcrypto) + +package openssl @@ -5187,6 +5187,14 @@ index 00000000000000..1f70c904dc237f + return nil +} + ++// hashToCryptoHash converts a hash.Hash implementation from this package to a crypto.Hash. ++func hashToCryptoHash(h hash.Hash) crypto.Hash { ++ if h, ok := h.(*Hash); ok { ++ return h.alg.ch ++ } ++ return 0 ++} ++ +// hashFuncToMD converts a hash.Hash function to a GOossl.EVP_MD_PTR. +// See [hashFuncHash] for details on error handling. +func hashFuncToMD(fn func() hash.Hash) (ossl.EVP_MD_PTR, error) { @@ -5433,92 +5441,104 @@ index 00000000000000..1f70c904dc237f + } + // Each padding type has its own requirements in terms of when to apply the padding, + // so it can't be just set at this point. -+ setPadding := func() error { -+ _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, padding, nil) -+ return err -+ } + switch padding { + case ossl.RSA_PKCS1_OAEP_PADDING: -+ md := hashToMD(h) -+ if md == nil { -+ return nil, errors.New("crypto/rsa: unsupported hash function") -+ } -+ var mgfMD ossl.EVP_MD_PTR -+ if mgfHash != nil { -+ // mgfHash is optional, but if it is set it must match a supported hash function. -+ mgfMD = hashToMD(mgfHash) -+ if mgfMD == nil { -+ return nil, errors.New("crypto/rsa: unsupported hash function") -+ } -+ } -+ // setPadding must happen before setting EVP_PKEY_CTRL_RSA_OAEP_MD. -+ if err := setPadding(); err != nil { -+ return nil, err -+ } -+ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_OAEP_MD, 0, unsafe.Pointer(md)); err != nil { -+ return nil, err -+ } -+ if mgfHash != nil { -+ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_MGF1_MD, 0, unsafe.Pointer(mgfMD)); err != nil { -+ return nil, err -+ } -+ } -+ // ctx takes ownership of label, so malloc a copy for OpenSSL to free. -+ // OpenSSL does not take ownership of the label if the length is zero, -+ // so better avoid the allocation. -+ var clabel *byte -+ if len(label) > 0 { -+ clabel = (*byte)(cryptoMalloc(len(label))) -+ copy((*[1 << 30]byte)(unsafe.Pointer(clabel))[:len(label)], label) -+ var err error -+ if major() == 3 { -+ _, err = ossl.EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, unsafe.Pointer(clabel), int32(len(label))) -+ } else { -+ _, err = ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_OAEP_LABEL, int32(len(label)), unsafe.Pointer(clabel)) -+ } -+ if err != nil { -+ cryptoFree(unsafe.Pointer(clabel)) -+ return nil, err -+ } -+ } ++ err = setOAEPPadding(ctx, h, mgfHash, label) + case ossl.RSA_PKCS1_PSS_PADDING: -+ alg := loadHash(ch, false) -+ if alg == nil { -+ return nil, errors.New("crypto/rsa: unsupported hash function") -+ } -+ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_MD, 0, unsafe.Pointer(alg.md)); err != nil { -+ return nil, err ++ err = setPSSPadding(ctx, saltLen, ch) ++ case ossl.RSA_PKCS1_PADDING: ++ err = setPKCS1Padding(ctx, ch) ++ default: ++ _, err = ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, padding, nil) ++ } ++ if err != nil { ++ return nil, err ++ } ++ return ctx, nil ++} ++ ++func setPSSPadding(ctx ossl.EVP_PKEY_CTX_PTR, saltLen int32, ch crypto.Hash) error { ++ alg := loadHash(ch, false) ++ if alg == nil { ++ return errors.New("crypto/rsa: unsupported hash function") ++ } ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_MD, 0, unsafe.Pointer(alg.md)); err != nil { ++ return err ++ } ++ // setPadding must happen after setting EVP_PKEY_CTRL_MD. ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, ossl.RSA_PKCS1_PSS_PADDING, nil); err != nil { ++ return err ++ } ++ if saltLen != 0 { ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PSS_SALTLEN, saltLen, nil); err != nil { ++ return err + } -+ // setPadding must happen after setting EVP_PKEY_CTRL_MD. -+ if err := setPadding(); err != nil { -+ return nil, err ++ } ++ return nil ++} ++ ++func setPKCS1Padding(ctx ossl.EVP_PKEY_CTX_PTR, ch crypto.Hash) error { ++ if ch == 0 { ++ // We support unhashed messages. ++ return nil ++ } ++ alg := loadHash(ch, false) ++ if alg == nil { ++ return errors.New("crypto/rsa: unsupported hash function") ++ } ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, -1, -1, ossl.EVP_PKEY_CTRL_MD, 0, unsafe.Pointer(alg.md)); err != nil { ++ return err ++ } ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, ossl.RSA_PKCS1_PADDING, nil); err != nil { ++ return err ++ } ++ return nil ++} ++ ++func setOAEPPadding(ctx ossl.EVP_PKEY_CTX_PTR, h, mgfHash hash.Hash, label []byte) error { ++ md := hashToMD(h) ++ if md == nil { ++ return errors.New("crypto/rsa: unsupported hash function") ++ } ++ var mgfMD ossl.EVP_MD_PTR ++ if mgfHash != nil { ++ // mgfHash is optional, but if it is set it must match a supported hash function. ++ mgfMD = hashToMD(mgfHash) ++ if mgfMD == nil { ++ return errors.New("crypto/rsa: unsupported hash function") + } -+ if saltLen != 0 { -+ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PSS_SALTLEN, saltLen, nil); err != nil { -+ return nil, err -+ } ++ } ++ // setPadding must happen before setting EVP_PKEY_CTRL_RSA_OAEP_MD. ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, ossl.RSA_PKCS1_OAEP_PADDING, nil); err != nil { ++ return err ++ } ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_OAEP_MD, 0, unsafe.Pointer(md)); err != nil { ++ return err ++ } ++ if mgfHash != nil { ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_MGF1_MD, 0, unsafe.Pointer(mgfMD)); err != nil { ++ return err + } -+ -+ case ossl.RSA_PKCS1_PADDING: -+ if ch != 0 { -+ // We support unhashed messages. -+ alg := loadHash(ch, false) -+ if alg == nil { -+ return nil, errors.New("crypto/rsa: unsupported hash function") -+ } -+ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, -1, -1, ossl.EVP_PKEY_CTRL_MD, 0, unsafe.Pointer(alg.md)); err != nil { -+ return nil, err -+ } -+ if err := setPadding(); err != nil { -+ return nil, err -+ } ++ } ++ // ctx takes ownership of label, so malloc a copy for OpenSSL to free. ++ // OpenSSL does not take ownership of the label if the length is zero, ++ // so better avoid the allocation. ++ var clabel *byte ++ if len(label) > 0 { ++ clabel = (*byte)(cryptoMalloc(len(label))) ++ copy((*[1 << 30]byte)(unsafe.Pointer(clabel))[:len(label)], label) ++ var err error ++ if major() == 3 { ++ _, err = ossl.EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, unsafe.Pointer(clabel), int32(len(label))) ++ } else { ++ _, err = ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_OAEP_LABEL, int32(len(label)), unsafe.Pointer(clabel)) + } -+ default: -+ if err := setPadding(); err != nil { -+ return nil, err ++ if err != nil { ++ cryptoFree(unsafe.Pointer(clabel)) ++ return err + } + } -+ return ctx, nil ++ return nil +} + +func cryptEVP(withKey withKeyFunc, padding int32, @@ -18588,10 +18608,10 @@ index 00000000000000..e933228919296d +} diff --git a/src/vendor/github.com/golang-fips/openssl/v2/rsa.go b/src/vendor/github.com/golang-fips/openssl/v2/rsa.go new file mode 100644 -index 00000000000000..f1cddf8b5103db +index 00000000000000..e989da8db9cfa6 --- /dev/null +++ b/src/vendor/github.com/golang-fips/openssl/v2/rsa.go -@@ -0,0 +1,401 @@ +@@ -0,0 +1,716 @@ +//go:build !cmd_go_bootstrap && (cgo || goexperiment.ms_nocgo_opensslcrypto) + +package openssl @@ -18959,16 +18979,143 @@ index 00000000000000..f1cddf8b5103db + return newEvpFromParams(ossl.EVP_PKEY_RSA, int32(selection), params) +} + -+// SupportsRSAPKCS1Encryption returns true if the RSA PKCS1 v1.5 padding is supported for encryption and decryption. -+var SupportsRSAPKCS1Encryption = sync.OnceValue(func() bool { -+ // Generate a temporary key to check for support. -+ // 2048 bits is a safe default that should be supported by all providers. -+ pkey, err := generateEVPPKey(ossl.EVP_PKEY_RSA, 2048, "") ++// SupportsRSAPKCS1v15Encryption returns true if the RSA PKCS1 v1.5 padding is supported for encryption and decryption. ++var SupportsRSAPKCS1v15Encryption = sync.OnceValue(func() bool { ++ pkey := testRSAPrivateKey() ++ ctx, err := ossl.EVP_PKEY_CTX_new(pkey, nil) + if err != nil { + return false + } -+ defer ossl.EVP_PKEY_free(pkey) ++ defer ossl.EVP_PKEY_CTX_free(ctx) ++ ++ if _, err := ossl.EVP_PKEY_encrypt_init(ctx); err != nil { ++ return false ++ } + ++ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, ossl.RSA_PKCS1_PADDING, nil); err != nil { ++ return false ++ } ++ ++ // In FIPS mode, setting the padding might succeed, but the actual encryption will fail. ++ // So we need to try to encrypt something to be sure. ++ in := []byte("test") ++ var outLen int ++ if _, err := ossl.EVP_PKEY_encrypt(ctx, nil, &outLen, &in[0], len(in)); err != nil { ++ return false ++ } ++ return true ++}) ++ ++var rsaPKCS1SignatureSupport sync.Map ++ ++// SupportsRSAPKCS1v15Signature returns true if the RSA PKCS1 v1.5 padding is supported for signatures with the given hash. ++func SupportsRSAPKCS1v15Signature(ch crypto.Hash) (supported bool) { ++ v, ok := rsaPKCS1SignatureSupport.Load(ch) ++ if ok { ++ return v.(bool) ++ } ++ defer func() { ++ rsaPKCS1SignatureSupport.Store(ch, supported) ++ }() ++ ++ pkey := testRSAPrivateKey() ++ ctx, err := ossl.EVP_PKEY_CTX_new(pkey, nil) ++ if err != nil { ++ return false ++ } ++ defer ossl.EVP_PKEY_CTX_free(ctx) ++ if _, err := ossl.EVP_PKEY_sign_init(ctx); err != nil { ++ return false ++ } ++ if setPKCS1Padding(ctx, ch) != nil { ++ return false ++ } ++ // In FIPS mode, setting the padding might succeed, but the actual signature will fail. ++ // So we need to try to sign something to be sure. ++ size := 1 ++ if ch != 0 { ++ size = ch.Size() ++ } ++ in := make([]byte, size, maxHashSize) ++ var outLen int ++ if _, err := ossl.EVP_PKEY_sign(ctx, nil, &outLen, &in[0], len(in)); err != nil { ++ return false ++ } ++ return true ++} ++ ++var rsaPSSSupport sync.Map ++ ++// SupportsRSAPSS returns true if the RSA PSS padding is supported for signatures with the given hash. ++func SupportsRSAPSS(ch crypto.Hash) (supported bool) { ++ v, ok := rsaPSSSupport.Load(ch) ++ if ok { ++ return v.(bool) ++ } ++ defer func() { ++ rsaPSSSupport.Store(ch, supported) ++ }() ++ ++ if !SupportsHash(ch) { ++ // Short-circuit if the hash itself is not supported. ++ return false ++ } ++ ++ pkey := testRSAPrivateKey() ++ ctx, err := ossl.EVP_PKEY_CTX_new(pkey, nil) ++ if err != nil { ++ return false ++ } ++ defer ossl.EVP_PKEY_CTX_free(ctx) ++ if _, err := ossl.EVP_PKEY_sign_init(ctx); err != nil { ++ return false ++ } ++ if setPSSPadding(ctx, 0, ch) != nil { ++ return false ++ } ++ // In FIPS mode, setting the padding might succeed, but the actual signature will fail. ++ // So we need to try to sign something to be sure. ++ in := make([]byte, ch.Size(), maxHashSize) ++ var outLen int ++ if _, err := ossl.EVP_PKEY_sign(ctx, nil, &outLen, &in[0], len(in)); err != nil { ++ return false ++ } ++ return true ++} ++ ++var rsaOAEPSupport sync.Map ++ ++type rsaOAEPSupportEntry struct { ++ ch crypto.Hash ++ mgfHash crypto.Hash ++} ++ ++// SupportsRSAOAEP returns true if the RSA OAEP padding is supported for encryption/decryption ++// with the given hash and MGF hash. ++func SupportsRSAOAEP(h, mgfHash hash.Hash) (supported bool) { ++ ch := hashToCryptoHash(h) ++ if ch == 0 { ++ return false ++ } ++ mgfCh := hashToCryptoHash(mgfHash) ++ if mgfCh == 0 { ++ return false ++ } ++ entry := rsaOAEPSupportEntry{ch, mgfCh} ++ v, ok := rsaOAEPSupport.Load(entry) ++ if ok { ++ return v.(bool) ++ } ++ defer func() { ++ rsaOAEPSupport.Store(entry, supported) ++ }() ++ ++ if !SupportsHash(ch) { ++ // Short-circuit if the hash itself is not supported. ++ return false ++ } ++ ++ pkey := testRSAPrivateKey() + ctx, err := ossl.EVP_PKEY_CTX_new(pkey, nil) + if err != nil { + return false @@ -18979,7 +19126,7 @@ index 00000000000000..f1cddf8b5103db + return false + } + -+ if _, err := ossl.EVP_PKEY_CTX_ctrl(ctx, ossl.EVP_PKEY_RSA, -1, ossl.EVP_PKEY_CTRL_RSA_PADDING, ossl.RSA_PKCS1_PADDING, nil); err != nil { ++ if setOAEPPadding(ctx, h, mgfHash, nil) != nil { + return false + } + @@ -18990,8 +19137,196 @@ index 00000000000000..f1cddf8b5103db + if _, err := ossl.EVP_PKEY_encrypt(ctx, nil, &outLen, &in[0], len(in)); err != nil { + return false + } -+ + return true ++} ++ ++// testRSAPrivateKey returns a test RSA private key for use in capability probing functions. ++// ++// The key is constructed from hard-coded parameters to avoid ++// spurious failures due to key generation issues and to avoid the speed cost of ++// key generation. ++var testRSAPrivateKey = sync.OnceValue(func() ossl.EVP_PKEY_PTR { ++ // RSA-2048 key "testRSA2048": ++ // https://www.rfc-editor.org/rfc/rfc9500.html#section-2.1 ++ N := []byte{ ++ 0xB0, 0xF9, 0xE8, 0x19, 0x43, 0xA7, 0xAE, 0x98, ++ 0x92, 0xAA, 0xDE, 0x17, 0xCA, 0x7C, 0x40, 0xF8, ++ 0x74, 0x4F, 0xED, 0x2F, 0x81, 0x48, 0xE6, 0xC8, ++ 0xEA, 0xA2, 0x7B, 0x7D, 0x00, 0x15, 0x48, 0xFB, ++ 0x51, 0x92, 0xAB, 0x28, 0xB5, 0x6C, 0x50, 0x60, ++ 0xB1, 0x18, 0xCC, 0xD1, 0x31, 0xE5, 0x94, 0x87, ++ 0x4C, 0x6C, 0xA9, 0x89, 0xB5, 0x6C, 0x27, 0x29, ++ 0x6F, 0x09, 0xFB, 0x93, 0xA0, 0x34, 0xDF, 0x32, ++ 0xE9, 0x7C, 0x6F, 0xF0, 0x99, 0x8C, 0xFD, 0x8E, ++ 0x6F, 0x42, 0xDD, 0xA5, 0x8A, 0xCD, 0x1F, 0xA9, ++ 0x79, 0x86, 0xF1, 0x44, 0xF3, 0xD1, 0x54, 0xD6, ++ 0x76, 0x50, 0x17, 0x5E, 0x68, 0x54, 0xB3, 0xA9, ++ 0x52, 0x00, 0x3B, 0xC0, 0x68, 0x87, 0xB8, 0x45, ++ 0x5A, 0xC2, 0xB1, 0x9F, 0x7B, 0x2F, 0x76, 0x50, ++ 0x4E, 0xBC, 0x98, 0xEC, 0x94, 0x55, 0x71, 0xB0, ++ 0x78, 0x92, 0x15, 0x0D, 0xDC, 0x6A, 0x74, 0xCA, ++ 0x0F, 0xBC, 0xD3, 0x54, 0x97, 0xCE, 0x81, 0x53, ++ 0x4D, 0xAF, 0x94, 0x18, 0x84, 0x4B, 0x13, 0xAE, ++ 0xA3, 0x1F, 0x9D, 0x5A, 0x6B, 0x95, 0x57, 0xBB, ++ 0xDF, 0x61, 0x9E, 0xFD, 0x4E, 0x88, 0x7F, 0x2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0xB4, 0xC9, 0x39, 0x85, 0x5D, 0x42, 0x12, ++ 0x09, 0x6F, 0x70, 0x28, 0x0A, 0x4E, 0xAE, 0x7C, ++ 0x8A, 0x27, 0xD9, 0xC8, 0xD0, 0x77, 0x2E, 0x65} ++ dQ := []byte{ ++ 0x8C, 0xB6, 0x85, 0x7A, 0x7B, 0xD5, 0x46, 0x5F, ++ 0x80, 0x04, 0x7E, 0x9B, 0x87, 0xBC, 0x00, 0x27, ++ 0x31, 0x84, 0x05, 0x81, 0xE0, 0x62, 0x61, 0x39, ++ 0x01, 0x2A, 0x5B, 0x50, 0x5F, 0x0A, 0x33, 0x84, ++ 0x7E, 0xB7, 0xB8, 0xC3, 0x28, 0x99, 0x49, 0xAD, ++ 0x48, 0x6F, 0x3B, 0x4B, 0x3D, 0x53, 0x9A, 0xB5, ++ 0xDA, 0x76, 0x30, 0x21, 0xCB, 0xC8, 0x2C, 0x1B, ++ 0xA2, 0x34, 0xA5, 0x66, 0x8D, 0xED, 0x08, 0x01, ++ 0xB8, 0x59, 0xF3, 0x43, 0xF1, 0xCE, 0x93, 0x04, ++ 0xE6, 0xFA, 0xA2, 0xB0, 0x02, 0xCA, 0xD9, 0xB7, ++ 0x8C, 0xDE, 0x5C, 0xDC, 0x2C, 0x1F, 0xB4, 0x17, ++ 0x1C, 0x42, 0x42, 0x16, 0x70, 0xA6, 0xAB, 0x0F, ++ 0x50, 0xCC, 0x4A, 0x19, 0x4E, 0xB3, 0x6D, 0x1C, ++ 0x91, 0xE9, 0x35, 0xBA, 0x01, 0xB9, 0x59, 0xD8, ++ 0x72, 0x8B, 0x9E, 0x64, 0x42, 0x6B, 0x3F, 0xC3, ++ 0xA7, 0x50, 0x6D, 0xEB, 0x52, 0x39, 0xA8, 0xA7} ++ ++ // Convert []byte to BigInt using BN_bin2bn and bnToBig ++ bytesToBigInt := func(b []byte) BigInt { ++ bn, err := ossl.BN_bin2bn(base(b), int32(len(b)), nil) ++ if err != nil { ++ panic(err) ++ } ++ defer ossl.BN_free(bn) ++ return bnToBig(bn) ++ } ++ ++ priv, err := NewPrivateKeyRSA( ++ bytesToBigInt(N), ++ bytesToBigInt(E), ++ bytesToBigInt(d), ++ bytesToBigInt(p), ++ bytesToBigInt(q), ++ bytesToBigInt(dP), ++ bytesToBigInt(dQ), ++ bytesToBigInt(qInv), ++ ) ++ if err != nil { ++ panic("failed to create test RSA private key: " + err.Error()) ++ } ++ // Prevent finalization to avoid freeing OpenSSL objects. ++ runtime.SetFinalizer(priv, nil) ++ return priv._pkey +}) diff --git a/src/vendor/github.com/golang-fips/openssl/v2/tls1prf.go b/src/vendor/github.com/golang-fips/openssl/v2/tls1prf.go new file mode 100644 @@ -33264,10 +33599,10 @@ index 00000000000000..f484a3e2211e04 +} diff --git a/src/vendor/github.com/microsoft/go-crypto-winnative/cng/rsa.go b/src/vendor/github.com/microsoft/go-crypto-winnative/cng/rsa.go new file mode 100644 -index 00000000000000..0269f9cf86539e +index 00000000000000..42f995a480e0fe --- /dev/null +++ b/src/vendor/github.com/microsoft/go-crypto-winnative/cng/rsa.go -@@ -0,0 +1,396 @@ +@@ -0,0 +1,404 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + @@ -33651,6 +33986,8 @@ index 00000000000000..0269f9cf86539e + +func cryptoHashToID(ch crypto.Hash) string { + switch ch { ++ case crypto.MD4: ++ return bcrypt.MD4_ALGORITHM + case crypto.MD5: + return bcrypt.MD5_ALGORITHM + case crypto.SHA1: @@ -33661,6 +33998,12 @@ index 00000000000000..0269f9cf86539e + return bcrypt.SHA384_ALGORITHM + case crypto.SHA512: + return bcrypt.SHA512_ALGORITHM ++ case crypto.SHA3_256: ++ return bcrypt.SHA3_256_ALGORITHM ++ case crypto.SHA3_384: ++ return bcrypt.SHA3_384_ALGORITHM ++ case crypto.SHA3_512: ++ return bcrypt.SHA3_512_ALGORITHM + } + return "" +} @@ -34983,11 +35326,11 @@ index 00000000000000..1722410e5af193 + return getSystemDirectory() + "\\" + dll +} diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt -index b6f6376eac041a..cc1444536adb31 100644 +index b6f6376eac041a..0fb122073acdff 100644 --- a/src/vendor/modules.txt +++ b/src/vendor/modules.txt @@ -1,3 +1,26 @@ -+# github.com/golang-fips/openssl/v2 v2.0.4-0.20251218145113-52cddb05a262 ++# github.com/golang-fips/openssl/v2 v2.0.4-0.20251219133548-db44f2109b85 +## explicit; go 1.24 +github.com/golang-fips/openssl/v2 +github.com/golang-fips/openssl/v2/bbig @@ -35003,7 +35346,7 @@ index b6f6376eac041a..cc1444536adb31 100644 +github.com/microsoft/go-crypto-darwin/internal/security +github.com/microsoft/go-crypto-darwin/internal/xsyscall +github.com/microsoft/go-crypto-darwin/xcrypto -+# github.com/microsoft/go-crypto-winnative v0.0.0-20251218121426-ba94af8d2bb8 ++# github.com/microsoft/go-crypto-winnative v0.0.0-20251219091053-f9796ee5d078 +## explicit; go 1.24 +github.com/microsoft/go-crypto-winnative/cng +github.com/microsoft/go-crypto-winnative/cng/bbig From ca5b3590f2beb4ca402c10c98a7834f3ad8b002f Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 19 Dec 2025 15:04:23 +0100 Subject: [PATCH 2/2] correct docs --- eng/_util/cmd/updatecryptodocs/docs.go | 1 + eng/doc/CrossPlatformCryptography.md | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/eng/_util/cmd/updatecryptodocs/docs.go b/eng/_util/cmd/updatecryptodocs/docs.go index 6df15ced431..f5bb4f279d2 100644 --- a/eng/_util/cmd/updatecryptodocs/docs.go +++ b/eng/_util/cmd/updatecryptodocs/docs.go @@ -303,6 +303,7 @@ var doc = Document{ Notes: []string{ "Supports only hash algorithms that are [supported as standalone hash functions](#hash-and-message-authentication-algorithms).", }, + MinGoVersion: "1.26", Platforms: Platforms{ MacOS: PlatformStatus{Supported: NotSupported}, }, diff --git a/eng/doc/CrossPlatformCryptography.md b/eng/doc/CrossPlatformCryptography.md index ccae5df8626..8996d3793eb 100644 --- a/eng/doc/CrossPlatformCryptography.md +++ b/eng/doc/CrossPlatformCryptography.md @@ -161,28 +161,28 @@ Operations that require random numbers (rand io.Reader) only support [rand.Reade | OAEP (MD5) | ✔️ | ✔️ | ✔️1 | | OAEP (SHA-1) | ✔️ | ✔️ | ✔️1 | | OAEP (SHA-2)2 | ✔️ | ✔️ | ✔️1 | -| OAEP (SHA-3)2 | ✔️ | ✔️ | ❌️ | -| PSS (MD5) | ✔️3 | ✔️ | ❌️ | -| PSS (SHA-1) | ✔️3 | ✔️ | ✔️4 | -| PSS (SHA-2)2 | ✔️3 | ✔️ | ✔️4 | -| PSS (SHA-3)2 | ✔️5 | ✔️ | ❌️ | +| OAEP (SHA-3)2,3 | ✔️ | ✔️ | ❌️ | +| PSS (MD5) | ✔️4 | ✔️ | ❌️ | +| PSS (SHA-1) | ✔️4 | ✔️ | ✔️5 | +| PSS (SHA-2)2 | ✔️4 | ✔️ | ✔️5 | +| PSS (SHA-3)2 | ✔️3 | ✔️ | ❌️ | | PKCS1v15 Signature (Unhashed) | ✔️ | ✔️ | ✔️ | | PKCS1v15 Signature (RIPMED160) | ❌️ | ✔️6 | ❌️ | | PKCS1v15 Signature (MD5) | ✔️ | ✔️ | ❌️ | | PKCS1v15 Signature (MD5-SHA1) | ✔️6 | ✔️6 | ❌️ | | PKCS1v15 Signature (SHA-1) | ✔️ | ✔️ | ✔️ | | PKCS1v15 Signature (SHA-2)2 | ✔️ | ✔️ | ✔️ | -| PKCS1v15 Signature (SHA-3) | ✔️5,7 | ✔️8 | ❌️ | +| PKCS1v15 Signature (SHA-3) | ✔️3,7 | ✔️8 | ❌️ | 1macOS doesn't support passing a custom label to OAEP functions. 2Supports only hash algorithms that are [supported as standalone hash functions](#hash-and-message-authentication-algorithms). -3Verifying PSS signatures with [rsa.PSSSaltLengthAuto](https://pkg.go.dev/crypto/rsa#pkg-constants) is not supported. +3Available starting in the Microsoft build of Go 1.26. -4Custom salt lengths are not supported. PSS always uses the [`rsa.PSSSaltLengthEqualsHash`](https://pkg.go.dev/crypto/rsa#pkg-constants). +4Verifying PSS signatures with [rsa.PSSSaltLengthAuto](https://pkg.go.dev/crypto/rsa#pkg-constants) is not supported. -5Available starting in the Microsoft build of Go 1.26. +5Custom salt lengths are not supported. PSS always uses the [`rsa.PSSSaltLengthEqualsHash`](https://pkg.go.dev/crypto/rsa#pkg-constants). 6Available starting in the Microsoft build of Go 1.24.