package hmac
Import Path
github.com/pion/stun/internal/hmac (on go.dev)
Dependency Relation
imports 5 packages, and imported by one package
Involved Source Files
Package hmac 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)
}
pool.go
Package-Level Functions (total 6)
AcquireSHA1 returns new HMAC from pool.
AcquireSHA256 returns new HMAC from SHA256 pool.
Equal compares two MACs for equality without leaking timing information.
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.
PutSHA1 puts h to pool.
PutSHA256 puts h to SHA256 pool.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |