Documentation
¶
Overview ¶
Package mac implements Families 3 and 4 (MAC and MAC with IV). Family 3: mac(), mac_verify() — HMAC-SHA256/384/512, HMAC-SHA3-256, AES-CMAC. Family 4: mac_iv(), mac_iv_verify() — AES-GMAC (requires nonce).
Index ¶
- Constants
- func Mac(key []byte, data []byte, algorithm string) ([]byte, error)
- func MacIV(key []byte, data []byte, algorithm string) (tag []byte, nonce []byte, err error)
- func MacIVVerify(key []byte, data []byte, nonce []byte, tag []byte, algorithm string) (bool, error)
- func MacVerify(key []byte, data []byte, tag []byte, algorithm string) (bool, error)
- func NewCMAC(block cipher.Block) (*cmac, error)
Constants ¶
const ( AlgorithmHMACSHA256 = "HMAC-SHA256" AlgorithmHMACSHA384 = "HMAC-SHA384" AlgorithmHMACSHA512 = "HMAC-SHA512" AlgorithmHMACSHA3_256 = "HMAC-SHA3-256" AlgorithmAESCMAC = "AES-CMAC" AlgorithmAESGMAC = "AES-GMAC" )
MAC algorithm identifiers.
Variables ¶
This section is empty.
Functions ¶
func Mac ¶
Mac computes a message authentication code over data using key and algorithm. Family 3: mac(key []byte, data []byte, algorithm string) ([]byte, error)
Supported algorithms: HMAC-SHA256, HMAC-SHA384, HMAC-SHA512, HMAC-SHA3-256, AES-CMAC.
func MacIV ¶
MacIV computes a GMAC tag and generates a nonce internally. Family 4: mac_iv(key []byte, data []byte, algorithm string) (tag []byte, nonce []byte, error)
Only algorithm: AES-GMAC. nonce is 12 bytes, generated internally. Caller must store and provide nonce on verify.
func MacIVVerify ¶
MacIVVerify verifies a GMAC tag with the nonce that was generated by MacIV. Family 4: mac_iv_verify(key, data, nonce, tag, algorithm) (bool, error)
Types ¶
This section is empty.