mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go,crypto: reject using Go+BoringCrypto and fips140 together
The combination is untested and nonsensical. Both are solutions to the same problem. For #69536 Change-Id: I95cc3baaf03b64ce08096e304e311a29e9577385 Reviewed-on: https://go-review.googlesource.com/c/go/+/637177 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
971448ddf8
commit
8ff4cee564
6 changed files with 25 additions and 0 deletions
|
|
@ -119,6 +119,10 @@ func Init() {
|
||||||
if Snapshot() {
|
if Snapshot() {
|
||||||
fsys.Bind(Dir(), filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140"))
|
fsys.Bind(Dir(), filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.Experiment.BoringCrypto && Enabled() {
|
||||||
|
base.Fatalf("go: cannot use GOFIPS140 with GOEXPERIMENT=boringcrypto")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var initDone bool
|
var initDone bool
|
||||||
|
|
|
||||||
3
src/cmd/go/testdata/script/env_changed.txt
vendored
3
src/cmd/go/testdata/script/env_changed.txt
vendored
|
|
@ -1,5 +1,8 @@
|
||||||
# Test query for non-defaults in the env
|
# Test query for non-defaults in the env
|
||||||
|
|
||||||
|
# Go+BoringCrypto conflicts with GOFIPS140.
|
||||||
|
[GOEXPERIMENT:boringcrypto] skip
|
||||||
|
|
||||||
env GOROOT=./a
|
env GOROOT=./a
|
||||||
env GOTOOLCHAIN=local
|
env GOTOOLCHAIN=local
|
||||||
env GOSUMDB=nodefault
|
env GOSUMDB=nodefault
|
||||||
|
|
|
||||||
3
src/cmd/go/testdata/script/fips.txt
vendored
3
src/cmd/go/testdata/script/fips.txt
vendored
|
|
@ -1,3 +1,6 @@
|
||||||
|
# Go+BoringCrypto conflicts with GOFIPS140.
|
||||||
|
[GOEXPERIMENT:boringcrypto] skip
|
||||||
|
|
||||||
# list with GOFIPS140=off
|
# list with GOFIPS140=off
|
||||||
env GOFIPS140=off
|
env GOFIPS140=off
|
||||||
go list -f '{{.DefaultGODEBUG}}'
|
go list -f '{{.DefaultGODEBUG}}'
|
||||||
|
|
|
||||||
3
src/cmd/go/testdata/script/fipssnap.txt
vendored
3
src/cmd/go/testdata/script/fipssnap.txt
vendored
|
|
@ -7,6 +7,9 @@ env alias=inprocess
|
||||||
skip 'no snapshots yet'
|
skip 'no snapshots yet'
|
||||||
env GOFIPS140=$snap
|
env GOFIPS140=$snap
|
||||||
|
|
||||||
|
# Go+BoringCrypto conflicts with GOFIPS140.
|
||||||
|
[GOEXPERIMENT:boringcrypto] skip
|
||||||
|
|
||||||
# default GODEBUG includes fips140=on
|
# default GODEBUG includes fips140=on
|
||||||
go list -f '{{.DefaultGODEBUG}}'
|
go list -f '{{.DefaultGODEBUG}}'
|
||||||
stdout fips140=on
|
stdout fips140=on
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import "C"
|
||||||
import (
|
import (
|
||||||
"crypto/internal/boring/sig"
|
"crypto/internal/boring/sig"
|
||||||
_ "crypto/internal/boring/syso"
|
_ "crypto/internal/boring/syso"
|
||||||
|
"crypto/internal/fips140"
|
||||||
"internal/stringslite"
|
"internal/stringslite"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
@ -31,6 +32,12 @@ func init() {
|
||||||
sig.BoringCrypto()
|
sig.BoringCrypto()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if fips140.Enabled {
|
||||||
|
panic("boringcrypto: cannot use GODEBUG=fips140 with GOEXPERIMENT=boringcrypto")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unreachable marks code that should be unreachable
|
// Unreachable marks code that should be unreachable
|
||||||
// when BoringCrypto is in use. It panics.
|
// when BoringCrypto is in use. It panics.
|
||||||
func Unreachable() {
|
func Unreachable() {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package fipstest
|
package fipstest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/internal/boring"
|
||||||
. "crypto/internal/fips140/check"
|
. "crypto/internal/fips140/check"
|
||||||
"crypto/internal/fips140/check/checktest"
|
"crypto/internal/fips140/check/checktest"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -22,6 +23,10 @@ import (
|
||||||
const enableFIPSTest = true
|
const enableFIPSTest = true
|
||||||
|
|
||||||
func TestFIPSCheckVerify(t *testing.T) {
|
func TestFIPSCheckVerify(t *testing.T) {
|
||||||
|
if boring.Enabled {
|
||||||
|
t.Skip("not testing fips140 with boringcrypto enabled")
|
||||||
|
}
|
||||||
|
|
||||||
if Verified {
|
if Verified {
|
||||||
t.Logf("verified")
|
t.Logf("verified")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue