Source file src/crypto/internal/fips140only/fips140only.go
1 // Copyright 2024 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package fips140only 6 7 import ( 8 "crypto/fips140" 9 "crypto/internal/fips140/sha256" 10 "crypto/internal/fips140/sha3" 11 "crypto/internal/fips140/sha512" 12 "hash" 13 ) 14 15 // Enforced reports whether FIPS 140-only mode is enabled and enforced, in which non-approved 16 // cryptography returns an error or panics. 17 func Enforced() bool { 18 return fips140.Enforced() 19 } 20 21 func ApprovedHash(h hash.Hash) bool { 22 switch h.(type) { 23 case *sha256.Digest, *sha512.Digest, *sha3.Digest: 24 return true 25 default: 26 return false 27 } 28 } 29