package cbcmac import ( "fmt" "testing" "xdx.jelly/xgcl/sm/sm4" ) func TestCbcMac(t *testing.T) { key := make([]byte, 16) msg := make([]byte, 16) c, err := sm4.NewCipher(key) if err != nil { t.Fatal(err) } mac, err := New(c) if err != nil { t.Fatal(err) } mac.Write(msg) m := mac.Sum(nil) if len(m) == 0 { t.Fatal("compute mac error") } fmt.Printf("%x\n", m) }