INNER CODE UNIT · Go
NewCBCMACWithPadding
emmansun/gmsm · cbcmac/cbcmac.go:54
func NewCBCMACWithPadding(b cipher.Block, size int, newPaddingFunc padding.NewPaddingFunc) BlockCipherMAC {
if size <= 0 || size > b.BlockSize() {
panic("cbcmac: invalid size")
}
return &cbcmac{b: b, pad: newPaddingFunc(uint(b.BlockSize())), size: size}
}
// Size returns the MAC value's number of bytes.
// See [github.com/emmansun/gmsm/cbcmac.BlockCipherMAC.Size].
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)