mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 12:16:20 +08:00
zuc: add test case
This commit is contained in:
parent
fdb89d3233
commit
08bb2e2b57
@ -230,15 +230,33 @@ func TestEIA256_Sum32(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEIA256_Finish32(t *testing.T) {
|
func TestEIA256_Finish(t *testing.T) {
|
||||||
expected := "f4f20d7c"
|
expected := []struct {
|
||||||
h, err := NewHash256(zucEIA256Tests[2].key, zucEIA256Tests[2].iv, 4)
|
expected string
|
||||||
|
macLen int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"9dd592c4",
|
||||||
|
4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"1f6f71e386a2ce01",
|
||||||
|
8,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bf5339cfd87bba97d70ef4f5973af8bb",
|
||||||
|
16,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, exp := range expected {
|
||||||
|
h, err := NewHash256(zucEIA256Tests[2].key, zucEIA256Tests[2].iv, exp.macLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
mac := h.Finish([]byte("emmansunshangmi1emmansun shangmiemmansun shangmi 1234"), 8*53)
|
mac := h.Finish([]byte("emmansunshangmi1emmansun shangmiemmansun shangmi 12345"), 8*53+4)
|
||||||
if hex.EncodeToString(mac) != expected {
|
if hex.EncodeToString(mac) != exp.expected {
|
||||||
t.Errorf("expected=%s, result=%s\n", expected, hex.EncodeToString(mac))
|
t.Errorf("expected=%s, result=%s\n", exp.expected, hex.EncodeToString(mac))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user