Skip to content

Commit

Permalink
[dev.boringcrypto] all: add boringcrypto build tags
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
rsc committed Apr 29, 2022
1 parent 1f0547c commit f4c0f42
Show file tree
Hide file tree
Showing 37 changed files with 153 additions and 43 deletions.
1 change: 0 additions & 1 deletion api/go1.16.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion misc/boring/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion misc/cgo/testshared/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
17 changes: 17 additions & 0 deletions src/cmd/api/goapi_boring_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 2 additions & 0 deletions src/cmd/go/go_boring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/cmd/link/internal/ld/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/boring/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/boring/boring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions src/crypto/boring/notboring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 2 additions & 0 deletions src/crypto/ecdsa/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
16 changes: 16 additions & 0 deletions src/crypto/ecdsa/notboring.go
Original file line number Diff line number Diff line change
@@ -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")
}
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
16 changes: 9 additions & 7 deletions src/crypto/internal/boring/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -95,21 +97,21 @@ record keeping.)
* This package is an SSL implementation written
* by Eric Young ([email protected]).
* 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 ([email protected]).
*
*
* 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:
Expand All @@ -124,10 +126,10 @@ record keeping.)
* Eric Young ([email protected])"
* 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 ([email protected])"
*
*
* 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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/aes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions src/crypto/internal/boring/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -16,6 +16,7 @@ package boring
import "C"
import (
"crypto/internal/boring/sig"
_ "crypto/internal/boring/syso"
"math/big"
)

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion src/crypto/internal/boring/fipstls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/notboring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/crypto/internal/boring/sha.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/crypto/internal/boring/syso/syso.go
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/crypto/rsa/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/rsa/boring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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".

Expand Down
16 changes: 16 additions & 0 deletions src/crypto/rsa/notboring.go
Original file line number Diff line number Diff line change
@@ -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")
}
4 changes: 2 additions & 2 deletions src/crypto/tls/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -124,5 +126,3 @@ func supportedSignatureAlgorithms() []SignatureScheme {
}
return fipsSupportedSignatureAlgorithms
}

var testingOnlyForceClientHelloSignatureAlgorithms []SignatureScheme
2 changes: 2 additions & 0 deletions src/crypto/tls/boring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading

0 comments on commit f4c0f42

Please sign in to comment.