--- /dev/null
+// Copyright 2025 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.
+
+package cryptotest
+
+import (
+ "crypto/internal/fips140"
+ "testing"
+)
+
+func MustSupportFIPS140(t *testing.T) {
+ t.Helper()
+ if err := fips140.Supported(); err != nil {
+ t.Skipf("test requires FIPS 140 mode: %v", err)
+ }
+}
import (
"bytes"
- "crypto/internal/fips140"
+ "crypto/internal/cryptotest"
. "crypto/internal/fips140/check"
"crypto/internal/fips140/check/checktest"
"fmt"
t.Fatalf("GODEBUG=fips140=on but verification did not run")
}
- if err := fips140.Supported(); err != nil {
- t.Skipf("skipping: %v", err)
- }
+ cryptotest.MustSupportFIPS140(t)
cmd := testenv.Command(t, testenv.Executable(t), "-test.v", "-test.run=^TestIntegrityCheck$")
cmd.Env = append(cmd.Environ(), "GODEBUG=fips140=on")
func TestIntegrityCheckFailure(t *testing.T) {
moduleStatus(t)
testenv.MustHaveExec(t)
- if err := fips140.Supported(); err != nil {
- t.Skipf("skipping: %v", err)
- }
+ cryptotest.MustSupportFIPS140(t)
bin, err := os.ReadFile(os.Args[0])
if err != nil {
}
func TestIntegrityCheckInfo(t *testing.T) {
- if err := fips140.Supported(); err != nil {
- t.Skipf("skipping: %v", err)
- }
+ cryptotest.MustSupportFIPS140(t)
// Check that the checktest symbols are initialized properly.
if checktest.NOPTRDATA != 1 {