Documentation ¶
Overview ¶
Package fasthmacsha implements the Keyed-Hash Message Authentication Code (HMAC) as defined in U.S. Federal Information Processing Standards Publication 198. An HMAC is a cryptographic hash that uses a key to sign a message. The receiver verifies the hash by recomputing it using the same key.
Receivers should be careful to use Equal to compare MACs in order to avoid timing side-channels:
// ValidMAC reports whether messageMAC is a valid HMAC tag for message. func ValidMAC(message, messageMAC, key []byte) bool { mac := hmac.New(sha256.New, key) mac.Write(message) expectedMAC := mac.Sum(nil) return hmac.Equal(messageMAC, expectedMAC) }
Index ¶
- Variables
- func AcquireDefaultHighway256() hash.Hash
- func AcquireSHA1() *sha1.Digest
- func AcquireSHA1Tuple() *[2]*sha1.Digest
- func AcquireSHA256() *sha256.Digest
- func AcquireSHA256Tuple() *[2]*sha256.Digest
- func AcquireSHA512() *sha512.Digest
- func AcquireSHA512Tuple() *[2]*sha512.Digest
- func Equal(mac1, mac2 []byte) bool
- func HMACHighway256(salt, key, in, out []byte) ([]byte, error)
- func HMACHighway256DefaultSalt(key, in, out []byte) ([]byte, error)
- func HMACSHA1(key, in, out []byte) ([]byte, error)
- func HMACSHA256(key, in, out []byte) ([]byte, error)
- func HMACSHA512(key, in, out []byte) ([]byte, error)
- func New(h func() hash.Hash, key []byte) hash.Hash
- func ReleaseDefaultHighway256(h hash.Hash)
- func ReleaseSHA1(d *sha1.Digest)
- func ReleaseSHA1Tuple(d *[2]*sha1.Digest)
- func ReleaseSHA256(d *sha256.Digest)
- func ReleaseSHA256Tuple(d *[2]*sha256.Digest)
- func ReleaseSHA512(d *sha512.Digest)
- func ReleaseSHA512Tuple(d *[2]*sha512.Digest)
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultHighwayhash256Salt holds the default salt DefaultHighwayhash256Salt = [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31} )
Functions ¶
func AcquireSHA1Tuple ¶
AcquireSHA1Tuple acquires [2]*sha1.Digest
func AcquireSHA256Tuple ¶
AcquireSHA256Tuple acquires [2]*sha256.Digest
func AcquireSHA512Tuple ¶
AcquireSHA512Tuple acquires [2]*sha512.Digest
func HMACHighway256 ¶
HMACHighway256 does hmac + highway256
func HMACHighway256DefaultSalt ¶
HMACHighway256DefaultSalt does hmac + highwayhash256 but use default salt
func HMACSHA256 ¶
HMACSHA256 does hmac + sha256
func HMACSHA512 ¶
HMACSHA512 does hmac + sha512
func New ¶
New returns a new HMAC hash using the given hash.Hash type and key. Note that unlike other hash implementations in the standard library, the returned Hash does not implement encoding.BinaryMarshaler or encoding.BinaryUnmarshaler.
func ReleaseSHA1Tuple ¶
ReleaseSHA1Tuple releases [2]*sha1.Digest
func ReleaseSHA256Tuple ¶
ReleaseSHA256Tuple releases [2]*sha256.Digest
func ReleaseSHA512Tuple ¶
ReleaseSHA512Tuple releases [2]*sha512.Digest
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package sha1 implements the SHA-1 hash algorithm as defined in RFC 3174.
|
Package sha1 implements the SHA-1 hash algorithm as defined in RFC 3174. |
Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4.
|
Package sha256 implements the SHA224 and SHA256 hash algorithms as defined in FIPS 180-4. |
Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256 hash algorithms as defined in FIPS 180-4.
|
Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256 hash algorithms as defined in FIPS 180-4. |