INNER CODE UNIT · Go

func

emmansun/gmsm · cbcmac/cbcmac.go:427

func (l *lmac) Size() int {
	return l.b1.BlockSize()
}

// 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 (l *lmac) MAC(src []byte) []byte {
	src = l.pad.Pad(src)
	blockSize := l.b1.BlockSize()
	tag := make([]byte, blockSize)
	for len(src) > blockSize {
		subtle.XORBytes(tag, tag, src[:blockSize])
		l.b1.Encrypt(tag, tag)
		src = src[blockSize:]
	}
	subtle.XORBytes(tag, tag, src[:blockSize])
	l.b2.Encrypt(tag, tag)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…