X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost28147%2Fmac_test.go;h=fe07bafce78199ddfb8e7553b49efabd97f7a18c;hb=1688639913419f679bc24139136d4d4b92f85ab6;hp=9f85665b7e3fd8af776994262e3e988e2ac07695;hpb=edd431beb779e95ccff14114367e2fe7bf5d4f7a;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost28147/mac_test.go b/src/cypherpunks.ru/gogost/gost28147/mac_test.go index 9f85665..fe07baf 100644 --- a/src/cypherpunks.ru/gogost/gost28147/mac_test.go +++ b/src/cypherpunks.ru/gogost/gost28147/mac_test.go @@ -33,32 +33,40 @@ func TestMACVectors(t *testing.T) { t.FailNow() } - m.Write([]byte("a")) - if bytes.Compare(m.Sum(nil), []byte{0xbd, 0x5d, 0x3b, 0x5b, 0x2b, 0x7b, 0x57, 0xaf}) != 0 { - t.FailNow() - } + t.Run("a", func(t *testing.T) { + m.Write([]byte("a")) + if bytes.Compare(m.Sum(nil), []byte{0xbd, 0x5d, 0x3b, 0x5b, 0x2b, 0x7b, 0x57, 0xaf}) != 0 { + t.FailNow() + } + }) - m.Reset() - m.Write([]byte("abc")) - if bytes.Compare(m.Sum(nil), []byte{0x28, 0x66, 0x1e, 0x40, 0x80, 0x5b, 0x1f, 0xf9}) != 0 { - t.FailNow() - } + t.Run("abc", func(t *testing.T) { + m.Reset() + m.Write([]byte("abc")) + if bytes.Compare(m.Sum(nil), []byte{0x28, 0x66, 0x1e, 0x40, 0x80, 0x5b, 0x1f, 0xf9}) != 0 { + t.FailNow() + } + }) - m.Reset() - for i := 0; i < 128; i++ { - m.Write([]byte("U")) - } - if bytes.Compare(m.Sum(nil), []byte{0x1a, 0x06, 0xd1, 0xba, 0xd7, 0x45, 0x80, 0xef}) != 0 { - t.FailNow() - } + t.Run("128U", func(t *testing.T) { + m.Reset() + for i := 0; i < 128; i++ { + m.Write([]byte("U")) + } + if bytes.Compare(m.Sum(nil), []byte{0x1a, 0x06, 0xd1, 0xba, 0xd7, 0x45, 0x80, 0xef}) != 0 { + t.FailNow() + } + }) - m.Reset() - for i := 0; i < 13; i++ { - m.Write([]byte("x")) - } - if bytes.Compare(m.Sum(nil), []byte{0x91, 0x7e, 0xe1, 0xf1, 0xa6, 0x68, 0xfb, 0xd3}) != 0 { - t.FailNow() - } + t.Run("xxxxxxxxxxxxx", func(t *testing.T) { + m.Reset() + for i := 0; i < 13; i++ { + m.Write([]byte("x")) + } + if bytes.Compare(m.Sum(nil), []byte{0x91, 0x7e, 0xe1, 0xf1, 0xa6, 0x68, 0xfb, 0xd3}) != 0 { + t.FailNow() + } + }) } func TestMACRandom(t *testing.T) {