Documentation
¶
Overview ¶
Package mac provides implementations of the MAC primitive.
MAC computes a tag for a given message that can be used to authenticate a message. MAC protects data integrity as well as provides for authenticity of the message.
Example:
package main
import (
"fmt"
"github.com/google/tink/go/mac"
"github.com/google/tink/go/keyset"
)
func main() {
kh, err := keyset.NewHandle(mac.HMACSHA256Tag256KeyTemplate())
if err != nil {
// handle the error
}
m := mac.New(kh)
mac , err := m.ComputeMac([]byte("this data needs to be MACed"))
if err != nil {
// handle error
}
if m.VerifyMAC(mac, []byte("this data needs to be MACed")); err != nil {
//handle error
}
}
Index ¶
- func HMACSHA256Tag128KeyTemplate() *tinkpb.KeyTemplate
- func HMACSHA256Tag256KeyTemplate() *tinkpb.KeyTemplate
- func HMACSHA512Tag256KeyTemplate() *tinkpb.KeyTemplate
- func HMACSHA512Tag512KeyTemplate() *tinkpb.KeyTemplate
- func New(h *keyset.Handle) (tink.MAC, error)
- func NewWithKeyManager(h *keyset.Handle, km registry.KeyManager) (tink.MAC, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HMACSHA256Tag128KeyTemplate ¶ added in v1.3.0
func HMACSHA256Tag128KeyTemplate() *tinkpb.KeyTemplate
HMACSHA256Tag128KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:
- Key size: 32 bytes
- Tag size: 16 bytes
- Hash function: SHA256
func HMACSHA256Tag256KeyTemplate ¶ added in v1.3.0
func HMACSHA256Tag256KeyTemplate() *tinkpb.KeyTemplate
HMACSHA256Tag256KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:
- Key size: 32 bytes
- Tag size: 32 bytes
- Hash function: SHA256
func HMACSHA512Tag256KeyTemplate ¶ added in v1.3.0
func HMACSHA512Tag256KeyTemplate() *tinkpb.KeyTemplate
HMACSHA512Tag256KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:
- Key size: 64 bytes
- Tag size: 32 bytes
- Hash function: SHA512
func HMACSHA512Tag512KeyTemplate ¶ added in v1.3.0
func HMACSHA512Tag512KeyTemplate() *tinkpb.KeyTemplate
HMACSHA512Tag512KeyTemplate is a KeyTemplate that generates a HMAC key with the following parameters:
- Key size: 64 bytes
- Tag size: 64 bytes
- Hash function: SHA512
func NewWithKeyManager ¶ added in v1.3.0
NewWithKeyManager creates a MAC primitive from the given keyset handle and a custom key manager.
Types ¶
This section is empty.