]> Cypherpunks.ru repositories - gogost.git/blob - src/cypherpunks.ru/gogost/gost34112012256/kdf_test.go
KDF_GOSTR3411_2012_256
[gogost.git] / src / cypherpunks.ru / gogost / gost34112012256 / kdf_test.go
1 // GoGOST -- Pure Go GOST cryptographic functions library
2 // Copyright (C) 2015-2019 Sergey Matveev <stargrave@stargrave.org>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 package gost34112012256
18
19 import (
20         "bytes"
21         "testing"
22 )
23
24 func TestKDFGOSTR34112012256(t *testing.T) {
25         kdf := NewKDF([]byte{
26                 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
27                 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
28                 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
29                 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
30         })
31         derived := kdf.Derive(
32                 nil,
33                 []byte{0x26, 0xbd, 0xb8, 0x78},
34                 []byte{0xaf, 0x21, 0x43, 0x41, 0x45, 0x65, 0x63, 0x78},
35         )
36         if bytes.Compare(derived, []byte{
37                 0xa1, 0xaa, 0x5f, 0x7d, 0xe4, 0x02, 0xd7, 0xb3,
38                 0xd3, 0x23, 0xf2, 0x99, 0x1c, 0x8d, 0x45, 0x34,
39                 0x01, 0x31, 0x37, 0x01, 0x0a, 0x83, 0x75, 0x4f,
40                 0xd0, 0xaf, 0x6d, 0x7c, 0xd4, 0x92, 0x2e, 0xd9,
41         }) != 0 {
42                 t.FailNow()
43         }
44 }