@@ -190,6 +190,10 @@ index 0000000000..6c8c00d11e
190190diff --git a/src/crypto/internal/backend/dummy.s b/src/crypto/internal/backend/dummy.s
191191new file mode 100644
192192index 0000000000..e69de29bb2
193+ --- /dev/null
194+ +++ b/src/crypto/internal/backend/dummy.s
195+ @@ -0,0 +1,1 @@
196+ + //go:build linux && cgo && !android && !gocrypt && !cmd_go_bootstrap && !msan && !no_openssl && !purego
193197diff --git a/src/crypto/internal/backend/nobackend.go b/src/crypto/internal/backend/nobackend.go
194198new file mode 100644
195199index 0000000000..15c1ee8cbe
@@ -200,8 +204,8 @@ index 0000000000..15c1ee8cbe
200204+ // Use of this source code is governed by a BSD-style
201205+ // license that can be found in the LICENSE file.
202206+
203- + //go:build !linux || !cgo || android || cmd_go_bootstrap || msan || no_openssl
204- + // +build !linux !cgo android cmd_go_bootstrap msan no_openssl
207+ + //go:build !linux || !cgo || android || cmd_go_bootstrap || msan || no_openssl || purego
208+ + // +build !linux !cgo android cmd_go_bootstrap msan no_openssl purego
205209+
206210+ package backend
207211+
@@ -369,8 +373,8 @@ index 0000000000..2087c555a4
369373+ // Use of this source code is governed by a BSD-style
370374+ // license that can be found in the LICENSE file.
371375+
372- + //go:build linux && cgo && !android && !gocrypt && !cmd_go_bootstrap && !msan && !no_openssl
373- + // +build linux,cgo,!android,!gocrypt,!cmd_go_bootstrap,!msan,!no_openssl
376+ + //go:build linux && cgo && !android && !gocrypt && !cmd_go_bootstrap && !msan && !no_openssl && !purego
377+ + // +build linux,cgo,!android,!gocrypt,!cmd_go_bootstrap,!msan,!no_openssl,!purego
374378+
375379+ // Package openssl provides access to OpenSSLCrypto implementation functions.
376380+ // Check the variable Enabled to find out whether OpenSSLCrypto is available.
@@ -883,13 +887,11 @@ diff --git a/src/crypto/tls/boring.go b/src/crypto/tls/boring.go
883887index aad96b1c74..bbf3d38339 100644
884888--- a/src/crypto/tls/boring.go
885889+++ b/src/crypto/tls/boring.go
886- @@ -6,9 +6,16 @@
890+ @@ -6,7 +6,16 @@
887891
888892 package tls
889893
890- - import (
891- - "crypto/internal/boring/fipstls"
892- - )
894+ - import "crypto/internal/boring/fipstls"
893895+ import (
894896+ boring "crypto/internal/backend"
895897+ "crypto/internal/boring/fipstls"
@@ -901,30 +903,8 @@ index aad96b1c74..bbf3d38339 100644
901903+ }
902904+ }
903905
904- // needFIPS returns fipstls.Required(); it avoids a new import in common.go.
905- func needFIPS() bool {
906- @@ -17,14 +24,18 @@ func needFIPS() bool {
907-
908- // fipsMinVersion replaces c.minVersion in FIPS-only mode.
909- func fipsMinVersion(c *Config) uint16 {
910- - // FIPS requires TLS 1.2.
911- + // FIPS requires TLS 1.2 or later.
912- return VersionTLS12
913- }
914-
915- // fipsMaxVersion replaces c.maxVersion in FIPS-only mode.
916- func fipsMaxVersion(c *Config) uint16 {
917- - // FIPS requires TLS 1.2.
918- - return VersionTLS12
919- + // FIPS requires TLS 1.2 or later.
920- + if boring.SupportsHKDF() {
921- + return VersionTLS13
922- + } else {
923- + return VersionTLS12
924- + }
925- }
926-
927- // default defaultFIPSCurvePreferences is the FIPS-allowed curves,
906+ // needFIPS returns fipstls.Required(), which is not available without the
907+ // boringcrypto build tag.
928908diff --git a/src/crypto/tls/boring_test.go b/src/crypto/tls/boring_test.go
929909index ba68f355eb..7bfe3f9417 100644
930910--- a/src/crypto/tls/boring_test.go
@@ -939,34 +919,34 @@ index ba68f355eb..7bfe3f9417 100644
939919 "crypto/rand"
940920 "crypto/rsa"
941921@@ -44,7 +46,11 @@ func TestBoringServerProtocolVersion(t *testing.T) {
942- test("VersionTLS10", VersionTLS10, "")
943- test("VersionTLS11", VersionTLS11, "")
944- test("VersionTLS12", VersionTLS12, "")
945- - test("VersionTLS13", VersionTLS13, "")
922+ test(t, "VersionTLS10", VersionTLS10, "")
923+ test(t, "VersionTLS11", VersionTLS11, "")
924+ test(t, "VersionTLS12", VersionTLS12, "")
925+ - test(t, "VersionTLS13", VersionTLS13, "")
946926+ if boring.Enabled && !boring.SupportsHKDF() {
947- + test("VersionTLS13", VersionTLS13, "client offered only unsupported versions")
927+ + test(t, "VersionTLS13", VersionTLS13, "client offered only unsupported versions")
948928+ } else {
949- + test("VersionTLS13", VersionTLS13, "")
929+ + test(t, "VersionTLS13", VersionTLS13, "")
950930+ }
951931
952- fipstls.Force()
953- defer fipstls.Abandon ()
932+ t.Run("fipstls", func(t *testing.T) {
933+ fipstls.Force ()
954934@@ -52,11 +58,13 @@ func TestBoringServerProtocolVersion(t *testing.T) {
955- test("VersionTLS10", VersionTLS10, "client offered only unsupported versions")
956- test("VersionTLS11", VersionTLS11, "client offered only unsupported versions")
957- test("VersionTLS12", VersionTLS12, "")
958- - test("VersionTLS13", VersionTLS13, "client offered only unsupported versions")
959- + if boring.SupportsHKDF() {
960- + test("VersionTLS13/fipstls", VersionTLS13, "")
935+ test(t, "VersionTLS10", VersionTLS10, "supported versions")
936+ test(t, "VersionTLS11", VersionTLS11, "supported versions")
937+ test(t, "VersionTLS12", VersionTLS12, "")
938+ - test(t, "VersionTLS13", VersionTLS13, "supported versions")
939+ + if boring.SupportsHKDF() {
940+ + test(t, "VersionTLS13/fipstls", VersionTLS13, "")
961941+ }
942+ })
962943 }
963944
964945 func isBoringVersion(v uint16) bool {
965946- return v == VersionTLS12
966947+ return v == VersionTLS12 || (boring.SupportsHKDF() && v == VersionTLS13)
967948 }
968949
969- func isBoringCipherSuite(id uint16) bool {
970950@@ -226,7 +236,14 @@ func TestBoringServerSignatureAndHash(t *testing.T) {
971951 // 1.3, and the ECDSA ones bind to the curve used.
972952 serverConfig.MaxVersion = VersionTLS12
@@ -1125,7 +1105,7 @@ index 04e6dfe018..b6ed936cd1 100644
11251105--- a/src/crypto/tls/cipher_suites.go
11261106+++ b/src/crypto/tls/cipher_suites.go
11271107@@ -354,6 +354,11 @@ var defaultCipherSuitesTLS13NoAES = []uint16{
1128- TLS_AES_256_GCM_SHA384 ,
1108+ TLS_RSA_WITH_3DES_EDE_CBC_SHA: true ,
11291109 }
11301110
11311111+ var defaultFIPSCipherSuitesTLS13 = []uint16{
@@ -1155,7 +1135,7 @@ index 5394d64ac6..db4e2dbf60 100644
11551135+ if boring.Enabled && !boring.SupportsHKDF() && v > VersionTLS12 {
11561136+ continue
11571137+ }
1158- if needFIPS() && (v < fipsMinVersion(c) || v > fipsMaxVersion(c) ) {
1138+ if needFIPS() && !slices.Contains(defaultSupportedVersionsFIPS, v ) {
11591139 continue
11601140 }
11611141diff --git a/src/crypto/tls/handshake_client_test.go b/src/crypto/tls/handshake_client_test.go
@@ -1178,10 +1158,10 @@ index ae8f80a7cf..30a8450f40 100644
11781158 import (
11791159 "crypto/ecdh"
11801160 "crypto/hmac"
1161+ "crypto/internal/mlkem768"
11811162+ "crypto/internal/boring"
11821163 "errors"
11831164 "fmt"
1184- "hash"
11851165@@ -58,9 +59,20 @@ func (c *cipherSuiteTLS13) expandLabel(secret []byte, label string, context []by
11861166 panic(fmt.Errorf("failed to construct HKDF label: %s", err))
11871167 }
@@ -1412,7 +1392,7 @@ index 08452c7b1d..0732db0662 100644
14121392
14131393 crypto/internal/alias
14141394@@ -427,11 +429,13 @@ var depsRules = `
1415- crypto/sha512
1395+ golang.org/x/ crypto/sha3
14161396 < CRYPTO;
14171397
14181398- CGO, fmt, net !< CRYPTO;
@@ -1424,8 +1404,8 @@ index 08452c7b1d..0732db0662 100644
14241404 < crypto/internal/boring/bbig
14251405+ < crypto/internal/backend/bbig
14261406 < crypto/rand
1407+ < crypto/internal/mlkem768
14271408 < crypto/ed25519
1428- < encoding/asn1
14291409@@ -629,6 +633,7 @@ func listStdPkgs(goroot string) ([]string, error) {
14301410 }
14311411
@@ -1452,66 +1432,6 @@ index 08452c7b1d..0732db0662 100644
14521432 haveImport["C"] = true // kludge: prevent C from appearing in crypto/internal/boring imports
14531433 }
14541434 fset := token.NewFileSet()
1455- diff --git a/src/runtime/pprof/proto_test.go b/src/runtime/pprof/proto_test.go
1456- index 780b481de8..63db9e9ed7 100644
1457- --- a/src/runtime/pprof/proto_test.go
1458- +++ b/src/runtime/pprof/proto_test.go
1459- @@ -15,6 +15,7 @@ import (
1460- "os/exec"
1461- "reflect"
1462- "runtime"
1463- + "strconv"
1464- "strings"
1465- "testing"
1466- "unsafe"
1467- @@ -95,11 +96,15 @@ func testPCs(t *testing.T) (addr1, addr2 uint64, map1, map2 *profile.Mapping) {
1468- // region of memory.
1469- t.Skipf("need 2 or more mappings, got %v", len(mprof.Mapping))
1470- }
1471- - addr1 = mprof.Mapping[0].Start
1472- + addr1 = findAddrInExecutableSection(t, mmap, mprof.Mapping[0])
1473- map1 = mprof.Mapping[0]
1474- + map1.Offset = (addr1 - map1.Start) + map1.Offset
1475- + map1.Start = addr1
1476- map1.BuildID, _ = elfBuildID(map1.File)
1477- - addr2 = mprof.Mapping[1].Start
1478- + addr2 = findAddrInExecutableSection(t, mmap, mprof.Mapping[1])
1479- map2 = mprof.Mapping[1]
1480- + map2.Offset = (addr2 - map2.Start) + map2.Offset
1481- + map2.Start = addr2
1482- map2.BuildID, _ = elfBuildID(map2.File)
1483- case "windows", "darwin", "ios":
1484- addr1 = uint64(abi.FuncPCABIInternal(f1))
1485- @@ -145,6 +150,29 @@ func testPCs(t *testing.T) (addr1, addr2 uint64, map1, map2 *profile.Mapping) {
1486- return
1487- }
1488-
1489- + func findAddrInExecutableSection(t *testing.T, mmap []byte, m *profile.Mapping) uint64 {
1490- + mappings := strings.Split(string(mmap), "\n")
1491- + for _, mapping := range mappings {
1492- + parts := strings.Fields(mapping)
1493- + if len(parts) < 6 {
1494- + continue
1495- + }
1496- + if !strings.Contains(parts[1], "x") {
1497- + continue
1498- + }
1499- + addr, err := strconv.ParseUint(strings.Split(parts[0], "-")[0], 16, 64)
1500- + if err != nil {
1501- + t.Fatal(err)
1502- + }
1503- + if addr >= m.Start && addr < m.Limit {
1504- + return addr
1505- + }
1506- + }
1507- +
1508- + t.Error("could not find executable section in /proc/self/maps")
1509- + return 0
1510- + }
1511- +
1512- func TestConvertCPUProfile(t *testing.T) {
1513- addr1, addr2, map1, map2 := testPCs(t)
1514-
15151435diff --git a/src/runtime/runtime_boring.go b/src/runtime/runtime_boring.go
15161436index 5a98b20253..dc25cdcfd5 100644
15171437--- a/src/runtime/runtime_boring.go
0 commit comments