Namespace: go.std.crypto.hmac
v1.0Contents
Summary
Provides a low-level interface to the crypto/hmac package.
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)
}
Index
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
Equal
Function v1.0(Equal mac1 mac2)
Equal compares two MACs for equality without leaking timing information.
Go input arguments: (mac1 []byte, mac2 []byte)
Go returns: bool
Joker input arguments: [^arrayOfByte mac1, ^arrayOfByte mac2]
Joker returns: ^Boolean
Types
-
(None.)