From a70bb8b9db344207279a03d14c096e0e457f2559 Mon Sep 17 00:00:00 2001 From: "bot-for-go[bot]" <199222863+bot-for-go[bot]@users.noreply.github.com> Date: Fri, 5 Dec 2025 16:07:25 +0000 Subject: [PATCH 1/3] Update submodule to latest master (f84f8d86): cmd/compile: fix mis-infer bounds in slice len/cap calculations --- go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go b/go index f22d37d5748..f84f8d86beb 160000 --- a/go +++ b/go @@ -1 +1 @@ -Subproject commit f22d37d574836ed4f1b42e283dda55dbd4d80aca +Subproject commit f84f8d86beb08631217e77d725a4b6528ed91dc2 From 945cbb58cfc4c5d9d0be5f44766b5212c28b22e2 Mon Sep 17 00:00:00 2001 From: George Adams Date: Mon, 8 Dec 2025 08:59:37 +0000 Subject: [PATCH 2/3] rebase patches --- patches/0004-Use-crypto-backends.patch | 208 ++++++------------------- 1 file changed, 46 insertions(+), 162 deletions(-) diff --git a/patches/0004-Use-crypto-backends.patch b/patches/0004-Use-crypto-backends.patch index f40db38740b..7b31cad945c 100644 --- a/patches/0004-Use-crypto-backends.patch +++ b/patches/0004-Use-crypto-backends.patch @@ -24,13 +24,13 @@ Subject: [PATCH] Use crypto backends src/crypto/dsa/notboring.go | 16 ++ src/crypto/ecdh/ecdh.go | 2 +- src/crypto/ecdh/ecdh_test.go | 4 + - src/crypto/ecdh/nist.go | 4 +- + src/crypto/ecdh/nist.go | 2 +- src/crypto/ecdsa/badlinkname.go | 19 ++ src/crypto/ecdsa/boring.go | 6 +- src/crypto/ecdsa/ecdsa.go | 10 +- src/crypto/ecdsa/notboring.go | 4 +- src/crypto/ed25519/boring.go | 71 +++++++ - src/crypto/ed25519/ed25519.go | 73 ++++++- + src/crypto/ed25519/ed25519.go | 70 +++++++ src/crypto/ed25519/ed25519_test.go | 13 +- src/crypto/ed25519/notboring.go | 16 ++ src/crypto/fips140/enforcement_test.go | 4 + @@ -46,7 +46,7 @@ Subject: [PATCH] Use crypto backends src/crypto/internal/fips140test/acvp_test.go | 6 + src/crypto/internal/fips140test/cast_test.go | 2 + src/crypto/internal/fips140test/fips_test.go | 2 +- - src/crypto/internal/rand/rand.go | 12 +- + src/crypto/internal/rand/rand.go | 2 +- src/crypto/md5/md5.go | 10 + src/crypto/md5/md5_test.go | 18 +- src/crypto/mlkem/mlkem.go | 109 ++++++++-- @@ -54,18 +54,18 @@ Subject: [PATCH] Use crypto backends src/crypto/pbkdf2/pbkdf2.go | 7 + src/crypto/pbkdf2/pbkdf2_test.go | 6 +- src/crypto/purego_test.go | 2 +- - src/crypto/rand/rand.go | 21 +- + src/crypto/rand/rand.go | 4 +- src/crypto/rand/rand_test.go | 9 +- src/crypto/rc4/rc4.go | 18 ++ src/crypto/rsa/boring.go | 12 +- src/crypto/rsa/boring_test.go | 2 +- src/crypto/rsa/darwin.go | 71 +++++++ - src/crypto/rsa/fips.go | 33 +-- + src/crypto/rsa/fips.go | 22 +- src/crypto/rsa/notboring.go | 4 +- - src/crypto/rsa/pkcs1v15.go | 8 +- + src/crypto/rsa/pkcs1v15.go | 6 +- src/crypto/rsa/pkcs1v15_test.go | 5 + src/crypto/rsa/pss_test.go | 13 +- - src/crypto/rsa/rsa.go | 15 +- + src/crypto/rsa/rsa.go | 13 +- src/crypto/rsa/rsa_test.go | 12 +- src/crypto/sha1/sha1.go | 8 +- src/crypto/sha1/sha1_test.go | 11 +- @@ -99,7 +99,7 @@ Subject: [PATCH] Use crypto backends src/hash/notboring_test.go | 9 + src/net/lookup_test.go | 3 + src/os/exec/exec_test.go | 9 + - 95 files changed, 1441 insertions(+), 184 deletions(-) + 95 files changed, 1416 insertions(+), 162 deletions(-) create mode 100644 src/crypto/dsa/boring.go create mode 100644 src/crypto/dsa/notboring.go create mode 100644 src/crypto/ecdsa/badlinkname.go @@ -125,7 +125,7 @@ index f0e3575637c62a..9eab3b4e66e60b 100644 package main diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go -index 1314403a56cad0..17387733a3e1a0 100644 +index 2a27d97990fa57..4a1d3b91d701bb 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -720,7 +720,7 @@ func (t *tester) registerTests() { @@ -154,7 +154,7 @@ index 1314403a56cad0..17387733a3e1a0 100644 pkg: "runtime/secret/...", }) } -@@ -1382,12 +1388,11 @@ func (t *tester) registerCgoTests(heading string) { +@@ -1377,12 +1383,11 @@ func (t *tester) registerCgoTests(heading string) { // a C linker warning on Linux. // in function `bio_ip_and_port_to_socket_and_addr': // warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking @@ -827,7 +827,7 @@ index 8a3eb87061ad8c..a09a9fc8148039 100644 for _, input := range invalidPrivateKeys[curve] { k, err := curve.NewPrivateKey(hexDecode(t, input)) diff --git a/src/crypto/ecdh/nist.go b/src/crypto/ecdh/nist.go -index de7348d9232349..3521c3bbd03959 100644 +index 13865ea7012989..3521c3bbd03959 100644 --- a/src/crypto/ecdh/nist.go +++ b/src/crypto/ecdh/nist.go @@ -6,7 +6,7 @@ package ecdh @@ -839,15 +839,6 @@ index de7348d9232349..3521c3bbd03959 100644 "crypto/internal/fips140/ecdh" "crypto/internal/fips140only" "crypto/internal/rand" -@@ -27,7 +27,7 @@ func (c *nistCurve) String() string { - } - - func (c *nistCurve) GenerateKey(r io.Reader) (*PrivateKey, error) { -- if boring.Enabled && r == boring.RandReader { -+ if boring.Enabled && rand.IsDefaultReader(r) { - key, bytes, err := boring.GenerateKeyECDH(c.name) - if err != nil { - return nil, err diff --git a/src/crypto/ecdsa/badlinkname.go b/src/crypto/ecdsa/badlinkname.go new file mode 100644 index 00000000000000..168efdb820c85b @@ -895,7 +886,7 @@ index 275c60b4de49eb..ff8bddf28c4545 100644 "math/big" ) diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go -index aee15b92838543..1eb2604505e229 100644 +index b336f32eb69ef5..1eb2604505e229 100644 --- a/src/crypto/ecdsa/ecdsa.go +++ b/src/crypto/ecdsa/ecdsa.go @@ -20,8 +20,8 @@ import ( @@ -913,7 +904,7 @@ index aee15b92838543..1eb2604505e229 100644 // ignored unless GODEBUG=cryptocustomrand=1 is set. This setting will be removed // in a future Go release. Instead, use [testing/cryptotest.SetGlobalRandom]. func GenerateKey(c elliptic.Curve, r io.Reader) (*PrivateKey, error) { -- if boring.Enabled && r == boring.RandReader { +- if boring.Enabled && rand.IsDefaultReader(r) { + if boring.Enabled && rand.IsDefaultReader(r) && boring.SupportsCurve(c.Params().Name) { x, y, d, err := boring.GenerateKeyECDSA(c.Params().Name) if err != nil { @@ -922,7 +913,7 @@ index aee15b92838543..1eb2604505e229 100644 // is set. This setting will be removed in a future Go release. Instead, use // [testing/cryptotest.SetGlobalRandom]. func SignASN1(r io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) { -- if boring.Enabled && r == boring.RandReader { +- if boring.Enabled && rand.IsDefaultReader(r) { + if boring.Enabled && rand.IsDefaultReader(r) && boring.SupportsCurve(priv.Curve.Params().Name) { b, err := boringPrivateKey(priv) if err != nil { @@ -1032,19 +1023,18 @@ index 00000000000000..4e18cdfbaad4fd + return key, nil +} diff --git a/src/crypto/ed25519/ed25519.go b/src/crypto/ed25519/ed25519.go -index f09dabe23e875d..00752fce1bae07 100644 +index a0263638ef19fe..00752fce1bae07 100644 --- a/src/crypto/ed25519/ed25519.go +++ b/src/crypto/ed25519/ed25519.go -@@ -17,7 +17,7 @@ package ed25519 +@@ -17,6 +17,7 @@ package ed25519 import ( "crypto" -- "crypto/internal/fips140/drbg" + boring "crypto/internal/backend" "crypto/internal/fips140/ed25519" "crypto/internal/fips140cache" "crypto/internal/fips140only" -@@ -28,6 +28,7 @@ import ( +@@ -27,6 +28,7 @@ import ( "internal/godebug" "io" "strconv" @@ -1052,15 +1042,7 @@ index f09dabe23e875d..00752fce1bae07 100644 ) const ( -@@ -153,13 +154,26 @@ func GenerateKey(random io.Reader) (PublicKey, PrivateKey, error) { - if random == nil { - if cryptocustomrand.Value() == "1" { - random = cryptorand.Reader -- if _, ok := random.(drbg.DefaultReader); !ok { -+ if !rand.IsDefaultReader(random) { - cryptocustomrand.IncNonDefault() - } - } else { +@@ -159,6 +161,19 @@ func GenerateKey(random io.Reader) (PublicKey, PrivateKey, error) { random = rand.Reader } } @@ -1080,7 +1062,7 @@ index f09dabe23e875d..00752fce1bae07 100644 seed := make([]byte, SeedSize) if _, err := io.ReadFull(random, seed); err != nil { -@@ -176,6 +190,17 @@ func GenerateKey(random io.Reader) (PublicKey, PrivateKey, error) { +@@ -175,6 +190,17 @@ func GenerateKey(random io.Reader) (PublicKey, PrivateKey, error) { // with RFC 8032. RFC 8032's private keys correspond to seeds in this // package. func NewKeyFromSeed(seed []byte) PrivateKey { @@ -1098,7 +1080,7 @@ index f09dabe23e875d..00752fce1bae07 100644 // Outline the function body so that the returned key can be stack-allocated. privateKey := make([]byte, PrivateKeySize) newKeyFromSeed(privateKey, seed) -@@ -194,6 +219,17 @@ func newKeyFromSeed(privateKey, seed []byte) { +@@ -193,6 +219,17 @@ func newKeyFromSeed(privateKey, seed []byte) { // Sign signs the message with privateKey and returns a signature. It will // panic if len(privateKey) is not [PrivateKeySize]. func Sign(privateKey PrivateKey, message []byte) []byte { @@ -1116,7 +1098,7 @@ index f09dabe23e875d..00752fce1bae07 100644 // Outline the function body so that the returned signature can be // stack-allocated. signature := make([]byte, SignatureSize) -@@ -223,6 +259,32 @@ func Verify(publicKey PublicKey, message, sig []byte) bool { +@@ -222,6 +259,32 @@ func Verify(publicKey PublicKey, message, sig []byte) bool { return VerifyWithOptions(publicKey, message, sig, &Options{Hash: crypto.Hash(0)}) == nil } @@ -1149,7 +1131,7 @@ index f09dabe23e875d..00752fce1bae07 100644 // VerifyWithOptions reports whether sig is a valid signature of message by // publicKey. A valid signature is indicated by returning a nil error. It will // panic if len(publicKey) is not [PublicKeySize]. -@@ -251,6 +313,13 @@ func VerifyWithOptions(publicKey PublicKey, message, sig []byte, opts *Options) +@@ -250,6 +313,13 @@ func VerifyWithOptions(publicKey PublicKey, message, sig []byte, opts *Options) } return ed25519.VerifyCtx(k, message, sig, opts.Context) case opts.Hash == crypto.Hash(0): // Ed25519 @@ -1504,7 +1486,7 @@ index 52fc9d34886003..9afaf522df475c 100644 "crypto/internal/fips140/aes" "crypto/internal/fips140/aes/gcm" diff --git a/src/crypto/internal/rand/rand.go b/src/crypto/internal/rand/rand.go -index 3a780952e705e5..b3113a3ee2e1fa 100644 +index 29648b9f386ed7..b3113a3ee2e1fa 100644 --- a/src/crypto/internal/rand/rand.go +++ b/src/crypto/internal/rand/rand.go @@ -5,7 +5,7 @@ @@ -1516,27 +1498,6 @@ index 3a780952e705e5..b3113a3ee2e1fa 100644 "crypto/internal/fips140/drbg" "crypto/internal/randutil" "internal/godebug" -@@ -55,7 +55,7 @@ var cryptocustomrand = godebug.New("cryptocustomrand") - // If returning a non-default Reader, it calls [randutil.MaybeReadByte] on it. - func CustomReader(r io.Reader) io.Reader { - if cryptocustomrand.Value() == "1" { -- if _, ok := r.(drbg.DefaultReader); !ok { -+ if !IsDefaultReader(r) { - randutil.MaybeReadByte(r) - cryptocustomrand.IncNonDefault() - } -@@ -63,3 +63,11 @@ func CustomReader(r io.Reader) io.Reader { - } - return Reader - } -+ -+// IsDefaultReader reports whether r is the default [crypto/rand.Reader]. -+// -+// If true, the Read method of r can be assumed to call [drbg.Read]. -+func IsDefaultReader(r io.Reader) bool { -+ _, ok := r.(drbg.DefaultReader) -+ return ok -+} diff --git a/src/crypto/md5/md5.go b/src/crypto/md5/md5.go index f1287887ff5e25..b2e26308349566 100644 --- a/src/crypto/md5/md5.go @@ -2004,7 +1965,7 @@ index 62be347e0c6822..d284b5cf7814a6 100644 } diff --git a/src/crypto/rand/rand.go b/src/crypto/rand/rand.go -index 004e6b6fedc7fc..e2279dbb2881b9 100644 +index 018fe013cef600..e2279dbb2881b9 100644 --- a/src/crypto/rand/rand.go +++ b/src/crypto/rand/rand.go @@ -7,7 +7,7 @@ @@ -2016,39 +1977,15 @@ index 004e6b6fedc7fc..e2279dbb2881b9 100644 "crypto/internal/fips140/drbg" "crypto/internal/rand" "io" -@@ -31,15 +31,7 @@ import ( - // - // In FIPS 140-3 mode, the output passes through an SP 800-90A Rev. 1 - // Deterministric Random Bit Generator (DRBG). --var Reader io.Reader -- --func init() { -- if boring.Enabled { -- Reader = boring.RandReader -- return -- } -- Reader = rand.Reader --} -+var Reader io.Reader = rand.Reader - - // fatal is [runtime.fatal], pushed via linkname. - // -@@ -57,9 +49,12 @@ func Read(b []byte) (n int, err error) { - // through a potentially overridden Reader, so we special-case the default - // case which we can keep non-escaping, and in the general case we read into +@@ -51,7 +51,7 @@ func Read(b []byte) (n int, err error) { // a heap buffer and copy from it. -- if _, ok := Reader.(drbg.DefaultReader); ok { -- boring.Unreachable() -- drbg.Read(b) -+ if rand.IsDefaultReader(Reader) { -+ if boring.Enabled { + if rand.IsDefaultReader(Reader) { + if boring.Enabled { +- _, err = io.ReadFull(boring.RandReader, b) + _, err = boring.RandReader.Read(b) -+ } else { -+ drbg.Read(b) -+ } - } else { - bb := make([]byte, len(b)) - _, err = io.ReadFull(Reader, bb) + } else { + drbg.Read(b) + } diff --git a/src/crypto/rand/rand_test.go b/src/crypto/rand/rand_test.go index 22ccb8a35334c9..832910da482f44 100644 --- a/src/crypto/rand/rand_test.go @@ -2264,10 +2201,10 @@ index 00000000000000..1b9c63523ee90e + return builder.Bytes() +} diff --git a/src/crypto/rsa/fips.go b/src/crypto/rsa/fips.go -index 75aa3d3d725757..504bd25d2c7df1 100644 +index fb2395886b053b..504bd25d2c7df1 100644 --- a/src/crypto/rsa/fips.go +++ b/src/crypto/rsa/fips.go -@@ -6,10 +6,11 @@ package rsa +@@ -6,7 +6,7 @@ package rsa import ( "crypto" @@ -2276,51 +2213,16 @@ index 75aa3d3d725757..504bd25d2c7df1 100644 "crypto/internal/fips140/rsa" "crypto/internal/fips140hash" "crypto/internal/fips140only" -+ "crypto/internal/rand" - "errors" - "hash" - "io" -@@ -59,9 +60,9 @@ func (opts *PSSOptions) saltLength() int { - // used. If opts.Hash is set, it overrides hash. - // - // The signature is randomized depending on the message, key, and salt size, --// using bytes from rand. Most applications should use [crypto/rand.Reader] as --// rand. --func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte, opts *PSSOptions) ([]byte, error) { -+// using bytes from random. Most applications should use [crypto/rand.Reader] as -+// random. -+func SignPSS(random io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte, opts *PSSOptions) ([]byte, error) { - if err := checkPublicKeySize(&priv.PublicKey); err != nil { - return nil, err - } -@@ -70,7 +71,7 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte, +@@ -71,7 +71,7 @@ func SignPSS(random io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte hash = opts.Hash } -- if boring.Enabled && rand == boring.RandReader { +- if boring.Enabled && rand.IsDefaultReader(random) { + if boring.Enabled && rand.IsDefaultReader(random) && boring.SupportsRSASaltLength(true, opts.saltLength()) && boring.SupportsRSAKeyPrimes(len(priv.Primes)) && boring.SupportsHash(hash) { bkey, err := boringPrivateKey(priv) if err != nil { return nil, err -@@ -87,7 +88,7 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte, - if fips140only.Enforced() && !fips140only.ApprovedHash(h) { - return nil, errors.New("crypto/rsa: use of hash functions other than SHA-2 or SHA-3 is not allowed in FIPS 140-only mode") - } -- if fips140only.Enforced() && !fips140only.ApprovedRandomReader(rand) { -+ if fips140only.Enforced() && !fips140only.ApprovedRandomReader(random) { - return nil, errors.New("crypto/rsa: only crypto/rand.Reader is allowed in FIPS 140-only mode") - } - -@@ -116,7 +117,7 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte, - } - } - -- return fipsError2(rsa.SignPSS(rand, k, h, digest, saltLength)) -+ return fipsError2(rsa.SignPSS(random, k, h, digest, saltLength)) - } - - // VerifyPSS verifies a PSS signature. -@@ -133,7 +134,7 @@ func VerifyPSS(pub *PublicKey, hash crypto.Hash, digest []byte, sig []byte, opts +@@ -134,7 +134,7 @@ func VerifyPSS(pub *PublicKey, hash crypto.Hash, digest []byte, sig []byte, opts return err } @@ -2329,7 +2231,7 @@ index 75aa3d3d725757..504bd25d2c7df1 100644 bkey, err := boringPublicKey(pub) if err != nil { return err -@@ -202,10 +203,12 @@ func EncryptOAEP(hash hash.Hash, random io.Reader, pub *PublicKey, msg []byte, l +@@ -203,10 +203,12 @@ func EncryptOAEP(hash hash.Hash, random io.Reader, pub *PublicKey, msg []byte, l // // See [EncryptOAEP] for additional details. func EncryptOAEPWithOptions(random io.Reader, pub *PublicKey, msg []byte, opts *OAEPOptions) ([]byte, error) { @@ -2345,16 +2247,16 @@ index 75aa3d3d725757..504bd25d2c7df1 100644 } func encryptOAEP(hash hash.Hash, mgfHash hash.Hash, random io.Reader, pub *PublicKey, msg []byte, label []byte) ([]byte, error) { -@@ -216,7 +219,7 @@ func encryptOAEP(hash hash.Hash, mgfHash hash.Hash, random io.Reader, pub *Publi +@@ -217,7 +219,7 @@ func encryptOAEP(hash hash.Hash, mgfHash hash.Hash, random io.Reader, pub *Publi defer hash.Reset() defer mgfHash.Reset() -- if boring.Enabled && random == boring.RandReader { +- if boring.Enabled && rand.IsDefaultReader(random) { + if boring.Enabled && rand.IsDefaultReader(random) && boring.SupportsRSAOAEPLabel(label) && hash == mgfHash { k := pub.Size() if len(msg) > k-2*hash.Size()-2 { return nil, ErrMessageTooLong -@@ -268,7 +271,7 @@ func decryptOAEP(hash, mgfHash hash.Hash, priv *PrivateKey, ciphertext []byte, l +@@ -269,7 +271,7 @@ func decryptOAEP(hash, mgfHash hash.Hash, priv *PrivateKey, ciphertext []byte, l return nil, err } @@ -2363,7 +2265,7 @@ index 75aa3d3d725757..504bd25d2c7df1 100644 k := priv.Size() if len(ciphertext) > k || k < hash.Size()*2+2 { -@@ -330,7 +333,7 @@ func SignPKCS1v15(random io.Reader, priv *PrivateKey, hash crypto.Hash, hashed [ +@@ -331,7 +333,7 @@ func SignPKCS1v15(random io.Reader, priv *PrivateKey, hash crypto.Hash, hashed [ return nil, err } @@ -2372,7 +2274,7 @@ index 75aa3d3d725757..504bd25d2c7df1 100644 bkey, err := boringPrivateKey(priv) if err != nil { return nil, err -@@ -373,7 +376,7 @@ func VerifyPKCS1v15(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte) +@@ -374,7 +376,7 @@ func VerifyPKCS1v15(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte) return err } @@ -2400,7 +2302,7 @@ index 2abc0436405f8a..3e4d6f3eef61e6 100644 func boringPublicKey(*PublicKey) (*boring.PublicKeyRSA, error) { panic("boringcrypto: not available") diff --git a/src/crypto/rsa/pkcs1v15.go b/src/crypto/rsa/pkcs1v15.go -index 0f216e0193252c..f1122ce61087bd 100644 +index 5269d7b971bda7..f1122ce61087bd 100644 --- a/src/crypto/rsa/pkcs1v15.go +++ b/src/crypto/rsa/pkcs1v15.go @@ -5,7 +5,7 @@ @@ -2412,15 +2314,6 @@ index 0f216e0193252c..f1122ce61087bd 100644 "crypto/internal/fips140/rsa" "crypto/internal/fips140only" "crypto/internal/rand" -@@ -61,7 +61,7 @@ func EncryptPKCS1v15(random io.Reader, pub *PublicKey, msg []byte) ([]byte, erro - return nil, ErrMessageTooLong - } - -- if boring.Enabled && random == boring.RandReader { -+ if boring.Enabled && rand.IsDefaultReader(random) { - bkey, err := boringPublicKey(pub) - if err != nil { - return nil, err @@ -115,7 +115,7 @@ func DecryptPKCS1v15(random io.Reader, priv *PrivateKey, ciphertext []byte) ([]b return nil, err } @@ -2514,7 +2407,7 @@ index e03f4ab06603c6..cd44f3af23b0d4 100644 t.Fatal(err) } diff --git a/src/crypto/rsa/rsa.go b/src/crypto/rsa/rsa.go -index 62f2de30b0b871..5cbedca4d3888d 100644 +index b94b129867727b..5cbedca4d3888d 100644 --- a/src/crypto/rsa/rsa.go +++ b/src/crypto/rsa/rsa.go @@ -43,8 +43,8 @@ package rsa @@ -2545,15 +2438,6 @@ index 62f2de30b0b871..5cbedca4d3888d 100644 case *PKCS1v15DecryptOptions: if l := opts.SessionKeyLen; l > 0 { -@@ -314,7 +315,7 @@ func GenerateKey(random io.Reader, bits int) (*PrivateKey, error) { - return nil, err - } - -- if boring.Enabled && random == boring.RandReader && -+ if boring.Enabled && rand.IsDefaultReader(random) && - (bits == 2048 || bits == 3072 || bits == 4096) { - bN, bE, bD, bP, bQ, bDp, bDq, bQinv, err := boring.GenerateKeyRSA(bits) - if err != nil { diff --git a/src/crypto/rsa/rsa_test.go b/src/crypto/rsa/rsa_test.go index 5ae4c1dd203874..678e94ade86af6 100644 --- a/src/crypto/rsa/rsa_test.go @@ -3855,10 +3739,10 @@ index 39ebb9d2f1edd3..3ab935ab1607f1 100644 "crypto/tls/internal/fips140tls" "crypto/x509" diff --git a/src/crypto/x509/verify_test.go b/src/crypto/x509/verify_test.go -index 6dadba3a566f5e..a84b8cdeb42471 100644 +index f9bd313737e21b..04548c961e74a8 100644 --- a/src/crypto/x509/verify_test.go +++ b/src/crypto/x509/verify_test.go -@@ -3080,7 +3080,7 @@ func dsaSelfSignedCNX(t *testing.T) []byte { +@@ -3127,7 +3127,7 @@ func dsaSelfSignedCNX(t *testing.T) []byte { t.Helper() var params dsa.Parameters if err := dsa.GenerateParameters(¶ms, rand.Reader, dsa.L1024N160); err != nil { From 330120bf10299b10056b5d7d959712dfee8f0f08 Mon Sep 17 00:00:00 2001 From: George Adams Date: Tue, 9 Dec 2025 09:05:17 +0000 Subject: [PATCH 3/3] rand use io.ReadFull --- patches/0004-Use-crypto-backends.patch | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/patches/0004-Use-crypto-backends.patch b/patches/0004-Use-crypto-backends.patch index 4993a94cb50..76185244794 100644 --- a/patches/0004-Use-crypto-backends.patch +++ b/patches/0004-Use-crypto-backends.patch @@ -55,7 +55,7 @@ Subject: [PATCH] Use crypto backends src/crypto/pbkdf2/pbkdf2.go | 7 + src/crypto/pbkdf2/pbkdf2_test.go | 6 +- src/crypto/purego_test.go | 2 +- - src/crypto/rand/rand.go | 4 +- + src/crypto/rand/rand.go | 2 +- src/crypto/rand/rand_test.go | 9 +- src/crypto/rc4/rc4.go | 18 ++ src/crypto/rsa/boring.go | 12 +- @@ -100,7 +100,7 @@ Subject: [PATCH] Use crypto backends src/hash/notboring_test.go | 9 + src/net/lookup_test.go | 3 + src/os/exec/exec_test.go | 9 + - 96 files changed, 1491 insertions(+), 177 deletions(-) + 96 files changed, 1490 insertions(+), 176 deletions(-) create mode 100644 src/crypto/dsa/boring.go create mode 100644 src/crypto/dsa/notboring.go create mode 100644 src/crypto/ecdsa/badlinkname.go @@ -2127,7 +2127,7 @@ index 62be347e0c6822..d284b5cf7814a6 100644 } diff --git a/src/crypto/rand/rand.go b/src/crypto/rand/rand.go -index 018fe013cef600..e2279dbb2881b9 100644 +index 018fe013cef600..ec710c6f935e3b 100644 --- a/src/crypto/rand/rand.go +++ b/src/crypto/rand/rand.go @@ -7,7 +7,7 @@ @@ -2139,15 +2139,6 @@ index 018fe013cef600..e2279dbb2881b9 100644 "crypto/internal/fips140/drbg" "crypto/internal/rand" "io" -@@ -51,7 +51,7 @@ func Read(b []byte) (n int, err error) { - // a heap buffer and copy from it. - if rand.IsDefaultReader(Reader) { - if boring.Enabled { -- _, err = io.ReadFull(boring.RandReader, b) -+ _, err = boring.RandReader.Read(b) - } else { - drbg.Read(b) - } diff --git a/src/crypto/rand/rand_test.go b/src/crypto/rand/rand_test.go index 22ccb8a35334c9..832910da482f44 100644 --- a/src/crypto/rand/rand_test.go