subtle

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Package subtle provides subtle implementations of the MAC primitive.

Index

Constants

This section is empty.

Variables

This section is empty.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL