INNER CODE UNIT · Go

func

emmansun/gmsm · cbcmac/cbcmac.go:148

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 {
		subtle.XORBytes(tag, tag, src[:blockSize])
		e.b1.Encrypt(tag, tag)
		src = src[blockSize:]
	}
	e.b2.Decrypt(tag, tag)
	e.b1.Encrypt(tag, tag)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…