INNER CODE UNIT · Go
NewANSIRetailMACWithPadding
emmansun/gmsm · cbcmac/cbcmac.go:142
func NewANSIRetailMACWithPadding(creator func(key []byte) (cipher.Block, error), key1, key2 []byte, size int, newPaddingFunc padding.NewPaddingFunc) BlockCipherMAC {
return (*ansiRetailMAC)(NewEMACWithPadding(creator, key1, key2, size, newPaddingFunc).(*emac))
}
// Size returns the MAC value's number of bytes.
// See [github.com/emmansun/gmsm/cbcmac.BlockCipherMAC.Size].
func (e *ansiRetailMAC) Size() int {
return e.size
}
// MAC calculates the MAC of the given data.
// The data is padded with the padding scheme of the block cipher before processing.
// See [github.com/emmansun/gmsm/cbcmac.BlockCipherMAC.MAC].
func (e *ansiRetailMAC) MAC(src []byte) []byte {
src = e.pad.Pad(src)
blockSize := e.b1.BlockSize()
tag := make([]byte, blockSize)
for len(src) > 0 {