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