forked from notaryproject/notary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request notaryproject#1320 from justincormack/fips-test
Rework the FIPS mode detection
- Loading branch information
Showing
3 changed files
with
37 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package notary | ||
|
||
import "os" | ||
import ( | ||
"crypto" | ||
// Need to import md5 so can test availability. | ||
_ "crypto/md5" | ||
) | ||
|
||
// FIPSEnvVar is the name of the environment variable that is being used to switch | ||
// between FIPS and non-FIPS mode | ||
const FIPSEnvVar = "GOFIPS" | ||
|
||
// FIPSEnabled returns true if environment variable `GOFIPS` has been set to enable | ||
// FIPS mode | ||
// FIPSEnabled returns true if running in FIPS mode. | ||
// If compiled in FIPS mode the md5 hash function is never available | ||
// even when imported. This seems to be the best test we have for it. | ||
func FIPSEnabled() bool { | ||
return os.Getenv(FIPSEnvVar) != "" | ||
return !crypto.MD5.Available() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters