]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.boringcrypto] all: add boringcrypto build tags
authorRuss Cox <rsc@golang.org>
Wed, 27 Apr 2022 13:02:52 +0000 (09:02 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 29 Apr 2022 14:23:22 +0000 (14:23 +0000)
A plain make.bash in this tree will produce a working,
standard Go toolchain, not a BoringCrypto-enabled one.

The BoringCrypto-enabled one will be created with:

GOEXPERIMENT=boringcrypto ./make.bash

For #51940.

Change-Id: Ia9102ed993242eb1cb7f9b93eca97e81986a27b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/395881
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
37 files changed:
api/go1.16.txt
misc/boring/release.sh
misc/cgo/testshared/shared_test.go
src/cmd/api/goapi_boring_test.go [new file with mode: 0644]
src/cmd/go/go_boring_test.go
src/cmd/link/internal/ld/lib.go
src/crypto/boring/boring.go
src/crypto/boring/boring_test.go
src/crypto/boring/notboring_test.go
src/crypto/ecdsa/boring.go
src/crypto/ecdsa/notboring.go [new file with mode: 0644]
src/crypto/internal/boring/Dockerfile
src/crypto/internal/boring/LICENSE
src/crypto/internal/boring/aes.go
src/crypto/internal/boring/boring.go
src/crypto/internal/boring/ecdsa.go
src/crypto/internal/boring/fipstls/stub.s [moved from src/crypto/internal/boring/fipstls/dummy.s with 94% similarity]
src/crypto/internal/boring/fipstls/tls.go
src/crypto/internal/boring/hmac.go
src/crypto/internal/boring/notboring.go
src/crypto/internal/boring/rand.go
src/crypto/internal/boring/rsa.go
src/crypto/internal/boring/sha.go
src/crypto/internal/boring/syso/goboringcrypto_linux_amd64.syso [moved from src/crypto/internal/boring/goboringcrypto_linux_amd64.syso with 100% similarity]
src/crypto/internal/boring/syso/syso.go [new file with mode: 0644]
src/crypto/rsa/boring.go
src/crypto/rsa/boring_test.go
src/crypto/rsa/notboring.go [new file with mode: 0644]
src/crypto/tls/boring.go
src/crypto/tls/boring_test.go
src/crypto/tls/fipsonly/fipsonly.go
src/crypto/tls/fipsonly/fipsonly_test.go
src/crypto/tls/handshake_client.go
src/crypto/tls/handshake_server.go
src/crypto/tls/notboring.go [new file with mode: 0644]
src/go/build/build.go
src/go/build/deps_test.go

index d9fb7e38843a70031016a833c0a417c73909a270..ce015fd6fb7ebdc8f7dfac932737d5ff18228fa9 100644 (file)
@@ -1,6 +1,5 @@
 pkg archive/zip, method (*ReadCloser) Open(string) (fs.File, error)
 pkg archive/zip, method (*Reader) Open(string) (fs.File, error)
-pkg crypto/boring, func Enabled() bool
 pkg crypto/x509, method (SystemRootsError) Unwrap() error
 pkg debug/elf, const DT_ADDRRNGHI = 1879047935
 pkg debug/elf, const DT_ADDRRNGHI DynTag
index 6ab440c91bf8f8c3a8368ec88f59ec7f84842d4b..6e72a56192a033f07603a0a2a1c2e432ef6022d5 100755 (executable)
@@ -18,7 +18,7 @@ git fetch
 git worktree add --track -b "$BRANCH" "$WORKTREE" origin/dev.boringcrypto
 
 cd "$WORKTREE/src"
-./make.bash
+GOEXPERIMENT=boringcrypto ./make.bash
 
 cd ../misc/boring
 for branch in "$@"; do
index b78083bc80638a2a476501e37e6ca630634c16a3..616630979c1bd2af0574078dfb3160328152e133 100644 (file)
@@ -57,7 +57,7 @@ func runWithEnv(t *testing.T, msg string, env []string, args ...string) {
 func goCmd(t *testing.T, args ...string) string {
        newargs := []string{args[0]}
        if *testX && args[0] != "env" {
-               newargs = append(newargs, "-x")
+               newargs = append(newargs, "-x", "-ldflags=-v")
        }
        newargs = append(newargs, args[1:]...)
        c := exec.Command("go", newargs...)
diff --git a/src/cmd/api/goapi_boring_test.go b/src/cmd/api/goapi_boring_test.go
new file mode 100644 (file)
index 0000000..f0e3575
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build boringcrypto
+
+package main
+
+import (
+       "fmt"
+       "os"
+)
+
+func init() {
+       fmt.Printf("SKIP with boringcrypto enabled\n")
+       os.Exit(0)
+}
index 0000497f0612f95aeae31bb9f699f0cfa14c73e1..ed0fbf3d53d75b19133c3b9f59c1d1b8fb4cc8cc 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package main_test
 
 import "testing"
index 5103e55e00f333000705ae67e6e67881179ec875..680f509ec57ac06305fc066459312ed82c00cf90 100644 (file)
@@ -1060,6 +1060,7 @@ var hostobj []Hostobj
 // Others trigger external mode.
 var internalpkg = []string{
        "crypto/internal/boring",
+       "crypto/internal/boring/syso",
        "crypto/x509",
        "net",
        "os/user",
index 19e2a0876f757d5035e43c4eb279221c2d0f7e7f..097c37e343fdb833dc2c1bb2c5c777d3dbe100ff 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 // Package boring exposes functions that are only available when building with
 // Go+BoringCrypto. This package is available on all targets as long as the
 // Go+BoringCrypto toolchain is used. Use the Enabled function to determine
index ace50de0c2b49ad952ad6e76751b310a4760dbc4..9e8fd353b7feaf8aab7ad7ccf262878fb150b387 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package boring_test
 
 import (
index e69a3a93fdf79bcb367d23fe61228945dab07474..ffe18e9109ab0bf8cabcab534675feab1a8a5975 100644 (file)
@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !boringcrypto
-// +build !boringcrypto
+//go:build (goexperiment.boringcrypto && !boringcrypto) || (!goexperiment.boringcrypto && boringcrypto)
+// +build goexperiment.boringcrypto,!boringcrypto !goexperiment.boringcrypto,boringcrypto
 
 package boring_test
 
 import "testing"
 
 func TestNotBoring(t *testing.T) {
-       t.Error("a file tagged !boringcrypto should not build under Go+BoringCrypto")
+       t.Error("goexperiment.boringcrypto and boringcrypto should be equivalent build tags")
 }
index fa15ecb850298a643023a59277cbf43c18b69320..d7de5c96e5387759f89e0c3332c4531ac8c74476 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package ecdsa
 
 import (
diff --git a/src/crypto/ecdsa/notboring.go b/src/crypto/ecdsa/notboring.go
new file mode 100644 (file)
index 0000000..039bd82
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !boringcrypto
+
+package ecdsa
+
+import "crypto/internal/boring"
+
+func boringPublicKey(*PublicKey) (*boring.PublicKeyECDSA, error) {
+       panic("boringcrypto: not available")
+}
+func boringPrivateKey(*PrivateKey) (*boring.PrivateKeyECDSA, error) {
+       panic("boringcrypto: not available")
+}
index dab7c85f7c591fea3effa254cc942595b976371b..5bd7438f694e898cdf7cfff89257b6b93469d29f 100644 (file)
@@ -8,8 +8,8 @@
 #
 #   $ podman build -t goboring:140sp3678 .
 #   $ podman run -it --name goboring-140sp3678 goboring:140sp3678
-#   $ podman cp goboring-140sp3678:/boring/godriver/goboringcrypto_linux_amd64.syso .
-#   $ sha256sum goboringcrypto_linux_amd64.syso # compare to docker output
+#   $ podman cp goboring-140sp3678:/boring/godriver/goboringcrypto_linux_amd64.syso syso
+#   $ sha256sum syso/goboringcrypto_linux_amd64.syso # compare to docker output
 #
 # The podman commands may need to run under sudo to work around a subuid/subgid bug.
 
index fc103a79d4a1846c34cc06669f71e662b72618ce..38990bdb771494d437782101a5b5d479e5f320ca 100644 (file)
@@ -1,6 +1,8 @@
 The Go source code and supporting files in this directory
 are covered by the usual Go license (see ../../../../LICENSE).
 
+When building with GOEXPERIMENT=boringcrypto, the following applies.
+
 The goboringcrypto_linux_amd64.syso object file is built
 from BoringSSL source code by build/build.sh and is covered
 by the BoringSSL license reproduced below and also at
@@ -40,7 +42,7 @@ record keeping.)
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
@@ -95,21 +97,21 @@ record keeping.)
  * This package is an SSL implementation written
  * by Eric Young (eay@cryptsoft.com).
  * The implementation was written so as to conform with Netscapes SSL.
- * 
+ *
  * This library is free for commercial and non-commercial use as long as
  * the following conditions are aheared to.  The following conditions
  * apply to all code found in this distribution, be it the RC4, RSA,
  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
  * included with this distribution is covered by the same copyright terms
  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- * 
+ *
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
  * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -124,10 +126,10 @@ record keeping.)
  *     Eric Young (eay@cryptsoft.com)"
  *    The word 'cryptographic' can be left out if the rouines from the library
  *    being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from 
+ * 4. If you include any Windows specific code (or a derivative thereof) from
  *    the apps directory (application code) you must include an acknowledgement:
  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -139,7 +141,7 @@ record keeping.)
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- * 
+ *
  * The licence and distribution terms for any publically available version or
  * derivative of this code cannot be changed.  i.e. this code cannot simply be
  * copied and put under another distribution licence
index b5d360151cc300041924b8f47816d748f294ffbe..515b60bb8a3fe3fb99f3735e29a8761a614f671c 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
index b8804ceb68c259c19582509ed06269332380dbf8..29e0baa1315e4b8c59c9f45ee4f68fa7ce134d60 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
@@ -16,6 +16,7 @@ package boring
 import "C"
 import (
        "crypto/internal/boring/sig"
+       _ "crypto/internal/boring/syso"
        "math/big"
 )
 
index b9c68a97afffd7ebfdee332c07d36f7ee05e30ae..20612e6a2c042b12c26c59f831d618298dde3099 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
similarity index 94%
rename from src/crypto/internal/boring/fipstls/dummy.s
rename to src/crypto/internal/boring/fipstls/stub.s
index 53bb7d943080118588aaebc27836dec1722ab05f..f2e5a503eaacb6d9e568ce7d5798adb8b51d9f36 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 // runtime_arg0 is declared in tls.go without a body.
 // It's provided by package runtime,
 // but the go command doesn't know that.
index 4127533fbd519ce8c09a0c41694c920fbff58fd9..701700e4e3ab36b5e57af7ebc0103b88c6f3248e 100644 (file)
@@ -2,8 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 // Package fipstls allows control over whether crypto/tls requires FIPS-approved settings.
-// This package's effects are independent of the use of the BoringCrypto implementation.
+// This package only exists with GOEXPERIMENT=boringcrypto, but the effects are independent
+// of the use of BoringCrypto.
 package fipstls
 
 import "sync/atomic"
index be0670c05a4ce0068280de912e259629c09f4456..c36fe6b26c48975129fdd40b30be118259a64bc8 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
index 2e2414c73b1ffedfcce275806dfe49c9ce22a88e..be1dd4b8fcb8edc7185f28292faf88aa2bb263b0 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !linux || !amd64 || !cgo || android || cmd_go_bootstrap || msan
-// +build !linux !amd64 !cgo android cmd_go_bootstrap msan
+//go:build !boringcrypto || !linux || !amd64 || !cgo || android || cmd_go_bootstrap || msan
+// +build !boringcrypto !linux !amd64 !cgo android cmd_go_bootstrap msan
 
 package boring
 
index 57937eb3c8d98c7dc2d6063e2566e3b2c94e4d04..d2e432e7b77c0b825c66ee04a63f1b40da969cd0 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
index 327dfa0309ef10dfb0e7b11d77f2213e464ee5b4..642287709e5c157046d0c6dc1ca37af891563de9 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
index 4672119df1b467499167ae6fe98377c71511deba..ba0cc2903429df18685cac7022e43a19a84fb930 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build linux && amd64 && !android && !cmd_go_bootstrap && !msan
-// +build linux,amd64,!android,!cmd_go_bootstrap,!msan
+//go:build boringcrypto && linux && amd64 && !android && !cmd_go_bootstrap && !msan
+// +build boringcrypto,linux,amd64,!android,!cmd_go_bootstrap,!msan
 
 package boring
 
diff --git a/src/crypto/internal/boring/syso/syso.go b/src/crypto/internal/boring/syso/syso.go
new file mode 100644 (file)
index 0000000..b338754
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build boringcrypto
+
+// This package only exists with GOEXPERIMENT=boringcrypto.
+// It provides the actual syso file.
+package syso
index 0f362a2f165bd2a1480c3ec0b12046be047fd98a..49a195f0f4e2634756e625035d63e3ecc26e74fe 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package rsa
 
 import (
index 11dcdf88fd0e09ce43e7885139fcb82d09da5b89..1373da99374503e15cd8d3dbdacaca9c38140239 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 // Note: Can run these tests against the non-BoringCrypto
 // version of the code by using "CGO_ENABLED=0 go test".
 
diff --git a/src/crypto/rsa/notboring.go b/src/crypto/rsa/notboring.go
new file mode 100644 (file)
index 0000000..2abc043
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !boringcrypto
+
+package rsa
+
+import "crypto/internal/boring"
+
+func boringPublicKey(*PublicKey) (*boring.PublicKeyRSA, error) {
+       panic("boringcrypto: not available")
+}
+func boringPrivateKey(*PrivateKey) (*boring.PrivateKeyRSA, error) {
+       panic("boringcrypto: not available")
+}
index dabc67423dca9b59d68f153d3784ae4ca9d49bdb..c40d4a0e484ae0582b7ce8126c25dfd8748369c9 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package tls
 
 import (
@@ -124,5 +126,3 @@ func supportedSignatureAlgorithms() []SignatureScheme {
        }
        return fipsSupportedSignatureAlgorithms
 }
-
-var testingOnlyForceClientHelloSignatureAlgorithms []SignatureScheme
index 8dd477a021484be8e2d28e5dd14b2d5463e5c4ee..12a7d937cb3640120cbc37eb83836b8c5ea75151 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package tls
 
 import (
index 85b3532d26dbe0ab3793cb5b74dd7594b5f2ed23..e5e47835e2f48dc9b9f492d3d9af76d3404b1240 100644 (file)
@@ -2,13 +2,15 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 // Package fipsonly restricts all TLS configuration to FIPS-approved settings.
 //
 // The effect is triggered by importing the package anywhere in a program, as in:
 //
 //     import _ "crypto/tls/fipsonly"
 //
-// This package only exists in the dev.boringcrypto branch of Go.
+// This package only exists when using Go compiled with GOEXPERIMENT=boringcrypto.
 package fipsonly
 
 // This functionality is provided as a side effect of an import to make
index facd24807dccccd867e5e1a7b4bc73b44f3ccd8f..f8485dc3ca1c295d196ebb69e315ea475fd47962 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build boringcrypto
+
 package fipsonly
 
 import (
index 7bf0f84417c767a430bc02f605b1f51f384b480f..de19b7ede5743ce19673bbf31bbd7a0a22d121fc 100644 (file)
@@ -34,6 +34,8 @@ type clientHandshakeState struct {
        session      *ClientSessionState
 }
 
+var testingOnlyForceClientHelloSignatureAlgorithms []SignatureScheme
+
 func (c *Conn) makeClientHello() (*clientHelloMsg, ecdheParameters, error) {
        config := c.config
        if len(config.ServerName) == 0 && !config.InsecureSkipVerify {
@@ -859,13 +861,14 @@ func (c *Conn) verifyServerCertificate(certificates [][]byte) error {
 
        if !c.config.InsecureSkipVerify {
                opts := x509.VerifyOptions{
-                       IsBoring: isBoringCertificate,
-
                        Roots:         c.config.RootCAs,
                        CurrentTime:   c.config.time(),
                        DNSName:       c.config.ServerName,
                        Intermediates: x509.NewCertPool(),
                }
+               if needFIPS() {
+                       opts.IsBoring = isBoringCertificate
+               }
                for _, cert := range certs[1:] {
                        opts.Intermediates.AddCert(cert)
                }
index 5db605681e46ac948b8cdfe9324a0641c3558768..2d71d0869a11e133f54ede3c183f2d3132b48654 100644 (file)
@@ -812,13 +812,14 @@ func (c *Conn) processCertsFromClient(certificate Certificate) error {
 
        if c.config.ClientAuth >= VerifyClientCertIfGiven && len(certs) > 0 {
                opts := x509.VerifyOptions{
-                       IsBoring: isBoringCertificate,
-
                        Roots:         c.config.ClientCAs,
                        CurrentTime:   c.config.time(),
                        Intermediates: x509.NewCertPool(),
                        KeyUsages:     []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
                }
+               if needFIPS() {
+                       opts.IsBoring = isBoringCertificate
+               }
 
                for _, cert := range certs[1:] {
                        opts.Intermediates.AddCert(cert)
diff --git a/src/crypto/tls/notboring.go b/src/crypto/tls/notboring.go
new file mode 100644 (file)
index 0000000..d79ea21
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !boringcrypto
+
+package tls
+
+import "crypto/x509"
+
+func needFIPS() bool { return false }
+
+func supportedSignatureAlgorithms() []SignatureScheme {
+       return defaultSupportedSignatureAlgorithms
+}
+
+func fipsMinVersion(c *Config) uint16              { panic("fipsMinVersion") }
+func fipsMaxVersion(c *Config) uint16              { panic("fipsMaxVersion") }
+func fipsCurvePreferences(c *Config) []CurveID     { panic("fipsCurvePreferences") }
+func fipsCipherSuites(c *Config) []uint16          { panic("fipsCipherSuites") }
+func isBoringCertificate(c *x509.Certificate) bool { panic("isBoringCertificate") }
+
+var fipsSupportedSignatureAlgorithms []SignatureScheme
index f40b4866350ee13f616ad3a846504f23ab72ef69..b373feab3316b6d938c2665ccdb113cd9bee692a 100644 (file)
@@ -1907,9 +1907,8 @@ func (ctxt *Context) matchTag(name string, allTags map[string]bool) bool {
        if name == "unix" && unixOS[ctxt.GOOS] {
                return true
        }
-       // Let applications know that the Go+BoringCrypto toolchain is in use.
        if name == "boringcrypto" {
-               return true
+               name = "goexperiment.boringcrypto" // boringcrypto is an old name for goexperiment.boringcrypto
        }
 
        // other tags
index 651257a3577e45371960b774b9eda55dd9087520..d955081869cc4f69263e8a6fb1b48b3e03b2e25f 100644 (file)
@@ -397,12 +397,12 @@ var depsRules = `
        NET, log
        < net/mail;
 
-       NONE < crypto/internal/boring/sig;
+       NONE < crypto/internal/boring/sig, crypto/internal/boring/syso;
        sync/atomic < crypto/internal/boring/fipstls;
 
        encoding/binary, golang.org/x/sys/cpu, hash,
        FMT, math/big, embed,
-       CGO, crypto/internal/boring/sig, crypto/internal/boring/fipstls
+       CGO, crypto/internal/boring/sig, crypto/internal/boring/fipstls, crypto/internal/boring/syso
        < crypto
        < crypto/subtle
        < crypto/internal/subtle