X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost28147%2Fmac_test.go;h=58ed6ecfcef0c8a98c0205c992d0e19daaee7a03;hb=69e668f3499122e0b1140f3bd927de41ad279b94;hp=0aea54c958642e4180de5f2551597d0882f65a48;hpb=9be6f384bae8ebeabc129ede9f8a597de12835d3;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost28147/mac_test.go b/src/cypherpunks.ru/gogost/gost28147/mac_test.go index 0aea54c..58ed6ec 100644 --- a/src/cypherpunks.ru/gogost/gost28147/mac_test.go +++ b/src/cypherpunks.ru/gogost/gost28147/mac_test.go @@ -25,11 +25,10 @@ import ( ) func TestMACVectors(t *testing.T) { - var key [KeySize]byte - copy(key[:], []byte("This is message\xFF length\x0032 bytes")) + key := []byte("This is message\xFF length\x0032 bytes") c := NewCipher(key, SboxDefault) var iv [8]byte - m, err := c.NewMAC(8, iv) + m, err := c.NewMAC(8, iv[:]) if err != nil { t.Fail() } @@ -65,16 +64,12 @@ func TestMACVectors(t *testing.T) { func TestMACRandom(t *testing.T) { var key [KeySize]byte rand.Read(key[:]) - c := NewCipher(key, SboxDefault) - f := func(ivRaw []byte, data []byte) bool { + c := NewCipher(key[:], SboxDefault) + f := func(iv [BlockSize]byte, data []byte) bool { if len(data) == 0 { return true } - var iv [8]byte - if len(ivRaw) >= 8 { - copy(iv[:], ivRaw[:8]) - } - m, err := c.NewMAC(8, iv) + m, err := c.NewMAC(8, iv[:]) if err != nil { t.Fail() } @@ -99,23 +94,23 @@ func TestMACRandom(t *testing.T) { } func TestMACInterface(t *testing.T) { - var key [32]byte + var key [KeySize]byte var iv [8]byte - c := NewCipher(key, SboxDefault) - m, _ := c.NewMAC(8, iv) + c := NewCipher(key[:], SboxDefault) + m, _ := c.NewMAC(8, iv[:]) var _ hash.Hash = m } func BenchmarkMAC(b *testing.B) { - var key [KeySize]byte - var iv [BlockSize]byte - rand.Read(key[:]) - rand.Read(iv[:]) + key := make([]byte, KeySize) + iv := make([]byte, BlockSize) + rand.Read(key) + rand.Read(iv) b1 := make([]byte, BlockSize) b2 := make([]byte, BlockSize) rand.Read(b1) rand.Read(b2) - c := NewCipher(key, SboxDefault) + c := NewCipher(key[:], SboxDefault) mac, _ := c.NewMAC(BlockSize, iv) b.ResetTimer() for i := 0; i < b.N; i++ {