func (d *cmac) Sum(in []byte) []byte {
	k := d.k1
	if d.p < len(d.digest) {
		k = d.k2
	}
	for i := 0; i < len(d.ci); i++ {
		d.digest[i] = d.ci[i] ^ k[i]
	}
	if d.p < len(d.digest) {
		d.digest[d.p] ^= 0x80
	}
	d.c.Encrypt(d.digest, d.digest)
	return append(in, d.digest...)
}
Sum returns the CMAC digest, one cipher block in length,
of the data written with Write.
package cmac
import (
	"crypto/cipher"
	"hash"
)
const (
	r64  = 0x1b
	r128 = 0x87
)
type cmac struct {
	k1, k2, ci, digest []byte
	p                  int  
	c                  cipher.Block
}
func New(c cipher.Block) hash.Hash {
	var r byte
	n := c.BlockSize()
	switch n {
	case 64 / 8:
		r = r64
	case 128 / 8:
		r = r128
	default:
		panic("crypto/cmac: NewCMAC: invalid cipher block size")
	}
	d := new(cmac)
	d.c = c
	d.k1 = make([]byte, n)
	d.k2 = make([]byte, n)
	d.ci = make([]byte, n)
	d.digest = make([]byte, n)
	c.Encrypt(d.k1, d.k1)
	if shift1(d.k1, d.k1) != 0 {
		d.k1[n-1] ^= r
	}
	if shift1(d.k1, d.k2) != 0 {
		d.k2[n-1] ^= r
	}
	return d
}
func (d *cmac) Reset() {
	for i := range d.ci {
		d.ci[i] = 0
	}
	d.p = 0
}
func (d *cmac) Write(p []byte) (n int, err error) {
	for _, c := range p {
		if d.p >= len(d.ci) {
			d.c.Encrypt(d.ci, d.ci)
			d.p = 0
		}
		d.ci[d.p] ^= c
		d.p++
	}
	return len(p), nil
}