// DigestSHA256Sum uses SHA256 digest to create the key which is the default behaviour since OpenSSL 1.1.0c
966758
func DigestSHA256Sum(data []byte) []byte {
	h := sha256.New()
	h.Write(data)
	return h.Sum(nil)
}
1180142
func Sum256s(out *[32]byte, msg, key []byte) {
	var (
		hVal  [8]uint32
		ctr   [2]uint32
		block [blake2s.BlockSize]byte
		off   int
	)
	hVal = hVal256s

	if k := len(key); k > 0 {
		hVal[0] ^= uint32(k) << 8 // mixin key-length

		copy(block[:], key)
		off = blake2s.BlockSize
		if len(msg) > 0 {
			blake2s.Core(&hVal, &ctr, blake2s.MsgFlag, block[:])
			off = 0
		}
	}

	if length := len(msg); length > blake2s.BlockSize {
		n := length & (^(blake2s.BlockSize - 1)) // length -= (length % BlockSize)
		if length == n {
			n -= blake2s.BlockSize
		}
		blake2s.Core(&hVal, &ctr, blake2s.MsgFlag, msg[:n])
		msg = msg[n:]
	}

	if len(msg) > 0 {
		off += copy(block[:], msg)
	}

	blake2s.ExtractHash(out, &hVal, &ctr, &block, off)
}
126618
func Sum256(data []byte) (result [Size]byte) {
	var d digest
	d.Reset()
	d.Write(data)
	result = d.checkSum()
	return
}
112269
func (s *BuildArtifacts) SetSha256sum(v string) *BuildArtifacts {
	s.Sha256sum = &v
	return s
}
968950
func DigestNameToCryptoHash(name string) (result crypto.Hash, err error) {
	var supported bool
	if result, supported = supportedAlgorithms[name]; !supported {
		err = errors.New("hmacauth: hash algorithm not supported: " +
			name)
	}
	return
}
1180099
func correctSha256(hash []byte, cookieSecret, username, password string) bool {
	comparisonHash := hashSha256(cookieSecret, username, password)
	// check that the lengths are equal before calling ConstantTimeCompare
	if len(hash) != len(comparisonHash) {
		return false
	}
	// prevents timing attack
	return subtle.ConstantTimeCompare(hash, comparisonHash) == 1
}
1255786
func HmacSHA256(key, origData []byte) (sum []byte) {
	mac := hmac.New(sha256.New, key)
	mac.Write(origData)
	return mac.Sum(nil)
}
315042
func (s *State232) Sum(b []byte) []byte {
	s.hash = Hash232(s.tail, s.seed)
	h := s.hash
	return append(b, byte(h>>24), byte(h>>16), byte(h>>8), byte(h))
}
256845
func getSha256(input []byte) []byte {
	sha := sha256.New()
	sha.Write(input)
	return sha.Sum(nil)
}
1289583
func Sum512(data []byte) [Size]byte {
	d := digest{function: crypto.SHA512}
	d.Reset()
	d.Write(data)
	return d.checkSum()
}
231597
func HmacSHA1(key, origData []byte) (sum []byte) {
	mac := hmac.New(sha1.New, key)
	mac.Write(origData)
	return mac.Sum(nil)
}
793315
func HMACSHA256PRF(key []byte, data []byte) ([]byte, error) {
	hash := hmac.New(sha256.New, key)
	hash.Write(data)
	return hash.Sum(nil), nil
}
528914
func doubleSha256(b []byte) []byte {
	hasher := sha256.New()
	hasher.Write(b) // nolint: errcheck, gas
	sum := hasher.Sum(nil)
	hasher.Reset()
	hasher.Write(sum) // nolint: errcheck, gas
	return hasher.Sum(nil)
}
923194
func (s *PluginConstraints) AcceptsSHA256(digest []byte) bool {
	if s.SHA256 == nil {
		return true
	}
	return bytes.Equal(s.SHA256, digest)
}
970459
func Sha1Sum(fpath string) (string, error) {
	name := cleanPath(fpath)
	f, err := os.Open(name)
	if err != nil {
		return "", err
	}
	defer f.Close()
	reader := bufio.NewReader(f)
	sha1 := sha1.New()
	_, err = io.Copy(sha1, reader)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%x", sha1.Sum(nil)), nil
}
449380
func Sha256(b []byte) string {
	h := sha256.New()
	h.Write(b)
	return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
1102845
func NewPBKDF2SHA256Hasher() *PBKDF2Hasher {
	return &PBKDF2Hasher{
		Algorithm:  "pbkdf2_sha256",
		Iterations: 180000,
		Size:       sha256.Size,
		Digest:     sha256.New,
	}
}