1
2
3
4
5 package fips140
6
7 import (
8 "crypto/internal/fips140"
9 "crypto/internal/fips140/check"
10 "internal/godebug"
11 )
12
13 var fips140GODEBUG = godebug.New("#fips140")
14
15
16
17
18
19
20
21
22
23 func Enabled() bool {
24 godebug := fips140GODEBUG.Value()
25 currentlyEnabled := godebug == "on" || godebug == "only" || godebug == "debug"
26 if currentlyEnabled != fips140.Enabled {
27 panic("crypto/fips140: GODEBUG setting changed after program start")
28 }
29 if fips140.Enabled && !check.Verified {
30 panic("crypto/fips140: FIPS 140-3 mode enabled, but integrity check didn't pass")
31 }
32 return fips140.Enabled
33 }
34
View as plain text