Files
xgcl/mac/cbcmac/cbcmac_test.go
T
2026-05-27 23:03:00 +08:00

28 lines
386 B
Go

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)
}