X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost3412128%2Fcipher_test.go;h=72cefc34ce61a4a04cba3b401f46b0550149b365;hb=5fc90f4d05f0515cc91dd9feceb813e2b753cbb7;hp=26f404ba8a93f2d013dac9c930804a2036e101b2;hpb=c07494bbd559b9d00f391e28cfd070e18afe9900;p=gogost.git diff --git a/gost3412128/cipher_test.go b/gost3412128/cipher_test.go index 26f404b..72cefc3 100644 --- a/gost3412128/cipher_test.go +++ b/gost3412128/cipher_test.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2019 Sergey Matveev +// Copyright (C) 2015-2022 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -116,8 +116,13 @@ func TestS(t *testing.T) { } } -func R(blk *[BlockSize]byte) { - l(blk, 1) +func R(blk []byte) { + t := blk[15] + for i := 0; i < 15; i++ { + t ^= gfCache[blk[i]][lc[i]] + } + copy(blk[1:], blk) + blk[0] = t } func TestR(t *testing.T) { @@ -125,28 +130,28 @@ func TestR(t *testing.T) { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, } - R(&blk) + R(blk[:]) if bytes.Compare(blk[:], []byte{ 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }) != 0 { t.FailNow() } - R(&blk) + R(blk[:]) if bytes.Compare(blk[:], []byte{ 0xa5, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }) != 0 { t.FailNow() } - R(&blk) + R(blk[:]) if bytes.Compare(blk[:], []byte{ 0x64, 0xa5, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }) != 0 { t.FailNow() } - R(&blk) + R(blk[:]) if bytes.Compare(blk[:], []byte{ 0x0d, 0x64, 0xa5, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -160,28 +165,28 @@ func TestL(t *testing.T) { 0x64, 0xa5, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } - l(&blk, 16) + l(&blk) if bytes.Compare(blk[:], []byte{ 0xd4, 0x56, 0x58, 0x4d, 0xd0, 0xe3, 0xe8, 0x4c, 0xc3, 0x16, 0x6e, 0x4b, 0x7f, 0xa2, 0x89, 0x0d, }) != 0 { t.FailNow() } - l(&blk, 16) + l(&blk) if bytes.Compare(blk[:], []byte{ 0x79, 0xd2, 0x62, 0x21, 0xb8, 0x7b, 0x58, 0x4c, 0xd4, 0x2f, 0xbc, 0x4f, 0xfe, 0xa5, 0xde, 0x9a, }) != 0 { t.FailNow() } - l(&blk, 16) + l(&blk) if bytes.Compare(blk[:], []byte{ 0x0e, 0x93, 0x69, 0x1a, 0x0c, 0xfc, 0x60, 0x40, 0x8b, 0x7b, 0x68, 0xf6, 0x6b, 0x51, 0x3c, 0x13, }) != 0 { t.FailNow() } - l(&blk, 16) + l(&blk) if bytes.Compare(blk[:], []byte{ 0xe6, 0xa8, 0x09, 0x4f, 0xee, 0x0a, 0xa2, 0x04, 0xfd, 0x97, 0xbc, 0xb0, 0xb4, 0x4b, 0x85, 0x80,