]> Cypherpunks.ru repositories - gogost.git/blob - prfplus/gost_test.go
300d76c0578929bb178a96a9629e3cb8e03b6469
[gogost.git] / prfplus / gost_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, version 3 of the License.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 package prfplus
17
18 import (
19         "bytes"
20         "testing"
21 )
22
23 func TestPRFIPsecPRFPlusGOSTR34112012256(t *testing.T) {
24         prf := NewPRFIPsecPRFPlusGOSTR34112012256([]byte{
25                 0xC9, 0xA9, 0xA7, 0x73, 0x20, 0xE2, 0xCC, 0x55,
26                 0x9E, 0xD7, 0x2D, 0xCE, 0x6F, 0x47, 0xE2, 0x19,
27                 0x2C, 0xCE, 0xA9, 0x5F, 0xA6, 0x48, 0x67, 0x05,
28                 0x82, 0xC0, 0x54, 0xC0, 0xEF, 0x36, 0xC2, 0x21,
29         })
30         dst := make([]byte, 64)
31         PRFPlus(prf, dst, []byte{
32                 0x01, 0x26, 0xBD, 0xB8, 0x78, 0x00, 0x1D, 0x80,
33                 0x60, 0x3C, 0x85, 0x44, 0xC7, 0x27, 0x01, 0x00,
34         })
35         if bytes.Compare(dst, []byte{
36                 0x2D, 0xE5, 0xEE, 0x84, 0xE1, 0x3D, 0x7B, 0xE5,
37                 0x36, 0x16, 0x67, 0x39, 0x13, 0x37, 0x0A, 0xB0,
38                 0x54, 0xC0, 0x74, 0xB7, 0x9B, 0x69, 0xA8, 0xA8,
39                 0x46, 0x82, 0xA9, 0xF0, 0x4F, 0xEC, 0xD5, 0x87,
40                 0x29, 0xF6, 0x0D, 0xDA, 0x45, 0x7B, 0xF2, 0x19,
41                 0xAA, 0x2E, 0xF9, 0x5D, 0x7A, 0x59, 0xBE, 0x95,
42                 0x4D, 0xE0, 0x08, 0xF4, 0xA5, 0x0D, 0x50, 0x4D,
43                 0xBD, 0xB6, 0x90, 0xBE, 0x68, 0x06, 0x01, 0x53,
44         }) != 0 {
45                 t.FailNow()
46         }
47 }
48
49 func TestPRFIPsecPRFPlusGOSTR34112012512(t *testing.T) {
50         prf := NewPRFIPsecPRFPlusGOSTR34112012512([]byte{
51                 0xC9, 0xA9, 0xA7, 0x73, 0x20, 0xE2, 0xCC, 0x55,
52                 0x9E, 0xD7, 0x2D, 0xCE, 0x6F, 0x47, 0xE2, 0x19,
53                 0x2C, 0xCE, 0xA9, 0x5F, 0xA6, 0x48, 0x67, 0x05,
54                 0x82, 0xC0, 0x54, 0xC0, 0xEF, 0x36, 0xC2, 0x21,
55         })
56         dst := make([]byte, 128)
57         PRFPlus(prf, dst, []byte{
58                 0x01, 0x26, 0xBD, 0xB8, 0x78, 0x00, 0x1D, 0x80,
59                 0x60, 0x3C, 0x85, 0x44, 0xC7, 0x27, 0x01, 0x00,
60         })
61         if bytes.Compare(dst, []byte{
62                 0x5D, 0xA6, 0x71, 0x43, 0xA5, 0xF1, 0x2A, 0x6D,
63                 0x6E, 0x47, 0x42, 0x59, 0x6F, 0x39, 0x24, 0x3F,
64                 0xCC, 0x61, 0x57, 0x45, 0x91, 0x5B, 0x32, 0x59,
65                 0x10, 0x06, 0xFF, 0x78, 0xA2, 0x08, 0x63, 0xD5,
66                 0xF8, 0x8E, 0x4A, 0xFC, 0x17, 0xFB, 0xBE, 0x70,
67                 0xB9, 0x50, 0x95, 0x73, 0xDB, 0x00, 0x5E, 0x96,
68                 0x26, 0x36, 0x98, 0x46, 0xCB, 0x86, 0x19, 0x99,
69                 0x71, 0x6C, 0x16, 0x5D, 0xD0, 0x6A, 0x15, 0x85,
70                 0x48, 0x34, 0x49, 0x5A, 0x43, 0x74, 0x6C, 0xB5,
71                 0x3F, 0x0A, 0xBA, 0x3B, 0xC4, 0x6E, 0xBC, 0xF8,
72                 0x77, 0x3C, 0xA6, 0x4A, 0xD3, 0x43, 0xC1, 0x22,
73                 0xEE, 0x2A, 0x57, 0x75, 0x57, 0x03, 0x81, 0x57,
74                 0xEE, 0x9C, 0x38, 0x8D, 0x96, 0xEF, 0x71, 0xD5,
75                 0x8B, 0xE5, 0xC1, 0xEF, 0xA1, 0xAF, 0xA9, 0x5E,
76                 0xBE, 0x83, 0xE3, 0x9D, 0x00, 0xE1, 0x9A, 0x5D,
77                 0x03, 0xDC, 0xD6, 0x0A, 0x01, 0xBC, 0xA8, 0xE3,
78         }) != 0 {
79                 t.FailNow()
80         }
81 }