Source File
sha512.go
Belonging Package
crypto/sha512
// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256// hash algorithms as defined in FIPS 180-4.//// All the hash.Hash implementations returned by this package also// implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler to// marshal and unmarshal the internal state of the hash.package sha512import ()func () {crypto.RegisterHash(crypto.SHA384, New384)crypto.RegisterHash(crypto.SHA512, New)crypto.RegisterHash(crypto.SHA512_224, New512_224)crypto.RegisterHash(crypto.SHA512_256, New512_256)}const (// Size is the size, in bytes, of a SHA-512 checksum.Size = 64// Size224 is the size, in bytes, of a SHA-512/224 checksum.Size224 = 28// Size256 is the size, in bytes, of a SHA-512/256 checksum.Size256 = 32// Size384 is the size, in bytes, of a SHA-384 checksum.Size384 = 48// BlockSize is the block size, in bytes, of the SHA-512/224,// SHA-512/256, SHA-384 and SHA-512 hash functions.BlockSize = 128)// New returns a new [hash.Hash] computing the SHA-512 checksum. The Hash// also implements [encoding.BinaryMarshaler], [encoding.BinaryAppender] and// [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal// state of the hash.func () hash.Hash {if boring.Enabled {return boring.NewSHA512()}return sha512.New()}// New512_224 returns a new [hash.Hash] computing the SHA-512/224 checksum. The Hash// also implements [encoding.BinaryMarshaler], [encoding.BinaryAppender] and// [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal// state of the hash.func () hash.Hash {return sha512.New512_224()}// New512_256 returns a new [hash.Hash] computing the SHA-512/256 checksum. The Hash// also implements [encoding.BinaryMarshaler], [encoding.BinaryAppender] and// [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal// state of the hash.func () hash.Hash {return sha512.New512_256()}// New384 returns a new [hash.Hash] computing the SHA-384 checksum. The Hash// also implements [encoding.BinaryMarshaler], [encoding.BinaryAppender] and// [encoding.BinaryUnmarshaler] to marshal and unmarshal the internal// state of the hash.func () hash.Hash {if boring.Enabled {return boring.NewSHA384()}return sha512.New384()}// Sum512 returns the SHA512 checksum of the data.func ( []byte) [Size]byte {if boring.Enabled {return boring.SHA512()}:= New().Write()var [Size]byte.Sum([:0])return}// Sum384 returns the SHA384 checksum of the data.func ( []byte) [Size384]byte {if boring.Enabled {return boring.SHA384()}:= New384().Write()var [Size384]byte.Sum([:0])return}// Sum512_224 returns the Sum512/224 checksum of the data.func ( []byte) [Size224]byte {:= New512_224().Write()var [Size224]byte.Sum([:0])return}// Sum512_256 returns the Sum512/256 checksum of the data.func ( []byte) [Size256]byte {:= New512_256().Write()var [Size256]byte.Sum([:0])return}
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)