Source file src/crypto/internal/fips140only/hash_fips140v1.0.go

     1  // Copyright 2026 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  //go:build fips140v1.0 || fips140v1.26
     6  
     7  package fips140only
     8  
     9  import (
    10  	"crypto/internal/fips140/sha256"
    11  	"crypto/internal/fips140/sha3"
    12  	"crypto/internal/fips140/sha512"
    13  	"crypto/internal/fips140hash"
    14  	"hash"
    15  )
    16  
    17  // ApprovedHash reports whether h, after [fips140hash.Unwrap], is an approved
    18  // hash implementation from the FIPS 140-3 module.
    19  func ApprovedHash(h hash.Hash) bool {
    20  	switch fips140hash.Unwrap(h).(type) {
    21  	case *sha256.Digest, *sha512.Digest, *sha3.Digest:
    22  		return true
    23  	default:
    24  		return false
    25  	}
    26  }
    27  

View as plain text