INNER CODE UNIT · Go

func

emmansun/gmsm · cbcmac/cbcmac.go:63

func (c *cbcmac) Size() int {
	return c.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 (c *cbcmac) MAC(src []byte) []byte {
	src = c.pad.Pad(src)
	blockSize := c.b.BlockSize()
	tag := make([]byte, blockSize)
	for len(src) > 0 {
		subtle.XORBytes(tag, tag, src[:blockSize])
		c.b.Encrypt(tag, tag)
		src = src[blockSize:]
	}
	return tag[:c.size]
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…