package subtle

import "github.com/google/tink/go/mac/subtle"

Package subtle provides subtle implementations of the MAC primitive.

Index

Functions

func ValidateCMACParams

func ValidateCMACParams(keySize, tagSize uint32) error

ValidateCMACParams validates the parameters for an AES-CMAC against the recommended parameters.

func ValidateHMACParams

func ValidateHMACParams(hash string, keySize uint32, tagSize uint32) error

ValidateHMACParams validates parameters of HMAC constructor.

Types

type AESCMAC

type AESCMAC struct {
	// contains filtered or unexported fields
}

AESCMAC represents an AES-CMAC struct that implements the MAC interface.

func NewAESCMAC

func NewAESCMAC(key []byte, tagLength uint32) (*AESCMAC, error)

NewAESCMAC creates a new AESCMAC object that implements the MAC interface.

func (AESCMAC) ComputeMAC

func (a AESCMAC) ComputeMAC(data []byte) ([]byte, error)

ComputeMAC computes message authentication code (MAC) for code data.

func (AESCMAC) VerifyMAC

func (a AESCMAC) VerifyMAC(mac, data []byte) error

VerifyMAC returns nil if mac is a correct authentication code (MAC) for data, otherwise it returns an error.

type HMAC

type HMAC struct {
	HashFunc func() hash.Hash
	Key      []byte
	TagSize  uint32
}

HMAC implementation of interface tink.MAC

func NewHMAC

func NewHMAC(hashAlg string, key []byte, tagSize uint32) (*HMAC, error)

NewHMAC creates a new instance of HMAC with the specified key and tag size.

func (*HMAC) ComputeMAC

func (h *HMAC) ComputeMAC(data []byte) ([]byte, error)

ComputeMAC computes message authentication code (MAC) for the given data.

func (*HMAC) VerifyMAC

func (h *HMAC) VerifyMAC(mac []byte, data []byte) error

VerifyMAC verifies whether the given MAC is a correct message authentication code (MAC) the given data.

Source Files

cmac.go hmac.go

Version
v1.7.0 (latest)
Published
Aug 10, 2022
Platform
linux/amd64
Imports
7 packages
Last checked
3 months ago

Tools for package owners.