1 |
1275 |
phoenix |
/*
|
2 |
|
|
* Quick & dirty crypto testing module.
|
3 |
|
|
*
|
4 |
|
|
* This will only exist until we have a better testing mechanism
|
5 |
|
|
* (e.g. a char device).
|
6 |
|
|
*
|
7 |
|
|
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
8 |
|
|
* Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
|
9 |
|
|
*
|
10 |
|
|
* This program is free software; you can redistribute it and/or modify it
|
11 |
|
|
* under the terms of the GNU General Public License as published by the Free
|
12 |
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
13 |
|
|
* any later version.
|
14 |
|
|
*
|
15 |
|
|
* 14 - 09 - 2003 Changes by Kartikey Mahendra Bhatt
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
#ifndef _CRYPTO_TCRYPT_H
|
19 |
|
|
#define _CRYPTO_TCRYPT_H
|
20 |
|
|
|
21 |
|
|
#define MAX_DIGEST_SIZE 64
|
22 |
|
|
#define MAX_TAP 8
|
23 |
|
|
|
24 |
|
|
#define MAX_KEYLEN 56
|
25 |
|
|
#define MAX_IVLEN 32
|
26 |
|
|
|
27 |
|
|
struct hash_testvec {
|
28 |
|
|
char plaintext[128];
|
29 |
|
|
unsigned char psize;
|
30 |
|
|
char digest[MAX_DIGEST_SIZE];
|
31 |
|
|
unsigned char np;
|
32 |
|
|
unsigned char tap[MAX_TAP];
|
33 |
|
|
};
|
34 |
|
|
|
35 |
|
|
struct hmac_testvec {
|
36 |
|
|
char key[128];
|
37 |
|
|
unsigned char ksize;
|
38 |
|
|
char plaintext[128];
|
39 |
|
|
unsigned char psize;
|
40 |
|
|
char digest[MAX_DIGEST_SIZE];
|
41 |
|
|
unsigned char np;
|
42 |
|
|
unsigned char tap[MAX_TAP];
|
43 |
|
|
};
|
44 |
|
|
|
45 |
|
|
struct cipher_testvec {
|
46 |
|
|
unsigned char fail;
|
47 |
|
|
unsigned char wk; /* weak key flag */
|
48 |
|
|
char key[MAX_KEYLEN];
|
49 |
|
|
unsigned char klen;
|
50 |
|
|
char iv[MAX_IVLEN];
|
51 |
|
|
char input[48];
|
52 |
|
|
unsigned char ilen;
|
53 |
|
|
char result[48];
|
54 |
|
|
unsigned char rlen;
|
55 |
|
|
int np;
|
56 |
|
|
unsigned char tap[MAX_TAP];
|
57 |
|
|
};
|
58 |
|
|
|
59 |
|
|
/*
|
60 |
|
|
* MD4 test vectors from RFC1320
|
61 |
|
|
*/
|
62 |
|
|
#define MD4_TEST_VECTORS 7
|
63 |
|
|
|
64 |
|
|
struct hash_testvec md4_tv_template [] = {
|
65 |
|
|
{
|
66 |
|
|
.plaintext = "",
|
67 |
|
|
.digest = { 0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31,
|
68 |
|
|
0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0 },
|
69 |
|
|
}, {
|
70 |
|
|
.plaintext = "a",
|
71 |
|
|
.psize = 1,
|
72 |
|
|
.digest = { 0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46,
|
73 |
|
|
0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24 },
|
74 |
|
|
}, {
|
75 |
|
|
.plaintext = "abc",
|
76 |
|
|
.psize = 3,
|
77 |
|
|
.digest = { 0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52,
|
78 |
|
|
0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d },
|
79 |
|
|
}, {
|
80 |
|
|
.plaintext = "message digest",
|
81 |
|
|
.psize = 14,
|
82 |
|
|
.digest = { 0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8,
|
83 |
|
|
0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b },
|
84 |
|
|
}, {
|
85 |
|
|
.plaintext = "abcdefghijklmnopqrstuvwxyz",
|
86 |
|
|
.psize = 26,
|
87 |
|
|
.digest = { 0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd,
|
88 |
|
|
0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9 },
|
89 |
|
|
.np = 2,
|
90 |
|
|
.tap = { 13, 13 },
|
91 |
|
|
}, {
|
92 |
|
|
.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
93 |
|
|
.psize = 62,
|
94 |
|
|
.digest = { 0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35,
|
95 |
|
|
0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4 },
|
96 |
|
|
}, {
|
97 |
|
|
.plaintext = "123456789012345678901234567890123456789012345678901234567890123"
|
98 |
|
|
"45678901234567890",
|
99 |
|
|
.psize = 80,
|
100 |
|
|
.digest = { 0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19,
|
101 |
|
|
0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36 },
|
102 |
|
|
},
|
103 |
|
|
};
|
104 |
|
|
|
105 |
|
|
/*
|
106 |
|
|
* MD5 test vectors from RFC1321
|
107 |
|
|
*/
|
108 |
|
|
#define MD5_TEST_VECTORS 7
|
109 |
|
|
|
110 |
|
|
struct hash_testvec md5_tv_template[] = {
|
111 |
|
|
{
|
112 |
|
|
.digest = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
|
113 |
|
|
0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e },
|
114 |
|
|
}, {
|
115 |
|
|
.plaintext = "a",
|
116 |
|
|
.psize = 1,
|
117 |
|
|
.digest = { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8,
|
118 |
|
|
0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 },
|
119 |
|
|
}, {
|
120 |
|
|
.plaintext = "abc",
|
121 |
|
|
.psize = 3,
|
122 |
|
|
.digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
|
123 |
|
|
0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 },
|
124 |
|
|
}, {
|
125 |
|
|
.plaintext = "message digest",
|
126 |
|
|
.psize = 14,
|
127 |
|
|
.digest = { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d,
|
128 |
|
|
0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 },
|
129 |
|
|
}, {
|
130 |
|
|
.plaintext = "abcdefghijklmnopqrstuvwxyz",
|
131 |
|
|
.psize = 26,
|
132 |
|
|
.digest = { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00,
|
133 |
|
|
0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b },
|
134 |
|
|
.np = 2,
|
135 |
|
|
.tap = {13, 13}
|
136 |
|
|
}, {
|
137 |
|
|
.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
138 |
|
|
.psize = 62,
|
139 |
|
|
.digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
|
140 |
|
|
0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f },
|
141 |
|
|
}, {
|
142 |
|
|
.plaintext = "12345678901234567890123456789012345678901234567890123456789012"
|
143 |
|
|
"345678901234567890",
|
144 |
|
|
.psize = 80,
|
145 |
|
|
.digest = { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55,
|
146 |
|
|
0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a },
|
147 |
|
|
}
|
148 |
|
|
};
|
149 |
|
|
|
150 |
|
|
/*
|
151 |
|
|
* SHA1 test vectors from from FIPS PUB 180-1
|
152 |
|
|
*/
|
153 |
|
|
#define SHA1_TEST_VECTORS 2
|
154 |
|
|
|
155 |
|
|
struct hash_testvec sha1_tv_template[] = {
|
156 |
|
|
{
|
157 |
|
|
.plaintext = "abc",
|
158 |
|
|
.psize = 3,
|
159 |
|
|
.digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
|
160 |
|
|
0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d },
|
161 |
|
|
}, {
|
162 |
|
|
.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
163 |
|
|
.psize = 56,
|
164 |
|
|
.digest = { 0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae,
|
165 |
|
|
0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1 },
|
166 |
|
|
.np = 2,
|
167 |
|
|
.tap = { 28, 28 }
|
168 |
|
|
}
|
169 |
|
|
};
|
170 |
|
|
|
171 |
|
|
/*
|
172 |
|
|
* SHA256 test vectors from from NIST
|
173 |
|
|
*/
|
174 |
|
|
#define SHA256_TEST_VECTORS 2
|
175 |
|
|
|
176 |
|
|
struct hash_testvec sha256_tv_template[] = {
|
177 |
|
|
{
|
178 |
|
|
.plaintext = "abc",
|
179 |
|
|
.psize = 3,
|
180 |
|
|
.digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
|
181 |
|
|
0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
|
182 |
|
|
0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
|
183 |
|
|
0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad },
|
184 |
|
|
}, {
|
185 |
|
|
.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
186 |
|
|
.psize = 56,
|
187 |
|
|
.digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
|
188 |
|
|
0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
|
189 |
|
|
0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
|
190 |
|
|
0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 },
|
191 |
|
|
.np = 2,
|
192 |
|
|
.tap = { 28, 28 }
|
193 |
|
|
},
|
194 |
|
|
};
|
195 |
|
|
|
196 |
|
|
/*
|
197 |
|
|
* SHA384 test vectors from from NIST and kerneli
|
198 |
|
|
*/
|
199 |
|
|
#define SHA384_TEST_VECTORS 4
|
200 |
|
|
|
201 |
|
|
struct hash_testvec sha384_tv_template[] = {
|
202 |
|
|
{
|
203 |
|
|
.plaintext= "abc",
|
204 |
|
|
.psize = 3,
|
205 |
|
|
.digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
|
206 |
|
|
0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
|
207 |
|
|
0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
|
208 |
|
|
0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
|
209 |
|
|
0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
|
210 |
|
|
0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 },
|
211 |
|
|
}, {
|
212 |
|
|
.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
213 |
|
|
.psize = 56,
|
214 |
|
|
.digest = { 0x33, 0x91, 0xfd, 0xdd, 0xfc, 0x8d, 0xc7, 0x39,
|
215 |
|
|
0x37, 0x07, 0xa6, 0x5b, 0x1b, 0x47, 0x09, 0x39,
|
216 |
|
|
0x7c, 0xf8, 0xb1, 0xd1, 0x62, 0xaf, 0x05, 0xab,
|
217 |
|
|
0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6,
|
218 |
|
|
0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f,
|
219 |
|
|
0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b},
|
220 |
|
|
}, {
|
221 |
|
|
.plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
|
222 |
|
|
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
|
223 |
|
|
.psize = 112,
|
224 |
|
|
.digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
|
225 |
|
|
0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
|
226 |
|
|
0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
|
227 |
|
|
0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
|
228 |
|
|
0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
|
229 |
|
|
0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 },
|
230 |
|
|
}, {
|
231 |
|
|
.plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
|
232 |
|
|
"efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
233 |
|
|
.psize = 104,
|
234 |
|
|
.digest = { 0x3d, 0x20, 0x89, 0x73, 0xab, 0x35, 0x08, 0xdb,
|
235 |
|
|
0xbd, 0x7e, 0x2c, 0x28, 0x62, 0xba, 0x29, 0x0a,
|
236 |
|
|
0xd3, 0x01, 0x0e, 0x49, 0x78, 0xc1, 0x98, 0xdc,
|
237 |
|
|
0x4d, 0x8f, 0xd0, 0x14, 0xe5, 0x82, 0x82, 0x3a,
|
238 |
|
|
0x89, 0xe1, 0x6f, 0x9b, 0x2a, 0x7b, 0xbc, 0x1a,
|
239 |
|
|
0xc9, 0x38, 0xe2, 0xd1, 0x99, 0xe8, 0xbe, 0xa4 },
|
240 |
|
|
.np = 4,
|
241 |
|
|
.tap = { 26, 26, 26, 26 }
|
242 |
|
|
},
|
243 |
|
|
};
|
244 |
|
|
|
245 |
|
|
/*
|
246 |
|
|
* SHA512 test vectors from from NIST and kerneli
|
247 |
|
|
*/
|
248 |
|
|
#define SHA512_TEST_VECTORS 4
|
249 |
|
|
|
250 |
|
|
struct hash_testvec sha512_tv_template[] = {
|
251 |
|
|
{
|
252 |
|
|
.plaintext = "abc",
|
253 |
|
|
.psize = 3,
|
254 |
|
|
.digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
|
255 |
|
|
0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
|
256 |
|
|
0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
|
257 |
|
|
0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
|
258 |
|
|
0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
|
259 |
|
|
0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
|
260 |
|
|
0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
|
261 |
|
|
0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f },
|
262 |
|
|
}, {
|
263 |
|
|
.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
264 |
|
|
.psize = 56,
|
265 |
|
|
.digest = { 0x20, 0x4a, 0x8f, 0xc6, 0xdd, 0xa8, 0x2f, 0x0a,
|
266 |
|
|
0x0c, 0xed, 0x7b, 0xeb, 0x8e, 0x08, 0xa4, 0x16,
|
267 |
|
|
0x57, 0xc1, 0x6e, 0xf4, 0x68, 0xb2, 0x28, 0xa8,
|
268 |
|
|
0x27, 0x9b, 0xe3, 0x31, 0xa7, 0x03, 0xc3, 0x35,
|
269 |
|
|
0x96, 0xfd, 0x15, 0xc1, 0x3b, 0x1b, 0x07, 0xf9,
|
270 |
|
|
0xaa, 0x1d, 0x3b, 0xea, 0x57, 0x78, 0x9c, 0xa0,
|
271 |
|
|
0x31, 0xad, 0x85, 0xc7, 0xa7, 0x1d, 0xd7, 0x03,
|
272 |
|
|
0x54, 0xec, 0x63, 0x12, 0x38, 0xca, 0x34, 0x45 },
|
273 |
|
|
}, {
|
274 |
|
|
.plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
|
275 |
|
|
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
|
276 |
|
|
.psize = 112,
|
277 |
|
|
.digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
|
278 |
|
|
0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
|
279 |
|
|
0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
|
280 |
|
|
0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
|
281 |
|
|
0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
|
282 |
|
|
0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
|
283 |
|
|
0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
|
284 |
|
|
0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 },
|
285 |
|
|
}, {
|
286 |
|
|
.plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
|
287 |
|
|
"efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
288 |
|
|
.psize = 104,
|
289 |
|
|
.digest = { 0x93, 0x0d, 0x0c, 0xef, 0xcb, 0x30, 0xff, 0x11,
|
290 |
|
|
0x33, 0xb6, 0x89, 0x81, 0x21, 0xf1, 0xcf, 0x3d,
|
291 |
|
|
0x27, 0x57, 0x8a, 0xfc, 0xaf, 0xe8, 0x67, 0x7c,
|
292 |
|
|
0x52, 0x57, 0xcf, 0x06, 0x99, 0x11, 0xf7, 0x5d,
|
293 |
|
|
0x8f, 0x58, 0x31, 0xb5, 0x6e, 0xbf, 0xda, 0x67,
|
294 |
|
|
0xb2, 0x78, 0xe6, 0x6d, 0xff, 0x8b, 0x84, 0xfe,
|
295 |
|
|
0x2b, 0x28, 0x70, 0xf7, 0x42, 0xa5, 0x80, 0xd8,
|
296 |
|
|
0xed, 0xb4, 0x19, 0x87, 0x23, 0x28, 0x50, 0xc9 },
|
297 |
|
|
.np = 4,
|
298 |
|
|
.tap = { 26, 26, 26, 26 }
|
299 |
|
|
},
|
300 |
|
|
};
|
301 |
|
|
|
302 |
|
|
#ifdef CONFIG_CRYPTO_HMAC
|
303 |
|
|
/*
|
304 |
|
|
* HMAC-MD5 test vectors from RFC2202
|
305 |
|
|
* (These need to be fixed to not use strlen).
|
306 |
|
|
*/
|
307 |
|
|
#define HMAC_MD5_TEST_VECTORS 7
|
308 |
|
|
|
309 |
|
|
struct hmac_testvec hmac_md5_tv_template[] =
|
310 |
|
|
{
|
311 |
|
|
{
|
312 |
|
|
.key = { [0 ... 15] = 0x0b },
|
313 |
|
|
.ksize = 16,
|
314 |
|
|
.plaintext = "Hi There",
|
315 |
|
|
.psize = 8,
|
316 |
|
|
.digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
|
317 |
|
|
0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
|
318 |
|
|
}, {
|
319 |
|
|
.key = { 'J', 'e', 'f', 'e' },
|
320 |
|
|
.ksize = 4,
|
321 |
|
|
.plaintext = "what do ya want for nothing?",
|
322 |
|
|
.psize = 28,
|
323 |
|
|
.digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
|
324 |
|
|
0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
|
325 |
|
|
.np = 2,
|
326 |
|
|
.tap = {14, 14}
|
327 |
|
|
}, {
|
328 |
|
|
.key = { [0 ... 15] = 0xaa },
|
329 |
|
|
.ksize = 16,
|
330 |
|
|
.plaintext = { [0 ... 49] = 0xdd },
|
331 |
|
|
.psize = 50,
|
332 |
|
|
.digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
|
333 |
|
|
0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 },
|
334 |
|
|
}, {
|
335 |
|
|
.key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
336 |
|
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
337 |
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, },
|
338 |
|
|
.ksize = 25,
|
339 |
|
|
.plaintext = { [0 ... 49] = 0xcd },
|
340 |
|
|
.psize = 50,
|
341 |
|
|
.digest = { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
|
342 |
|
|
0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 },
|
343 |
|
|
}, {
|
344 |
|
|
.key = { [0 ... 15] = 0x0c },
|
345 |
|
|
.ksize = 16,
|
346 |
|
|
.plaintext = "Test With Truncation",
|
347 |
|
|
.psize = 20,
|
348 |
|
|
.digest = { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
|
349 |
|
|
0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c },
|
350 |
|
|
}, {
|
351 |
|
|
.key = { [0 ... 79] = 0xaa },
|
352 |
|
|
.ksize = 80,
|
353 |
|
|
.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
|
354 |
|
|
.psize = 54,
|
355 |
|
|
.digest = { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f,
|
356 |
|
|
0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd },
|
357 |
|
|
}, {
|
358 |
|
|
.key = { [0 ... 79] = 0xaa },
|
359 |
|
|
.ksize = 80,
|
360 |
|
|
.plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
|
361 |
|
|
"Block-Size Data",
|
362 |
|
|
.psize = 73,
|
363 |
|
|
.digest = { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee,
|
364 |
|
|
0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e },
|
365 |
|
|
},
|
366 |
|
|
};
|
367 |
|
|
|
368 |
|
|
/*
|
369 |
|
|
* HMAC-SHA1 test vectors from RFC2202
|
370 |
|
|
*/
|
371 |
|
|
#define HMAC_SHA1_TEST_VECTORS 7
|
372 |
|
|
|
373 |
|
|
struct hmac_testvec hmac_sha1_tv_template[] = {
|
374 |
|
|
{
|
375 |
|
|
.key = { [0 ... 19] = 0x0b },
|
376 |
|
|
.ksize = 20,
|
377 |
|
|
.plaintext = "Hi There",
|
378 |
|
|
.psize = 8,
|
379 |
|
|
.digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
|
380 |
|
|
0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1,
|
381 |
|
|
0x46, 0xbe },
|
382 |
|
|
}, {
|
383 |
|
|
.key = { 'J', 'e', 'f', 'e' },
|
384 |
|
|
.ksize = 4,
|
385 |
|
|
.plaintext = "what do ya want for nothing?",
|
386 |
|
|
.psize = 28,
|
387 |
|
|
.digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74,
|
388 |
|
|
0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 },
|
389 |
|
|
.np = 2,
|
390 |
|
|
.tap = { 14, 14 }
|
391 |
|
|
}, {
|
392 |
|
|
.key = { [0 ... 19] = 0xaa },
|
393 |
|
|
.ksize = 20,
|
394 |
|
|
.plaintext = { [0 ... 49] = 0xdd },
|
395 |
|
|
.psize = 50,
|
396 |
|
|
.digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3,
|
397 |
|
|
0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 },
|
398 |
|
|
}, {
|
399 |
|
|
.key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
400 |
|
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
401 |
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 },
|
402 |
|
|
.ksize = 25,
|
403 |
|
|
.plaintext = { [0 ... 49] = 0xcd },
|
404 |
|
|
.psize = 50,
|
405 |
|
|
.digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84,
|
406 |
|
|
0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda },
|
407 |
|
|
}, {
|
408 |
|
|
.key = { [0 ... 19] = 0x0c },
|
409 |
|
|
.ksize = 20,
|
410 |
|
|
.plaintext = "Test With Truncation",
|
411 |
|
|
.psize = 20,
|
412 |
|
|
.digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
|
413 |
|
|
0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 },
|
414 |
|
|
}, {
|
415 |
|
|
.key = { [0 ... 79] = 0xaa },
|
416 |
|
|
.ksize = 80,
|
417 |
|
|
.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
|
418 |
|
|
.psize = 54,
|
419 |
|
|
.digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
|
420 |
|
|
0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 },
|
421 |
|
|
}, {
|
422 |
|
|
.key = { [0 ... 79] = 0xaa },
|
423 |
|
|
.ksize = 80,
|
424 |
|
|
.plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
|
425 |
|
|
"Block-Size Data",
|
426 |
|
|
.psize = 73,
|
427 |
|
|
.digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b,
|
428 |
|
|
0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 },
|
429 |
|
|
},
|
430 |
|
|
};
|
431 |
|
|
|
432 |
|
|
/*
|
433 |
|
|
* HMAC-SHA256 test vectors from
|
434 |
|
|
* draft-ietf-ipsec-ciph-sha-256-01.txt
|
435 |
|
|
*/
|
436 |
|
|
#define HMAC_SHA256_TEST_VECTORS 10
|
437 |
|
|
|
438 |
|
|
struct hmac_testvec hmac_sha256_tv_template[] = {
|
439 |
|
|
{
|
440 |
|
|
.key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
441 |
|
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
442 |
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
443 |
|
|
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20},
|
444 |
|
|
.ksize = 32,
|
445 |
|
|
.plaintext = "abc",
|
446 |
|
|
.psize = 3,
|
447 |
|
|
.digest = { 0xa2, 0x1b, 0x1f, 0x5d, 0x4c, 0xf4, 0xf7, 0x3a,
|
448 |
|
|
0x4d, 0xd9, 0x39, 0x75, 0x0f, 0x7a, 0x06, 0x6a,
|
449 |
|
|
0x7f, 0x98, 0xcc, 0x13, 0x1c, 0xb1, 0x6a, 0x66,
|
450 |
|
|
0x92, 0x75, 0x90, 0x21, 0xcf, 0xab, 0x81, 0x81 },
|
451 |
|
|
}, {
|
452 |
|
|
.key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
453 |
|
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
454 |
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
455 |
|
|
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
|
456 |
|
|
.ksize = 32,
|
457 |
|
|
.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
458 |
|
|
.psize = 56,
|
459 |
|
|
.digest = { 0x10, 0x4f, 0xdc, 0x12, 0x57, 0x32, 0x8f, 0x08,
|
460 |
|
|
0x18, 0x4b, 0xa7, 0x31, 0x31, 0xc5, 0x3c, 0xae,
|
461 |
|
|
0xe6, 0x98, 0xe3, 0x61, 0x19, 0x42, 0x11, 0x49,
|
462 |
|
|
0xea, 0x8c, 0x71, 0x24, 0x56, 0x69, 0x7d, 0x30 },
|
463 |
|
|
}, {
|
464 |
|
|
.key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
465 |
|
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
466 |
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
467 |
|
|
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
|
468 |
|
|
.ksize = 32,
|
469 |
|
|
.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
470 |
|
|
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
471 |
|
|
.psize = 112,
|
472 |
|
|
.digest = { 0x47, 0x03, 0x05, 0xfc, 0x7e, 0x40, 0xfe, 0x34,
|
473 |
|
|
0xd3, 0xee, 0xb3, 0xe7, 0x73, 0xd9, 0x5a, 0xab,
|
474 |
|
|
0x73, 0xac, 0xf0, 0xfd, 0x06, 0x04, 0x47, 0xa5,
|
475 |
|
|
0xeb, 0x45, 0x95, 0xbf, 0x33, 0xa9, 0xd1, 0xa3 },
|
476 |
|
|
}, {
|
477 |
|
|
.key = { [0 ... 31] = 0x0b },
|
478 |
|
|
.ksize = 32,
|
479 |
|
|
.plaintext = "Hi There",
|
480 |
|
|
.psize = 8,
|
481 |
|
|
.digest = { 0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb, 0xc6,
|
482 |
|
|
0x99, 0x03, 0xa0, 0xf1, 0xcf, 0x2b, 0xbd, 0xc5,
|
483 |
|
|
0xba, 0x0a, 0xa3, 0xf3, 0xd9, 0xae, 0x3c, 0x1c,
|
484 |
|
|
0x7a, 0x3b, 0x16, 0x96, 0xa0, 0xb6, 0x8c, 0xf7 },
|
485 |
|
|
}, {
|
486 |
|
|
.key = "Jefe",
|
487 |
|
|
.ksize = 4,
|
488 |
|
|
.plaintext = "what do ya want for nothing?",
|
489 |
|
|
.psize = 28,
|
490 |
|
|
.digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
|
491 |
|
|
0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
|
492 |
|
|
0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
|
493 |
|
|
0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 },
|
494 |
|
|
.np = 2,
|
495 |
|
|
.tap = { 14, 14 }
|
496 |
|
|
}, {
|
497 |
|
|
.key = { [0 ... 31] = 0xaa },
|
498 |
|
|
.ksize = 32,
|
499 |
|
|
.plaintext = { [0 ... 49] = 0xdd },
|
500 |
|
|
.psize = 50,
|
501 |
|
|
.digest = { 0xcd, 0xcb, 0x12, 0x20, 0xd1, 0xec, 0xcc, 0xea,
|
502 |
|
|
0x91, 0xe5, 0x3a, 0xba, 0x30, 0x92, 0xf9, 0x62,
|
503 |
|
|
0xe5, 0x49, 0xfe, 0x6c, 0xe9, 0xed, 0x7f, 0xdc,
|
504 |
|
|
0x43, 0x19, 0x1f, 0xbd, 0xe4, 0x5c, 0x30, 0xb0 },
|
505 |
|
|
}, {
|
506 |
|
|
.key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
507 |
|
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
508 |
|
|
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
509 |
|
|
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
|
510 |
|
|
0x21, 0x22, 0x23, 0x24, 0x25 },
|
511 |
|
|
.ksize = 37,
|
512 |
|
|
.plaintext = { [0 ... 49] = 0xcd },
|
513 |
|
|
.psize = 50,
|
514 |
|
|
.digest = { 0xd4, 0x63, 0x3c, 0x17, 0xf6, 0xfb, 0x8d, 0x74,
|
515 |
|
|
0x4c, 0x66, 0xde, 0xe0, 0xf8, 0xf0, 0x74, 0x55,
|
516 |
|
|
0x6e, 0xc4, 0xaf, 0x55, 0xef, 0x07, 0x99, 0x85,
|
517 |
|
|
0x41, 0x46, 0x8e, 0xb4, 0x9b, 0xd2, 0xe9, 0x17 },
|
518 |
|
|
}, {
|
519 |
|
|
.key = { [0 ... 31] = 0x0c },
|
520 |
|
|
.ksize = 32,
|
521 |
|
|
.plaintext = "Test With Truncation",
|
522 |
|
|
.psize = 20,
|
523 |
|
|
.digest = { 0x75, 0x46, 0xaf, 0x01, 0x84, 0x1f, 0xc0, 0x9b,
|
524 |
|
|
0x1a, 0xb9, 0xc3, 0x74, 0x9a, 0x5f, 0x1c, 0x17,
|
525 |
|
|
0xd4, 0xf5, 0x89, 0x66, 0x8a, 0x58, 0x7b, 0x27,
|
526 |
|
|
0x00, 0xa9, 0xc9, 0x7c, 0x11, 0x93, 0xcf, 0x42 },
|
527 |
|
|
}, {
|
528 |
|
|
.key = { [0 ... 79] = 0xaa },
|
529 |
|
|
.ksize = 80,
|
530 |
|
|
.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
|
531 |
|
|
.psize = 54,
|
532 |
|
|
.digest = { 0x69, 0x53, 0x02, 0x5e, 0xd9, 0x6f, 0x0c, 0x09,
|
533 |
|
|
0xf8, 0x0a, 0x96, 0xf7, 0x8e, 0x65, 0x38, 0xdb,
|
534 |
|
|
0xe2, 0xe7, 0xb8, 0x20, 0xe3, 0xdd, 0x97, 0x0e,
|
535 |
|
|
0x7d, 0xdd, 0x39, 0x09, 0x1b, 0x32, 0x35, 0x2f },
|
536 |
|
|
}, {
|
537 |
|
|
.key = { [0 ... 79] = 0xaa },
|
538 |
|
|
.ksize = 80,
|
539 |
|
|
.plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
|
540 |
|
|
"One Block-Size Data",
|
541 |
|
|
.psize = 73,
|
542 |
|
|
.digest = { 0x63, 0x55, 0xac, 0x22, 0xe8, 0x90, 0xd0, 0xa3,
|
543 |
|
|
0xc8, 0x48, 0x1a, 0x5c, 0xa4, 0x82, 0x5b, 0xc8,
|
544 |
|
|
0x84, 0xd3, 0xe7, 0xa1, 0xff, 0x98, 0xa2, 0xfc,
|
545 |
|
|
0x2a, 0xc7, 0xd8, 0xe0, 0x64, 0xc3, 0xb2, 0xe6 },
|
546 |
|
|
},
|
547 |
|
|
};
|
548 |
|
|
|
549 |
|
|
#endif /* CONFIG_CRYPTO_HMAC */
|
550 |
|
|
|
551 |
|
|
/*
|
552 |
|
|
* DES test vectors.
|
553 |
|
|
*/
|
554 |
|
|
#define DES_ENC_TEST_VECTORS 10
|
555 |
|
|
#define DES_DEC_TEST_VECTORS 4
|
556 |
|
|
#define DES_CBC_ENC_TEST_VECTORS 5
|
557 |
|
|
#define DES_CBC_DEC_TEST_VECTORS 4
|
558 |
|
|
#define DES3_EDE_ENC_TEST_VECTORS 3
|
559 |
|
|
#define DES3_EDE_DEC_TEST_VECTORS 3
|
560 |
|
|
|
561 |
|
|
struct cipher_testvec des_enc_tv_template[] = {
|
562 |
|
|
{ /* From Applied Cryptography */
|
563 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
564 |
|
|
.klen = 8,
|
565 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
|
566 |
|
|
.ilen = 8,
|
567 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
|
568 |
|
|
.rlen = 8,
|
569 |
|
|
}, { /* Same key, different plaintext block */
|
570 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
571 |
|
|
.klen = 8,
|
572 |
|
|
.input = { 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
|
573 |
|
|
.ilen = 8,
|
574 |
|
|
.result = { 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
|
575 |
|
|
.rlen = 8,
|
576 |
|
|
}, { /* Sbox test from NBS */
|
577 |
|
|
.key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
|
578 |
|
|
.klen = 8,
|
579 |
|
|
.input = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
|
580 |
|
|
.ilen = 8,
|
581 |
|
|
.result = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
|
582 |
|
|
.rlen = 8,
|
583 |
|
|
}, { /* Three blocks */
|
584 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
585 |
|
|
.klen = 8,
|
586 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
587 |
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
|
588 |
|
|
0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
|
589 |
|
|
.ilen = 24,
|
590 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
591 |
|
|
0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
|
592 |
|
|
0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
|
593 |
|
|
.rlen = 24,
|
594 |
|
|
}, { /* Weak key */
|
595 |
|
|
.fail = 1,
|
596 |
|
|
.wk = 1,
|
597 |
|
|
.key = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
|
598 |
|
|
.klen = 8,
|
599 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
|
600 |
|
|
.ilen = 8,
|
601 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
|
602 |
|
|
.rlen = 8,
|
603 |
|
|
}, { /* Two blocks -- for testing encryption across pages */
|
604 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
605 |
|
|
.klen = 8,
|
606 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
607 |
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
|
608 |
|
|
.ilen = 16,
|
609 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
610 |
|
|
0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
|
611 |
|
|
.rlen = 16,
|
612 |
|
|
.np = 2,
|
613 |
|
|
.tap = { 8, 8 }
|
614 |
|
|
}, { /* Four blocks -- for testing encryption with chunking */
|
615 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
616 |
|
|
.klen = 8,
|
617 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
618 |
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
|
619 |
|
|
0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef,
|
620 |
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
|
621 |
|
|
.ilen = 32,
|
622 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
623 |
|
|
0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
|
624 |
|
|
0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90,
|
625 |
|
|
0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
|
626 |
|
|
.rlen = 32,
|
627 |
|
|
.np = 3,
|
628 |
|
|
.tap = { 14, 10, 8 }
|
629 |
|
|
}, {
|
630 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
631 |
|
|
.klen = 8,
|
632 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
633 |
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
|
634 |
|
|
0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
|
635 |
|
|
.ilen = 24,
|
636 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
637 |
|
|
0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
|
638 |
|
|
0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
|
639 |
|
|
.rlen = 24,
|
640 |
|
|
.np = 4,
|
641 |
|
|
.tap = { 2, 1, 3, 18 }
|
642 |
|
|
}, {
|
643 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
644 |
|
|
.klen = 8,
|
645 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
646 |
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
|
647 |
|
|
.ilen = 16,
|
648 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
649 |
|
|
0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
|
650 |
|
|
.rlen = 16,
|
651 |
|
|
.np = 5,
|
652 |
|
|
.tap = { 2, 2, 2, 2, 8 }
|
653 |
|
|
}, {
|
654 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
655 |
|
|
.klen = 8,
|
656 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
|
657 |
|
|
.ilen = 8,
|
658 |
|
|
.result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
|
659 |
|
|
.rlen = 8,
|
660 |
|
|
.np = 8,
|
661 |
|
|
.tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
|
662 |
|
|
},
|
663 |
|
|
};
|
664 |
|
|
|
665 |
|
|
struct cipher_testvec des_dec_tv_template[] = {
|
666 |
|
|
{ /* From Applied Cryptography */
|
667 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
668 |
|
|
.klen = 8,
|
669 |
|
|
.input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
|
670 |
|
|
.ilen = 8,
|
671 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
|
672 |
|
|
.rlen = 8,
|
673 |
|
|
}, { /* Sbox test from NBS */
|
674 |
|
|
.key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
|
675 |
|
|
.klen = 8,
|
676 |
|
|
.input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
|
677 |
|
|
.ilen = 8,
|
678 |
|
|
.result = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
|
679 |
|
|
.rlen = 8,
|
680 |
|
|
}, { /* Two blocks, for chunking test */
|
681 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
682 |
|
|
.klen = 8,
|
683 |
|
|
.input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
684 |
|
|
0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
|
685 |
|
|
.ilen = 16,
|
686 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
687 |
|
|
0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
|
688 |
|
|
.rlen = 16,
|
689 |
|
|
.np = 2,
|
690 |
|
|
.tap = { 8, 8 }
|
691 |
|
|
}, {
|
692 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
693 |
|
|
.klen = 8,
|
694 |
|
|
.input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
|
695 |
|
|
0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
|
696 |
|
|
.ilen = 16,
|
697 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
|
698 |
|
|
0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
|
699 |
|
|
.rlen = 16,
|
700 |
|
|
.np = 3,
|
701 |
|
|
.tap = { 3, 12, 1 }
|
702 |
|
|
},
|
703 |
|
|
};
|
704 |
|
|
|
705 |
|
|
struct cipher_testvec des_cbc_enc_tv_template[] = {
|
706 |
|
|
{ /* From OpenSSL */
|
707 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
|
708 |
|
|
.klen = 8,
|
709 |
|
|
.iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
|
710 |
|
|
.input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
|
711 |
|
|
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
|
712 |
|
|
0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
|
713 |
|
|
.ilen = 24,
|
714 |
|
|
.result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
|
715 |
|
|
0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
|
716 |
|
|
0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
|
717 |
|
|
.rlen = 24,
|
718 |
|
|
}, { /* FIPS Pub 81 */
|
719 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
720 |
|
|
.klen = 8,
|
721 |
|
|
.iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
|
722 |
|
|
.input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
|
723 |
|
|
.ilen = 8,
|
724 |
|
|
.result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
|
725 |
|
|
.rlen = 8,
|
726 |
|
|
}, {
|
727 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
728 |
|
|
.klen = 8,
|
729 |
|
|
.iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
|
730 |
|
|
.input = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
|
731 |
|
|
.ilen = 8,
|
732 |
|
|
.result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
|
733 |
|
|
.rlen = 8,
|
734 |
|
|
}, {
|
735 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
736 |
|
|
.klen = 8,
|
737 |
|
|
.iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
|
738 |
|
|
.input = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
|
739 |
|
|
.ilen = 8,
|
740 |
|
|
.result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
|
741 |
|
|
.rlen = 8,
|
742 |
|
|
}, { /* Copy of openssl vector for chunk testing */
|
743 |
|
|
/* From OpenSSL */
|
744 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
|
745 |
|
|
.klen = 8,
|
746 |
|
|
.iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
|
747 |
|
|
.input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
|
748 |
|
|
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
|
749 |
|
|
0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
|
750 |
|
|
.ilen = 24,
|
751 |
|
|
.result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
|
752 |
|
|
0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
|
753 |
|
|
0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
|
754 |
|
|
.rlen = 24,
|
755 |
|
|
.np = 2,
|
756 |
|
|
.tap = { 13, 11 }
|
757 |
|
|
},
|
758 |
|
|
};
|
759 |
|
|
|
760 |
|
|
struct cipher_testvec des_cbc_dec_tv_template[] = {
|
761 |
|
|
{ /* FIPS Pub 81 */
|
762 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
763 |
|
|
.klen = 8,
|
764 |
|
|
.iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
|
765 |
|
|
.input = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
|
766 |
|
|
.ilen = 8,
|
767 |
|
|
.result = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
|
768 |
|
|
.rlen = 8,
|
769 |
|
|
}, {
|
770 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
771 |
|
|
.klen = 8,
|
772 |
|
|
.iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
|
773 |
|
|
.input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
|
774 |
|
|
.ilen = 8,
|
775 |
|
|
.result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
|
776 |
|
|
.rlen = 8,
|
777 |
|
|
}, {
|
778 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
779 |
|
|
.klen = 8,
|
780 |
|
|
.iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
|
781 |
|
|
.input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
|
782 |
|
|
.ilen = 8,
|
783 |
|
|
.result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
|
784 |
|
|
.rlen = 8,
|
785 |
|
|
}, { /* Copy of above, for chunk testing */
|
786 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
787 |
|
|
.klen = 8,
|
788 |
|
|
.iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
|
789 |
|
|
.input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
|
790 |
|
|
.ilen = 8,
|
791 |
|
|
.result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
|
792 |
|
|
.rlen = 8,
|
793 |
|
|
.np = 2,
|
794 |
|
|
.tap = { 4, 4 }
|
795 |
|
|
},
|
796 |
|
|
};
|
797 |
|
|
|
798 |
|
|
/*
|
799 |
|
|
* We really need some more test vectors, especially for DES3 CBC.
|
800 |
|
|
*/
|
801 |
|
|
struct cipher_testvec des3_ede_enc_tv_template[] = {
|
802 |
|
|
{ /* These are from openssl */
|
803 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
804 |
|
|
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
805 |
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
|
806 |
|
|
.klen = 24,
|
807 |
|
|
.input = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
|
808 |
|
|
.ilen = 8,
|
809 |
|
|
.result = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
|
810 |
|
|
.rlen = 8,
|
811 |
|
|
}, {
|
812 |
|
|
.key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
|
813 |
|
|
0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
|
814 |
|
|
0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
|
815 |
|
|
.klen = 24,
|
816 |
|
|
.input = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
|
817 |
|
|
.ilen = 8,
|
818 |
|
|
.result = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
|
819 |
|
|
.rlen = 8,
|
820 |
|
|
}, {
|
821 |
|
|
.key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
|
822 |
|
|
0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
|
823 |
|
|
0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
|
824 |
|
|
.klen = 24,
|
825 |
|
|
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
826 |
|
|
.ilen = 8,
|
827 |
|
|
.result = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
|
828 |
|
|
.rlen = 8,
|
829 |
|
|
},
|
830 |
|
|
};
|
831 |
|
|
|
832 |
|
|
struct cipher_testvec des3_ede_dec_tv_template[] = {
|
833 |
|
|
{ /* These are from openssl */
|
834 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
835 |
|
|
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
836 |
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
|
837 |
|
|
.klen = 24,
|
838 |
|
|
.input = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
|
839 |
|
|
.ilen = 8,
|
840 |
|
|
.result = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
|
841 |
|
|
.rlen = 8,
|
842 |
|
|
}, {
|
843 |
|
|
.key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
|
844 |
|
|
0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
|
845 |
|
|
0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
|
846 |
|
|
.klen = 24,
|
847 |
|
|
.input = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
|
848 |
|
|
.ilen = 8,
|
849 |
|
|
.result = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
|
850 |
|
|
.rlen = 8,
|
851 |
|
|
}, {
|
852 |
|
|
.key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
|
853 |
|
|
0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
|
854 |
|
|
0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
|
855 |
|
|
.klen = 24,
|
856 |
|
|
.input = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
|
857 |
|
|
.ilen = 8,
|
858 |
|
|
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
859 |
|
|
.rlen = 8,
|
860 |
|
|
},
|
861 |
|
|
};
|
862 |
|
|
|
863 |
|
|
/*
|
864 |
|
|
* Blowfish test vectors.
|
865 |
|
|
*/
|
866 |
|
|
#define BF_ENC_TEST_VECTORS 6
|
867 |
|
|
#define BF_DEC_TEST_VECTORS 6
|
868 |
|
|
#define BF_CBC_ENC_TEST_VECTORS 1
|
869 |
|
|
#define BF_CBC_DEC_TEST_VECTORS 1
|
870 |
|
|
|
871 |
|
|
struct cipher_testvec bf_enc_tv_template[] = {
|
872 |
|
|
{ /* DES test vectors from OpenSSL */
|
873 |
|
|
.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
874 |
|
|
.klen = 8,
|
875 |
|
|
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
876 |
|
|
.ilen = 8,
|
877 |
|
|
.result = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
|
878 |
|
|
.rlen = 8,
|
879 |
|
|
}, {
|
880 |
|
|
.key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
|
881 |
|
|
.klen = 8,
|
882 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
883 |
|
|
.ilen = 8,
|
884 |
|
|
.result = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
|
885 |
|
|
.rlen = 8,
|
886 |
|
|
}, {
|
887 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
|
888 |
|
|
.klen = 8,
|
889 |
|
|
.input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
890 |
|
|
.ilen = 8,
|
891 |
|
|
.result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
|
892 |
|
|
.rlen = 8,
|
893 |
|
|
}, { /* Vary the keylength... */
|
894 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
895 |
|
|
0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
|
896 |
|
|
.klen = 16,
|
897 |
|
|
.input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
898 |
|
|
.ilen = 8,
|
899 |
|
|
.result = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
|
900 |
|
|
.rlen = 8,
|
901 |
|
|
}, {
|
902 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
903 |
|
|
0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
|
904 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44 },
|
905 |
|
|
.klen = 21,
|
906 |
|
|
.input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
907 |
|
|
.ilen = 8,
|
908 |
|
|
.result = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
|
909 |
|
|
.rlen = 8,
|
910 |
|
|
}, { /* Generated with bf488 */
|
911 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
912 |
|
|
0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
|
913 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
914 |
|
|
0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
|
915 |
|
|
0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
|
916 |
|
|
0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
|
917 |
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
918 |
|
|
.klen = 56,
|
919 |
|
|
.input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
920 |
|
|
.ilen = 8,
|
921 |
|
|
.result = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
|
922 |
|
|
.rlen = 8,
|
923 |
|
|
},
|
924 |
|
|
};
|
925 |
|
|
|
926 |
|
|
struct cipher_testvec bf_dec_tv_template[] = {
|
927 |
|
|
{ /* DES test vectors from OpenSSL */
|
928 |
|
|
.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
929 |
|
|
.klen = 8,
|
930 |
|
|
.input = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
|
931 |
|
|
.ilen = 8,
|
932 |
|
|
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
933 |
|
|
.rlen = 8,
|
934 |
|
|
}, {
|
935 |
|
|
.key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
|
936 |
|
|
.klen = 8,
|
937 |
|
|
.input = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
|
938 |
|
|
.ilen = 8,
|
939 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
940 |
|
|
.rlen = 8,
|
941 |
|
|
}, {
|
942 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
|
943 |
|
|
.klen = 8,
|
944 |
|
|
.input = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
|
945 |
|
|
.ilen = 8,
|
946 |
|
|
.result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
947 |
|
|
.rlen = 8,
|
948 |
|
|
}, { /* Vary the keylength... */
|
949 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
950 |
|
|
0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
|
951 |
|
|
.klen = 16,
|
952 |
|
|
.input = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
|
953 |
|
|
.ilen = 8,
|
954 |
|
|
.result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
955 |
|
|
.rlen = 8,
|
956 |
|
|
}, {
|
957 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
958 |
|
|
0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
|
959 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44 },
|
960 |
|
|
.klen = 21,
|
961 |
|
|
.input = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
|
962 |
|
|
.ilen = 8,
|
963 |
|
|
.result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
964 |
|
|
.rlen = 8,
|
965 |
|
|
}, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
|
966 |
|
|
.key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
967 |
|
|
0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
|
968 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
969 |
|
|
0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
|
970 |
|
|
0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
|
971 |
|
|
0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
|
972 |
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
973 |
|
|
.klen = 56,
|
974 |
|
|
.input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
|
975 |
|
|
.ilen = 8,
|
976 |
|
|
.result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
977 |
|
|
.rlen = 8,
|
978 |
|
|
},
|
979 |
|
|
};
|
980 |
|
|
|
981 |
|
|
struct cipher_testvec bf_cbc_enc_tv_template[] = {
|
982 |
|
|
{ /* From OpenSSL */
|
983 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
984 |
|
|
0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
|
985 |
|
|
.klen = 16,
|
986 |
|
|
.iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
987 |
|
|
.input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
|
988 |
|
|
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
|
989 |
|
|
0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
|
990 |
|
|
0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
|
991 |
|
|
.ilen = 32,
|
992 |
|
|
.result = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
|
993 |
|
|
0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
|
994 |
|
|
0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
|
995 |
|
|
0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
|
996 |
|
|
.rlen = 32,
|
997 |
|
|
},
|
998 |
|
|
};
|
999 |
|
|
|
1000 |
|
|
struct cipher_testvec bf_cbc_dec_tv_template[] = {
|
1001 |
|
|
{ /* From OpenSSL */
|
1002 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
1003 |
|
|
0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
|
1004 |
|
|
.klen = 16,
|
1005 |
|
|
.iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
|
1006 |
|
|
.input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
|
1007 |
|
|
0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
|
1008 |
|
|
0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
|
1009 |
|
|
0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
|
1010 |
|
|
.ilen = 32,
|
1011 |
|
|
.result = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
|
1012 |
|
|
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
|
1013 |
|
|
0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
|
1014 |
|
|
0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
|
1015 |
|
|
.rlen = 32,
|
1016 |
|
|
},
|
1017 |
|
|
};
|
1018 |
|
|
|
1019 |
|
|
/*
|
1020 |
|
|
* Twofish test vectors.
|
1021 |
|
|
*/
|
1022 |
|
|
#define TF_ENC_TEST_VECTORS 3
|
1023 |
|
|
#define TF_DEC_TEST_VECTORS 3
|
1024 |
|
|
#define TF_CBC_ENC_TEST_VECTORS 4
|
1025 |
|
|
#define TF_CBC_DEC_TEST_VECTORS 4
|
1026 |
|
|
|
1027 |
|
|
struct cipher_testvec tf_enc_tv_template[] = {
|
1028 |
|
|
{
|
1029 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1030 |
|
|
.klen = 16,
|
1031 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1032 |
|
|
.ilen = 16,
|
1033 |
|
|
.result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1034 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
|
1035 |
|
|
.rlen = 16,
|
1036 |
|
|
}, {
|
1037 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
1038 |
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
1039 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
|
1040 |
|
|
.klen = 24,
|
1041 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1042 |
|
|
.ilen = 16,
|
1043 |
|
|
.result = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
|
1044 |
|
|
0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
|
1045 |
|
|
.rlen = 16,
|
1046 |
|
|
}, {
|
1047 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
1048 |
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
1049 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1050 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1051 |
|
|
.klen = 32,
|
1052 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1053 |
|
|
.ilen = 16,
|
1054 |
|
|
.result = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
|
1055 |
|
|
0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
|
1056 |
|
|
.rlen = 16,
|
1057 |
|
|
},
|
1058 |
|
|
};
|
1059 |
|
|
|
1060 |
|
|
struct cipher_testvec tf_dec_tv_template[] = {
|
1061 |
|
|
{
|
1062 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1063 |
|
|
.klen = 16,
|
1064 |
|
|
.input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1065 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
|
1066 |
|
|
.ilen = 16,
|
1067 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1068 |
|
|
.rlen = 16,
|
1069 |
|
|
}, {
|
1070 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
1071 |
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
1072 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
|
1073 |
|
|
.klen = 24,
|
1074 |
|
|
.input = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
|
1075 |
|
|
0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
|
1076 |
|
|
.ilen = 16,
|
1077 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1078 |
|
|
.rlen = 16,
|
1079 |
|
|
}, {
|
1080 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
1081 |
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
1082 |
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1083 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1084 |
|
|
.klen = 32,
|
1085 |
|
|
.input = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
|
1086 |
|
|
0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
|
1087 |
|
|
.ilen = 16,
|
1088 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1089 |
|
|
.rlen = 16,
|
1090 |
|
|
},
|
1091 |
|
|
};
|
1092 |
|
|
|
1093 |
|
|
struct cipher_testvec tf_cbc_enc_tv_template[] = {
|
1094 |
|
|
{ /* Generated with Nettle */
|
1095 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1096 |
|
|
.klen = 16,
|
1097 |
|
|
.iv = { [0 ... 15] = 0x00 },
|
1098 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1099 |
|
|
.ilen = 16,
|
1100 |
|
|
.result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1101 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
|
1102 |
|
|
.rlen = 16,
|
1103 |
|
|
}, {
|
1104 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1105 |
|
|
.klen = 16,
|
1106 |
|
|
.iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1107 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
|
1108 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1109 |
|
|
.ilen = 16,
|
1110 |
|
|
.result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
|
1111 |
|
|
0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
|
1112 |
|
|
.rlen = 16,
|
1113 |
|
|
}, {
|
1114 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1115 |
|
|
.klen = 16,
|
1116 |
|
|
.iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
|
1117 |
|
|
0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
|
1118 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1119 |
|
|
.ilen = 16,
|
1120 |
|
|
.result = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
|
1121 |
|
|
0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
|
1122 |
|
|
.rlen = 16,
|
1123 |
|
|
}, {
|
1124 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1125 |
|
|
.klen = 16,
|
1126 |
|
|
.iv = { [0 ... 15] = 0x00 },
|
1127 |
|
|
.input = { [0 ... 47] = 0x00 },
|
1128 |
|
|
.ilen = 48,
|
1129 |
|
|
.result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1130 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
|
1131 |
|
|
0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
|
1132 |
|
|
0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
|
1133 |
|
|
0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
|
1134 |
|
|
0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
|
1135 |
|
|
.rlen = 48,
|
1136 |
|
|
},
|
1137 |
|
|
};
|
1138 |
|
|
|
1139 |
|
|
struct cipher_testvec tf_cbc_dec_tv_template[] = {
|
1140 |
|
|
{ /* Reverse of the first four above */
|
1141 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1142 |
|
|
.klen = 16,
|
1143 |
|
|
.iv = { [0 ... 15] = 0x00 },
|
1144 |
|
|
.input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1145 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
|
1146 |
|
|
.ilen = 16,
|
1147 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1148 |
|
|
.rlen = 16,
|
1149 |
|
|
}, {
|
1150 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1151 |
|
|
.klen = 16,
|
1152 |
|
|
.iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1153 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
|
1154 |
|
|
.input = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
|
1155 |
|
|
0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
|
1156 |
|
|
.ilen = 16,
|
1157 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1158 |
|
|
.rlen = 16,
|
1159 |
|
|
}, {
|
1160 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1161 |
|
|
.klen = 16,
|
1162 |
|
|
.iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
|
1163 |
|
|
0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
|
1164 |
|
|
.input = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
|
1165 |
|
|
0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
|
1166 |
|
|
.ilen = 16,
|
1167 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1168 |
|
|
.rlen = 16,
|
1169 |
|
|
}, {
|
1170 |
|
|
.key = { [0 ... 15] = 0x00 },
|
1171 |
|
|
.klen = 16,
|
1172 |
|
|
.iv = { [0 ... 15] = 0x00 },
|
1173 |
|
|
.input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
|
1174 |
|
|
0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
|
1175 |
|
|
0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
|
1176 |
|
|
0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
|
1177 |
|
|
0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
|
1178 |
|
|
0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
|
1179 |
|
|
.ilen = 48,
|
1180 |
|
|
.result = { [0 ... 47] = 0x00 },
|
1181 |
|
|
.rlen = 48,
|
1182 |
|
|
},
|
1183 |
|
|
};
|
1184 |
|
|
|
1185 |
|
|
/*
|
1186 |
|
|
* Serpent test vectors. These are backwards because Serpent writes
|
1187 |
|
|
* octect sequences in right-to-left mode.
|
1188 |
|
|
*/
|
1189 |
|
|
#define SERPENT_ENC_TEST_VECTORS 4
|
1190 |
|
|
#define SERPENT_DEC_TEST_VECTORS 4
|
1191 |
|
|
|
1192 |
|
|
struct cipher_testvec serpent_enc_tv_template[] =
|
1193 |
|
|
{
|
1194 |
|
|
{
|
1195 |
|
|
.input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1196 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1197 |
|
|
.ilen = 16,
|
1198 |
|
|
.result = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
|
1199 |
|
|
0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
|
1200 |
|
|
.rlen = 16,
|
1201 |
|
|
}, {
|
1202 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1203 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1204 |
|
|
.klen = 16,
|
1205 |
|
|
.input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1206 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1207 |
|
|
.ilen = 16,
|
1208 |
|
|
.result = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
|
1209 |
|
|
0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
|
1210 |
|
|
.rlen = 16,
|
1211 |
|
|
}, {
|
1212 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1213 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
1214 |
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
1215 |
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
|
1216 |
|
|
.klen = 32,
|
1217 |
|
|
.input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1218 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1219 |
|
|
.ilen = 16,
|
1220 |
|
|
.result = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
|
1221 |
|
|
0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
|
1222 |
|
|
.rlen = 16,
|
1223 |
|
|
}, {
|
1224 |
|
|
.key = { [15] = 0x80 },
|
1225 |
|
|
.klen = 16,
|
1226 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1227 |
|
|
.ilen = 16,
|
1228 |
|
|
.result = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
|
1229 |
|
|
0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
|
1230 |
|
|
.rlen = 16,
|
1231 |
|
|
},
|
1232 |
|
|
};
|
1233 |
|
|
|
1234 |
|
|
struct cipher_testvec serpent_dec_tv_template[] =
|
1235 |
|
|
{
|
1236 |
|
|
{
|
1237 |
|
|
.input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
|
1238 |
|
|
0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
|
1239 |
|
|
.ilen = 16,
|
1240 |
|
|
.result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1241 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1242 |
|
|
.rlen = 16,
|
1243 |
|
|
}, {
|
1244 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1245 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1246 |
|
|
.klen = 16,
|
1247 |
|
|
.input = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
|
1248 |
|
|
0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
|
1249 |
|
|
.ilen = 16,
|
1250 |
|
|
.result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1251 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1252 |
|
|
.rlen = 16,
|
1253 |
|
|
}, {
|
1254 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1255 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
1256 |
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
1257 |
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
|
1258 |
|
|
.klen = 32,
|
1259 |
|
|
.input = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
|
1260 |
|
|
0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
|
1261 |
|
|
.ilen = 16,
|
1262 |
|
|
.result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1263 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1264 |
|
|
.rlen = 16,
|
1265 |
|
|
}, {
|
1266 |
|
|
.key = { [15] = 0x80 },
|
1267 |
|
|
.klen = 16,
|
1268 |
|
|
.input = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
|
1269 |
|
|
0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
|
1270 |
|
|
.ilen = 16,
|
1271 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1272 |
|
|
.rlen = 16,
|
1273 |
|
|
},
|
1274 |
|
|
};
|
1275 |
|
|
|
1276 |
|
|
/* Cast6 test vectors from RFC 2612 */
|
1277 |
|
|
#define CAST6_ENC_TEST_VECTORS 3
|
1278 |
|
|
#define CAST6_DEC_TEST_VECTORS 3
|
1279 |
|
|
|
1280 |
|
|
struct cipher_testvec cast6_enc_tv_template[] =
|
1281 |
|
|
{
|
1282 |
|
|
{
|
1283 |
|
|
.key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
|
1284 |
|
|
0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
|
1285 |
|
|
.klen = 16,
|
1286 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1287 |
|
|
.ilen = 16,
|
1288 |
|
|
.result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
|
1289 |
|
|
0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
|
1290 |
|
|
.rlen = 16,
|
1291 |
|
|
}, {
|
1292 |
|
|
.key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
|
1293 |
|
|
0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
|
1294 |
|
|
0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
|
1295 |
|
|
.klen = 24,
|
1296 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1297 |
|
|
.ilen = 16,
|
1298 |
|
|
.result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
|
1299 |
|
|
0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
|
1300 |
|
|
.rlen = 16,
|
1301 |
|
|
}, {
|
1302 |
|
|
.key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
|
1303 |
|
|
0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
|
1304 |
|
|
0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
|
1305 |
|
|
0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
|
1306 |
|
|
.klen = 32,
|
1307 |
|
|
.input = { [0 ... 15] = 0x00 },
|
1308 |
|
|
.ilen = 16,
|
1309 |
|
|
.result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
|
1310 |
|
|
0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
|
1311 |
|
|
.rlen = 16,
|
1312 |
|
|
},
|
1313 |
|
|
};
|
1314 |
|
|
|
1315 |
|
|
struct cipher_testvec cast6_dec_tv_template[] =
|
1316 |
|
|
{
|
1317 |
|
|
{
|
1318 |
|
|
.key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
|
1319 |
|
|
0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
|
1320 |
|
|
.klen = 16,
|
1321 |
|
|
.input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
|
1322 |
|
|
0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
|
1323 |
|
|
.ilen = 16,
|
1324 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1325 |
|
|
.rlen = 16,
|
1326 |
|
|
}, {
|
1327 |
|
|
.key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
|
1328 |
|
|
0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
|
1329 |
|
|
0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
|
1330 |
|
|
.klen = 24,
|
1331 |
|
|
.input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
|
1332 |
|
|
0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
|
1333 |
|
|
.ilen = 16,
|
1334 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1335 |
|
|
.rlen = 16,
|
1336 |
|
|
}, {
|
1337 |
|
|
.key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
|
1338 |
|
|
0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
|
1339 |
|
|
0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
|
1340 |
|
|
0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
|
1341 |
|
|
.klen = 32,
|
1342 |
|
|
.input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
|
1343 |
|
|
0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
|
1344 |
|
|
.ilen = 16,
|
1345 |
|
|
.result = { [0 ... 15] = 0x00 },
|
1346 |
|
|
.rlen = 16,
|
1347 |
|
|
},
|
1348 |
|
|
};
|
1349 |
|
|
|
1350 |
|
|
|
1351 |
|
|
/*
|
1352 |
|
|
* AES test vectors.
|
1353 |
|
|
*/
|
1354 |
|
|
#define AES_ENC_TEST_VECTORS 3
|
1355 |
|
|
#define AES_DEC_TEST_VECTORS 3
|
1356 |
|
|
|
1357 |
|
|
struct cipher_testvec aes_enc_tv_template[] = {
|
1358 |
|
|
{ /* From FIPS-197 */
|
1359 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1360 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1361 |
|
|
.klen = 16,
|
1362 |
|
|
.input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1363 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1364 |
|
|
.ilen = 16,
|
1365 |
|
|
.result = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
|
1366 |
|
|
0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
|
1367 |
|
|
.rlen = 16,
|
1368 |
|
|
}, {
|
1369 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1370 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
1371 |
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
|
1372 |
|
|
.klen = 24,
|
1373 |
|
|
.input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1374 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1375 |
|
|
.ilen = 16,
|
1376 |
|
|
.result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
|
1377 |
|
|
0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
|
1378 |
|
|
.rlen = 16,
|
1379 |
|
|
}, {
|
1380 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1381 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
1382 |
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
1383 |
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
|
1384 |
|
|
.klen = 32,
|
1385 |
|
|
.input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1386 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1387 |
|
|
.ilen = 16,
|
1388 |
|
|
.result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
|
1389 |
|
|
0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
|
1390 |
|
|
.rlen = 16,
|
1391 |
|
|
},
|
1392 |
|
|
};
|
1393 |
|
|
|
1394 |
|
|
struct cipher_testvec aes_dec_tv_template[] = {
|
1395 |
|
|
{ /* From FIPS-197 */
|
1396 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1397 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
1398 |
|
|
.klen = 16,
|
1399 |
|
|
.input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
|
1400 |
|
|
0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
|
1401 |
|
|
.ilen = 16,
|
1402 |
|
|
.result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1403 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1404 |
|
|
.rlen = 16,
|
1405 |
|
|
}, {
|
1406 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1407 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
1408 |
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
|
1409 |
|
|
.klen = 24,
|
1410 |
|
|
.input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
|
1411 |
|
|
0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
|
1412 |
|
|
.ilen = 16,
|
1413 |
|
|
.result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1414 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1415 |
|
|
.rlen = 16,
|
1416 |
|
|
}, {
|
1417 |
|
|
.key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
1418 |
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
1419 |
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
1420 |
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
|
1421 |
|
|
.klen = 32,
|
1422 |
|
|
.input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
|
1423 |
|
|
0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
|
1424 |
|
|
.ilen = 16,
|
1425 |
|
|
.result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
1426 |
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
|
1427 |
|
|
.rlen = 16,
|
1428 |
|
|
},
|
1429 |
|
|
};
|
1430 |
|
|
|
1431 |
|
|
/* Cast5 test vectors from RFC 2144 */
|
1432 |
|
|
#define CAST5_ENC_TEST_VECTORS 3
|
1433 |
|
|
#define CAST5_DEC_TEST_VECTORS 3
|
1434 |
|
|
|
1435 |
|
|
struct cipher_testvec cast5_enc_tv_template[] =
|
1436 |
|
|
{
|
1437 |
|
|
{
|
1438 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
1439 |
|
|
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
|
1440 |
|
|
.klen = 16,
|
1441 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1442 |
|
|
.ilen = 8,
|
1443 |
|
|
.result = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
|
1444 |
|
|
.rlen = 8,
|
1445 |
|
|
}, {
|
1446 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
1447 |
|
|
0x23, 0x45 },
|
1448 |
|
|
.klen = 10,
|
1449 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1450 |
|
|
.ilen = 8,
|
1451 |
|
|
.result = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
|
1452 |
|
|
.rlen = 8,
|
1453 |
|
|
}, {
|
1454 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
|
1455 |
|
|
.klen = 5,
|
1456 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1457 |
|
|
.ilen = 8,
|
1458 |
|
|
.result = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
|
1459 |
|
|
.rlen = 8,
|
1460 |
|
|
},
|
1461 |
|
|
};
|
1462 |
|
|
|
1463 |
|
|
struct cipher_testvec cast5_dec_tv_template[] =
|
1464 |
|
|
{
|
1465 |
|
|
{
|
1466 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
1467 |
|
|
0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
|
1468 |
|
|
.klen = 16,
|
1469 |
|
|
.input = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
|
1470 |
|
|
.ilen = 8,
|
1471 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1472 |
|
|
.rlen = 8,
|
1473 |
|
|
}, {
|
1474 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
|
1475 |
|
|
0x23, 0x45 },
|
1476 |
|
|
.klen = 10,
|
1477 |
|
|
.input = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
|
1478 |
|
|
.ilen = 8,
|
1479 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1480 |
|
|
.rlen = 8,
|
1481 |
|
|
}, {
|
1482 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
|
1483 |
|
|
.klen = 5,
|
1484 |
|
|
.input = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
|
1485 |
|
|
.ilen = 8,
|
1486 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1487 |
|
|
.rlen = 8,
|
1488 |
|
|
},
|
1489 |
|
|
};
|
1490 |
|
|
|
1491 |
|
|
/*
|
1492 |
|
|
* ARC4 test vectors from OpenSSL
|
1493 |
|
|
*/
|
1494 |
|
|
#define ARC4_ENC_TEST_VECTORS 7
|
1495 |
|
|
#define ARC4_DEC_TEST_VECTORS 7
|
1496 |
|
|
|
1497 |
|
|
struct cipher_testvec arc4_enc_tv_template[] =
|
1498 |
|
|
{
|
1499 |
|
|
{
|
1500 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1501 |
|
|
.klen = 8,
|
1502 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1503 |
|
|
.ilen = 8,
|
1504 |
|
|
.result = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
|
1505 |
|
|
.rlen = 8,
|
1506 |
|
|
}, {
|
1507 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1508 |
|
|
.klen = 8,
|
1509 |
|
|
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1510 |
|
|
.ilen = 8,
|
1511 |
|
|
.result = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
|
1512 |
|
|
.rlen = 8,
|
1513 |
|
|
}, {
|
1514 |
|
|
.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1515 |
|
|
.klen = 8,
|
1516 |
|
|
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1517 |
|
|
.ilen = 8,
|
1518 |
|
|
.result = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
|
1519 |
|
|
.rlen = 8,
|
1520 |
|
|
}, {
|
1521 |
|
|
.key = { 0xef, 0x01, 0x23, 0x45},
|
1522 |
|
|
.klen = 4,
|
1523 |
|
|
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
1524 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
1525 |
|
|
0x00, 0x00, 0x00, 0x00 },
|
1526 |
|
|
.ilen = 20,
|
1527 |
|
|
.result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
|
1528 |
|
|
0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
|
1529 |
|
|
0x36, 0xb6, 0x78, 0x58 },
|
1530 |
|
|
.rlen = 20,
|
1531 |
|
|
}, {
|
1532 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1533 |
|
|
.klen = 8,
|
1534 |
|
|
.input = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
1535 |
|
|
0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
1536 |
|
|
0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
1537 |
|
|
0x12, 0x34, 0x56, 0x78 },
|
1538 |
|
|
.ilen = 28,
|
1539 |
|
|
.result = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
|
1540 |
|
|
0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
|
1541 |
|
|
0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
|
1542 |
|
|
0x40, 0x01, 0x1e, 0xcf },
|
1543 |
|
|
.rlen = 28,
|
1544 |
|
|
}, {
|
1545 |
|
|
.key = { 0xef, 0x01, 0x23, 0x45 },
|
1546 |
|
|
.klen = 4,
|
1547 |
|
|
.input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
1548 |
|
|
0x00, 0x00 },
|
1549 |
|
|
.ilen = 10,
|
1550 |
|
|
.result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
|
1551 |
|
|
0xbd, 0x61 },
|
1552 |
|
|
.rlen = 10,
|
1553 |
|
|
}, {
|
1554 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
|
1555 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1556 |
|
|
.klen = 16,
|
1557 |
|
|
.input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
|
1558 |
|
|
.ilen = 8,
|
1559 |
|
|
.result = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
|
1560 |
|
|
.rlen = 8,
|
1561 |
|
|
},
|
1562 |
|
|
};
|
1563 |
|
|
|
1564 |
|
|
struct cipher_testvec arc4_dec_tv_template[] =
|
1565 |
|
|
{
|
1566 |
|
|
{
|
1567 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1568 |
|
|
.klen = 8,
|
1569 |
|
|
.input = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
|
1570 |
|
|
.ilen = 8,
|
1571 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1572 |
|
|
.rlen = 8,
|
1573 |
|
|
}, {
|
1574 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1575 |
|
|
.klen = 8,
|
1576 |
|
|
.input = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
|
1577 |
|
|
.ilen = 8,
|
1578 |
|
|
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1579 |
|
|
.rlen = 8,
|
1580 |
|
|
}, {
|
1581 |
|
|
.key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1582 |
|
|
.klen = 8,
|
1583 |
|
|
.input = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
|
1584 |
|
|
.ilen = 8,
|
1585 |
|
|
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1586 |
|
|
.rlen = 8,
|
1587 |
|
|
}, {
|
1588 |
|
|
.key = { 0xef, 0x01, 0x23, 0x45},
|
1589 |
|
|
.klen = 4,
|
1590 |
|
|
.input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
|
1591 |
|
|
0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
|
1592 |
|
|
0x36, 0xb6, 0x78, 0x58 },
|
1593 |
|
|
.ilen = 20,
|
1594 |
|
|
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
1595 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
1596 |
|
|
0x00, 0x00, 0x00, 0x00 },
|
1597 |
|
|
.rlen = 20,
|
1598 |
|
|
}, {
|
1599 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
|
1600 |
|
|
.klen = 8,
|
1601 |
|
|
.input = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
|
1602 |
|
|
0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
|
1603 |
|
|
0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
|
1604 |
|
|
0x40, 0x01, 0x1e, 0xcf },
|
1605 |
|
|
.ilen = 28,
|
1606 |
|
|
.result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
1607 |
|
|
0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
1608 |
|
|
0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
1609 |
|
|
0x12, 0x34, 0x56, 0x78 },
|
1610 |
|
|
.rlen = 28,
|
1611 |
|
|
}, {
|
1612 |
|
|
.key = { 0xef, 0x01, 0x23, 0x45 },
|
1613 |
|
|
.klen = 4,
|
1614 |
|
|
.input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
|
1615 |
|
|
0xbd, 0x61 },
|
1616 |
|
|
.ilen = 10,
|
1617 |
|
|
.result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
1618 |
|
|
0x00, 0x00 },
|
1619 |
|
|
.rlen = 10,
|
1620 |
|
|
}, {
|
1621 |
|
|
.key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
|
1622 |
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
1623 |
|
|
.klen = 16,
|
1624 |
|
|
.input = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
|
1625 |
|
|
.ilen = 8,
|
1626 |
|
|
.result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
|
1627 |
|
|
.rlen = 8,
|
1628 |
|
|
},
|
1629 |
|
|
};
|
1630 |
|
|
|
1631 |
|
|
|
1632 |
|
|
/*
|
1633 |
|
|
* Compression stuff.
|
1634 |
|
|
*/
|
1635 |
|
|
#define COMP_BUF_SIZE 512
|
1636 |
|
|
|
1637 |
|
|
struct comp_testvec {
|
1638 |
|
|
int inlen, outlen;
|
1639 |
|
|
char input[COMP_BUF_SIZE];
|
1640 |
|
|
char output[COMP_BUF_SIZE];
|
1641 |
|
|
};
|
1642 |
|
|
|
1643 |
|
|
/*
|
1644 |
|
|
* Deflate test vectors (null-terminated strings).
|
1645 |
|
|
* Params: winbits=11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
|
1646 |
|
|
*/
|
1647 |
|
|
#define DEFLATE_COMP_TEST_VECTORS 2
|
1648 |
|
|
#define DEFLATE_DECOMP_TEST_VECTORS 2
|
1649 |
|
|
|
1650 |
|
|
struct comp_testvec deflate_comp_tv_template[] = {
|
1651 |
|
|
{
|
1652 |
|
|
.inlen = 70,
|
1653 |
|
|
.outlen = 38,
|
1654 |
|
|
.input = "Join us now and share the software "
|
1655 |
|
|
"Join us now and share the software ",
|
1656 |
|
|
.output = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
|
1657 |
|
|
0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
|
1658 |
|
|
0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
|
1659 |
|
|
0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
|
1660 |
|
|
0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
|
1661 |
|
|
}, {
|
1662 |
|
|
.inlen = 191,
|
1663 |
|
|
.outlen = 122,
|
1664 |
|
|
.input = "This document describes a compression method based on the DEFLATE"
|
1665 |
|
|
"compression algorithm. This document defines the application of "
|
1666 |
|
|
"the DEFLATE algorithm to the IP Payload Compression Protocol.",
|
1667 |
|
|
.output = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
|
1668 |
|
|
0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
|
1669 |
|
|
0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
|
1670 |
|
|
0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
|
1671 |
|
|
0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
|
1672 |
|
|
0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
|
1673 |
|
|
0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
|
1674 |
|
|
0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
|
1675 |
|
|
0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
|
1676 |
|
|
0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
|
1677 |
|
|
0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
|
1678 |
|
|
0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
|
1679 |
|
|
0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
|
1680 |
|
|
0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
|
1681 |
|
|
0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
|
1682 |
|
|
0xfa, 0x02 },
|
1683 |
|
|
},
|
1684 |
|
|
};
|
1685 |
|
|
|
1686 |
|
|
struct comp_testvec deflate_decomp_tv_template[] = {
|
1687 |
|
|
{
|
1688 |
|
|
.inlen = 122,
|
1689 |
|
|
.outlen = 191,
|
1690 |
|
|
.input = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
|
1691 |
|
|
0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
|
1692 |
|
|
0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
|
1693 |
|
|
0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
|
1694 |
|
|
0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
|
1695 |
|
|
0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
|
1696 |
|
|
0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
|
1697 |
|
|
0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
|
1698 |
|
|
0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
|
1699 |
|
|
0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
|
1700 |
|
|
0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
|
1701 |
|
|
0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
|
1702 |
|
|
0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
|
1703 |
|
|
0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
|
1704 |
|
|
0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
|
1705 |
|
|
0xfa, 0x02 },
|
1706 |
|
|
.output = "This document describes a compression method based on the DEFLATE"
|
1707 |
|
|
"compression algorithm. This document defines the application of "
|
1708 |
|
|
"the DEFLATE algorithm to the IP Payload Compression Protocol.",
|
1709 |
|
|
}, {
|
1710 |
|
|
.inlen = 38,
|
1711 |
|
|
.outlen = 70,
|
1712 |
|
|
.input = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
|
1713 |
|
|
0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
|
1714 |
|
|
0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
|
1715 |
|
|
0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
|
1716 |
|
|
0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
|
1717 |
|
|
.output = "Join us now and share the software "
|
1718 |
|
|
"Join us now and share the software ",
|
1719 |
|
|
},
|
1720 |
|
|
};
|
1721 |
|
|
|
1722 |
|
|
#endif /* _CRYPTO_TCRYPT_H */
|