[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / crypto / tcrypt.h
bloba3097afae5932b052cd92803fe3687b29e5d4ab8
1 /*
2 * Quick & dirty crypto testing module.
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
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.
15 * 14 - 09 - 2003 Changes by Kartikey Mahendra Bhatt
18 #ifndef _CRYPTO_TCRYPT_H
19 #define _CRYPTO_TCRYPT_H
21 #define MAX_DIGEST_SIZE 64
22 #define MAX_TAP 8
24 #define MAX_KEYLEN 56
25 #define MAX_IVLEN 32
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 char key[128]; /* only used with keyed hash algorithms */
34 unsigned char ksize;
37 struct hmac_testvec {
38 char key[128];
39 unsigned char ksize;
40 char plaintext[128];
41 unsigned char psize;
42 char digest[MAX_DIGEST_SIZE];
43 unsigned char np;
44 unsigned char tap[MAX_TAP];
47 struct cipher_testvec {
48 unsigned char fail;
49 unsigned char wk; /* weak key flag */
50 char key[MAX_KEYLEN];
51 unsigned char klen;
52 char iv[MAX_IVLEN];
53 char input[48];
54 unsigned char ilen;
55 char result[48];
56 unsigned char rlen;
57 int np;
58 unsigned char tap[MAX_TAP];
62 * MD4 test vectors from RFC1320
64 #define MD4_TEST_VECTORS 7
66 static struct hash_testvec md4_tv_template [] = {
68 .plaintext = "",
69 .digest = { 0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31,
70 0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0 },
71 }, {
72 .plaintext = "a",
73 .psize = 1,
74 .digest = { 0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46,
75 0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24 },
76 }, {
77 .plaintext = "abc",
78 .psize = 3,
79 .digest = { 0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52,
80 0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d },
81 }, {
82 .plaintext = "message digest",
83 .psize = 14,
84 .digest = { 0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8,
85 0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b },
86 }, {
87 .plaintext = "abcdefghijklmnopqrstuvwxyz",
88 .psize = 26,
89 .digest = { 0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd,
90 0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9 },
91 .np = 2,
92 .tap = { 13, 13 },
93 }, {
94 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
95 .psize = 62,
96 .digest = { 0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35,
97 0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4 },
98 }, {
99 .plaintext = "123456789012345678901234567890123456789012345678901234567890123"
100 "45678901234567890",
101 .psize = 80,
102 .digest = { 0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19,
103 0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36 },
108 * MD5 test vectors from RFC1321
110 #define MD5_TEST_VECTORS 7
112 static struct hash_testvec md5_tv_template[] = {
114 .digest = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
115 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e },
116 }, {
117 .plaintext = "a",
118 .psize = 1,
119 .digest = { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8,
120 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 },
121 }, {
122 .plaintext = "abc",
123 .psize = 3,
124 .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
125 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 },
126 }, {
127 .plaintext = "message digest",
128 .psize = 14,
129 .digest = { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d,
130 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 },
131 }, {
132 .plaintext = "abcdefghijklmnopqrstuvwxyz",
133 .psize = 26,
134 .digest = { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00,
135 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b },
136 .np = 2,
137 .tap = {13, 13}
138 }, {
139 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
140 .psize = 62,
141 .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
142 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f },
143 }, {
144 .plaintext = "12345678901234567890123456789012345678901234567890123456789012"
145 "345678901234567890",
146 .psize = 80,
147 .digest = { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55,
148 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a },
153 * SHA1 test vectors from from FIPS PUB 180-1
155 #define SHA1_TEST_VECTORS 2
157 static struct hash_testvec sha1_tv_template[] = {
159 .plaintext = "abc",
160 .psize = 3,
161 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
162 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d },
163 }, {
164 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
165 .psize = 56,
166 .digest = { 0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae,
167 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1 },
168 .np = 2,
169 .tap = { 28, 28 }
174 * SHA256 test vectors from from NIST
176 #define SHA256_TEST_VECTORS 2
178 static struct hash_testvec sha256_tv_template[] = {
180 .plaintext = "abc",
181 .psize = 3,
182 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
183 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
184 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
185 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad },
186 }, {
187 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
188 .psize = 56,
189 .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
190 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
191 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
192 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 },
193 .np = 2,
194 .tap = { 28, 28 }
199 * SHA384 test vectors from from NIST and kerneli
201 #define SHA384_TEST_VECTORS 4
203 static struct hash_testvec sha384_tv_template[] = {
205 .plaintext= "abc",
206 .psize = 3,
207 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
208 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
209 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
210 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
211 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
212 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 },
213 }, {
214 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
215 .psize = 56,
216 .digest = { 0x33, 0x91, 0xfd, 0xdd, 0xfc, 0x8d, 0xc7, 0x39,
217 0x37, 0x07, 0xa6, 0x5b, 0x1b, 0x47, 0x09, 0x39,
218 0x7c, 0xf8, 0xb1, 0xd1, 0x62, 0xaf, 0x05, 0xab,
219 0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6,
220 0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f,
221 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b},
222 }, {
223 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
224 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
225 .psize = 112,
226 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
227 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
228 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
229 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
230 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
231 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 },
232 }, {
233 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
234 "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
235 .psize = 104,
236 .digest = { 0x3d, 0x20, 0x89, 0x73, 0xab, 0x35, 0x08, 0xdb,
237 0xbd, 0x7e, 0x2c, 0x28, 0x62, 0xba, 0x29, 0x0a,
238 0xd3, 0x01, 0x0e, 0x49, 0x78, 0xc1, 0x98, 0xdc,
239 0x4d, 0x8f, 0xd0, 0x14, 0xe5, 0x82, 0x82, 0x3a,
240 0x89, 0xe1, 0x6f, 0x9b, 0x2a, 0x7b, 0xbc, 0x1a,
241 0xc9, 0x38, 0xe2, 0xd1, 0x99, 0xe8, 0xbe, 0xa4 },
242 .np = 4,
243 .tap = { 26, 26, 26, 26 }
248 * SHA512 test vectors from from NIST and kerneli
250 #define SHA512_TEST_VECTORS 4
252 static struct hash_testvec sha512_tv_template[] = {
254 .plaintext = "abc",
255 .psize = 3,
256 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
257 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
258 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
259 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
260 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
261 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
262 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
263 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f },
264 }, {
265 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
266 .psize = 56,
267 .digest = { 0x20, 0x4a, 0x8f, 0xc6, 0xdd, 0xa8, 0x2f, 0x0a,
268 0x0c, 0xed, 0x7b, 0xeb, 0x8e, 0x08, 0xa4, 0x16,
269 0x57, 0xc1, 0x6e, 0xf4, 0x68, 0xb2, 0x28, 0xa8,
270 0x27, 0x9b, 0xe3, 0x31, 0xa7, 0x03, 0xc3, 0x35,
271 0x96, 0xfd, 0x15, 0xc1, 0x3b, 0x1b, 0x07, 0xf9,
272 0xaa, 0x1d, 0x3b, 0xea, 0x57, 0x78, 0x9c, 0xa0,
273 0x31, 0xad, 0x85, 0xc7, 0xa7, 0x1d, 0xd7, 0x03,
274 0x54, 0xec, 0x63, 0x12, 0x38, 0xca, 0x34, 0x45 },
275 }, {
276 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
277 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
278 .psize = 112,
279 .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
280 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
281 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
282 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
283 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
284 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
285 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
286 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 },
287 }, {
288 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
289 "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
290 .psize = 104,
291 .digest = { 0x93, 0x0d, 0x0c, 0xef, 0xcb, 0x30, 0xff, 0x11,
292 0x33, 0xb6, 0x89, 0x81, 0x21, 0xf1, 0xcf, 0x3d,
293 0x27, 0x57, 0x8a, 0xfc, 0xaf, 0xe8, 0x67, 0x7c,
294 0x52, 0x57, 0xcf, 0x06, 0x99, 0x11, 0xf7, 0x5d,
295 0x8f, 0x58, 0x31, 0xb5, 0x6e, 0xbf, 0xda, 0x67,
296 0xb2, 0x78, 0xe6, 0x6d, 0xff, 0x8b, 0x84, 0xfe,
297 0x2b, 0x28, 0x70, 0xf7, 0x42, 0xa5, 0x80, 0xd8,
298 0xed, 0xb4, 0x19, 0x87, 0x23, 0x28, 0x50, 0xc9 },
299 .np = 4,
300 .tap = { 26, 26, 26, 26 }
306 * WHIRLPOOL test vectors from Whirlpool package
307 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
308 * submission
310 #define WP512_TEST_VECTORS 8
312 static struct hash_testvec wp512_tv_template[] = {
314 .plaintext = "",
315 .psize = 0,
316 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
317 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
318 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
319 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
320 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
321 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57,
322 0xEA, 0x89, 0x64, 0xE5, 0x9B, 0x63, 0xD9, 0x37,
323 0x08, 0xB1, 0x38, 0xCC, 0x42, 0xA6, 0x6E, 0xB3 },
326 }, {
327 .plaintext = "a",
328 .psize = 1,
329 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
330 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
331 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
332 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
333 0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
334 0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59,
335 0x1A, 0x92, 0x20, 0x0D, 0x56, 0x01, 0x95, 0xE5,
336 0x3B, 0x47, 0x85, 0x84, 0xFD, 0xAE, 0x23, 0x1A },
337 }, {
338 .plaintext = "abc",
339 .psize = 3,
340 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
341 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
342 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
343 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
344 0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
345 0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6,
346 0xC7, 0x97, 0xFC, 0x9D, 0x95, 0xD8, 0xB5, 0x82,
347 0xD2, 0x25, 0x29, 0x20, 0x76, 0xD4, 0xEE, 0xF5 },
348 }, {
349 .plaintext = "message digest",
350 .psize = 14,
351 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
352 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
353 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
354 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
355 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
356 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6,
357 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33,
358 0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E },
359 }, {
360 .plaintext = "abcdefghijklmnopqrstuvwxyz",
361 .psize = 26,
362 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
363 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
364 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
365 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
366 0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
367 0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6,
368 0xF6, 0x8F, 0x67, 0x3E, 0x72, 0x07, 0x86, 0x5D,
369 0x5D, 0x98, 0x19, 0xA3, 0xDB, 0xA4, 0xEB, 0x3B },
370 }, {
371 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
372 "abcdefghijklmnopqrstuvwxyz0123456789",
373 .psize = 62,
374 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
375 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
376 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
377 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
378 0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
379 0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6,
380 0x55, 0x17, 0xCC, 0x87, 0x9D, 0x7B, 0x96, 0x21,
381 0x42, 0xC6, 0x5F, 0x5A, 0x7A, 0xF0, 0x14, 0x67 },
382 }, {
383 .plaintext = "1234567890123456789012345678901234567890"
384 "1234567890123456789012345678901234567890",
385 .psize = 80,
386 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
387 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
388 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
389 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
390 0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
391 0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A,
392 0x2C, 0x60, 0x48, 0x1E, 0x88, 0xC5, 0xA2, 0x0B,
393 0x2C, 0x2A, 0x80, 0xCF, 0x3A, 0x9A, 0x08, 0x3B },
394 }, {
395 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
396 .psize = 32,
397 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
398 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
399 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
400 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
401 0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
402 0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56,
403 0x93, 0x9B, 0xAA, 0xA0, 0xAD, 0xFF, 0x9A, 0xE6,
404 0x74, 0x5B, 0x7B, 0x18, 0x1C, 0x3B, 0xE3, 0xFD },
408 #define WP384_TEST_VECTORS 8
410 static struct hash_testvec wp384_tv_template[] = {
412 .plaintext = "",
413 .psize = 0,
414 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
415 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
416 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
417 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
418 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
419 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57 },
422 }, {
423 .plaintext = "a",
424 .psize = 1,
425 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
426 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
427 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
428 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
429 0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
430 0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59 },
431 }, {
432 .plaintext = "abc",
433 .psize = 3,
434 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
435 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
436 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
437 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
438 0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
439 0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6 },
440 }, {
441 .plaintext = "message digest",
442 .psize = 14,
443 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
444 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
445 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
446 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
447 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
448 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 },
449 }, {
450 .plaintext = "abcdefghijklmnopqrstuvwxyz",
451 .psize = 26,
452 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
453 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
454 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
455 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
456 0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
457 0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6 },
458 }, {
459 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
460 "abcdefghijklmnopqrstuvwxyz0123456789",
461 .psize = 62,
462 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
463 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
464 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
465 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
466 0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
467 0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6 },
468 }, {
469 .plaintext = "1234567890123456789012345678901234567890"
470 "1234567890123456789012345678901234567890",
471 .psize = 80,
472 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
473 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
474 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
475 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
476 0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
477 0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A },
478 }, {
479 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
480 .psize = 32,
481 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
482 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
483 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
484 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
485 0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
486 0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56 },
490 #define WP256_TEST_VECTORS 8
492 static struct hash_testvec wp256_tv_template[] = {
494 .plaintext = "",
495 .psize = 0,
496 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
497 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
498 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
499 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7 },
502 }, {
503 .plaintext = "a",
504 .psize = 1,
505 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
506 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
507 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
508 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42 },
509 }, {
510 .plaintext = "abc",
511 .psize = 3,
512 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
513 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
514 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
515 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C },
516 }, {
517 .plaintext = "message digest",
518 .psize = 14,
519 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
520 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
521 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
522 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B },
523 }, {
524 .plaintext = "abcdefghijklmnopqrstuvwxyz",
525 .psize = 26,
526 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
527 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
528 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
529 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B },
530 }, {
531 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
532 "abcdefghijklmnopqrstuvwxyz0123456789",
533 .psize = 62,
534 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
535 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
536 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
537 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E },
538 }, {
539 .plaintext = "1234567890123456789012345678901234567890"
540 "1234567890123456789012345678901234567890",
541 .psize = 80,
542 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
543 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
544 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
545 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29 },
546 }, {
547 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
548 .psize = 32,
549 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
550 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
551 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
552 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 },
557 * TIGER test vectors from Tiger website
559 #define TGR192_TEST_VECTORS 6
561 static struct hash_testvec tgr192_tv_template[] = {
563 .plaintext = "",
564 .psize = 0,
565 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
566 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
567 0xf3, 0x73, 0xde, 0x2d, 0x49, 0x58, 0x4e, 0x7a },
568 }, {
569 .plaintext = "abc",
570 .psize = 3,
571 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
572 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
573 0x93, 0x5f, 0x7b, 0x95, 0x1c, 0x13, 0x29, 0x51 },
574 }, {
575 .plaintext = "Tiger",
576 .psize = 5,
577 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
578 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
579 0x37, 0x79, 0x0c, 0x11, 0x6f, 0x9d, 0x2b, 0xdf },
580 }, {
581 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
582 .psize = 64,
583 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
584 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
585 0xb5, 0x86, 0x44, 0x50, 0x34, 0xa5, 0xa3, 0x86 },
586 }, {
587 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
588 .psize = 64,
589 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
590 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
591 0x57, 0x89, 0x65, 0x65, 0x97, 0x5f, 0x91, 0x97 },
592 }, {
593 .plaintext = "Tiger - A Fast New Hash Function, "
594 "by Ross Anderson and Eli Biham, "
595 "proceedings of Fast Software Encryption 3, "
596 "Cambridge, 1996.",
597 .psize = 125,
598 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
599 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
600 0xdd, 0x68, 0x15, 0x1d, 0x50, 0x39, 0x74, 0xfc },
604 #define TGR160_TEST_VECTORS 6
606 static struct hash_testvec tgr160_tv_template[] = {
608 .plaintext = "",
609 .psize = 0,
610 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
611 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
612 0xf3, 0x73, 0xde, 0x2d },
613 }, {
614 .plaintext = "abc",
615 .psize = 3,
616 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
617 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
618 0x93, 0x5f, 0x7b, 0x95 },
619 }, {
620 .plaintext = "Tiger",
621 .psize = 5,
622 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
623 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
624 0x37, 0x79, 0x0c, 0x11 },
625 }, {
626 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
627 .psize = 64,
628 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
629 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
630 0xb5, 0x86, 0x44, 0x50 },
631 }, {
632 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
633 .psize = 64,
634 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
635 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
636 0x57, 0x89, 0x65, 0x65 },
637 }, {
638 .plaintext = "Tiger - A Fast New Hash Function, "
639 "by Ross Anderson and Eli Biham, "
640 "proceedings of Fast Software Encryption 3, "
641 "Cambridge, 1996.",
642 .psize = 125,
643 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
644 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
645 0xdd, 0x68, 0x15, 0x1d },
649 #define TGR128_TEST_VECTORS 6
651 static struct hash_testvec tgr128_tv_template[] = {
653 .plaintext = "",
654 .psize = 0,
655 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
656 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f },
657 }, {
658 .plaintext = "abc",
659 .psize = 3,
660 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
661 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf },
662 }, {
663 .plaintext = "Tiger",
664 .psize = 5,
665 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
666 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec },
667 }, {
668 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
669 .psize = 64,
670 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
671 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e },
672 }, {
673 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
674 .psize = 64,
675 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
676 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9 },
677 }, {
678 .plaintext = "Tiger - A Fast New Hash Function, "
679 "by Ross Anderson and Eli Biham, "
680 "proceedings of Fast Software Encryption 3, "
681 "Cambridge, 1996.",
682 .psize = 125,
683 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
684 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24 },
688 #ifdef CONFIG_CRYPTO_HMAC
690 * HMAC-MD5 test vectors from RFC2202
691 * (These need to be fixed to not use strlen).
693 #define HMAC_MD5_TEST_VECTORS 7
695 static struct hmac_testvec hmac_md5_tv_template[] =
698 .key = { [0 ... 15] = 0x0b },
699 .ksize = 16,
700 .plaintext = "Hi There",
701 .psize = 8,
702 .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
703 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
704 }, {
705 .key = { 'J', 'e', 'f', 'e' },
706 .ksize = 4,
707 .plaintext = "what do ya want for nothing?",
708 .psize = 28,
709 .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
710 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
711 .np = 2,
712 .tap = {14, 14}
713 }, {
714 .key = { [0 ... 15] = 0xaa },
715 .ksize = 16,
716 .plaintext = { [0 ... 49] = 0xdd },
717 .psize = 50,
718 .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
719 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 },
720 }, {
721 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
722 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
723 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, },
724 .ksize = 25,
725 .plaintext = { [0 ... 49] = 0xcd },
726 .psize = 50,
727 .digest = { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
728 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 },
729 }, {
730 .key = { [0 ... 15] = 0x0c },
731 .ksize = 16,
732 .plaintext = "Test With Truncation",
733 .psize = 20,
734 .digest = { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
735 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c },
736 }, {
737 .key = { [0 ... 79] = 0xaa },
738 .ksize = 80,
739 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
740 .psize = 54,
741 .digest = { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f,
742 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd },
743 }, {
744 .key = { [0 ... 79] = 0xaa },
745 .ksize = 80,
746 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
747 "Block-Size Data",
748 .psize = 73,
749 .digest = { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee,
750 0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e },
755 * HMAC-SHA1 test vectors from RFC2202
757 #define HMAC_SHA1_TEST_VECTORS 7
759 static struct hmac_testvec hmac_sha1_tv_template[] = {
761 .key = { [0 ... 19] = 0x0b },
762 .ksize = 20,
763 .plaintext = "Hi There",
764 .psize = 8,
765 .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
766 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1,
767 0x46, 0xbe },
768 }, {
769 .key = { 'J', 'e', 'f', 'e' },
770 .ksize = 4,
771 .plaintext = "what do ya want for nothing?",
772 .psize = 28,
773 .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74,
774 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 },
775 .np = 2,
776 .tap = { 14, 14 }
777 }, {
778 .key = { [0 ... 19] = 0xaa },
779 .ksize = 20,
780 .plaintext = { [0 ... 49] = 0xdd },
781 .psize = 50,
782 .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3,
783 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 },
784 }, {
785 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
786 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
787 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 },
788 .ksize = 25,
789 .plaintext = { [0 ... 49] = 0xcd },
790 .psize = 50,
791 .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84,
792 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda },
793 }, {
794 .key = { [0 ... 19] = 0x0c },
795 .ksize = 20,
796 .plaintext = "Test With Truncation",
797 .psize = 20,
798 .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
799 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 },
800 }, {
801 .key = { [0 ... 79] = 0xaa },
802 .ksize = 80,
803 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
804 .psize = 54,
805 .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
806 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 },
807 }, {
808 .key = { [0 ... 79] = 0xaa },
809 .ksize = 80,
810 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
811 "Block-Size Data",
812 .psize = 73,
813 .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b,
814 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 },
819 * HMAC-SHA256 test vectors from
820 * draft-ietf-ipsec-ciph-sha-256-01.txt
822 #define HMAC_SHA256_TEST_VECTORS 10
824 static struct hmac_testvec hmac_sha256_tv_template[] = {
826 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
827 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
828 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
829 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20},
830 .ksize = 32,
831 .plaintext = "abc",
832 .psize = 3,
833 .digest = { 0xa2, 0x1b, 0x1f, 0x5d, 0x4c, 0xf4, 0xf7, 0x3a,
834 0x4d, 0xd9, 0x39, 0x75, 0x0f, 0x7a, 0x06, 0x6a,
835 0x7f, 0x98, 0xcc, 0x13, 0x1c, 0xb1, 0x6a, 0x66,
836 0x92, 0x75, 0x90, 0x21, 0xcf, 0xab, 0x81, 0x81 },
837 }, {
838 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
839 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
840 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
841 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
842 .ksize = 32,
843 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
844 .psize = 56,
845 .digest = { 0x10, 0x4f, 0xdc, 0x12, 0x57, 0x32, 0x8f, 0x08,
846 0x18, 0x4b, 0xa7, 0x31, 0x31, 0xc5, 0x3c, 0xae,
847 0xe6, 0x98, 0xe3, 0x61, 0x19, 0x42, 0x11, 0x49,
848 0xea, 0x8c, 0x71, 0x24, 0x56, 0x69, 0x7d, 0x30 },
849 }, {
850 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
851 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
852 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
853 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
854 .ksize = 32,
855 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
856 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
857 .psize = 112,
858 .digest = { 0x47, 0x03, 0x05, 0xfc, 0x7e, 0x40, 0xfe, 0x34,
859 0xd3, 0xee, 0xb3, 0xe7, 0x73, 0xd9, 0x5a, 0xab,
860 0x73, 0xac, 0xf0, 0xfd, 0x06, 0x04, 0x47, 0xa5,
861 0xeb, 0x45, 0x95, 0xbf, 0x33, 0xa9, 0xd1, 0xa3 },
862 }, {
863 .key = { [0 ... 31] = 0x0b },
864 .ksize = 32,
865 .plaintext = "Hi There",
866 .psize = 8,
867 .digest = { 0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb, 0xc6,
868 0x99, 0x03, 0xa0, 0xf1, 0xcf, 0x2b, 0xbd, 0xc5,
869 0xba, 0x0a, 0xa3, 0xf3, 0xd9, 0xae, 0x3c, 0x1c,
870 0x7a, 0x3b, 0x16, 0x96, 0xa0, 0xb6, 0x8c, 0xf7 },
871 }, {
872 .key = "Jefe",
873 .ksize = 4,
874 .plaintext = "what do ya want for nothing?",
875 .psize = 28,
876 .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
877 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
878 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
879 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 },
880 .np = 2,
881 .tap = { 14, 14 }
882 }, {
883 .key = { [0 ... 31] = 0xaa },
884 .ksize = 32,
885 .plaintext = { [0 ... 49] = 0xdd },
886 .psize = 50,
887 .digest = { 0xcd, 0xcb, 0x12, 0x20, 0xd1, 0xec, 0xcc, 0xea,
888 0x91, 0xe5, 0x3a, 0xba, 0x30, 0x92, 0xf9, 0x62,
889 0xe5, 0x49, 0xfe, 0x6c, 0xe9, 0xed, 0x7f, 0xdc,
890 0x43, 0x19, 0x1f, 0xbd, 0xe4, 0x5c, 0x30, 0xb0 },
891 }, {
892 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
893 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
894 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
895 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
896 0x21, 0x22, 0x23, 0x24, 0x25 },
897 .ksize = 37,
898 .plaintext = { [0 ... 49] = 0xcd },
899 .psize = 50,
900 .digest = { 0xd4, 0x63, 0x3c, 0x17, 0xf6, 0xfb, 0x8d, 0x74,
901 0x4c, 0x66, 0xde, 0xe0, 0xf8, 0xf0, 0x74, 0x55,
902 0x6e, 0xc4, 0xaf, 0x55, 0xef, 0x07, 0x99, 0x85,
903 0x41, 0x46, 0x8e, 0xb4, 0x9b, 0xd2, 0xe9, 0x17 },
904 }, {
905 .key = { [0 ... 31] = 0x0c },
906 .ksize = 32,
907 .plaintext = "Test With Truncation",
908 .psize = 20,
909 .digest = { 0x75, 0x46, 0xaf, 0x01, 0x84, 0x1f, 0xc0, 0x9b,
910 0x1a, 0xb9, 0xc3, 0x74, 0x9a, 0x5f, 0x1c, 0x17,
911 0xd4, 0xf5, 0x89, 0x66, 0x8a, 0x58, 0x7b, 0x27,
912 0x00, 0xa9, 0xc9, 0x7c, 0x11, 0x93, 0xcf, 0x42 },
913 }, {
914 .key = { [0 ... 79] = 0xaa },
915 .ksize = 80,
916 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
917 .psize = 54,
918 .digest = { 0x69, 0x53, 0x02, 0x5e, 0xd9, 0x6f, 0x0c, 0x09,
919 0xf8, 0x0a, 0x96, 0xf7, 0x8e, 0x65, 0x38, 0xdb,
920 0xe2, 0xe7, 0xb8, 0x20, 0xe3, 0xdd, 0x97, 0x0e,
921 0x7d, 0xdd, 0x39, 0x09, 0x1b, 0x32, 0x35, 0x2f },
922 }, {
923 .key = { [0 ... 79] = 0xaa },
924 .ksize = 80,
925 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
926 "One Block-Size Data",
927 .psize = 73,
928 .digest = { 0x63, 0x55, 0xac, 0x22, 0xe8, 0x90, 0xd0, 0xa3,
929 0xc8, 0x48, 0x1a, 0x5c, 0xa4, 0x82, 0x5b, 0xc8,
930 0x84, 0xd3, 0xe7, 0xa1, 0xff, 0x98, 0xa2, 0xfc,
931 0x2a, 0xc7, 0xd8, 0xe0, 0x64, 0xc3, 0xb2, 0xe6 },
935 #endif /* CONFIG_CRYPTO_HMAC */
938 * DES test vectors.
940 #define DES_ENC_TEST_VECTORS 10
941 #define DES_DEC_TEST_VECTORS 4
942 #define DES_CBC_ENC_TEST_VECTORS 5
943 #define DES_CBC_DEC_TEST_VECTORS 4
944 #define DES3_EDE_ENC_TEST_VECTORS 3
945 #define DES3_EDE_DEC_TEST_VECTORS 3
947 static struct cipher_testvec des_enc_tv_template[] = {
948 { /* From Applied Cryptography */
949 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
950 .klen = 8,
951 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
952 .ilen = 8,
953 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
954 .rlen = 8,
955 }, { /* Same key, different plaintext block */
956 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
957 .klen = 8,
958 .input = { 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
959 .ilen = 8,
960 .result = { 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
961 .rlen = 8,
962 }, { /* Sbox test from NBS */
963 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
964 .klen = 8,
965 .input = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
966 .ilen = 8,
967 .result = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
968 .rlen = 8,
969 }, { /* Three blocks */
970 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
971 .klen = 8,
972 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
973 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
974 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
975 .ilen = 24,
976 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
977 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
978 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
979 .rlen = 24,
980 }, { /* Weak key */
981 .fail = 1,
982 .wk = 1,
983 .key = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
984 .klen = 8,
985 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
986 .ilen = 8,
987 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
988 .rlen = 8,
989 }, { /* Two blocks -- for testing encryption across pages */
990 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
991 .klen = 8,
992 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
993 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
994 .ilen = 16,
995 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
996 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
997 .rlen = 16,
998 .np = 2,
999 .tap = { 8, 8 }
1000 }, { /* Four blocks -- for testing encryption with chunking */
1001 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1002 .klen = 8,
1003 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1004 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1005 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef,
1006 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1007 .ilen = 32,
1008 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1009 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1010 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90,
1011 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1012 .rlen = 32,
1013 .np = 3,
1014 .tap = { 14, 10, 8 }
1015 }, {
1016 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1017 .klen = 8,
1018 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1019 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1020 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
1021 .ilen = 24,
1022 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1023 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1024 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1025 .rlen = 24,
1026 .np = 4,
1027 .tap = { 2, 1, 3, 18 }
1028 }, {
1029 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1030 .klen = 8,
1031 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1032 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1033 .ilen = 16,
1034 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1035 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1036 .rlen = 16,
1037 .np = 5,
1038 .tap = { 2, 2, 2, 2, 8 }
1039 }, {
1040 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1041 .klen = 8,
1042 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1043 .ilen = 8,
1044 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1045 .rlen = 8,
1046 .np = 8,
1047 .tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
1051 static struct cipher_testvec des_dec_tv_template[] = {
1052 { /* From Applied Cryptography */
1053 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1054 .klen = 8,
1055 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1056 .ilen = 8,
1057 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1058 .rlen = 8,
1059 }, { /* Sbox test from NBS */
1060 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
1061 .klen = 8,
1062 .input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1063 .ilen = 8,
1064 .result = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
1065 .rlen = 8,
1066 }, { /* Two blocks, for chunking test */
1067 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1068 .klen = 8,
1069 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1070 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1071 .ilen = 16,
1072 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1073 0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1074 .rlen = 16,
1075 .np = 2,
1076 .tap = { 8, 8 }
1077 }, {
1078 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1079 .klen = 8,
1080 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1081 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1082 .ilen = 16,
1083 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1084 0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1085 .rlen = 16,
1086 .np = 3,
1087 .tap = { 3, 12, 1 }
1091 static struct cipher_testvec des_cbc_enc_tv_template[] = {
1092 { /* From OpenSSL */
1093 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1094 .klen = 8,
1095 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1096 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1097 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1098 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1099 .ilen = 24,
1100 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1101 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1102 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
1103 .rlen = 24,
1104 }, { /* FIPS Pub 81 */
1105 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1106 .klen = 8,
1107 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1108 .input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1109 .ilen = 8,
1110 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1111 .rlen = 8,
1112 }, {
1113 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1114 .klen = 8,
1115 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1116 .input = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1117 .ilen = 8,
1118 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1119 .rlen = 8,
1120 }, {
1121 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1122 .klen = 8,
1123 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1124 .input = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1125 .ilen = 8,
1126 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1127 .rlen = 8,
1128 }, { /* Copy of openssl vector for chunk testing */
1129 /* From OpenSSL */
1130 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1131 .klen = 8,
1132 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1133 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1134 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1135 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1136 .ilen = 24,
1137 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1138 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1139 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
1140 .rlen = 24,
1141 .np = 2,
1142 .tap = { 13, 11 }
1146 static struct cipher_testvec des_cbc_dec_tv_template[] = {
1147 { /* FIPS Pub 81 */
1148 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1149 .klen = 8,
1150 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1151 .input = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1152 .ilen = 8,
1153 .result = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1154 .rlen = 8,
1155 }, {
1156 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1157 .klen = 8,
1158 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1159 .input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1160 .ilen = 8,
1161 .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1162 .rlen = 8,
1163 }, {
1164 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1165 .klen = 8,
1166 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1167 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1168 .ilen = 8,
1169 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1170 .rlen = 8,
1171 }, { /* Copy of above, for chunk testing */
1172 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1173 .klen = 8,
1174 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1175 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1176 .ilen = 8,
1177 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1178 .rlen = 8,
1179 .np = 2,
1180 .tap = { 4, 4 }
1185 * We really need some more test vectors, especially for DES3 CBC.
1187 static struct cipher_testvec des3_ede_enc_tv_template[] = {
1188 { /* These are from openssl */
1189 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1190 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1191 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1192 .klen = 24,
1193 .input = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1194 .ilen = 8,
1195 .result = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1196 .rlen = 8,
1197 }, {
1198 .key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1199 0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1200 0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1201 .klen = 24,
1202 .input = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1203 .ilen = 8,
1204 .result = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1205 .rlen = 8,
1206 }, {
1207 .key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1208 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1209 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1210 .klen = 24,
1211 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1212 .ilen = 8,
1213 .result = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1214 .rlen = 8,
1218 static struct cipher_testvec des3_ede_dec_tv_template[] = {
1219 { /* These are from openssl */
1220 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1221 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1222 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1223 .klen = 24,
1224 .input = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1225 .ilen = 8,
1226 .result = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1227 .rlen = 8,
1228 }, {
1229 .key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1230 0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1231 0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1232 .klen = 24,
1233 .input = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1234 .ilen = 8,
1235 .result = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1236 .rlen = 8,
1237 }, {
1238 .key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1239 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1240 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1241 .klen = 24,
1242 .input = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1243 .ilen = 8,
1244 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1245 .rlen = 8,
1250 * Blowfish test vectors.
1252 #define BF_ENC_TEST_VECTORS 6
1253 #define BF_DEC_TEST_VECTORS 6
1254 #define BF_CBC_ENC_TEST_VECTORS 1
1255 #define BF_CBC_DEC_TEST_VECTORS 1
1257 static struct cipher_testvec bf_enc_tv_template[] = {
1258 { /* DES test vectors from OpenSSL */
1259 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
1260 .klen = 8,
1261 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1262 .ilen = 8,
1263 .result = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1264 .rlen = 8,
1265 }, {
1266 .key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1267 .klen = 8,
1268 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1269 .ilen = 8,
1270 .result = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1271 .rlen = 8,
1272 }, {
1273 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1274 .klen = 8,
1275 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1276 .ilen = 8,
1277 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1278 .rlen = 8,
1279 }, { /* Vary the keylength... */
1280 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1281 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1282 .klen = 16,
1283 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1284 .ilen = 8,
1285 .result = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1286 .rlen = 8,
1287 }, {
1288 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1289 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1290 0x00, 0x11, 0x22, 0x33, 0x44 },
1291 .klen = 21,
1292 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1293 .ilen = 8,
1294 .result = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1295 .rlen = 8,
1296 }, { /* Generated with bf488 */
1297 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1298 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1299 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1300 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1301 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1302 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
1303 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1304 .klen = 56,
1305 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1306 .ilen = 8,
1307 .result = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1308 .rlen = 8,
1312 static struct cipher_testvec bf_dec_tv_template[] = {
1313 { /* DES test vectors from OpenSSL */
1314 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1315 .klen = 8,
1316 .input = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1317 .ilen = 8,
1318 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1319 .rlen = 8,
1320 }, {
1321 .key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1322 .klen = 8,
1323 .input = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1324 .ilen = 8,
1325 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1326 .rlen = 8,
1327 }, {
1328 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1329 .klen = 8,
1330 .input = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1331 .ilen = 8,
1332 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1333 .rlen = 8,
1334 }, { /* Vary the keylength... */
1335 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1336 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1337 .klen = 16,
1338 .input = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1339 .ilen = 8,
1340 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1341 .rlen = 8,
1342 }, {
1343 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1344 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1345 0x00, 0x11, 0x22, 0x33, 0x44 },
1346 .klen = 21,
1347 .input = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1348 .ilen = 8,
1349 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1350 .rlen = 8,
1351 }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
1352 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1353 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1354 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1355 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1356 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1357 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
1358 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1359 .klen = 56,
1360 .input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1361 .ilen = 8,
1362 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1363 .rlen = 8,
1367 static struct cipher_testvec bf_cbc_enc_tv_template[] = {
1368 { /* From OpenSSL */
1369 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1370 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1371 .klen = 16,
1372 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1373 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1374 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1375 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1376 0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1377 .ilen = 32,
1378 .result = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1379 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1380 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1381 0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1382 .rlen = 32,
1386 static struct cipher_testvec bf_cbc_dec_tv_template[] = {
1387 { /* From OpenSSL */
1388 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1389 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1390 .klen = 16,
1391 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1392 .input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1393 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1394 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1395 0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1396 .ilen = 32,
1397 .result = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1398 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1399 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1400 0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1401 .rlen = 32,
1406 * Twofish test vectors.
1408 #define TF_ENC_TEST_VECTORS 3
1409 #define TF_DEC_TEST_VECTORS 3
1410 #define TF_CBC_ENC_TEST_VECTORS 4
1411 #define TF_CBC_DEC_TEST_VECTORS 4
1413 static struct cipher_testvec tf_enc_tv_template[] = {
1415 .key = { [0 ... 15] = 0x00 },
1416 .klen = 16,
1417 .input = { [0 ... 15] = 0x00 },
1418 .ilen = 16,
1419 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1420 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1421 .rlen = 16,
1422 }, {
1423 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1424 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1425 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1426 .klen = 24,
1427 .input = { [0 ... 15] = 0x00 },
1428 .ilen = 16,
1429 .result = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1430 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1431 .rlen = 16,
1432 }, {
1433 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1434 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1435 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1436 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1437 .klen = 32,
1438 .input = { [0 ... 15] = 0x00 },
1439 .ilen = 16,
1440 .result = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1441 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1442 .rlen = 16,
1446 static struct cipher_testvec tf_dec_tv_template[] = {
1448 .key = { [0 ... 15] = 0x00 },
1449 .klen = 16,
1450 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1451 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1452 .ilen = 16,
1453 .result = { [0 ... 15] = 0x00 },
1454 .rlen = 16,
1455 }, {
1456 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1457 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1458 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1459 .klen = 24,
1460 .input = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1461 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1462 .ilen = 16,
1463 .result = { [0 ... 15] = 0x00 },
1464 .rlen = 16,
1465 }, {
1466 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1467 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1468 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1469 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1470 .klen = 32,
1471 .input = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1472 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1473 .ilen = 16,
1474 .result = { [0 ... 15] = 0x00 },
1475 .rlen = 16,
1479 static struct cipher_testvec tf_cbc_enc_tv_template[] = {
1480 { /* Generated with Nettle */
1481 .key = { [0 ... 15] = 0x00 },
1482 .klen = 16,
1483 .iv = { [0 ... 15] = 0x00 },
1484 .input = { [0 ... 15] = 0x00 },
1485 .ilen = 16,
1486 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1487 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1488 .rlen = 16,
1489 }, {
1490 .key = { [0 ... 15] = 0x00 },
1491 .klen = 16,
1492 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1493 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1494 .input = { [0 ... 15] = 0x00 },
1495 .ilen = 16,
1496 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1497 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1498 .rlen = 16,
1499 }, {
1500 .key = { [0 ... 15] = 0x00 },
1501 .klen = 16,
1502 .iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1503 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1504 .input = { [0 ... 15] = 0x00 },
1505 .ilen = 16,
1506 .result = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1507 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1508 .rlen = 16,
1509 }, {
1510 .key = { [0 ... 15] = 0x00 },
1511 .klen = 16,
1512 .iv = { [0 ... 15] = 0x00 },
1513 .input = { [0 ... 47] = 0x00 },
1514 .ilen = 48,
1515 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1516 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1517 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1518 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1519 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1520 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1521 .rlen = 48,
1525 static struct cipher_testvec tf_cbc_dec_tv_template[] = {
1526 { /* Reverse of the first four above */
1527 .key = { [0 ... 15] = 0x00 },
1528 .klen = 16,
1529 .iv = { [0 ... 15] = 0x00 },
1530 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1531 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1532 .ilen = 16,
1533 .result = { [0 ... 15] = 0x00 },
1534 .rlen = 16,
1535 }, {
1536 .key = { [0 ... 15] = 0x00 },
1537 .klen = 16,
1538 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1539 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1540 .input = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1541 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1542 .ilen = 16,
1543 .result = { [0 ... 15] = 0x00 },
1544 .rlen = 16,
1545 }, {
1546 .key = { [0 ... 15] = 0x00 },
1547 .klen = 16,
1548 .iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1549 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1550 .input = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1551 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1552 .ilen = 16,
1553 .result = { [0 ... 15] = 0x00 },
1554 .rlen = 16,
1555 }, {
1556 .key = { [0 ... 15] = 0x00 },
1557 .klen = 16,
1558 .iv = { [0 ... 15] = 0x00 },
1559 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1560 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1561 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1562 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1563 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1564 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1565 .ilen = 48,
1566 .result = { [0 ... 47] = 0x00 },
1567 .rlen = 48,
1572 * Serpent test vectors. These are backwards because Serpent writes
1573 * octet sequences in right-to-left mode.
1575 #define SERPENT_ENC_TEST_VECTORS 4
1576 #define SERPENT_DEC_TEST_VECTORS 4
1578 #define TNEPRES_ENC_TEST_VECTORS 4
1579 #define TNEPRES_DEC_TEST_VECTORS 4
1581 static struct cipher_testvec serpent_enc_tv_template[] =
1584 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1585 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1586 .ilen = 16,
1587 .result = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1588 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1589 .rlen = 16,
1590 }, {
1591 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1592 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1593 .klen = 16,
1594 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1595 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1596 .ilen = 16,
1597 .result = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1598 0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1599 .rlen = 16,
1600 }, {
1601 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1602 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1603 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1604 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1605 .klen = 32,
1606 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1607 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1608 .ilen = 16,
1609 .result = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1610 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1611 .rlen = 16,
1612 }, {
1613 .key = { [15] = 0x80 },
1614 .klen = 16,
1615 .input = { [0 ... 15] = 0x00 },
1616 .ilen = 16,
1617 .result = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1618 0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1619 .rlen = 16,
1623 static struct cipher_testvec tnepres_enc_tv_template[] =
1625 { /* KeySize=128, PT=0, I=1 */
1626 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1627 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1628 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1629 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1630 .klen = 16,
1631 .ilen = 16,
1632 .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05,
1633 0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd },
1634 .rlen = 16,
1635 }, { /* KeySize=192, PT=0, I=1 */
1636 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1637 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1638 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1639 .klen = 24,
1640 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1641 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1642 .ilen = 16,
1643 .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68,
1644 0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 },
1645 .rlen = 16,
1646 }, { /* KeySize=256, PT=0, I=1 */
1647 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1648 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1649 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1650 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1651 .klen = 32,
1652 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1653 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1654 .ilen = 16,
1655 .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb,
1656 0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 },
1657 .rlen = 16,
1658 }, { /* KeySize=256, I=257 */
1659 .key = { 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
1660 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
1661 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1662 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1663 .klen = 32,
1664 .input = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1665 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1666 .ilen = 16,
1667 .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b,
1668 0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde },
1669 .rlen = 16,
1674 static struct cipher_testvec serpent_dec_tv_template[] =
1677 .input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1678 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1679 .ilen = 16,
1680 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1681 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1682 .rlen = 16,
1683 }, {
1684 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1685 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1686 .klen = 16,
1687 .input = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1688 0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1689 .ilen = 16,
1690 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1691 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1692 .rlen = 16,
1693 }, {
1694 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1695 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1696 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1697 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1698 .klen = 32,
1699 .input = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1700 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1701 .ilen = 16,
1702 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1703 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1704 .rlen = 16,
1705 }, {
1706 .key = { [15] = 0x80 },
1707 .klen = 16,
1708 .input = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1709 0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1710 .ilen = 16,
1711 .result = { [0 ... 15] = 0x00 },
1712 .rlen = 16,
1716 static struct cipher_testvec tnepres_dec_tv_template[] =
1719 .input = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
1720 0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
1721 .ilen = 16,
1722 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1723 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1724 .rlen = 16,
1725 }, {
1726 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1727 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1728 .klen = 16,
1729 .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47,
1730 0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e },
1731 .ilen = 16,
1732 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1733 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1734 .rlen = 16,
1735 }, {
1736 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1737 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1738 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1739 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1740 .klen = 32,
1741 .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49,
1742 0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee },
1743 .ilen = 16,
1744 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1745 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1746 .rlen = 16,
1747 }, { /* KeySize=128, I=121 */
1748 .key = { [15] = 0x80 },
1749 .klen = 16,
1750 .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06,
1751 0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 },
1752 .ilen = 16,
1753 .result = { [0 ... 15] = 0x00 },
1754 .rlen = 16,
1759 /* Cast6 test vectors from RFC 2612 */
1760 #define CAST6_ENC_TEST_VECTORS 3
1761 #define CAST6_DEC_TEST_VECTORS 3
1763 static struct cipher_testvec cast6_enc_tv_template[] =
1766 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1767 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1768 .klen = 16,
1769 .input = { [0 ... 15] = 0x00 },
1770 .ilen = 16,
1771 .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
1772 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1773 .rlen = 16,
1774 }, {
1775 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1776 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1777 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1778 .klen = 24,
1779 .input = { [0 ... 15] = 0x00 },
1780 .ilen = 16,
1781 .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
1782 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1783 .rlen = 16,
1784 }, {
1785 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1786 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1787 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
1788 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
1789 .klen = 32,
1790 .input = { [0 ... 15] = 0x00 },
1791 .ilen = 16,
1792 .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
1793 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1794 .rlen = 16,
1798 static struct cipher_testvec cast6_dec_tv_template[] =
1801 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1802 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1803 .klen = 16,
1804 .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
1805 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1806 .ilen = 16,
1807 .result = { [0 ... 15] = 0x00 },
1808 .rlen = 16,
1809 }, {
1810 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1811 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1812 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1813 .klen = 24,
1814 .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
1815 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1816 .ilen = 16,
1817 .result = { [0 ... 15] = 0x00 },
1818 .rlen = 16,
1819 }, {
1820 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1821 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1822 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
1823 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
1824 .klen = 32,
1825 .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
1826 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1827 .ilen = 16,
1828 .result = { [0 ... 15] = 0x00 },
1829 .rlen = 16,
1835 * AES test vectors.
1837 #define AES_ENC_TEST_VECTORS 3
1838 #define AES_DEC_TEST_VECTORS 3
1840 static struct cipher_testvec aes_enc_tv_template[] = {
1841 { /* From FIPS-197 */
1842 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1843 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1844 .klen = 16,
1845 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1846 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1847 .ilen = 16,
1848 .result = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
1849 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
1850 .rlen = 16,
1851 }, {
1852 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1853 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1854 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1855 .klen = 24,
1856 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1857 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1858 .ilen = 16,
1859 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1860 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1861 .rlen = 16,
1862 }, {
1863 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1864 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1865 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1866 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1867 .klen = 32,
1868 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1869 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1870 .ilen = 16,
1871 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1872 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1873 .rlen = 16,
1877 static struct cipher_testvec aes_dec_tv_template[] = {
1878 { /* From FIPS-197 */
1879 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1880 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1881 .klen = 16,
1882 .input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
1883 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
1884 .ilen = 16,
1885 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1886 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1887 .rlen = 16,
1888 }, {
1889 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1890 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1891 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1892 .klen = 24,
1893 .input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1894 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1895 .ilen = 16,
1896 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1897 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1898 .rlen = 16,
1899 }, {
1900 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1901 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1902 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1903 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1904 .klen = 32,
1905 .input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1906 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1907 .ilen = 16,
1908 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1909 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1910 .rlen = 16,
1914 /* Cast5 test vectors from RFC 2144 */
1915 #define CAST5_ENC_TEST_VECTORS 3
1916 #define CAST5_DEC_TEST_VECTORS 3
1918 static struct cipher_testvec cast5_enc_tv_template[] =
1921 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1922 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
1923 .klen = 16,
1924 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1925 .ilen = 8,
1926 .result = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
1927 .rlen = 8,
1928 }, {
1929 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1930 0x23, 0x45 },
1931 .klen = 10,
1932 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1933 .ilen = 8,
1934 .result = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
1935 .rlen = 8,
1936 }, {
1937 .key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
1938 .klen = 5,
1939 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1940 .ilen = 8,
1941 .result = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
1942 .rlen = 8,
1946 static struct cipher_testvec cast5_dec_tv_template[] =
1949 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1950 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
1951 .klen = 16,
1952 .input = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
1953 .ilen = 8,
1954 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1955 .rlen = 8,
1956 }, {
1957 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1958 0x23, 0x45 },
1959 .klen = 10,
1960 .input = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
1961 .ilen = 8,
1962 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1963 .rlen = 8,
1964 }, {
1965 .key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
1966 .klen = 5,
1967 .input = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
1968 .ilen = 8,
1969 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1970 .rlen = 8,
1975 * ARC4 test vectors from OpenSSL
1977 #define ARC4_ENC_TEST_VECTORS 7
1978 #define ARC4_DEC_TEST_VECTORS 7
1980 static struct cipher_testvec arc4_enc_tv_template[] =
1983 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1984 .klen = 8,
1985 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1986 .ilen = 8,
1987 .result = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
1988 .rlen = 8,
1989 }, {
1990 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1991 .klen = 8,
1992 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1993 .ilen = 8,
1994 .result = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
1995 .rlen = 8,
1996 }, {
1997 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1998 .klen = 8,
1999 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2000 .ilen = 8,
2001 .result = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
2002 .rlen = 8,
2003 }, {
2004 .key = { 0xef, 0x01, 0x23, 0x45},
2005 .klen = 4,
2006 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2007 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2008 0x00, 0x00, 0x00, 0x00 },
2009 .ilen = 20,
2010 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2011 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
2012 0x36, 0xb6, 0x78, 0x58 },
2013 .rlen = 20,
2014 }, {
2015 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2016 .klen = 8,
2017 .input = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2018 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2019 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2020 0x12, 0x34, 0x56, 0x78 },
2021 .ilen = 28,
2022 .result = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
2023 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
2024 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
2025 0x40, 0x01, 0x1e, 0xcf },
2026 .rlen = 28,
2027 }, {
2028 .key = { 0xef, 0x01, 0x23, 0x45 },
2029 .klen = 4,
2030 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2031 0x00, 0x00 },
2032 .ilen = 10,
2033 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2034 0xbd, 0x61 },
2035 .rlen = 10,
2036 }, {
2037 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
2038 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2039 .klen = 16,
2040 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
2041 .ilen = 8,
2042 .result = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
2043 .rlen = 8,
2047 static struct cipher_testvec arc4_dec_tv_template[] =
2050 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2051 .klen = 8,
2052 .input = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
2053 .ilen = 8,
2054 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2055 .rlen = 8,
2056 }, {
2057 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2058 .klen = 8,
2059 .input = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
2060 .ilen = 8,
2061 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2062 .rlen = 8,
2063 }, {
2064 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2065 .klen = 8,
2066 .input = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
2067 .ilen = 8,
2068 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2069 .rlen = 8,
2070 }, {
2071 .key = { 0xef, 0x01, 0x23, 0x45},
2072 .klen = 4,
2073 .input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2074 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
2075 0x36, 0xb6, 0x78, 0x58 },
2076 .ilen = 20,
2077 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2078 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2079 0x00, 0x00, 0x00, 0x00 },
2080 .rlen = 20,
2081 }, {
2082 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2083 .klen = 8,
2084 .input = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
2085 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
2086 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
2087 0x40, 0x01, 0x1e, 0xcf },
2088 .ilen = 28,
2089 .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2090 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2091 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2092 0x12, 0x34, 0x56, 0x78 },
2093 .rlen = 28,
2094 }, {
2095 .key = { 0xef, 0x01, 0x23, 0x45 },
2096 .klen = 4,
2097 .input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2098 0xbd, 0x61 },
2099 .ilen = 10,
2100 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2101 0x00, 0x00 },
2102 .rlen = 10,
2103 }, {
2104 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
2105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2106 .klen = 16,
2107 .input = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
2108 .ilen = 8,
2109 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
2110 .rlen = 8,
2115 * TEA test vectors
2117 #define TEA_ENC_TEST_VECTORS 4
2118 #define TEA_DEC_TEST_VECTORS 4
2120 static struct cipher_testvec tea_enc_tv_template[] =
2123 .key = { [0 ... 15] = 0x00 },
2124 .klen = 16,
2125 .input = { [0 ... 8] = 0x00 },
2126 .ilen = 8,
2127 .result = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
2128 .rlen = 8,
2129 }, {
2130 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2131 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2132 .klen = 16,
2133 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2134 .ilen = 8,
2135 .result = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
2136 .rlen = 8,
2137 }, {
2138 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2139 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2140 .klen = 16,
2141 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2142 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2143 .ilen = 16,
2144 .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
2145 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2146 .rlen = 16,
2147 }, {
2148 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2149 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2150 .klen = 16,
2151 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2152 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2153 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2154 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2155 .ilen = 32,
2156 .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
2157 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2158 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
2159 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
2160 .rlen = 32,
2164 static struct cipher_testvec tea_dec_tv_template[] =
2167 .key = { [0 ... 15] = 0x00 },
2168 .klen = 16,
2169 .input = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
2170 .ilen = 8,
2171 .result = { [0 ... 8] = 0x00 },
2172 .rlen = 8,
2173 }, {
2174 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2175 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2176 .klen = 16,
2177 .input = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
2178 .ilen = 8,
2179 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2180 .rlen = 8,
2181 }, {
2182 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2183 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2184 .klen = 16,
2185 .input = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
2186 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2187 .ilen = 16,
2188 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2189 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2190 .rlen = 16,
2191 }, {
2192 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2193 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2194 .klen = 16,
2195 .input = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
2196 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2197 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
2198 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
2199 .ilen = 32,
2200 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2201 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2202 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2203 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2204 .rlen = 32,
2209 * XTEA test vectors
2211 #define XTEA_ENC_TEST_VECTORS 4
2212 #define XTEA_DEC_TEST_VECTORS 4
2214 static struct cipher_testvec xtea_enc_tv_template[] =
2217 .key = { [0 ... 15] = 0x00 },
2218 .klen = 16,
2219 .input = { [0 ... 8] = 0x00 },
2220 .ilen = 8,
2221 .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
2222 .rlen = 8,
2223 }, {
2224 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2225 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2226 .klen = 16,
2227 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2228 .ilen = 8,
2229 .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
2230 .rlen = 8,
2231 }, {
2232 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2233 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2234 .klen = 16,
2235 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2236 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2237 .ilen = 16,
2238 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
2239 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2240 .rlen = 16,
2241 }, {
2242 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2243 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2244 .klen = 16,
2245 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2246 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2247 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2248 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2249 .ilen = 32,
2250 .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2251 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2252 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
2253 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2254 .rlen = 32,
2258 static struct cipher_testvec xtea_dec_tv_template[] =
2261 .key = { [0 ... 15] = 0x00 },
2262 .klen = 16,
2263 .input = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
2264 .ilen = 8,
2265 .result = { [0 ... 8] = 0x00 },
2266 .rlen = 8,
2267 }, {
2268 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2269 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2270 .klen = 16,
2271 .input = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
2272 .ilen = 8,
2273 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2274 .rlen = 8,
2275 }, {
2276 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2277 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2278 .klen = 16,
2279 .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
2280 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2281 .ilen = 16,
2282 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2283 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2284 .rlen = 16,
2285 }, {
2286 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2287 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2288 .klen = 16,
2289 .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2290 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2291 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
2292 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2293 .ilen = 32,
2294 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2295 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2296 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2297 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2298 .rlen = 32,
2303 * KHAZAD test vectors.
2305 #define KHAZAD_ENC_TEST_VECTORS 5
2306 #define KHAZAD_DEC_TEST_VECTORS 5
2308 static struct cipher_testvec khazad_enc_tv_template[] = {
2310 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2312 .klen = 16,
2313 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2314 .ilen = 8,
2315 .result = { 0x49, 0xa4, 0xce, 0x32, 0xac, 0x19, 0x0e, 0x3f },
2316 .rlen = 8,
2317 }, {
2318 .key = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
2319 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2320 .klen = 16,
2321 .input = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2322 .ilen = 8,
2323 .result = { 0x7e, 0x82, 0x12, 0xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
2324 .rlen = 8,
2325 }, {
2326 .key = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
2327 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2328 .klen = 16,
2329 .input = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2330 .ilen = 8,
2331 .result = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
2332 .rlen = 8,
2333 }, {
2334 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2335 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2336 .klen = 16,
2337 .input = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2338 .ilen = 8,
2339 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2340 .rlen = 8,
2341 }, {
2342 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2343 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2344 .klen = 16,
2345 .input = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
2346 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2347 .ilen = 16,
2348 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
2349 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2350 .rlen = 16,
2354 static struct cipher_testvec khazad_dec_tv_template[] = {
2356 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2358 .klen = 16,
2359 .input = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f },
2360 .ilen = 8,
2361 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2362 .rlen = 8,
2363 }, {
2364 .key = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
2365 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2366 .klen = 16,
2367 .input = { 0X7e, 0X82, 0X12, 0Xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
2368 .ilen = 8,
2369 .result = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2370 .rlen = 8,
2371 }, {
2372 .key = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
2373 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2374 .klen = 16,
2375 .input = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
2376 .ilen = 8,
2377 .result = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2378 .rlen = 8,
2379 }, {
2380 .key = { 0x2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2381 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2382 .klen = 16,
2383 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2384 .ilen = 8,
2385 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2386 .rlen = 8,
2387 }, {
2388 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2389 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2390 .klen = 16,
2391 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
2392 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2393 .ilen = 16,
2394 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
2395 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2396 .rlen = 16,
2401 * Anubis test vectors.
2404 #define ANUBIS_ENC_TEST_VECTORS 5
2405 #define ANUBIS_DEC_TEST_VECTORS 5
2406 #define ANUBIS_CBC_ENC_TEST_VECTORS 2
2407 #define ANUBIS_CBC_DEC_TEST_VECTORS 2
2409 static struct cipher_testvec anubis_enc_tv_template[] = {
2411 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2412 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2413 .klen = 16,
2414 .input = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2415 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2416 .ilen = 16,
2417 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2418 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
2419 .rlen = 16,
2420 }, {
2422 .key = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2423 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2424 0x03, 0x03, 0x03, 0x03 },
2425 .klen = 20,
2426 .input = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2427 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
2428 .ilen = 16,
2429 .result = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
2430 0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
2431 .rlen = 16,
2432 }, {
2433 .key = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2434 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2435 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2436 0x24, 0x24, 0x24, 0x24 },
2437 .klen = 28,
2438 .input = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2439 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
2440 .ilen = 16,
2441 .result = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
2442 0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
2443 .rlen = 16,
2444 }, {
2445 .key = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2446 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2447 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2448 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2449 .klen = 32,
2450 .input = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2451 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2452 .ilen = 16,
2453 .result = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
2454 0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
2455 .rlen = 16,
2456 }, {
2457 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2458 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2459 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2460 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2461 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2462 .klen = 40,
2463 .input = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2464 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2465 .ilen = 16,
2466 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2467 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
2468 .rlen = 16,
2472 static struct cipher_testvec anubis_dec_tv_template[] = {
2474 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2475 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2476 .klen = 16,
2477 .input = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2478 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
2479 .ilen = 16,
2480 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2481 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2482 .rlen = 16,
2483 }, {
2485 .key = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2486 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2487 0x03, 0x03, 0x03, 0x03 },
2488 .klen = 20,
2489 .input = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
2490 0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
2491 .ilen = 16,
2492 .result = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2493 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
2494 .rlen = 16,
2495 }, {
2496 .key = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2497 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2498 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2499 0x24, 0x24, 0x24, 0x24 },
2500 .klen = 28,
2501 .input = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
2502 0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
2503 .ilen = 16,
2504 .result = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2505 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
2506 .rlen = 16,
2507 }, {
2508 .key = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2509 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2510 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2511 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2512 .klen = 32,
2513 .input = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
2514 0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
2515 .ilen = 16,
2516 .result = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2517 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2518 .rlen = 16,
2519 }, {
2520 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2521 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2522 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2523 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2524 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2525 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2526 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
2527 .klen = 40,
2528 .ilen = 16,
2529 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2530 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2531 .rlen = 16,
2535 static struct cipher_testvec anubis_cbc_enc_tv_template[] = {
2537 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2538 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2539 .klen = 16,
2540 .input = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2541 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2542 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2543 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2544 .ilen = 32,
2545 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2546 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
2547 0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
2548 0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
2549 .rlen = 32,
2550 }, {
2551 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2552 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2553 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2554 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2555 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2556 .klen = 40,
2557 .input = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2558 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2559 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2560 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2561 .ilen = 32,
2562 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2563 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
2564 0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
2565 0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
2566 .rlen = 32,
2570 static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
2572 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2573 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2574 .klen = 16,
2575 .input = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2576 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
2577 0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
2578 0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
2579 .ilen = 32,
2580 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2581 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2582 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2583 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2584 .rlen = 32,
2585 }, {
2586 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2587 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2588 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2589 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2590 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2591 .klen = 40,
2592 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2593 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
2594 0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
2595 0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
2596 .ilen = 32,
2597 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2598 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2599 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2600 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2601 .rlen = 32,
2606 * Compression stuff.
2608 #define COMP_BUF_SIZE 512
2610 struct comp_testvec {
2611 int inlen, outlen;
2612 char input[COMP_BUF_SIZE];
2613 char output[COMP_BUF_SIZE];
2617 * Deflate test vectors (null-terminated strings).
2618 * Params: winbits=11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
2620 #define DEFLATE_COMP_TEST_VECTORS 2
2621 #define DEFLATE_DECOMP_TEST_VECTORS 2
2623 static struct comp_testvec deflate_comp_tv_template[] = {
2625 .inlen = 70,
2626 .outlen = 38,
2627 .input = "Join us now and share the software "
2628 "Join us now and share the software ",
2629 .output = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
2630 0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
2631 0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
2632 0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
2633 0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
2634 }, {
2635 .inlen = 191,
2636 .outlen = 122,
2637 .input = "This document describes a compression method based on the DEFLATE"
2638 "compression algorithm. This document defines the application of "
2639 "the DEFLATE algorithm to the IP Payload Compression Protocol.",
2640 .output = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
2641 0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
2642 0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
2643 0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
2644 0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
2645 0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
2646 0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
2647 0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
2648 0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
2649 0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
2650 0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
2651 0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
2652 0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
2653 0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
2654 0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
2655 0xfa, 0x02 },
2659 static struct comp_testvec deflate_decomp_tv_template[] = {
2661 .inlen = 122,
2662 .outlen = 191,
2663 .input = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
2664 0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
2665 0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
2666 0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
2667 0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
2668 0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
2669 0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
2670 0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
2671 0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
2672 0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
2673 0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
2674 0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
2675 0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
2676 0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
2677 0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
2678 0xfa, 0x02 },
2679 .output = "This document describes a compression method based on the DEFLATE"
2680 "compression algorithm. This document defines the application of "
2681 "the DEFLATE algorithm to the IP Payload Compression Protocol.",
2682 }, {
2683 .inlen = 38,
2684 .outlen = 70,
2685 .input = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
2686 0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
2687 0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
2688 0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
2689 0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
2690 .output = "Join us now and share the software "
2691 "Join us now and share the software ",
2696 * Michael MIC test vectors from IEEE 802.11i
2698 #define MICHAEL_MIC_TEST_VECTORS 6
2700 static struct hash_testvec michael_mic_tv_template[] =
2703 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2704 .ksize = 8,
2705 .plaintext = { },
2706 .psize = 0,
2707 .digest = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 }
2710 .key = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 },
2711 .ksize = 8,
2712 .plaintext = { 'M' },
2713 .psize = 1,
2714 .digest = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f }
2717 .key = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f },
2718 .ksize = 8,
2719 .plaintext = { 'M', 'i' },
2720 .psize = 2,
2721 .digest = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 }
2724 .key = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 },
2725 .ksize = 8,
2726 .plaintext = { 'M', 'i', 'c' },
2727 .psize = 3,
2728 .digest = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb }
2731 .key = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb },
2732 .ksize = 8,
2733 .plaintext = { 'M', 'i', 'c', 'h' },
2734 .psize = 4,
2735 .digest = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 }
2738 .key = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 },
2739 .ksize = 8,
2740 .plaintext = { 'M', 'i', 'c', 'h', 'a', 'e', 'l' },
2741 .psize = 7,
2742 .digest = { 0x0a, 0x94, 0x2b, 0x12, 0x4e, 0xca, 0xa5, 0x46 },
2746 #endif /* _CRYPTO_TCRYPT_H */