Skip to content

Commit 8ff4cee

Browse files
FiloSottilegopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Russ Cox <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent 971448d commit 8ff4cee

File tree

6 files changed

+25
-0
lines changed

6 files changed

+25
-0
lines changed

src/cmd/go/internal/fips140/fips140.go

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ func Init() {
119119
if Snapshot() {
120120
fsys.Bind(Dir(), filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140"))
121121
}
122+
123+
if cfg.Experiment.BoringCrypto && Enabled() {
124+
base.Fatalf("go: cannot use GOFIPS140 with GOEXPERIMENT=boringcrypto")
125+
}
122126
}
123127

124128
var initDone bool

src/cmd/go/testdata/script/env_changed.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Test query for non-defaults in the env
22

3+
# Go+BoringCrypto conflicts with GOFIPS140.
4+
[GOEXPERIMENT:boringcrypto] skip
5+
36
env GOROOT=./a
47
env GOTOOLCHAIN=local
58
env GOSUMDB=nodefault

src/cmd/go/testdata/script/fips.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Go+BoringCrypto conflicts with GOFIPS140.
2+
[GOEXPERIMENT:boringcrypto] skip
3+
14
# list with GOFIPS140=off
25
env GOFIPS140=off
36
go list -f '{{.DefaultGODEBUG}}'

src/cmd/go/testdata/script/fipssnap.txt

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ env alias=inprocess
77
skip 'no snapshots yet'
88
env GOFIPS140=$snap
99

10+
# Go+BoringCrypto conflicts with GOFIPS140.
11+
[GOEXPERIMENT:boringcrypto] skip
12+
1013
# default GODEBUG includes fips140=on
1114
go list -f '{{.DefaultGODEBUG}}'
1215
stdout fips140=on

src/crypto/internal/boring/boring.go

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import "C"
1616
import (
1717
"crypto/internal/boring/sig"
1818
_ "crypto/internal/boring/syso"
19+
"crypto/internal/fips140"
1920
"internal/stringslite"
2021
"math/bits"
2122
"unsafe"
@@ -31,6 +32,12 @@ func init() {
3132
sig.BoringCrypto()
3233
}
3334

35+
func init() {
36+
if fips140.Enabled {
37+
panic("boringcrypto: cannot use GODEBUG=fips140 with GOEXPERIMENT=boringcrypto")
38+
}
39+
}
40+
3441
// Unreachable marks code that should be unreachable
3542
// when BoringCrypto is in use. It panics.
3643
func Unreachable() {

src/crypto/internal/fips140test/check_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package fipstest
66

77
import (
8+
"crypto/internal/boring"
89
. "crypto/internal/fips140/check"
910
"crypto/internal/fips140/check/checktest"
1011
"fmt"
@@ -22,6 +23,10 @@ import (
2223
const enableFIPSTest = true
2324

2425
func TestFIPSCheckVerify(t *testing.T) {
26+
if boring.Enabled {
27+
t.Skip("not testing fips140 with boringcrypto enabled")
28+
}
29+
2530
if Verified {
2631
t.Logf("verified")
2732
return

0 commit comments

Comments
 (0)