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