[MTD] [NAND] Add Blackfin BF52x support in bf5xx_nand driver
[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  * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests
16  * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net>
17  * 2003-09-14 Changes by Kartikey Mahendra Bhatt
18  *
19  */
20 #ifndef _CRYPTO_TCRYPT_H
21 #define _CRYPTO_TCRYPT_H
22
23 #define MAX_DIGEST_SIZE         64
24 #define MAX_TAP                 8
25
26 #define MAX_KEYLEN              56
27 #define MAX_IVLEN               32
28
29 struct hash_testvec {
30         /* only used with keyed hash algorithms */
31         char key[132] __attribute__ ((__aligned__(4)));
32         char plaintext[240];
33         char digest[MAX_DIGEST_SIZE];
34         unsigned char tap[MAX_TAP];
35         unsigned char psize;
36         unsigned char np;
37         unsigned char ksize;
38 };
39
40 struct cipher_testvec {
41         char key[MAX_KEYLEN] __attribute__ ((__aligned__(4)));
42         char iv[MAX_IVLEN];
43         char input[512];
44         char result[512];
45         unsigned char tap[MAX_TAP];
46         int np;
47         unsigned char fail;
48         unsigned char wk; /* weak key flag */
49         unsigned char klen;
50         unsigned short ilen;
51         unsigned short rlen;
52 };
53
54 struct cipher_speed {
55         unsigned char klen;
56         unsigned int blen;
57 };
58
59 struct hash_speed {
60         unsigned int blen;      /* buffer length */
61         unsigned int plen;      /* per-update length */
62 };
63
64 /*
65  * MD4 test vectors from RFC1320
66  */
67 #define MD4_TEST_VECTORS        7
68
69 static struct hash_testvec md4_tv_template [] = {
70         {
71                 .plaintext = "",
72                 .digest = { 0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31,
73                             0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0 },
74         }, {
75                 .plaintext = "a",
76                 .psize  = 1,
77                 .digest = { 0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46,
78                             0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24 },
79         }, {
80                 .plaintext = "abc",
81                 .psize  = 3,
82                 .digest = { 0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52,
83                             0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d },
84         }, {
85                 .plaintext = "message digest",
86                 .psize  = 14,
87                 .digest = { 0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8,
88                             0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b },
89         }, {
90                 .plaintext = "abcdefghijklmnopqrstuvwxyz",
91                 .psize  = 26,
92                 .digest = { 0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd,
93                             0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9 },
94                 .np     = 2,
95                 .tap    = { 13, 13 },
96         }, {
97                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
98                 .psize  = 62,
99                 .digest = { 0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35,
100                             0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4 },
101         }, {
102                 .plaintext = "123456789012345678901234567890123456789012345678901234567890123"
103                              "45678901234567890",
104                 .psize  = 80,
105                 .digest = { 0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19,
106                             0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36 },
107         },
108 };
109
110 /*
111  * MD5 test vectors from RFC1321
112  */
113 #define MD5_TEST_VECTORS        7
114
115 static struct hash_testvec md5_tv_template[] = {
116         {
117                 .digest = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
118                             0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e },
119         }, {
120                 .plaintext = "a",
121                 .psize  = 1,
122                 .digest = { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8,
123                             0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 },
124         }, {
125                 .plaintext = "abc",
126                 .psize  = 3,
127                 .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
128                             0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 },
129         }, {
130                 .plaintext = "message digest",
131                 .psize  = 14,
132                 .digest = { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d,
133                             0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 },
134         }, {
135                 .plaintext = "abcdefghijklmnopqrstuvwxyz",
136                 .psize  = 26,
137                 .digest = { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00,
138                             0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b },
139                 .np     = 2,
140                 .tap    = {13, 13}
141         }, {
142                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
143                 .psize  = 62,
144                 .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
145                             0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f },
146         }, {
147                 .plaintext = "12345678901234567890123456789012345678901234567890123456789012"
148                              "345678901234567890",
149                 .psize  = 80,
150                 .digest = { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55,
151                             0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a },
152         }
153 };
154
155 /*
156  * SHA1 test vectors  from from FIPS PUB 180-1
157  */
158 #define SHA1_TEST_VECTORS       2
159
160 static struct hash_testvec sha1_tv_template[] = {
161         {
162                 .plaintext = "abc",
163                 .psize  = 3,
164                 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
165                             0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d },
166         }, {
167                 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
168                 .psize  = 56,
169                 .digest = { 0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae,
170                             0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1 },
171                 .np     = 2,
172                 .tap    = { 28, 28 }
173         }
174 };
175
176 /*
177  * SHA256 test vectors from from NIST
178  */
179 #define SHA256_TEST_VECTORS     2
180
181 static struct hash_testvec sha256_tv_template[] = {
182         {
183                 .plaintext = "abc",
184                 .psize  = 3,
185                 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
186                             0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
187                             0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
188                             0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad },
189         }, {
190                 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
191                 .psize  = 56,
192                 .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
193                             0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
194                             0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
195                             0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 },
196                 .np     = 2,
197                 .tap    = { 28, 28 }
198         },
199 };
200
201 /*
202  * SHA384 test vectors from from NIST and kerneli
203  */
204 #define SHA384_TEST_VECTORS     4
205
206 static struct hash_testvec sha384_tv_template[] = {
207         {
208                 .plaintext= "abc",
209                 .psize  = 3,
210                 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
211                             0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
212                             0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
213                             0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
214                             0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
215                             0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 },
216         }, {
217                 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
218                 .psize  = 56,
219                 .digest = { 0x33, 0x91, 0xfd, 0xdd, 0xfc, 0x8d, 0xc7, 0x39,
220                             0x37, 0x07, 0xa6, 0x5b, 0x1b, 0x47, 0x09, 0x39,
221                             0x7c, 0xf8, 0xb1, 0xd1, 0x62, 0xaf, 0x05, 0xab,
222                             0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6,
223                             0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f,
224                             0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b},
225         }, {
226                 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
227                              "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
228                 .psize  = 112,
229                 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
230                             0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
231                             0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
232                             0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
233                             0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
234                             0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39  },
235         }, {
236                 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
237                              "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
238                 .psize  = 104,
239                 .digest = { 0x3d, 0x20, 0x89, 0x73, 0xab, 0x35, 0x08, 0xdb,
240                             0xbd, 0x7e, 0x2c, 0x28, 0x62, 0xba, 0x29, 0x0a,
241                             0xd3, 0x01, 0x0e, 0x49, 0x78, 0xc1, 0x98, 0xdc,
242                             0x4d, 0x8f, 0xd0, 0x14, 0xe5, 0x82, 0x82, 0x3a,
243                             0x89, 0xe1, 0x6f, 0x9b, 0x2a, 0x7b, 0xbc, 0x1a,
244                             0xc9, 0x38, 0xe2, 0xd1, 0x99, 0xe8, 0xbe, 0xa4 },
245                 .np     = 4,
246                 .tap    = { 26, 26, 26, 26 }
247         },
248 };
249
250 /*
251  * SHA512 test vectors from from NIST and kerneli
252  */
253 #define SHA512_TEST_VECTORS     4
254
255 static struct hash_testvec sha512_tv_template[] = {
256         {
257                 .plaintext = "abc",
258                 .psize  = 3,
259                 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
260                             0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
261                             0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
262                             0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
263                             0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
264                             0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
265                             0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
266                             0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f },
267         }, {
268                 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
269                 .psize  = 56,
270                 .digest = { 0x20, 0x4a, 0x8f, 0xc6, 0xdd, 0xa8, 0x2f, 0x0a,
271                             0x0c, 0xed, 0x7b, 0xeb, 0x8e, 0x08, 0xa4, 0x16,
272                             0x57, 0xc1, 0x6e, 0xf4, 0x68, 0xb2, 0x28, 0xa8,
273                             0x27, 0x9b, 0xe3, 0x31, 0xa7, 0x03, 0xc3, 0x35,
274                             0x96, 0xfd, 0x15, 0xc1, 0x3b, 0x1b, 0x07, 0xf9,
275                             0xaa, 0x1d, 0x3b, 0xea, 0x57, 0x78, 0x9c, 0xa0,
276                             0x31, 0xad, 0x85, 0xc7, 0xa7, 0x1d, 0xd7, 0x03,
277                             0x54, 0xec, 0x63, 0x12, 0x38, 0xca, 0x34, 0x45 },
278         }, {
279                 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
280                              "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
281                 .psize  = 112,
282                 .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
283                             0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
284                             0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
285                             0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
286                             0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
287                             0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
288                             0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
289                             0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 },
290         }, {
291                 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
292                              "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
293                 .psize  = 104,
294                 .digest = { 0x93, 0x0d, 0x0c, 0xef, 0xcb, 0x30, 0xff, 0x11,
295                             0x33, 0xb6, 0x89, 0x81, 0x21, 0xf1, 0xcf, 0x3d,
296                             0x27, 0x57, 0x8a, 0xfc, 0xaf, 0xe8, 0x67, 0x7c,
297                             0x52, 0x57, 0xcf, 0x06, 0x99, 0x11, 0xf7, 0x5d,
298                             0x8f, 0x58, 0x31, 0xb5, 0x6e, 0xbf, 0xda, 0x67,
299                             0xb2, 0x78, 0xe6, 0x6d, 0xff, 0x8b, 0x84, 0xfe,
300                             0x2b, 0x28, 0x70, 0xf7, 0x42, 0xa5, 0x80, 0xd8,
301                             0xed, 0xb4, 0x19, 0x87, 0x23, 0x28, 0x50, 0xc9 },
302                 .np     = 4,
303                 .tap    = { 26, 26, 26, 26 }
304         },
305 };
306
307
308 /*
309  * WHIRLPOOL test vectors from Whirlpool package
310  * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
311  * submission
312  */
313 #define WP512_TEST_VECTORS      8
314
315 static struct hash_testvec wp512_tv_template[] = {
316         {
317                 .plaintext = "",
318                 .psize  = 0,
319                 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
320                             0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
321                             0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
322                             0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
323                             0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
324                             0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57,
325                             0xEA, 0x89, 0x64, 0xE5, 0x9B, 0x63, 0xD9, 0x37,
326                             0x08, 0xB1, 0x38, 0xCC, 0x42, 0xA6, 0x6E, 0xB3 },
327
328
329         }, {
330                 .plaintext = "a",
331                 .psize  = 1,
332                 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
333                             0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
334                             0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
335                             0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
336                             0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
337                             0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59,
338                             0x1A, 0x92, 0x20, 0x0D, 0x56, 0x01, 0x95, 0xE5,
339                             0x3B, 0x47, 0x85, 0x84, 0xFD, 0xAE, 0x23, 0x1A },
340         }, {
341                 .plaintext = "abc",
342                 .psize  = 3,
343                 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
344                             0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
345                             0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
346                             0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
347                             0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
348                             0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6,
349                             0xC7, 0x97, 0xFC, 0x9D, 0x95, 0xD8, 0xB5, 0x82,
350                             0xD2, 0x25, 0x29, 0x20, 0x76, 0xD4, 0xEE, 0xF5 },
351         }, {
352                 .plaintext = "message digest",
353                 .psize  = 14,
354                 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
355                             0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
356                             0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
357                             0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
358                             0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
359                             0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6,
360                             0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33,
361                             0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E },
362         }, {
363                 .plaintext = "abcdefghijklmnopqrstuvwxyz",
364                 .psize  = 26,
365                 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
366                             0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
367                             0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
368                             0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
369                             0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
370                             0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6,
371                             0xF6, 0x8F, 0x67, 0x3E, 0x72, 0x07, 0x86, 0x5D,
372                             0x5D, 0x98, 0x19, 0xA3, 0xDB, 0xA4, 0xEB, 0x3B },
373         }, {
374                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
375                              "abcdefghijklmnopqrstuvwxyz0123456789",
376                 .psize  = 62,
377                 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
378                             0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
379                             0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
380                             0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
381                             0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
382                             0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6,
383                             0x55, 0x17, 0xCC, 0x87, 0x9D, 0x7B, 0x96, 0x21,
384                             0x42, 0xC6, 0x5F, 0x5A, 0x7A, 0xF0, 0x14, 0x67 },
385         }, {
386                 .plaintext = "1234567890123456789012345678901234567890"
387                              "1234567890123456789012345678901234567890",
388                 .psize  = 80,
389                 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
390                             0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
391                             0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
392                             0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
393                             0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
394                             0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A,
395                             0x2C, 0x60, 0x48, 0x1E, 0x88, 0xC5, 0xA2, 0x0B,
396                             0x2C, 0x2A, 0x80, 0xCF, 0x3A, 0x9A, 0x08, 0x3B },
397         }, {
398                 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
399                 .psize  = 32,
400                 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
401                             0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
402                             0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
403                             0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
404                             0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
405                             0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56,
406                             0x93, 0x9B, 0xAA, 0xA0, 0xAD, 0xFF, 0x9A, 0xE6,
407                             0x74, 0x5B, 0x7B, 0x18, 0x1C, 0x3B, 0xE3, 0xFD },
408         },
409 };
410
411 #define WP384_TEST_VECTORS      8
412
413 static struct hash_testvec wp384_tv_template[] = {
414         {
415                 .plaintext = "",
416                 .psize  = 0,
417                 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
418                             0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
419                             0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
420                             0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
421                             0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
422                             0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57 },
423
424
425         }, {
426                 .plaintext = "a",
427                 .psize  = 1,
428                 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
429                             0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
430                             0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
431                             0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
432                             0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
433                             0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59 },
434         }, {
435                 .plaintext = "abc",
436                 .psize  = 3,
437                 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
438                             0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
439                             0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
440                             0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
441                             0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
442                             0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6 },
443         }, {
444                 .plaintext = "message digest",
445                 .psize  = 14,
446                 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
447                             0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
448                             0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
449                             0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
450                             0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
451                             0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 },
452         }, {
453                 .plaintext = "abcdefghijklmnopqrstuvwxyz",
454                 .psize  = 26,
455                 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
456                             0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
457                             0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
458                             0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
459                             0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
460                             0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6 },
461         }, {
462                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
463                              "abcdefghijklmnopqrstuvwxyz0123456789",
464                 .psize  = 62,
465                 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
466                             0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
467                             0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
468                             0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
469                             0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
470                             0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6 },
471         }, {
472                 .plaintext = "1234567890123456789012345678901234567890"
473                              "1234567890123456789012345678901234567890",
474                 .psize  = 80,
475                 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
476                             0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
477                             0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
478                             0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
479                             0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
480                             0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A },
481         }, {
482                 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
483                 .psize  = 32,
484                 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
485                             0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
486                             0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
487                             0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
488                             0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
489                             0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56 },
490         },
491 };
492
493 #define WP256_TEST_VECTORS      8
494
495 static struct hash_testvec wp256_tv_template[] = {
496         {
497                 .plaintext = "",
498                 .psize  = 0,
499                 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
500                             0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
501                             0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
502                             0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7 },
503
504
505         }, {
506                 .plaintext = "a",
507                 .psize  = 1,
508                 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
509                             0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
510                             0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
511                             0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42 },
512         }, {
513                 .plaintext = "abc",
514                 .psize  = 3,
515                 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
516                             0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
517                             0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
518                             0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C },
519         }, {
520                 .plaintext = "message digest",
521                 .psize  = 14,
522                 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
523                             0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
524                             0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
525                             0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B },
526         }, {
527                 .plaintext = "abcdefghijklmnopqrstuvwxyz",
528                 .psize  = 26,
529                 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
530                             0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
531                             0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
532                             0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B },
533         }, {
534                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
535                              "abcdefghijklmnopqrstuvwxyz0123456789",
536                 .psize  = 62,
537                 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
538                             0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
539                             0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
540                             0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E },
541         }, {
542                 .plaintext = "1234567890123456789012345678901234567890"
543                              "1234567890123456789012345678901234567890",
544                 .psize  = 80,
545                 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
546                             0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
547                             0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
548                             0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29 },
549         }, {
550                 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
551                 .psize  = 32,
552                 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
553                             0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
554                             0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
555                             0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 },
556         },
557 };
558
559 /*
560  * TIGER test vectors from Tiger website
561  */
562 #define TGR192_TEST_VECTORS     6
563
564 static struct hash_testvec tgr192_tv_template[] = {
565         {
566                 .plaintext = "",
567                 .psize  = 0,
568                 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
569                             0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
570                             0xf3, 0x73, 0xde, 0x2d, 0x49, 0x58, 0x4e, 0x7a },
571         }, {
572                 .plaintext = "abc",
573                 .psize  = 3,
574                 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
575                             0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
576                             0x93, 0x5f, 0x7b, 0x95, 0x1c, 0x13, 0x29, 0x51 },
577         }, {
578                 .plaintext = "Tiger",
579                 .psize  = 5,
580                 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
581                             0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
582                             0x37, 0x79, 0x0c, 0x11, 0x6f, 0x9d, 0x2b, 0xdf },
583         }, {
584                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
585                 .psize  = 64,
586                 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
587                             0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
588                             0xb5, 0x86, 0x44, 0x50, 0x34, 0xa5, 0xa3, 0x86 },
589         }, {
590                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
591                 .psize  = 64,
592                 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
593                             0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
594                             0x57, 0x89, 0x65, 0x65, 0x97, 0x5f, 0x91, 0x97 },
595         }, {
596                 .plaintext = "Tiger - A Fast New Hash Function, "
597                              "by Ross Anderson and Eli Biham, "
598                              "proceedings of Fast Software Encryption 3, "
599                              "Cambridge, 1996.",
600                 .psize  = 125,
601                 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
602                             0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
603                             0xdd, 0x68, 0x15, 0x1d, 0x50, 0x39, 0x74, 0xfc },
604         },
605 };
606
607 #define TGR160_TEST_VECTORS     6
608
609 static struct hash_testvec tgr160_tv_template[] = {
610         {
611                 .plaintext = "",
612                 .psize  = 0,
613                 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
614                             0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
615                             0xf3, 0x73, 0xde, 0x2d },
616         }, {
617                 .plaintext = "abc",
618                 .psize  = 3,
619                 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
620                             0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
621                             0x93, 0x5f, 0x7b, 0x95 },
622         }, {
623                 .plaintext = "Tiger",
624                 .psize  = 5,
625                 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
626                             0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
627                             0x37, 0x79, 0x0c, 0x11 },
628         }, {
629                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
630                 .psize  = 64,
631                 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
632                             0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
633                             0xb5, 0x86, 0x44, 0x50 },
634         }, {
635                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
636                 .psize  = 64,
637                 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
638                             0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
639                             0x57, 0x89, 0x65, 0x65 },
640         }, {
641                 .plaintext = "Tiger - A Fast New Hash Function, "
642                              "by Ross Anderson and Eli Biham, "
643                              "proceedings of Fast Software Encryption 3, "
644                              "Cambridge, 1996.",
645                 .psize  = 125,
646                 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
647                             0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
648                             0xdd, 0x68, 0x15, 0x1d },
649         },
650 };
651
652 #define TGR128_TEST_VECTORS     6
653
654 static struct hash_testvec tgr128_tv_template[] = {
655         {
656                 .plaintext = "",
657                 .psize  = 0,
658                 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
659                             0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f },
660         }, {
661                 .plaintext = "abc",
662                 .psize  = 3,
663                 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
664                             0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf },
665         }, {
666                 .plaintext = "Tiger",
667                 .psize  = 5,
668                 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
669                             0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec },
670         }, {
671                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
672                 .psize  = 64,
673                 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
674                             0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e },
675         }, {
676                 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
677                 .psize  = 64,
678                 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
679                             0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9 },
680         }, {
681                 .plaintext = "Tiger - A Fast New Hash Function, "
682                              "by Ross Anderson and Eli Biham, "
683                              "proceedings of Fast Software Encryption 3, "
684                              "Cambridge, 1996.",
685                 .psize  = 125,
686                 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
687                             0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24 },
688         },
689 };
690
691 /*
692  * HMAC-MD5 test vectors from RFC2202
693  * (These need to be fixed to not use strlen).
694  */
695 #define HMAC_MD5_TEST_VECTORS   7
696
697 static struct hash_testvec hmac_md5_tv_template[] =
698 {
699         {
700                 .key    = { [0 ... 15] =  0x0b },
701                 .ksize  = 16,
702                 .plaintext = "Hi There",
703                 .psize  = 8,
704                 .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
705                             0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
706         }, {
707                 .key    = { 'J', 'e', 'f', 'e' },
708                 .ksize  = 4,
709                 .plaintext = "what do ya want for nothing?",
710                 .psize  = 28,
711                 .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
712                             0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
713                 .np     = 2,
714                 .tap    = {14, 14}
715         }, {
716                 .key    = { [0 ... 15] = 0xaa },
717                 .ksize  = 16,
718                 .plaintext = { [0 ... 49] =  0xdd },
719                 .psize  = 50,
720                 .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
721                             0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 },
722         }, {
723                 .key    = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
724                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
725                             0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, },
726                 .ksize  = 25,
727                 .plaintext = { [0 ... 49] =  0xcd },
728                 .psize  = 50,
729                 .digest = { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
730                             0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 },
731         }, {
732                 .key    = { [0 ... 15] = 0x0c },
733                 .ksize  = 16,
734                 .plaintext = "Test With Truncation",
735                 .psize  = 20,
736                 .digest = { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
737                             0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c },
738         }, {
739                 .key    = { [0 ... 79] =  0xaa },
740                 .ksize  = 80,
741                 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
742                 .psize  = 54,
743                 .digest = { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f,
744                             0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd },
745         }, {
746                 .key    = { [0 ... 79] =  0xaa },
747                 .ksize  = 80,
748                 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
749                              "Block-Size Data",
750                 .psize  = 73,
751                 .digest = { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee,
752                             0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e },
753         },
754 };
755
756 /*
757  * HMAC-SHA1 test vectors from RFC2202
758  */
759 #define HMAC_SHA1_TEST_VECTORS  7
760
761 static struct hash_testvec hmac_sha1_tv_template[] = {
762         {
763                 .key    = { [0 ... 19] = 0x0b },
764                 .ksize  = 20,
765                 .plaintext = "Hi There",
766                 .psize  = 8,
767                 .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
768                             0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1,
769                             0x46, 0xbe },
770         }, {
771                 .key    = { 'J', 'e', 'f', 'e' },
772                 .ksize  = 4,
773                 .plaintext = "what do ya want for nothing?",
774                 .psize  = 28,
775                 .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74,
776                             0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 },
777                 .np     = 2,
778                 .tap    = { 14, 14 }
779         }, {
780                 .key    = { [0 ... 19] = 0xaa },
781                 .ksize  = 20,
782                 .plaintext = { [0 ... 49] = 0xdd },
783                 .psize  = 50,
784                 .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3,
785                             0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 },
786         }, {
787                 .key    = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
788                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
789                             0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 },
790                 .ksize  = 25,
791                 .plaintext = { [0 ... 49] = 0xcd },
792                 .psize  = 50,
793                 .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84,
794                             0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda },
795         }, {
796                 .key    = { [0 ... 19] = 0x0c },
797                 .ksize  = 20,
798                 .plaintext = "Test With Truncation",
799                 .psize  = 20,
800                 .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
801                             0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 },
802         }, {
803                 .key    = { [0 ... 79] = 0xaa },
804                 .ksize  = 80,
805                 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
806                 .psize  = 54,
807                 .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
808                             0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 },
809         }, {
810                 .key    = { [0 ... 79] = 0xaa },
811                 .ksize  = 80,
812                 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
813                              "Block-Size Data",
814                 .psize  = 73,
815                 .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b,
816                             0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 },
817         },
818 };
819
820 /*
821  * HMAC-SHA256 test vectors from
822  * draft-ietf-ipsec-ciph-sha-256-01.txt
823  */
824 #define HMAC_SHA256_TEST_VECTORS        10
825
826 static struct hash_testvec hmac_sha256_tv_template[] = {
827         {
828                 .key    = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
829                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
830                             0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
831                             0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20},
832                 .ksize  = 32,
833                 .plaintext = "abc",
834                 .psize  = 3,
835                 .digest = { 0xa2, 0x1b, 0x1f, 0x5d, 0x4c, 0xf4, 0xf7, 0x3a,
836                             0x4d, 0xd9, 0x39, 0x75, 0x0f, 0x7a, 0x06, 0x6a,
837                             0x7f, 0x98, 0xcc, 0x13, 0x1c, 0xb1, 0x6a, 0x66,
838                             0x92, 0x75, 0x90, 0x21, 0xcf, 0xab, 0x81, 0x81 },
839         }, {
840                 .key    = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
841                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
842                             0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
843                             0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
844                 .ksize  = 32,
845                 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
846                 .psize  = 56,
847                 .digest = { 0x10, 0x4f, 0xdc, 0x12, 0x57, 0x32, 0x8f, 0x08,
848                             0x18, 0x4b, 0xa7, 0x31, 0x31, 0xc5, 0x3c, 0xae,
849                             0xe6, 0x98, 0xe3, 0x61, 0x19, 0x42, 0x11, 0x49,
850                             0xea, 0x8c, 0x71, 0x24, 0x56, 0x69, 0x7d, 0x30 },
851         }, {
852                 .key    = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
853                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
854                             0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
855                             0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
856                 .ksize  = 32,
857                 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
858                              "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
859                 .psize  = 112,
860                 .digest = { 0x47, 0x03, 0x05, 0xfc, 0x7e, 0x40, 0xfe, 0x34,
861                             0xd3, 0xee, 0xb3, 0xe7, 0x73, 0xd9, 0x5a, 0xab,
862                             0x73, 0xac, 0xf0, 0xfd, 0x06, 0x04, 0x47, 0xa5,
863                             0xeb, 0x45, 0x95, 0xbf, 0x33, 0xa9, 0xd1, 0xa3 },
864         }, {
865                 .key    = { [0 ... 31] = 0x0b },
866                 .ksize  = 32,
867                 .plaintext = "Hi There",
868                 .psize  = 8,
869                 .digest = { 0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb, 0xc6,
870                             0x99, 0x03, 0xa0, 0xf1, 0xcf, 0x2b, 0xbd, 0xc5,
871                             0xba, 0x0a, 0xa3, 0xf3, 0xd9, 0xae, 0x3c, 0x1c,
872                             0x7a, 0x3b, 0x16, 0x96, 0xa0, 0xb6, 0x8c, 0xf7 },
873         }, {
874                 .key    = "Jefe",
875                 .ksize  = 4,
876                 .plaintext = "what do ya want for nothing?",
877                 .psize  = 28,
878                 .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
879                             0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
880                             0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
881                             0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 },
882                 .np     = 2,
883                 .tap    = { 14, 14 }
884         }, {
885                 .key    = { [0 ... 31] = 0xaa },
886                 .ksize  = 32,
887                 .plaintext = { [0 ... 49] = 0xdd },
888                 .psize  = 50,
889                 .digest = { 0xcd, 0xcb, 0x12, 0x20, 0xd1, 0xec, 0xcc, 0xea,
890                             0x91, 0xe5, 0x3a, 0xba, 0x30, 0x92, 0xf9, 0x62,
891                             0xe5, 0x49, 0xfe, 0x6c, 0xe9, 0xed, 0x7f, 0xdc,
892                             0x43, 0x19, 0x1f, 0xbd, 0xe4, 0x5c, 0x30, 0xb0 },
893         }, {
894                 .key    = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
895                             0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
896                             0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
897                             0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
898                             0x21, 0x22, 0x23, 0x24, 0x25 },
899                 .ksize  = 37,
900                 .plaintext = { [0 ... 49] = 0xcd },
901                 .psize  = 50,
902                 .digest = { 0xd4, 0x63, 0x3c, 0x17, 0xf6, 0xfb, 0x8d, 0x74,
903                             0x4c, 0x66, 0xde, 0xe0, 0xf8, 0xf0, 0x74, 0x55,
904                             0x6e, 0xc4, 0xaf, 0x55, 0xef, 0x07, 0x99, 0x85,
905                             0x41, 0x46, 0x8e, 0xb4, 0x9b, 0xd2, 0xe9, 0x17 },
906         }, {
907                 .key    = { [0 ... 31] = 0x0c },
908                 .ksize  = 32,
909                 .plaintext = "Test With Truncation",
910                 .psize  = 20,
911                 .digest = { 0x75, 0x46, 0xaf, 0x01, 0x84, 0x1f, 0xc0, 0x9b,
912                             0x1a, 0xb9, 0xc3, 0x74, 0x9a, 0x5f, 0x1c, 0x17,
913                             0xd4, 0xf5, 0x89, 0x66, 0x8a, 0x58, 0x7b, 0x27,
914                             0x00, 0xa9, 0xc9, 0x7c, 0x11, 0x93, 0xcf, 0x42 },
915         }, {
916                 .key    = { [0 ... 79] = 0xaa },
917                 .ksize  = 80,
918                 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
919                 .psize  = 54,
920                 .digest = { 0x69, 0x53, 0x02, 0x5e, 0xd9, 0x6f, 0x0c, 0x09,
921                             0xf8, 0x0a, 0x96, 0xf7, 0x8e, 0x65, 0x38, 0xdb,
922                             0xe2, 0xe7, 0xb8, 0x20, 0xe3, 0xdd, 0x97, 0x0e,
923                             0x7d, 0xdd, 0x39, 0x09, 0x1b, 0x32, 0x35, 0x2f },
924         }, {
925                 .key    = { [0 ... 79] = 0xaa },
926                 .ksize  = 80,
927                 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
928                              "One Block-Size Data",
929                 .psize  = 73,
930                 .digest = { 0x63, 0x55, 0xac, 0x22, 0xe8, 0x90, 0xd0, 0xa3,
931                             0xc8, 0x48, 0x1a, 0x5c, 0xa4, 0x82, 0x5b, 0xc8,
932                             0x84, 0xd3, 0xe7, 0xa1, 0xff, 0x98, 0xa2, 0xfc,
933                             0x2a, 0xc7, 0xd8, 0xe0, 0x64, 0xc3, 0xb2, 0xe6 },
934         },
935 };
936
937 #define XCBC_AES_TEST_VECTORS 6
938
939 static struct hash_testvec aes_xcbc128_tv_template[] = {
940         {
941                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
942                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
943                 .plaintext = { [0 ... 15] = 0 },
944                 .digest = { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
945                             0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29 },
946                 .psize  = 0,
947                 .ksize  = 16,
948         }, {
949                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
950                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
951                 .plaintext = { 0x00, 0x01, 0x02 },
952                 .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
953                             0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f },
954                 .psize  = 3,
955                 .ksize  = 16,
956         } , {
957                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
958                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
959                 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
960                                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
961                 .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
962                             0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 },
963                 .psize  = 16,
964                 .ksize  = 16,
965         }, {
966                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
967                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
968                 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
969                                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
970                                0x10, 0x11, 0x12, 0x13 },
971                 .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15,
972                             0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 },
973                 .tap    = { 10, 10 },
974                 .psize  = 20,
975                 .np     = 2,
976                 .ksize  = 16,
977         }, {
978                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
979                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
980                 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
981                                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
982                                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
983                                0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
984                 .digest = { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
985                             0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4 },
986                 .psize  = 32,
987                 .ksize  = 16,
988         }, {
989                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
990                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
991                 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
992                                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
993                                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
994                                0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
995                                0x20, 0x21 },
996                 .digest = { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
997                             0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8 },
998                 .tap    = { 17, 17 },
999                 .psize  = 34,
1000                 .np     = 2,
1001                 .ksize  = 16,
1002         }
1003 };
1004
1005 /*
1006  * SHA384 HMAC test vectors from RFC4231
1007  */
1008
1009 #define HMAC_SHA384_TEST_VECTORS        4
1010
1011 static struct hash_testvec hmac_sha384_tv_template[] = {
1012         {
1013                 .key    = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1014                             0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1015                             0x0b, 0x0b, 0x0b, 0x0b }, // (20 bytes)
1016                 .ksize  = 20,
1017                 .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 }, // ("Hi There")
1018                 .psize  = 8,
1019                 .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
1020                             0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
1021                             0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
1022                             0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
1023                             0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
1024                             0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 },
1025         }, {
1026                 .key    = { 0x4a, 0x65, 0x66, 0x65 }, // ("Jefe")
1027                 .ksize  = 4,
1028                 .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
1029                                0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, // ("what do ya want ")
1030                                0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
1031                                0x69, 0x6e, 0x67, 0x3f }, // ("for nothing?")
1032                 .psize  = 28,
1033                 .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
1034                             0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
1035                             0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
1036                             0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
1037                             0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
1038                             0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 },
1039                 .np     = 4,
1040                 .tap    = { 7, 7, 7, 7 }
1041         }, {
1042                 .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1043                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1044                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1045                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1046                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1047                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1048                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1049                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1050                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1051                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1052                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1053                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1054                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1055                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1056                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1057                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1058                             0xaa, 0xaa, 0xaa }, // (131 bytes)
1059                 .ksize  = 131,
1060                 .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
1061                                0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, // ("Test Using Large")
1062                                0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
1063                                0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, // ("r Than Block-Siz")
1064                                0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
1065                                0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, // ("e Key - Hash Key")
1066                                0x20, 0x46, 0x69, 0x72, 0x73, 0x74 }, // (" First")
1067                 .psize  = 54,
1068                 .digest = { 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90,
1069                             0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4,
1070                             0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
1071                             0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6,
1072                             0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82,
1073                             0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52 },
1074         }, {
1075                 .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1076                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1077                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1078                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1079                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1080                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1081                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1082                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1083                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1084                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1085                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1086                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1087                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1088                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1089                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1090                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1091                             0xaa, 0xaa, 0xaa }, // (131 bytes)
1092                 .ksize  = 131,
1093                 .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
1094                                0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, // ("This is a test u")
1095                                0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
1096                                0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, // ("sing a larger th")
1097                                0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
1098                                0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, // ("an block-size ke")
1099                                0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
1100                                0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, // ("y and a larger t")
1101                                0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
1102                                0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, // ("han block-size d")
1103                                0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
1104                                0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, // ("ata. The key nee")
1105                                0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
1106                                0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, // ("ds to be hashed ")
1107                                0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
1108                                0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, // ("before being use")
1109                                0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
1110                                0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, // ("d by the HMAC al")
1111                                0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e }, // ("gorithm.")
1112                 .psize  = 152,
1113                 .digest = { 0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d,
1114                             0x35, 0x1e, 0x2f, 0x25, 0x4e, 0x8f, 0xd3, 0x2c,
1115                             0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a,
1116                             0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5,
1117                             0xa6, 0x78, 0xcc, 0x31, 0xe7, 0x99, 0x17, 0x6d,
1118                             0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e },
1119         },
1120 };
1121
1122 /*
1123  * SHA512 HMAC test vectors from RFC4231
1124  */
1125
1126 #define HMAC_SHA512_TEST_VECTORS        4
1127
1128 static struct hash_testvec hmac_sha512_tv_template[] = {
1129         {
1130                 .key    = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1131                             0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1132                             0x0b, 0x0b, 0x0b, 0x0b }, // (20 bytes)
1133                 .ksize  = 20,
1134                 .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 }, // ("Hi There")
1135                 .psize  = 8,
1136                 .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
1137                             0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
1138                             0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
1139                             0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
1140                             0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
1141                             0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
1142                             0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
1143                             0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 },
1144         }, {
1145                 .key    = { 0x4a, 0x65, 0x66, 0x65 }, // ("Jefe")
1146                 .ksize  = 4,
1147                 .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
1148                                0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, // ("what do ya want ")
1149                                0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
1150                                0x69, 0x6e, 0x67, 0x3f }, // ("for nothing?")
1151                 .psize  = 28,
1152                 .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
1153                             0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
1154                             0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
1155                             0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
1156                             0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
1157                             0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
1158                             0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
1159                             0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 },
1160                 .np     = 4,
1161                 .tap    = { 7, 7, 7, 7 }
1162         }, {
1163                 .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1164                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1165                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1166                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1167                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1168                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1169                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1170                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1171                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1172                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1173                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1174                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1175                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1176                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1177                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1178                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1179                             0xaa, 0xaa, 0xaa }, // (131 bytes)
1180                 .ksize  = 131,
1181                 .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
1182                                0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, // ("Test Using Large")
1183                                0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
1184                                0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, // ("r Than Block-Siz")
1185                                0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
1186                                0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, // ("e Key - Hash Key")
1187                                0x20, 0x46, 0x69, 0x72, 0x73, 0x74 }, // (" First")
1188                 .psize  = 54,
1189                 .digest = { 0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb,
1190                             0xb7, 0x14, 0x93, 0xc1, 0xdd, 0x7b, 0xe8, 0xb4,
1191                             0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1,
1192                             0x12, 0x1b, 0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52,
1193                             0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25, 0x98,
1194                             0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52,
1195                             0x95, 0xe6, 0x4f, 0x73, 0xf6, 0x3f, 0x0a, 0xec,
1196                             0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98 },
1197         }, {
1198                 .key    = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1199                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1200                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1201                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1202                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1203                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1204                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1205                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1206                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1207                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1208                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1209                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1210                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1211                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1212                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1213                             0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1214                             0xaa, 0xaa, 0xaa }, // (131 bytes)
1215                 .ksize  = 131,
1216                 .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
1217                                0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, // ("This is a test u")
1218                                0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
1219                                0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, // ("sing a larger th")
1220                                0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
1221                                0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, // ("an block-size ke")
1222                                0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
1223                                0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, // ("y and a larger t")
1224                                0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
1225                                0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, // ("han block-size d")
1226                                0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
1227                                0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, // ("ata. The key nee")
1228                                0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
1229                                0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, // ("ds to be hashed ")
1230                                0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
1231                                0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, // ("before being use")
1232                                0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
1233                                0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, // ("d by the HMAC al")
1234                                0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e }, // ("gorithm.")
1235                 .psize  = 152,
1236                 .digest = { 0xe3, 0x7b, 0x6a, 0x77, 0x5d, 0xc8, 0x7d, 0xba,
1237                             0xa4, 0xdf, 0xa9, 0xf9, 0x6e, 0x5e, 0x3f, 0xfd,
1238                             0xde, 0xbd, 0x71, 0xf8, 0x86, 0x72, 0x89, 0x86,
1239                             0x5d, 0xf5, 0xa3, 0x2d, 0x20, 0xcd, 0xc9, 0x44,
1240                             0xb6, 0x02, 0x2c, 0xac, 0x3c, 0x49, 0x82, 0xb1,
1241                             0x0d, 0x5e, 0xeb, 0x55, 0xc3, 0xe4, 0xde, 0x15,
1242                             0x13, 0x46, 0x76, 0xfb, 0x6d, 0xe0, 0x44, 0x60,
1243                             0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58 },
1244         },
1245 };
1246
1247 /*
1248  * DES test vectors.
1249  */
1250 #define DES_ENC_TEST_VECTORS            10
1251 #define DES_DEC_TEST_VECTORS            4
1252 #define DES_CBC_ENC_TEST_VECTORS        5
1253 #define DES_CBC_DEC_TEST_VECTORS        4
1254 #define DES3_EDE_ENC_TEST_VECTORS       3
1255 #define DES3_EDE_DEC_TEST_VECTORS       3
1256
1257 static struct cipher_testvec des_enc_tv_template[] = {
1258         { /* From Applied Cryptography */
1259                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1260                 .klen   = 8,
1261                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1262                 .ilen   = 8,
1263                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1264                 .rlen   = 8,
1265         }, { /* Same key, different plaintext block */
1266                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1267                 .klen   = 8,
1268                 .input  = { 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1269                 .ilen   = 8,
1270                 .result = { 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1271                 .rlen   = 8,
1272         }, { /* Sbox test from NBS */
1273                 .key    = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
1274                 .klen   = 8,
1275                 .input  = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
1276                 .ilen   = 8,
1277                 .result = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1278                 .rlen   = 8,
1279         }, { /* Three blocks */
1280                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1281                 .klen   = 8,
1282                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1283                             0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1284                             0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
1285                 .ilen   = 24,
1286                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1287                             0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1288                             0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1289                 .rlen   = 24,
1290         }, { /* Weak key */
1291                 .fail   = 1,
1292                 .wk     = 1,
1293                 .key    = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
1294                 .klen   = 8,
1295                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1296                 .ilen   = 8,
1297                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1298                 .rlen   = 8,
1299         }, { /* Two blocks -- for testing encryption across pages */
1300                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1301                 .klen   = 8,
1302                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1303                             0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1304                 .ilen   = 16,
1305                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1306                             0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1307                 .rlen   = 16,
1308                 .np     = 2,
1309                 .tap    = { 8, 8 }
1310         }, { /* Four blocks -- for testing encryption with chunking */
1311                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1312                 .klen   = 8,
1313                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1314                             0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1315                             0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef,
1316                             0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1317                 .ilen   = 32,
1318                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1319                             0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1320                             0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90,
1321                             0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1322                 .rlen   = 32,
1323                 .np     = 3,
1324                 .tap    = { 14, 10, 8 }
1325         }, {
1326                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1327                 .klen   = 8,
1328                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1329                             0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1330                             0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
1331                 .ilen   = 24,
1332                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1333                             0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1334                             0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1335                 .rlen   = 24,
1336                 .np     = 4,
1337                 .tap    = { 2, 1, 3, 18 }
1338         }, {
1339                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1340                 .klen   = 8,
1341                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1342                             0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1343                 .ilen   = 16,
1344                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1345                             0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1346                 .rlen   = 16,
1347                 .np     = 5,
1348                 .tap    = { 2, 2, 2, 2, 8 }
1349         }, {
1350                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1351                 .klen   = 8,
1352                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1353                 .ilen   = 8,
1354                 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1355                 .rlen   = 8,
1356                 .np     = 8,
1357                 .tap    = { 1, 1, 1, 1, 1, 1, 1, 1 }
1358         },
1359 };
1360
1361 static struct cipher_testvec des_dec_tv_template[] = {
1362         { /* From Applied Cryptography */
1363                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1364                 .klen   = 8,
1365                 .input  = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1366                 .ilen   = 8,
1367                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1368                 .rlen   = 8,
1369         }, { /* Sbox test from NBS */
1370                 .key    = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
1371                 .klen   = 8,
1372                 .input  = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1373                 .ilen   = 8,
1374                 .result = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
1375                 .rlen   = 8,
1376         }, { /* Two blocks, for chunking test */
1377                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1378                 .klen   = 8,
1379                 .input  = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1380                             0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1381                 .ilen   = 16,
1382                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1383                             0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1384                 .rlen   = 16,
1385                 .np     = 2,
1386                 .tap    = { 8, 8 }
1387         }, {
1388                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1389                 .klen   = 8,
1390                 .input  = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1391                             0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1392                 .ilen   = 16,
1393                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1394                             0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1395                 .rlen   = 16,
1396                 .np     = 3,
1397                 .tap    = { 3, 12, 1 }
1398         },
1399 };
1400
1401 static struct cipher_testvec des_cbc_enc_tv_template[] = {
1402         { /* From OpenSSL */
1403                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1404                 .klen   = 8,
1405                 .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1406                 .input  = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1407                             0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1408                             0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1409                 .ilen   = 24,
1410                 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1411                             0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1412                             0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
1413                 .rlen   = 24,
1414         }, { /* FIPS Pub 81 */
1415                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1416                 .klen   = 8,
1417                 .iv     = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1418                 .input  = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1419                 .ilen   = 8,
1420                 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1421                 .rlen   = 8,
1422         }, {
1423                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1424                 .klen   = 8,
1425                 .iv     = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1426                 .input  = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1427                 .ilen   = 8,
1428                 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1429                 .rlen   = 8,
1430         }, {
1431                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1432                 .klen   = 8,
1433                 .iv     = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1434                 .input  = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1435                 .ilen   = 8,
1436                 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1437                 .rlen   = 8,
1438         }, { /* Copy of openssl vector for chunk testing */
1439              /* From OpenSSL */
1440                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1441                 .klen   = 8,
1442                 .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1443                 .input  = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1444                             0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1445                             0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1446                 .ilen   = 24,
1447                 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1448                             0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1449                             0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
1450                 .rlen   = 24,
1451                 .np     = 2,
1452                 .tap    = { 13, 11 }
1453         },
1454 };
1455
1456 static struct cipher_testvec des_cbc_dec_tv_template[] = {
1457         { /* FIPS Pub 81 */
1458                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1459                 .klen   = 8,
1460                 .iv     = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1461                 .input  = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1462                 .ilen   = 8,
1463                 .result = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1464                 .rlen   = 8,
1465         }, {
1466                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1467                 .klen   = 8,
1468                 .iv     = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1469                 .input  = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1470                 .ilen   = 8,
1471                 .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1472                 .rlen   = 8,
1473         }, {
1474                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1475                 .klen   = 8,
1476                 .iv     = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1477                 .input  = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1478                 .ilen   = 8,
1479                 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1480                 .rlen   = 8,
1481         }, { /* Copy of above, for chunk testing */
1482                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1483                 .klen   = 8,
1484                 .iv     = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1485                 .input  = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1486                 .ilen   = 8,
1487                 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1488                 .rlen   = 8,
1489                 .np     = 2,
1490                 .tap    = { 4, 4 }
1491         },
1492 };
1493
1494 /*
1495  * We really need some more test vectors, especially for DES3 CBC.
1496  */
1497 static struct cipher_testvec des3_ede_enc_tv_template[] = {
1498         { /* These are from openssl */
1499                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1500                             0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1501                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1502                 .klen   = 24,
1503                 .input  = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1504                 .ilen   = 8,
1505                 .result = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1506                 .rlen   = 8,
1507         }, {
1508                 .key    = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1509                             0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1510                             0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1511                 .klen   = 24,
1512                 .input  = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1513                 .ilen   = 8,
1514                 .result = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1515                 .rlen   = 8,
1516         }, {
1517                 .key    = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1518                             0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1519                             0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1520                 .klen   = 24,
1521                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1522                 .ilen   = 8,
1523                 .result = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1524                 .rlen   = 8,
1525         },
1526 };
1527
1528 static struct cipher_testvec des3_ede_dec_tv_template[] = {
1529         { /* These are from openssl */
1530                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1531                             0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1532                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1533                 .klen   = 24,
1534                 .input  = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1535                 .ilen   = 8,
1536                 .result = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1537                 .rlen   = 8,
1538         }, {
1539                 .key    = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1540                             0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1541                             0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1542                 .klen   = 24,
1543                 .input  = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1544                 .ilen   = 8,
1545                 .result = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1546                 .rlen   = 8,
1547         }, {
1548                 .key    = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1549                             0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1550                             0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1551                 .klen   = 24,
1552                 .input  = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1553                 .ilen   = 8,
1554                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1555                 .rlen   = 8,
1556         },
1557 };
1558
1559 /*
1560  * Blowfish test vectors.
1561  */
1562 #define BF_ENC_TEST_VECTORS     6
1563 #define BF_DEC_TEST_VECTORS     6
1564 #define BF_CBC_ENC_TEST_VECTORS 1
1565 #define BF_CBC_DEC_TEST_VECTORS 1
1566
1567 static struct cipher_testvec bf_enc_tv_template[] = {
1568         { /* DES test vectors from OpenSSL */
1569                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
1570                 .klen   = 8,
1571                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1572                 .ilen   = 8,
1573                 .result = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1574                 .rlen   = 8,
1575         }, {
1576                 .key    = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1577                 .klen   = 8,
1578                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1579                 .ilen   = 8,
1580                 .result = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1581                 .rlen   = 8,
1582         }, {
1583                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1584                 .klen   = 8,
1585                 .input  = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1586                 .ilen   = 8,
1587                 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1588                 .rlen   = 8,
1589         }, { /* Vary the keylength... */
1590                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1591                             0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1592                 .klen   = 16,
1593                 .input  = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1594                 .ilen   = 8,
1595                 .result = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1596                 .rlen   = 8,
1597         }, {
1598                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1599                             0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1600                             0x00, 0x11, 0x22, 0x33, 0x44 },
1601                 .klen   = 21,
1602                 .input  = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1603                 .ilen   = 8,
1604                 .result = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1605                 .rlen   = 8,
1606         }, { /* Generated with bf488 */
1607                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1608                             0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1609                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1610                             0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1611                             0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1612                             0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
1613                             0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1614                 .klen   = 56,
1615                 .input  = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1616                 .ilen   = 8,
1617                 .result = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1618                 .rlen   = 8,
1619         },
1620 };
1621
1622 static struct cipher_testvec bf_dec_tv_template[] = {
1623         { /* DES test vectors from OpenSSL */
1624                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1625                 .klen   = 8,
1626                 .input  = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1627                 .ilen   = 8,
1628                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1629                 .rlen   = 8,
1630         }, {
1631                 .key    = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1632                 .klen   = 8,
1633                 .input  = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1634                 .ilen   = 8,
1635                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1636                 .rlen   = 8,
1637         }, {
1638                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1639                 .klen   = 8,
1640                 .input  = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1641                 .ilen   = 8,
1642                 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1643                 .rlen   = 8,
1644         }, { /* Vary the keylength... */
1645                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1646                             0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1647                 .klen   = 16,
1648                 .input  = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1649                 .ilen   = 8,
1650                 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1651                 .rlen   = 8,
1652         }, {
1653                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1654                             0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1655                             0x00, 0x11, 0x22, 0x33, 0x44 },
1656                 .klen   = 21,
1657                 .input  = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1658                 .ilen   = 8,
1659                 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1660                 .rlen   = 8,
1661         }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
1662                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1663                             0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1664                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1665                             0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1666                             0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1667                             0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
1668                             0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1669                 .klen   = 56,
1670                 .input  = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1671                 .ilen   = 8,
1672                 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1673                 .rlen   = 8,
1674         },
1675 };
1676
1677 static struct cipher_testvec bf_cbc_enc_tv_template[] = {
1678         { /* From OpenSSL */
1679                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1680                             0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1681                 .klen   = 16,
1682                 .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1683                 .input  = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1684                             0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1685                             0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1686                             0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1687                 .ilen   = 32,
1688                 .result = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1689                             0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1690                             0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1691                             0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1692                 .rlen   = 32,
1693         },
1694 };
1695
1696 static struct cipher_testvec bf_cbc_dec_tv_template[] = {
1697         { /* From OpenSSL */
1698                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1699                             0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1700                 .klen   = 16,
1701                 .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1702                 .input  = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1703                             0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1704                             0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1705                             0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1706                 .ilen   = 32,
1707                 .result = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1708                             0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1709                             0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1710                             0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1711                 .rlen   = 32,
1712         },
1713 };
1714
1715 /*
1716  * Twofish test vectors.
1717  */
1718 #define TF_ENC_TEST_VECTORS             3
1719 #define TF_DEC_TEST_VECTORS             3
1720 #define TF_CBC_ENC_TEST_VECTORS         4
1721 #define TF_CBC_DEC_TEST_VECTORS         4
1722
1723 static struct cipher_testvec tf_enc_tv_template[] = {
1724         {
1725                 .key    = { [0 ... 15] = 0x00 },
1726                 .klen   = 16,
1727                 .input  = { [0 ... 15] = 0x00 },
1728                 .ilen   = 16,
1729                 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1730                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1731                 .rlen   = 16,
1732         }, {
1733                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1734                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1735                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1736                 .klen   = 24,
1737                 .input  = { [0 ... 15] = 0x00 },
1738                 .ilen   = 16,
1739                 .result = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1740                             0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1741                 .rlen   = 16,
1742         }, {
1743                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1744                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1745                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1746                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1747                 .klen   = 32,
1748                 .input  = { [0 ... 15] = 0x00 },
1749                 .ilen   = 16,
1750                 .result = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1751                             0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1752                 .rlen   = 16,
1753         },
1754 };
1755
1756 static struct cipher_testvec tf_dec_tv_template[] = {
1757         {
1758                 .key    = { [0 ... 15] = 0x00 },
1759                 .klen   = 16,
1760                 .input  = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1761                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1762                 .ilen   = 16,
1763                 .result = { [0 ... 15] = 0x00 },
1764                 .rlen   = 16,
1765         }, {
1766                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1767                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1768                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1769                 .klen   = 24,
1770                 .input  = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1771                             0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1772                 .ilen   = 16,
1773                 .result = { [0 ... 15] = 0x00 },
1774                 .rlen   = 16,
1775         }, {
1776                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1777                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1778                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1779                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1780                 .klen   = 32,
1781                 .input  = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1782                             0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1783                 .ilen   = 16,
1784                 .result = { [0 ... 15] = 0x00 },
1785                 .rlen   = 16,
1786         },
1787 };
1788
1789 static struct cipher_testvec tf_cbc_enc_tv_template[] = {
1790         { /* Generated with Nettle */
1791                 .key    = { [0 ... 15] = 0x00 },
1792                 .klen   = 16,
1793                 .iv     = { [0 ... 15] = 0x00 },
1794                 .input  = { [0 ... 15] = 0x00 },
1795                 .ilen   = 16,
1796                 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1797                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1798                 .rlen   = 16,
1799         }, {
1800                 .key    = { [0 ... 15] = 0x00 },
1801                 .klen   = 16,
1802                 .iv     = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1803                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1804                 .input  = { [0 ... 15] = 0x00 },
1805                 .ilen   = 16,
1806                 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1807                             0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1808                 .rlen   = 16,
1809         }, {
1810                 .key    = { [0 ... 15] = 0x00 },
1811                 .klen   = 16,
1812                 .iv     = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1813                             0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1814                 .input  = { [0 ... 15] = 0x00 },
1815                 .ilen   = 16,
1816                 .result = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1817                             0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1818                 .rlen   = 16,
1819         }, {
1820                 .key    = { [0 ... 15] = 0x00 },
1821                 .klen   = 16,
1822                 .iv     = { [0 ... 15] = 0x00 },
1823                 .input  = { [0 ... 47] = 0x00 },
1824                 .ilen   = 48,
1825                 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1826                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1827                             0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1828                             0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1829                             0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1830                             0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1831                 .rlen   = 48,
1832         },
1833 };
1834
1835 static struct cipher_testvec tf_cbc_dec_tv_template[] = {
1836         { /* Reverse of the first four above */
1837                 .key    = { [0 ... 15] = 0x00 },
1838                 .klen   = 16,
1839                 .iv     = { [0 ... 15] = 0x00 },
1840                 .input  = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1841                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1842                 .ilen   = 16,
1843                 .result = { [0 ... 15] = 0x00 },
1844                 .rlen   = 16,
1845         }, {
1846                 .key    = { [0 ... 15] = 0x00 },
1847                 .klen   = 16,
1848                 .iv     = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1849                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1850                 .input  = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1851                             0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1852                 .ilen   = 16,
1853                 .result = { [0 ... 15] = 0x00 },
1854                 .rlen   = 16,
1855         }, {
1856                 .key    = { [0 ... 15] = 0x00 },
1857                 .klen   = 16,
1858                 .iv     = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1859                             0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1860                 .input  = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1861                             0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1862                 .ilen   = 16,
1863                 .result = { [0 ... 15] = 0x00 },
1864                 .rlen   = 16,
1865         }, {
1866                 .key    = { [0 ... 15] = 0x00 },
1867                 .klen   = 16,
1868                 .iv     = { [0 ... 15] = 0x00 },
1869                 .input  = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1870                             0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1871                             0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1872                             0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1873                             0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1874                             0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1875                 .ilen   = 48,
1876                 .result = { [0 ... 47] = 0x00 },
1877                 .rlen   = 48,
1878         },
1879 };
1880
1881 /*
1882  * Serpent test vectors.  These are backwards because Serpent writes
1883  * octet sequences in right-to-left mode.
1884  */
1885 #define SERPENT_ENC_TEST_VECTORS        4
1886 #define SERPENT_DEC_TEST_VECTORS        4
1887
1888 #define TNEPRES_ENC_TEST_VECTORS        4
1889 #define TNEPRES_DEC_TEST_VECTORS        4
1890
1891 static struct cipher_testvec serpent_enc_tv_template[] = {
1892         {
1893                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1894                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1895                 .ilen   = 16,
1896                 .result = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1897                             0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1898                 .rlen   = 16,
1899         }, {
1900                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1901                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1902                 .klen   = 16,
1903                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1904                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1905                 .ilen   = 16,
1906                 .result = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1907                             0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1908                 .rlen   = 16,
1909         }, {
1910                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1911                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1912                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1913                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1914                 .klen   = 32,
1915                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1916                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1917                 .ilen   = 16,
1918                 .result = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1919                             0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1920                 .rlen   = 16,
1921         }, {
1922                 .key    = { [15] = 0x80 },
1923                 .klen   = 16,
1924                 .input  = { [0 ... 15] = 0x00 },
1925                 .ilen   = 16,
1926                 .result = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1927                             0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1928                 .rlen   = 16,
1929         },
1930 };
1931
1932 static struct cipher_testvec tnepres_enc_tv_template[] = {
1933         { /* KeySize=128, PT=0, I=1 */
1934                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1935                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1936                 .key    = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1937                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1938                 .klen   = 16,
1939                 .ilen   = 16,
1940                 .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05,
1941                             0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd },
1942                 .rlen   = 16,
1943         }, { /* KeySize=192, PT=0, I=1 */
1944                 .key    = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1945                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1946                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1947                 .klen   = 24,
1948                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1949                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1950                 .ilen   = 16,
1951                 .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68,
1952                             0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 },
1953                 .rlen   = 16,
1954         }, { /* KeySize=256, PT=0, I=1 */
1955                 .key    = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1956                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1957                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1958                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1959                 .klen   = 32,
1960                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1961                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1962                 .ilen   = 16,
1963                 .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb,
1964                             0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 },
1965                 .rlen   = 16,
1966         }, { /* KeySize=256, I=257 */
1967                 .key    = { 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
1968                             0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
1969                             0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1970                             0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1971                 .klen   = 32,
1972                 .input  = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1973                             0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1974                 .ilen   = 16,
1975                 .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b,
1976                             0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde },
1977                 .rlen   = 16,
1978         },
1979 };
1980
1981
1982 static struct cipher_testvec serpent_dec_tv_template[] = {
1983         {
1984                 .input  = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1985                             0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1986                 .ilen   = 16,
1987                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1988                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1989                 .rlen   = 16,
1990         }, {
1991                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1992                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1993                 .klen   = 16,
1994                 .input  = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1995                             0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1996                 .ilen   = 16,
1997                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1998                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1999                 .rlen   = 16,
2000         }, {
2001                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2002                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2003                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2004                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2005                 .klen   = 32,
2006                 .input  = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
2007                             0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
2008                 .ilen   = 16,
2009                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2010                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2011                 .rlen   = 16,
2012         }, {
2013                 .key    = { [15] = 0x80 },
2014                 .klen   = 16,
2015                 .input  = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
2016                             0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
2017                 .ilen   = 16,
2018                 .result = { [0 ... 15] = 0x00 },
2019                 .rlen   = 16,
2020         },
2021 };
2022
2023 static struct cipher_testvec tnepres_dec_tv_template[] = {
2024         {
2025                 .input  = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
2026                             0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
2027                 .ilen   = 16,
2028                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2029                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2030                 .rlen   = 16,
2031         }, {
2032                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2033                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2034                 .klen   = 16,
2035                 .input  = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47,
2036                             0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e },
2037                 .ilen   = 16,
2038                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2039                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2040                 .rlen   = 16,
2041         }, {
2042                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2043                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2044                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2045                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2046                 .klen   = 32,
2047                 .input  = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49,
2048                             0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee },
2049                 .ilen   = 16,
2050                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2051                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2052                 .rlen   = 16,
2053         }, { /* KeySize=128, I=121 */
2054                 .key    = { [15] = 0x80 },
2055                 .klen   = 16,
2056                 .input  = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06,
2057                             0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 },
2058                 .ilen   = 16,
2059                 .result = { [0 ... 15] = 0x00 },
2060                 .rlen   = 16,
2061         },
2062 };
2063
2064
2065 /* Cast6 test vectors from RFC 2612 */
2066 #define CAST6_ENC_TEST_VECTORS  3
2067 #define CAST6_DEC_TEST_VECTORS  3
2068
2069 static struct cipher_testvec cast6_enc_tv_template[] = {
2070         {
2071                 .key    = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
2072                             0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
2073                 .klen   = 16,
2074                 .input  = { [0 ... 15] = 0x00 },
2075                 .ilen   = 16,
2076                 .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
2077                             0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
2078                 .rlen   = 16,
2079         }, {
2080                 .key    = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
2081                             0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
2082                             0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
2083                 .klen   = 24,
2084                 .input  = { [0 ... 15] = 0x00 },
2085                 .ilen   = 16,
2086                 .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
2087                             0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
2088                 .rlen   = 16,
2089         }, {
2090                 .key    = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
2091                             0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
2092                             0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
2093                             0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
2094                 .klen   = 32,
2095                 .input  = { [0 ... 15] = 0x00 },
2096                 .ilen   = 16,
2097                 .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
2098                             0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
2099                 .rlen   = 16,
2100         },
2101 };
2102
2103 static struct cipher_testvec cast6_dec_tv_template[] = {
2104         {
2105                 .key    = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
2106                             0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
2107                 .klen   = 16,
2108                 .input  = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
2109                             0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
2110                 .ilen   = 16,
2111                 .result = { [0 ... 15] = 0x00 },
2112                 .rlen   = 16,
2113         }, {
2114                 .key    = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
2115                             0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
2116                             0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
2117                 .klen   = 24,
2118                 .input  = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
2119                             0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
2120                 .ilen   = 16,
2121                 .result = { [0 ... 15] = 0x00 },
2122                 .rlen   = 16,
2123         }, {
2124                 .key    = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
2125                             0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
2126                             0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
2127                             0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
2128                 .klen   = 32,
2129                 .input  = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
2130                             0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
2131                 .ilen   = 16,
2132                 .result = { [0 ... 15] = 0x00 },
2133                 .rlen   = 16,
2134         },
2135 };
2136
2137
2138 /*
2139  * AES test vectors.
2140  */
2141 #define AES_ENC_TEST_VECTORS 3
2142 #define AES_DEC_TEST_VECTORS 3
2143 #define AES_CBC_ENC_TEST_VECTORS 2
2144 #define AES_CBC_DEC_TEST_VECTORS 2
2145 #define AES_LRW_ENC_TEST_VECTORS 8
2146 #define AES_LRW_DEC_TEST_VECTORS 8
2147 #define AES_XTS_ENC_TEST_VECTORS 4
2148 #define AES_XTS_DEC_TEST_VECTORS 4
2149
2150 static struct cipher_testvec aes_enc_tv_template[] = {
2151         { /* From FIPS-197 */
2152                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2153                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2154                 .klen   = 16,
2155                 .input  = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
2156                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
2157                 .ilen   = 16,
2158                 .result = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
2159                             0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
2160                 .rlen   = 16,
2161         }, {
2162                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2163                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2164                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
2165                 .klen   = 24,
2166                 .input  = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
2167                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
2168                 .ilen   = 16,
2169                 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
2170                             0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
2171                 .rlen   = 16,
2172         }, {
2173                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2174                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2175                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2176                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2177                 .klen   = 32,
2178                 .input  = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
2179                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
2180                 .ilen   = 16,
2181                 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
2182                             0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
2183                 .rlen   = 16,
2184         },
2185 };
2186
2187 static struct cipher_testvec aes_dec_tv_template[] = {
2188         { /* From FIPS-197 */
2189                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2190                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
2191                 .klen   = 16,
2192                 .input  = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
2193                             0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
2194                 .ilen   = 16,
2195                 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
2196                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
2197                 .rlen   = 16,
2198         }, {
2199                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2200                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2201                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
2202                 .klen   = 24,
2203                 .input  = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
2204                             0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
2205                 .ilen   = 16,
2206                 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
2207                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
2208                 .rlen   = 16,
2209         }, {
2210                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2211                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2212                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2213                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2214                 .klen   = 32,
2215                 .input  = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
2216                             0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
2217                 .ilen   = 16,
2218                 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
2219                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
2220                 .rlen   = 16,
2221         },
2222 };
2223
2224 static struct cipher_testvec aes_cbc_enc_tv_template[] = {
2225         { /* From RFC 3602 */
2226                 .key    = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
2227                             0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
2228                 .klen   = 16,
2229                 .iv     = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
2230                             0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
2231                 .input  = { "Single block msg" },
2232                 .ilen   = 16,
2233                 .result = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
2234                             0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a },
2235                 .rlen   = 16,
2236         }, {
2237                 .key    = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
2238                             0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
2239                 .klen   = 16,
2240                 .iv     = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
2241                             0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
2242                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2243                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2244                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2245                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2246                 .ilen   = 32,
2247                 .result = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
2248                             0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
2249                             0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
2250                             0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 },
2251                 .rlen   = 32,
2252         },
2253 };
2254
2255 static struct cipher_testvec aes_cbc_dec_tv_template[] = {
2256         { /* From RFC 3602 */
2257                 .key    = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
2258                             0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
2259                 .klen   = 16,
2260                 .iv     = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
2261                             0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
2262                 .input  = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
2263                             0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a },
2264                 .ilen   = 16,
2265                 .result = { "Single block msg" },
2266                 .rlen   = 16,
2267         }, {
2268                 .key    = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
2269                             0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
2270                 .klen   = 16,
2271                 .iv     = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
2272                             0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
2273                 .input  = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
2274                             0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
2275                             0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
2276                             0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 },
2277                 .ilen   = 32,
2278                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2279                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2280                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2281                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2282                 .rlen   = 32,
2283         },
2284 };
2285
2286 static struct cipher_testvec aes_lrw_enc_tv_template[] = {
2287         /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
2288         { /* LRW-32-AES 1 */
2289                 .key    = { 0x45, 0x62, 0xac, 0x25, 0xf8, 0x28, 0x17, 0x6d,
2290                             0x4c, 0x26, 0x84, 0x14, 0xb5, 0x68, 0x01, 0x85,
2291                             0x25, 0x8e, 0x2a, 0x05, 0xe7, 0x3e, 0x9d, 0x03,
2292                             0xee, 0x5a, 0x83, 0x0c, 0xcc, 0x09, 0x4c, 0x87 },
2293                 .klen   = 32,
2294                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2295                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2296                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2297                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2298                 .ilen   = 16,
2299                 .result = { 0xf1, 0xb2, 0x73, 0xcd, 0x65, 0xa3, 0xdf, 0x5f,
2300                             0xe9, 0x5d, 0x48, 0x92, 0x54, 0x63, 0x4e, 0xb8 },
2301                 .rlen   = 16,
2302         }, { /* LRW-32-AES 2 */
2303                 .key    = { 0x59, 0x70, 0x47, 0x14, 0xf5, 0x57, 0x47, 0x8c,
2304                             0xd7, 0x79, 0xe8, 0x0f, 0x54, 0x88, 0x79, 0x44,
2305                             0x0d, 0x48, 0xf0, 0xb7, 0xb1, 0x5a, 0x53, 0xea,
2306                             0x1c, 0xaa, 0x6b, 0x29, 0xc2, 0xca, 0xfb, 0xaf
2307                 },
2308                 .klen   = 32,
2309                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2310                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 },
2311                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2312                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2313                 .ilen   = 16,
2314                 .result = { 0x00, 0xc8, 0x2b, 0xae, 0x95, 0xbb, 0xcd, 0xe5,
2315                             0x27, 0x4f, 0x07, 0x69, 0xb2, 0x60, 0xe1, 0x36 },
2316                 .rlen   = 16,
2317         }, { /* LRW-32-AES 3 */
2318                 .key    = { 0xd8, 0x2a, 0x91, 0x34, 0xb2, 0x6a, 0x56, 0x50,
2319                             0x30, 0xfe, 0x69, 0xe2, 0x37, 0x7f, 0x98, 0x47,
2320                             0xcd, 0xf9, 0x0b, 0x16, 0x0c, 0x64, 0x8f, 0xb6,
2321                             0xb0, 0x0d, 0x0d, 0x1b, 0xae, 0x85, 0x87, 0x1f },
2322                 .klen   = 32,
2323                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2324                             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2325                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2326                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2327                 .ilen   = 16,
2328                 .result = { 0x76, 0x32, 0x21, 0x83, 0xed, 0x8f, 0xf1, 0x82,
2329                             0xf9, 0x59, 0x62, 0x03, 0x69, 0x0e, 0x5e, 0x01 },
2330                 .rlen   = 16,
2331         }, { /* LRW-32-AES 4 */
2332                 .key    = { 0x0f, 0x6a, 0xef, 0xf8, 0xd3, 0xd2, 0xbb, 0x15,
2333                             0x25, 0x83, 0xf7, 0x3c, 0x1f, 0x01, 0x28, 0x74,
2334                             0xca, 0xc6, 0xbc, 0x35, 0x4d, 0x4a, 0x65, 0x54,
2335                             0x90, 0xae, 0x61, 0xcf, 0x7b, 0xae, 0xbd, 0xcc,
2336                             0xad, 0xe4, 0x94, 0xc5, 0x4a, 0x29, 0xae, 0x70 },
2337                 .klen   = 40,
2338                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2339                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2340                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2341                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2342                 .ilen   = 16,
2343                 .result = { 0x9c, 0x0f, 0x15, 0x2f, 0x55, 0xa2, 0xd8, 0xf0,
2344                             0xd6, 0x7b, 0x8f, 0x9e, 0x28, 0x22, 0xbc, 0x41 },
2345                 .rlen   = 16,
2346         }, { /* LRW-32-AES 5 */
2347                 .key    = { 0x8a, 0xd4, 0xee, 0x10, 0x2f, 0xbd, 0x81, 0xff,
2348                             0xf8, 0x86, 0xce, 0xac, 0x93, 0xc5, 0xad, 0xc6,
2349                             0xa0, 0x19, 0x07, 0xc0, 0x9d, 0xf7, 0xbb, 0xdd,
2350                             0x52, 0x13, 0xb2, 0xb7, 0xf0, 0xff, 0x11, 0xd8,
2351                             0xd6, 0x08, 0xd0, 0xcd, 0x2e, 0xb1, 0x17, 0x6f },
2352                 .klen   = 40,
2353                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2354                             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2355                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2356                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2357                 .ilen   = 16,
2358                 .result = { 0xd4, 0x27, 0x6a, 0x7f, 0x14, 0x91, 0x3d, 0x65,
2359                             0xc8, 0x60, 0x48, 0x02, 0x87, 0xe3, 0x34, 0x06 },
2360                 .rlen   = 16,
2361         }, { /* LRW-32-AES 6 */
2362                 .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2363                             0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2364                             0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2365                             0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2366                             0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2367                             0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2368                 .klen   = 48,
2369                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2370                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2371                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2372                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2373                 .ilen   = 16,
2374                 .result = { 0xbd, 0x06, 0xb8, 0xe1, 0xdb, 0x98, 0x89, 0x9e,
2375                             0xc4, 0x98, 0xe4, 0x91, 0xcf, 0x1c, 0x70, 0x2b },
2376                 .rlen   = 16,
2377         }, { /* LRW-32-AES 7 */
2378                 .key    = { 0xfb, 0x76, 0x15, 0xb2, 0x3d, 0x80, 0x89, 0x1d,
2379                             0xd4, 0x70, 0x98, 0x0b, 0xc7, 0x95, 0x84, 0xc8,
2380                             0xb2, 0xfb, 0x64, 0xce, 0x60, 0x97, 0x87, 0x8d,
2381                             0x17, 0xfc, 0xe4, 0x5a, 0x49, 0xe8, 0x30, 0xb7,
2382                             0x6e, 0x78, 0x17, 0xe7, 0x2d, 0x5e, 0x12, 0xd4,
2383                             0x60, 0x64, 0x04, 0x7a, 0xf1, 0x2f, 0x9e, 0x0c },
2384                 .klen   = 48,
2385                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2386                             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2387                 .input  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2388                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2389                 .ilen   = 16,
2390                 .result = { 0x5b, 0x90, 0x8e, 0xc1, 0xab, 0xdd, 0x67, 0x5f,
2391                             0x3d, 0x69, 0x8a, 0x95, 0x53, 0xc8, 0x9c, 0xe5 },
2392                 .rlen   = 16,
2393         }, {
2394 /* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
2395                 .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2396                             0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2397                             0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2398                             0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2399                             0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2400                             0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2401                 .klen   = 48,
2402                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2403                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2404                 .input  = { 0x05, 0x11, 0xb7, 0x18, 0xab, 0xc6, 0x2d, 0xac,
2405                             0x70, 0x5d, 0xf6, 0x22, 0x94, 0xcd, 0xe5, 0x6c,
2406                             0x17, 0x6b, 0xf6, 0x1c, 0xf0, 0xf3, 0x6e, 0xf8,
2407                             0x50, 0x38, 0x1f, 0x71, 0x49, 0xb6, 0x57, 0xd6,
2408                             0x8f, 0xcb, 0x8d, 0x6b, 0xe3, 0xa6, 0x29, 0x90,
2409                             0xfe, 0x2a, 0x62, 0x82, 0xae, 0x6d, 0x8b, 0xf6,
2410                             0xad, 0x1e, 0x9e, 0x20, 0x5f, 0x38, 0xbe, 0x04,
2411                             0xda, 0x10, 0x8e, 0xed, 0xa2, 0xa4, 0x87, 0xab,
2412                             0xda, 0x6b, 0xb4, 0x0c, 0x75, 0xba, 0xd3, 0x7c,
2413                             0xc9, 0xac, 0x42, 0x31, 0x95, 0x7c, 0xc9, 0x04,
2414                             0xeb, 0xd5, 0x6e, 0x32, 0x69, 0x8a, 0xdb, 0xa6,
2415                             0x15, 0xd7, 0x3f, 0x4f, 0x2f, 0x66, 0x69, 0x03,
2416                             0x9c, 0x1f, 0x54, 0x0f, 0xde, 0x1f, 0xf3, 0x65,
2417                             0x4c, 0x96, 0x12, 0xed, 0x7c, 0x92, 0x03, 0x01,
2418                             0x6f, 0xbc, 0x35, 0x93, 0xac, 0xf1, 0x27, 0xf1,
2419                             0xb4, 0x96, 0x82, 0x5a, 0x5f, 0xb0, 0xa0, 0x50,
2420                             0x89, 0xa4, 0x8e, 0x66, 0x44, 0x85, 0xcc, 0xfd,
2421                             0x33, 0x14, 0x70, 0xe3, 0x96, 0xb2, 0xc3, 0xd3,
2422                             0xbb, 0x54, 0x5a, 0x1a, 0xf9, 0x74, 0xa2, 0xc5,
2423                             0x2d, 0x64, 0x75, 0xdd, 0xb4, 0x54, 0xe6, 0x74,
2424                             0x8c, 0xd3, 0x9d, 0x9e, 0x86, 0xab, 0x51, 0x53,
2425                             0xb7, 0x93, 0x3e, 0x6f, 0xd0, 0x4e, 0x2c, 0x40,
2426                             0xf6, 0xa8, 0x2e, 0x3e, 0x9d, 0xf4, 0x66, 0xa5,
2427                             0x76, 0x12, 0x73, 0x44, 0x1a, 0x56, 0xd7, 0x72,
2428                             0x88, 0xcd, 0x21, 0x8c, 0x4c, 0x0f, 0xfe, 0xda,
2429                             0x95, 0xe0, 0x3a, 0xa6, 0xa5, 0x84, 0x46, 0xcd,
2430                             0xd5, 0x3e, 0x9d, 0x3a, 0xe2, 0x67, 0xe6, 0x60,
2431                             0x1a, 0xe2, 0x70, 0x85, 0x58, 0xc2, 0x1b, 0x09,
2432                             0xe1, 0xd7, 0x2c, 0xca, 0xad, 0xa8, 0x8f, 0xf9,
2433                             0xac, 0xb3, 0x0e, 0xdb, 0xca, 0x2e, 0xe2, 0xb8,
2434                             0x51, 0x71, 0xd9, 0x3c, 0x6c, 0xf1, 0x56, 0xf8,
2435                             0xea, 0x9c, 0xf1, 0xfb, 0x0c, 0xe6, 0xb7, 0x10,
2436                             0x1c, 0xf8, 0xa9, 0x7c, 0xe8, 0x53, 0x35, 0xc1,
2437                             0x90, 0x3e, 0x76, 0x4a, 0x74, 0xa4, 0x21, 0x2c,
2438                             0xf6, 0x2c, 0x4e, 0x0f, 0x94, 0x3a, 0x88, 0x2e,
2439                             0x41, 0x09, 0x6a, 0x33, 0x7d, 0xf6, 0xdd, 0x3f,
2440                             0x8d, 0x23, 0x31, 0x74, 0x84, 0xeb, 0x88, 0x6e,
2441                             0xcc, 0xb9, 0xbc, 0x22, 0x83, 0x19, 0x07, 0x22,
2442                             0xa5, 0x2d, 0xdf, 0xa5, 0xf3, 0x80, 0x85, 0x78,
2443                             0x84, 0x39, 0x6a, 0x6d, 0x6a, 0x99, 0x4f, 0xa5,
2444                             0x15, 0xfe, 0x46, 0xb0, 0xe4, 0x6c, 0xa5, 0x41,
2445                             0x3c, 0xce, 0x8f, 0x42, 0x60, 0x71, 0xa7, 0x75,
2446                             0x08, 0x40, 0x65, 0x8a, 0x82, 0xbf, 0xf5, 0x43,
2447                             0x71, 0x96, 0xa9, 0x4d, 0x44, 0x8a, 0x20, 0xbe,
2448                             0xfa, 0x4d, 0xbb, 0xc0, 0x7d, 0x31, 0x96, 0x65,
2449                             0xe7, 0x75, 0xe5, 0x3e, 0xfd, 0x92, 0x3b, 0xc9,
2450                             0x55, 0xbb, 0x16, 0x7e, 0xf7, 0xc2, 0x8c, 0xa4,
2451                             0x40, 0x1d, 0xe5, 0xef, 0x0e, 0xdf, 0xe4, 0x9a,
2452                             0x62, 0x73, 0x65, 0xfd, 0x46, 0x63, 0x25, 0x3d,
2453                             0x2b, 0xaf, 0xe5, 0x64, 0xfe, 0xa5, 0x5c, 0xcf,
2454                             0x24, 0xf3, 0xb4, 0xac, 0x64, 0xba, 0xdf, 0x4b,
2455                             0xc6, 0x96, 0x7d, 0x81, 0x2d, 0x8d, 0x97, 0xf7,
2456                             0xc5, 0x68, 0x77, 0x84, 0x32, 0x2b, 0xcc, 0x85,
2457                             0x74, 0x96, 0xf0, 0x12, 0x77, 0x61, 0xb9, 0xeb,
2458                             0x71, 0xaa, 0x82, 0xcb, 0x1c, 0xdb, 0x89, 0xc8,
2459                             0xc6, 0xb5, 0xe3, 0x5c, 0x7d, 0x39, 0x07, 0x24,
2460                             0xda, 0x39, 0x87, 0x45, 0xc0, 0x2b, 0xbb, 0x01,
2461                             0xac, 0xbc, 0x2a, 0x5c, 0x7f, 0xfc, 0xe8, 0xce,
2462                             0x6d, 0x9c, 0x6f, 0xed, 0xd3, 0xc1, 0xa1, 0xd6,
2463                             0xc5, 0x55, 0xa9, 0x66, 0x2f, 0xe1, 0xc8, 0x32,
2464                             0xa6, 0x5d, 0xa4, 0x3a, 0x98, 0x73, 0xe8, 0x45,
2465                             0xa4, 0xc7, 0xa8, 0xb4, 0xf6, 0x13, 0x03, 0xf6,
2466                             0xe9, 0x2e, 0xc4, 0x29, 0x0f, 0x84, 0xdb, 0xc4,
2467                             0x21, 0xc4, 0xc2, 0x75, 0x67, 0x89, 0x37, 0x0a },
2468                 .ilen   = 512,
2469                 .result = { 0x1a, 0x1d, 0xa9, 0x30, 0xad, 0xf9, 0x2f, 0x9b,
2470                             0xb6, 0x1d, 0xae, 0xef, 0xf0, 0x2f, 0xf8, 0x5a,
2471                             0x39, 0x3c, 0xbf, 0x2a, 0xb2, 0x45, 0xb2, 0x23,
2472                             0x1b, 0x63, 0x3c, 0xcf, 0xaa, 0xbe, 0xcf, 0x4e,
2473                             0xfa, 0xe8, 0x29, 0xc2, 0x20, 0x68, 0x2b, 0x3c,
2474                             0x2e, 0x8b, 0xf7, 0x6e, 0x25, 0xbd, 0xe3, 0x3d,
2475                             0x66, 0x27, 0xd6, 0xaf, 0xd6, 0x64, 0x3e, 0xe3,
2476                             0xe8, 0x58, 0x46, 0x97, 0x39, 0x51, 0x07, 0xde,
2477                             0xcb, 0x37, 0xbc, 0xa9, 0xc0, 0x5f, 0x75, 0xc3,
2478                             0x0e, 0x84, 0x23, 0x1d, 0x16, 0xd4, 0x1c, 0x59,
2479                             0x9c, 0x1a, 0x02, 0x55, 0xab, 0x3a, 0x97, 0x1d,
2480                             0xdf, 0xdd, 0xc7, 0x06, 0x51, 0xd7, 0x70, 0xae,
2481                             0x23, 0xc6, 0x8c, 0xf5, 0x1e, 0xa0, 0xe5, 0x82,
2482                             0xb8, 0xb2, 0xbf, 0x04, 0xa0, 0x32, 0x8e, 0x68,
2483                             0xeb, 0xaf, 0x6e, 0x2d, 0x94, 0x22, 0x2f, 0xce,
2484                             0x4c, 0xb5, 0x59, 0xe2, 0xa2, 0x2f, 0xa0, 0x98,
2485                             0x1a, 0x97, 0xc6, 0xd4, 0xb5, 0x00, 0x59, 0xf2,
2486                             0x84, 0x14, 0x72, 0xb1, 0x9a, 0x6e, 0xa3, 0x7f,
2487                             0xea, 0x20, 0xe7, 0xcb, 0x65, 0x77, 0x3a, 0xdf,
2488                             0xc8, 0x97, 0x67, 0x15, 0xc2, 0x2a, 0x27, 0xcc,
2489                             0x18, 0x55, 0xa1, 0x24, 0x0b, 0x24, 0x24, 0xaf,
2490                             0x5b, 0xec, 0x68, 0xb8, 0xc8, 0xf5, 0xba, 0x63,
2491                             0xff, 0xed, 0x89, 0xce, 0xd5, 0x3d, 0x88, 0xf3,
2492                             0x25, 0xef, 0x05, 0x7c, 0x3a, 0xef, 0xeb, 0xd8,
2493                             0x7a, 0x32, 0x0d, 0xd1, 0x1e, 0x58, 0x59, 0x99,
2494                             0x90, 0x25, 0xb5, 0x26, 0xb0, 0xe3, 0x2b, 0x6c,
2495                             0x4c, 0xa9, 0x8b, 0x84, 0x4f, 0x5e, 0x01, 0x50,
2496                             0x41, 0x30, 0x58, 0xc5, 0x62, 0x74, 0x52, 0x1d,
2497                             0x45, 0x24, 0x6a, 0x42, 0x64, 0x4f, 0x97, 0x1c,
2498                             0xa8, 0x66, 0xb5, 0x6d, 0x79, 0xd4, 0x0d, 0x48,
2499                             0xc5, 0x5f, 0xf3, 0x90, 0x32, 0xdd, 0xdd, 0xe1,
2500                             0xe4, 0xa9, 0x9f, 0xfc, 0xc3, 0x52, 0x5a, 0x46,
2501                             0xe4, 0x81, 0x84, 0x95, 0x36, 0x59, 0x7a, 0x6b,
2502                             0xaa, 0xb3, 0x60, 0xad, 0xce, 0x9f, 0x9f, 0x28,
2503                             0xe0, 0x01, 0x75, 0x22, 0xc4, 0x4e, 0xa9, 0x62,
2504                             0x5c, 0x62, 0x0d, 0x00, 0xcb, 0x13, 0xe8, 0x43,
2505                             0x72, 0xd4, 0x2d, 0x53, 0x46, 0xb5, 0xd1, 0x16,
2506                             0x22, 0x18, 0xdf, 0x34, 0x33, 0xf5, 0xd6, 0x1c,
2507                             0xb8, 0x79, 0x78, 0x97, 0x94, 0xff, 0x72, 0x13,
2508                             0x4c, 0x27, 0xfc, 0xcb, 0xbf, 0x01, 0x53, 0xa6,
2509                             0xb4, 0x50, 0x6e, 0xde, 0xdf, 0xb5, 0x43, 0xa4,
2510                             0x59, 0xdf, 0x52, 0xf9, 0x7c, 0xe0, 0x11, 0x6f,
2511                             0x2d, 0x14, 0x8e, 0x24, 0x61, 0x2c, 0xe1, 0x17,
2512                             0xcc, 0xce, 0x51, 0x0c, 0x19, 0x8a, 0x82, 0x30,
2513                             0x94, 0xd5, 0x3d, 0x6a, 0x53, 0x06, 0x5e, 0xbd,
2514                             0xb7, 0xeb, 0xfa, 0xfd, 0x27, 0x51, 0xde, 0x85,
2515                             0x1e, 0x86, 0x53, 0x11, 0x53, 0x94, 0x00, 0xee,
2516                             0x2b, 0x8c, 0x08, 0x2a, 0xbf, 0xdd, 0xae, 0x11,
2517                             0xcb, 0x1e, 0xa2, 0x07, 0x9a, 0x80, 0xcf, 0x62,
2518                             0x9b, 0x09, 0xdc, 0x95, 0x3c, 0x96, 0x8e, 0xb1,
2519                             0x09, 0xbd, 0xe4, 0xeb, 0xdb, 0xca, 0x70, 0x7a,
2520                             0x9e, 0xfa, 0x31, 0x18, 0x45, 0x3c, 0x21, 0x33,
2521                             0xb0, 0xb3, 0x2b, 0xea, 0xf3, 0x71, 0x2d, 0xe1,
2522                             0x03, 0xad, 0x1b, 0x48, 0xd4, 0x67, 0x27, 0xf0,
2523                             0x62, 0xe4, 0x3d, 0xfb, 0x9b, 0x08, 0x76, 0xe7,
2524                             0xdd, 0x2b, 0x01, 0x39, 0x04, 0x5a, 0x58, 0x7a,
2525                             0xf7, 0x11, 0x90, 0xec, 0xbd, 0x51, 0x5c, 0x32,
2526                             0x6b, 0xd7, 0x35, 0x39, 0x02, 0x6b, 0xf2, 0xa6,
2527                             0xd0, 0x0d, 0x07, 0xe1, 0x06, 0xc4, 0x5b, 0x7d,
2528                             0xe4, 0x6a, 0xd7, 0xee, 0x15, 0x1f, 0x83, 0xb4,
2529                             0xa3, 0xa7, 0x5e, 0xc3, 0x90, 0xb7, 0xef, 0xd3,
2530                             0xb7, 0x4f, 0xf8, 0x92, 0x4c, 0xb7, 0x3c, 0x29,
2531                             0xcd, 0x7e, 0x2b, 0x5d, 0x43, 0xea, 0x42, 0xe7,
2532                             0x74, 0x3f, 0x7d, 0x58, 0x88, 0x75, 0xde, 0x3e },
2533                 .rlen   = 512,
2534         }
2535 };
2536
2537 static struct cipher_testvec aes_lrw_dec_tv_template[] = {
2538         /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
2539         /* same as enc vectors with input and result reversed */
2540         { /* LRW-32-AES 1 */
2541                 .key    = { 0x45, 0x62, 0xac, 0x25, 0xf8, 0x28, 0x17, 0x6d,
2542                             0x4c, 0x26, 0x84, 0x14, 0xb5, 0x68, 0x01, 0x85,
2543                             0x25, 0x8e, 0x2a, 0x05, 0xe7, 0x3e, 0x9d, 0x03,
2544                             0xee, 0x5a, 0x83, 0x0c, 0xcc, 0x09, 0x4c, 0x87 },
2545                 .klen   = 32,
2546                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2547                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2548                 .input  = { 0xf1, 0xb2, 0x73, 0xcd, 0x65, 0xa3, 0xdf, 0x5f,
2549                             0xe9, 0x5d, 0x48, 0x92, 0x54, 0x63, 0x4e, 0xb8 },
2550                 .ilen   = 16,
2551                 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2552                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2553                 .rlen   = 16,
2554         }, { /* LRW-32-AES 2 */
2555                 .key    = { 0x59, 0x70, 0x47, 0x14, 0xf5, 0x57, 0x47, 0x8c,
2556                             0xd7, 0x79, 0xe8, 0x0f, 0x54, 0x88, 0x79, 0x44,
2557                             0x0d, 0x48, 0xf0, 0xb7, 0xb1, 0x5a, 0x53, 0xea,
2558                             0x1c, 0xaa, 0x6b, 0x29, 0xc2, 0xca, 0xfb, 0xaf
2559                 },
2560                 .klen   = 32,
2561                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2562                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 },
2563                 .input  = { 0x00, 0xc8, 0x2b, 0xae, 0x95, 0xbb, 0xcd, 0xe5,
2564                             0x27, 0x4f, 0x07, 0x69, 0xb2, 0x60, 0xe1, 0x36 },
2565                 .ilen   = 16,
2566                 .result  = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2567                              0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2568                 .rlen   = 16,
2569         }, { /* LRW-32-AES 3 */
2570                 .key    = { 0xd8, 0x2a, 0x91, 0x34, 0xb2, 0x6a, 0x56, 0x50,
2571                             0x30, 0xfe, 0x69, 0xe2, 0x37, 0x7f, 0x98, 0x47,
2572                             0xcd, 0xf9, 0x0b, 0x16, 0x0c, 0x64, 0x8f, 0xb6,
2573                             0xb0, 0x0d, 0x0d, 0x1b, 0xae, 0x85, 0x87, 0x1f },
2574                 .klen   = 32,
2575                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2576                             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2577                 .input  = { 0x76, 0x32, 0x21, 0x83, 0xed, 0x8f, 0xf1, 0x82,
2578                             0xf9, 0x59, 0x62, 0x03, 0x69, 0x0e, 0x5e, 0x01 },
2579                 .ilen   = 16,
2580                 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2581                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2582                 .rlen   = 16,
2583         }, { /* LRW-32-AES 4 */
2584                 .key    = { 0x0f, 0x6a, 0xef, 0xf8, 0xd3, 0xd2, 0xbb, 0x15,
2585                             0x25, 0x83, 0xf7, 0x3c, 0x1f, 0x01, 0x28, 0x74,
2586                             0xca, 0xc6, 0xbc, 0x35, 0x4d, 0x4a, 0x65, 0x54,
2587                             0x90, 0xae, 0x61, 0xcf, 0x7b, 0xae, 0xbd, 0xcc,
2588                             0xad, 0xe4, 0x94, 0xc5, 0x4a, 0x29, 0xae, 0x70 },
2589                 .klen   = 40,
2590                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2591                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2592                 .input  = { 0x9c, 0x0f, 0x15, 0x2f, 0x55, 0xa2, 0xd8, 0xf0,
2593                             0xd6, 0x7b, 0x8f, 0x9e, 0x28, 0x22, 0xbc, 0x41 },
2594                 .ilen   = 16,
2595                 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2596                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2597                 .rlen   = 16,
2598         }, { /* LRW-32-AES 5 */
2599                 .key    = { 0x8a, 0xd4, 0xee, 0x10, 0x2f, 0xbd, 0x81, 0xff,
2600                             0xf8, 0x86, 0xce, 0xac, 0x93, 0xc5, 0xad, 0xc6,
2601                             0xa0, 0x19, 0x07, 0xc0, 0x9d, 0xf7, 0xbb, 0xdd,
2602                             0x52, 0x13, 0xb2, 0xb7, 0xf0, 0xff, 0x11, 0xd8,
2603                             0xd6, 0x08, 0xd0, 0xcd, 0x2e, 0xb1, 0x17, 0x6f },
2604                 .klen   = 40,
2605                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2606                             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2607                 .input  = { 0xd4, 0x27, 0x6a, 0x7f, 0x14, 0x91, 0x3d, 0x65,
2608                             0xc8, 0x60, 0x48, 0x02, 0x87, 0xe3, 0x34, 0x06 },
2609                 .ilen   = 16,
2610                 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2611                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2612                 .rlen   = 16,
2613         }, { /* LRW-32-AES 6 */
2614                 .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2615                             0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2616                             0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2617                             0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2618                             0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2619                             0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2620                 .klen   = 48,
2621                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2622                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2623                 .input  = { 0xbd, 0x06, 0xb8, 0xe1, 0xdb, 0x98, 0x89, 0x9e,
2624                             0xc4, 0x98, 0xe4, 0x91, 0xcf, 0x1c, 0x70, 0x2b },
2625                 .ilen   = 16,
2626                 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2627                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2628                 .rlen   = 16,
2629         }, { /* LRW-32-AES 7 */
2630                 .key    = { 0xfb, 0x76, 0x15, 0xb2, 0x3d, 0x80, 0x89, 0x1d,
2631                             0xd4, 0x70, 0x98, 0x0b, 0xc7, 0x95, 0x84, 0xc8,
2632                             0xb2, 0xfb, 0x64, 0xce, 0x60, 0x97, 0x87, 0x8d,
2633                             0x17, 0xfc, 0xe4, 0x5a, 0x49, 0xe8, 0x30, 0xb7,
2634                             0x6e, 0x78, 0x17, 0xe7, 0x2d, 0x5e, 0x12, 0xd4,
2635                             0x60, 0x64, 0x04, 0x7a, 0xf1, 0x2f, 0x9e, 0x0c },
2636                 .klen   = 48,
2637                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2638                             0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2639                 .input  = { 0x5b, 0x90, 0x8e, 0xc1, 0xab, 0xdd, 0x67, 0x5f,
2640                             0x3d, 0x69, 0x8a, 0x95, 0x53, 0xc8, 0x9c, 0xe5 },
2641                 .ilen   = 16,
2642                 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2643                             0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2644                 .rlen   = 16,
2645         }, {
2646 /* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
2647                 .key    = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2648                             0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2649                             0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2650                             0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2651                             0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2652                             0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2653                 .klen   = 48,
2654                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2655                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2656                 .input  = { 0x1a, 0x1d, 0xa9, 0x30, 0xad, 0xf9, 0x2f, 0x9b,
2657                             0xb6, 0x1d, 0xae, 0xef, 0xf0, 0x2f, 0xf8, 0x5a,
2658                             0x39, 0x3c, 0xbf, 0x2a, 0xb2, 0x45, 0xb2, 0x23,
2659                             0x1b, 0x63, 0x3c, 0xcf, 0xaa, 0xbe, 0xcf, 0x4e,
2660                             0xfa, 0xe8, 0x29, 0xc2, 0x20, 0x68, 0x2b, 0x3c,
2661                             0x2e, 0x8b, 0xf7, 0x6e, 0x25, 0xbd, 0xe3, 0x3d,
2662                             0x66, 0x27, 0xd6, 0xaf, 0xd6, 0x64, 0x3e, 0xe3,
2663                             0xe8, 0x58, 0x46, 0x97, 0x39, 0x51, 0x07, 0xde,
2664                             0xcb, 0x37, 0xbc, 0xa9, 0xc0, 0x5f, 0x75, 0xc3,
2665                             0x0e, 0x84, 0x23, 0x1d, 0x16, 0xd4, 0x1c, 0x59,
2666                             0x9c, 0x1a, 0x02, 0x55, 0xab, 0x3a, 0x97, 0x1d,
2667                             0xdf, 0xdd, 0xc7, 0x06, 0x51, 0xd7, 0x70, 0xae,
2668                             0x23, 0xc6, 0x8c, 0xf5, 0x1e, 0xa0, 0xe5, 0x82,
2669                             0xb8, 0xb2, 0xbf, 0x04, 0xa0, 0x32, 0x8e, 0x68,
2670                             0xeb, 0xaf, 0x6e, 0x2d, 0x94, 0x22, 0x2f, 0xce,
2671                             0x4c, 0xb5, 0x59, 0xe2, 0xa2, 0x2f, 0xa0, 0x98,
2672                             0x1a, 0x97, 0xc6, 0xd4, 0xb5, 0x00, 0x59, 0xf2,
2673                             0x84, 0x14, 0x72, 0xb1, 0x9a, 0x6e, 0xa3, 0x7f,
2674                             0xea, 0x20, 0xe7, 0xcb, 0x65, 0x77, 0x3a, 0xdf,
2675                             0xc8, 0x97, 0x67, 0x15, 0xc2, 0x2a, 0x27, 0xcc,
2676                             0x18, 0x55, 0xa1, 0x24, 0x0b, 0x24, 0x24, 0xaf,
2677                             0x5b, 0xec, 0x68, 0xb8, 0xc8, 0xf5, 0xba, 0x63,
2678                             0xff, 0xed, 0x89, 0xce, 0xd5, 0x3d, 0x88, 0xf3,
2679                             0x25, 0xef, 0x05, 0x7c, 0x3a, 0xef, 0xeb, 0xd8,
2680                             0x7a, 0x32, 0x0d, 0xd1, 0x1e, 0x58, 0x59, 0x99,
2681                             0x90, 0x25, 0xb5, 0x26, 0xb0, 0xe3, 0x2b, 0x6c,
2682                             0x4c, 0xa9, 0x8b, 0x84, 0x4f, 0x5e, 0x01, 0x50,
2683                             0x41, 0x30, 0x58, 0xc5, 0x62, 0x74, 0x52, 0x1d,
2684                             0x45, 0x24, 0x6a, 0x42, 0x64, 0x4f, 0x97, 0x1c,
2685                             0xa8, 0x66, 0xb5, 0x6d, 0x79, 0xd4, 0x0d, 0x48,
2686                             0xc5, 0x5f, 0xf3, 0x90, 0x32, 0xdd, 0xdd, 0xe1,
2687                             0xe4, 0xa9, 0x9f, 0xfc, 0xc3, 0x52, 0x5a, 0x46,
2688                             0xe4, 0x81, 0x84, 0x95, 0x36, 0x59, 0x7a, 0x6b,
2689                             0xaa, 0xb3, 0x60, 0xad, 0xce, 0x9f, 0x9f, 0x28,
2690                             0xe0, 0x01, 0x75, 0x22, 0xc4, 0x4e, 0xa9, 0x62,
2691                             0x5c, 0x62, 0x0d, 0x00, 0xcb, 0x13, 0xe8, 0x43,
2692                             0x72, 0xd4, 0x2d, 0x53, 0x46, 0xb5, 0xd1, 0x16,
2693                             0x22, 0x18, 0xdf, 0x34, 0x33, 0xf5, 0xd6, 0x1c,
2694                             0xb8, 0x79, 0x78, 0x97, 0x94, 0xff, 0x72, 0x13,
2695                             0x4c, 0x27, 0xfc, 0xcb, 0xbf, 0x01, 0x53, 0xa6,
2696                             0xb4, 0x50, 0x6e, 0xde, 0xdf, 0xb5, 0x43, 0xa4,
2697                             0x59, 0xdf, 0x52, 0xf9, 0x7c, 0xe0, 0x11, 0x6f,
2698                             0x2d, 0x14, 0x8e, 0x24, 0x61, 0x2c, 0xe1, 0x17,
2699                             0xcc, 0xce, 0x51, 0x0c, 0x19, 0x8a, 0x82, 0x30,
2700                             0x94, 0xd5, 0x3d, 0x6a, 0x53, 0x06, 0x5e, 0xbd,
2701                             0xb7, 0xeb, 0xfa, 0xfd, 0x27, 0x51, 0xde, 0x85,
2702                             0x1e, 0x86, 0x53, 0x11, 0x53, 0x94, 0x00, 0xee,
2703                             0x2b, 0x8c, 0x08, 0x2a, 0xbf, 0xdd, 0xae, 0x11,
2704                             0xcb, 0x1e, 0xa2, 0x07, 0x9a, 0x80, 0xcf, 0x62,
2705                             0x9b, 0x09, 0xdc, 0x95, 0x3c, 0x96, 0x8e, 0xb1,
2706                             0x09, 0xbd, 0xe4, 0xeb, 0xdb, 0xca, 0x70, 0x7a,
2707                             0x9e, 0xfa, 0x31, 0x18, 0x45, 0x3c, 0x21, 0x33,
2708                             0xb0, 0xb3, 0x2b, 0xea, 0xf3, 0x71, 0x2d, 0xe1,
2709                             0x03, 0xad, 0x1b, 0x48, 0xd4, 0x67, 0x27, 0xf0,
2710                             0x62, 0xe4, 0x3d, 0xfb, 0x9b, 0x08, 0x76, 0xe7,
2711                             0xdd, 0x2b, 0x01, 0x39, 0x04, 0x5a, 0x58, 0x7a,
2712                             0xf7, 0x11, 0x90, 0xec, 0xbd, 0x51, 0x5c, 0x32,
2713                             0x6b, 0xd7, 0x35, 0x39, 0x02, 0x6b, 0xf2, 0xa6,
2714                             0xd0, 0x0d, 0x07, 0xe1, 0x06, 0xc4, 0x5b, 0x7d,
2715                             0xe4, 0x6a, 0xd7, 0xee, 0x15, 0x1f, 0x83, 0xb4,
2716                             0xa3, 0xa7, 0x5e, 0xc3, 0x90, 0xb7, 0xef, 0xd3,
2717                             0xb7, 0x4f, 0xf8, 0x92, 0x4c, 0xb7, 0x3c, 0x29,
2718                             0xcd, 0x7e, 0x2b, 0x5d, 0x43, 0xea, 0x42, 0xe7,
2719                             0x74, 0x3f, 0x7d, 0x58, 0x88, 0x75, 0xde, 0x3e },
2720                 .ilen   = 512,
2721                 .result = { 0x05, 0x11, 0xb7, 0x18, 0xab, 0xc6, 0x2d, 0xac,
2722                             0x70, 0x5d, 0xf6, 0x22, 0x94, 0xcd, 0xe5, 0x6c,
2723                             0x17, 0x6b, 0xf6, 0x1c, 0xf0, 0xf3, 0x6e, 0xf8,
2724                             0x50, 0x38, 0x1f, 0x71, 0x49, 0xb6, 0x57, 0xd6,
2725                             0x8f, 0xcb, 0x8d, 0x6b, 0xe3, 0xa6, 0x29, 0x90,
2726                             0xfe, 0x2a, 0x62, 0x82, 0xae, 0x6d, 0x8b, 0xf6,
2727                             0xad, 0x1e, 0x9e, 0x20, 0x5f, 0x38, 0xbe, 0x04,
2728                             0xda, 0x10, 0x8e, 0xed, 0xa2, 0xa4, 0x87, 0xab,
2729                             0xda, 0x6b, 0xb4, 0x0c, 0x75, 0xba, 0xd3, 0x7c,
2730                             0xc9, 0xac, 0x42, 0x31, 0x95, 0x7c, 0xc9, 0x04,
2731                             0xeb, 0xd5, 0x6e, 0x32, 0x69, 0x8a, 0xdb, 0xa6,
2732                             0x15, 0xd7, 0x3f, 0x4f, 0x2f, 0x66, 0x69, 0x03,
2733                             0x9c, 0x1f, 0x54, 0x0f, 0xde, 0x1f, 0xf3, 0x65,
2734                             0x4c, 0x96, 0x12, 0xed, 0x7c, 0x92, 0x03, 0x01,
2735                             0x6f, 0xbc, 0x35, 0x93, 0xac, 0xf1, 0x27, 0xf1,
2736                             0xb4, 0x96, 0x82, 0x5a, 0x5f, 0xb0, 0xa0, 0x50,
2737                             0x89, 0xa4, 0x8e, 0x66, 0x44, 0x85, 0xcc, 0xfd,
2738                             0x33, 0x14, 0x70, 0xe3, 0x96, 0xb2, 0xc3, 0xd3,
2739                             0xbb, 0x54, 0x5a, 0x1a, 0xf9, 0x74, 0xa2, 0xc5,
2740                             0x2d, 0x64, 0x75, 0xdd, 0xb4, 0x54, 0xe6, 0x74,
2741                             0x8c, 0xd3, 0x9d, 0x9e, 0x86, 0xab, 0x51, 0x53,
2742                             0xb7, 0x93, 0x3e, 0x6f, 0xd0, 0x4e, 0x2c, 0x40,
2743                             0xf6, 0xa8, 0x2e, 0x3e, 0x9d, 0xf4, 0x66, 0xa5,
2744                             0x76, 0x12, 0x73, 0x44, 0x1a, 0x56, 0xd7, 0x72,
2745                             0x88, 0xcd, 0x21, 0x8c, 0x4c, 0x0f, 0xfe, 0xda,
2746                             0x95, 0xe0, 0x3a, 0xa6, 0xa5, 0x84, 0x46, 0xcd,
2747                             0xd5, 0x3e, 0x9d, 0x3a, 0xe2, 0x67, 0xe6, 0x60,
2748                             0x1a, 0xe2, 0x70, 0x85, 0x58, 0xc2, 0x1b, 0x09,
2749                             0xe1, 0xd7, 0x2c, 0xca, 0xad, 0xa8, 0x8f, 0xf9,
2750                             0xac, 0xb3, 0x0e, 0xdb, 0xca, 0x2e, 0xe2, 0xb8,
2751                             0x51, 0x71, 0xd9, 0x3c, 0x6c, 0xf1, 0x56, 0xf8,
2752                             0xea, 0x9c, 0xf1, 0xfb, 0x0c, 0xe6, 0xb7, 0x10,
2753                             0x1c, 0xf8, 0xa9, 0x7c, 0xe8, 0x53, 0x35, 0xc1,
2754                             0x90, 0x3e, 0x76, 0x4a, 0x74, 0xa4, 0x21, 0x2c,
2755                             0xf6, 0x2c, 0x4e, 0x0f, 0x94, 0x3a, 0x88, 0x2e,
2756                             0x41, 0x09, 0x6a, 0x33, 0x7d, 0xf6, 0xdd, 0x3f,
2757                             0x8d, 0x23, 0x31, 0x74, 0x84, 0xeb, 0x88, 0x6e,
2758                             0xcc, 0xb9, 0xbc, 0x22, 0x83, 0x19, 0x07, 0x22,
2759                             0xa5, 0x2d, 0xdf, 0xa5, 0xf3, 0x80, 0x85, 0x78,
2760                             0x84, 0x39, 0x6a, 0x6d, 0x6a, 0x99, 0x4f, 0xa5,
2761                             0x15, 0xfe, 0x46, 0xb0, 0xe4, 0x6c, 0xa5, 0x41,
2762                             0x3c, 0xce, 0x8f, 0x42, 0x60, 0x71, 0xa7, 0x75,
2763                             0x08, 0x40, 0x65, 0x8a, 0x82, 0xbf, 0xf5, 0x43,
2764                             0x71, 0x96, 0xa9, 0x4d, 0x44, 0x8a, 0x20, 0xbe,
2765                             0xfa, 0x4d, 0xbb, 0xc0, 0x7d, 0x31, 0x96, 0x65,
2766                             0xe7, 0x75, 0xe5, 0x3e, 0xfd, 0x92, 0x3b, 0xc9,
2767                             0x55, 0xbb, 0x16, 0x7e, 0xf7, 0xc2, 0x8c, 0xa4,
2768                             0x40, 0x1d, 0xe5, 0xef, 0x0e, 0xdf, 0xe4, 0x9a,
2769                             0x62, 0x73, 0x65, 0xfd, 0x46, 0x63, 0x25, 0x3d,
2770                             0x2b, 0xaf, 0xe5, 0x64, 0xfe, 0xa5, 0x5c, 0xcf,
2771                             0x24, 0xf3, 0xb4, 0xac, 0x64, 0xba, 0xdf, 0x4b,
2772                             0xc6, 0x96, 0x7d, 0x81, 0x2d, 0x8d, 0x97, 0xf7,
2773                             0xc5, 0x68, 0x77, 0x84, 0x32, 0x2b, 0xcc, 0x85,
2774                             0x74, 0x96, 0xf0, 0x12, 0x77, 0x61, 0xb9, 0xeb,
2775                             0x71, 0xaa, 0x82, 0xcb, 0x1c, 0xdb, 0x89, 0xc8,
2776                             0xc6, 0xb5, 0xe3, 0x5c, 0x7d, 0x39, 0x07, 0x24,
2777                             0xda, 0x39, 0x87, 0x45, 0xc0, 0x2b, 0xbb, 0x01,
2778                             0xac, 0xbc, 0x2a, 0x5c, 0x7f, 0xfc, 0xe8, 0xce,
2779                             0x6d, 0x9c, 0x6f, 0xed, 0xd3, 0xc1, 0xa1, 0xd6,
2780                             0xc5, 0x55, 0xa9, 0x66, 0x2f, 0xe1, 0xc8, 0x32,
2781                             0xa6, 0x5d, 0xa4, 0x3a, 0x98, 0x73, 0xe8, 0x45,
2782                             0xa4, 0xc7, 0xa8, 0xb4, 0xf6, 0x13, 0x03, 0xf6,
2783                             0xe9, 0x2e, 0xc4, 0x29, 0x0f, 0x84, 0xdb, 0xc4,
2784                             0x21, 0xc4, 0xc2, 0x75, 0x67, 0x89, 0x37, 0x0a },
2785                 .rlen   = 512,
2786         }
2787 };
2788
2789 static struct cipher_testvec aes_xts_enc_tv_template[] = {
2790         /* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
2791         { /* XTS-AES 1 */
2792                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2793                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2794                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2795                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2796                 .klen   = 32,
2797                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2798                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2799                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2800                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2801                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2802                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2803                 .ilen   = 32,
2804                 .result = { 0x91, 0x7c, 0xf6, 0x9e, 0xbd, 0x68, 0xb2, 0xec,
2805                             0x9b, 0x9f, 0xe9, 0xa3, 0xea, 0xdd, 0xa6, 0x92,
2806                             0xcd, 0x43, 0xd2, 0xf5, 0x95, 0x98, 0xed, 0x85,
2807                             0x8c, 0x02, 0xc2, 0x65, 0x2f, 0xbf, 0x92, 0x2e },
2808                 .rlen   = 32,
2809         }, { /* XTS-AES 2 */
2810                 .key    = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
2811                             0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
2812                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
2813                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
2814                 .klen   = 32,
2815                 .iv     = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
2816                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2817                 .input  = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
2818                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
2819                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
2820                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
2821                 .ilen   = 32,
2822                 .result = { 0xc4, 0x54, 0x18, 0x5e, 0x6a, 0x16, 0x93, 0x6e,
2823                             0x39, 0x33, 0x40, 0x38, 0xac, 0xef, 0x83, 0x8b,
2824                             0xfb, 0x18, 0x6f, 0xff, 0x74, 0x80, 0xad, 0xc4,
2825                             0x28, 0x93, 0x82, 0xec, 0xd6, 0xd3, 0x94, 0xf0 },
2826                 .rlen   = 32,
2827         }, { /* XTS-AES 3 */
2828                 .key    = { 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
2829                             0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0,
2830                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
2831                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
2832                 .klen   = 32,
2833                 .iv     = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
2834                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2835                 .input  = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
2836                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
2837                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
2838                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
2839                 .ilen   = 32,
2840                 .result = { 0xaf, 0x85, 0x33, 0x6b, 0x59, 0x7a, 0xfc, 0x1a,
2841                             0x90, 0x0b, 0x2e, 0xb2, 0x1e, 0xc9, 0x49, 0xd2,
2842                             0x92, 0xdf, 0x4c, 0x04, 0x7e, 0x0b, 0x21, 0x53,
2843                             0x21, 0x86, 0xa5, 0x97, 0x1a, 0x22, 0x7a, 0x89 },
2844                 .rlen   = 32,
2845         }, { /* XTS-AES 4 */
2846                 .key    = { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
2847                             0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
2848                             0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
2849                             0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95 },
2850                 .klen   = 32,
2851                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2852                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2853                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2854                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2855                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2856                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2857                             0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2858                             0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
2859                             0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2860                             0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
2861                             0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
2862                             0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
2863                             0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
2864                             0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
2865                             0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
2866                             0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
2867                             0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
2868                             0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
2869                             0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
2870                             0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
2871                             0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
2872                             0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
2873                             0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
2874                             0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
2875                             0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
2876                             0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
2877                             0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
2878                             0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
2879                             0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
2880                             0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
2881                             0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
2882                             0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
2883                             0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2884                             0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
2885                             0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2886                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2887                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2888                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2889                             0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2890                             0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
2891                             0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2892                             0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
2893                             0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
2894                             0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
2895                             0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
2896                             0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
2897                             0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
2898                             0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
2899                             0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
2900                             0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
2901                             0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
2902                             0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
2903                             0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
2904                             0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
2905                             0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
2906                             0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
2907                             0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
2908                             0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
2909                             0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
2910                             0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
2911                             0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
2912                             0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
2913                             0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
2914                             0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
2915                             0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2916                             0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
2917                 .ilen   = 512,
2918                 .result = { 0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76,
2919                             0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2,
2920                             0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25,
2921                             0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c,
2922                             0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f,
2923                             0x83, 0x33, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00,
2924                             0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad,
2925                             0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12,
2926                             0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5,
2927                             0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5,
2928                             0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc,
2929                             0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce,
2930                             0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4,
2931                             0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84,
2932                             0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a,
2933                             0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65,
2934                             0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89,
2935                             0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51,
2936                             0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15,
2937                             0x88, 0xed, 0xe8, 0x21, 0x03, 0xa2, 0x52, 0xd8,
2938                             0xa7, 0x50, 0xe8, 0x76, 0x8d, 0xef, 0xff, 0xed,
2939                             0x91, 0x22, 0x81, 0x0a, 0xae, 0xb9, 0x9f, 0x91,
2940                             0x72, 0xaf, 0x82, 0xb6, 0x04, 0xdc, 0x4b, 0x8e,
2941                             0x51, 0xbc, 0xb0, 0x82, 0x35, 0xa6, 0xf4, 0x34,
2942                             0x13, 0x32, 0xe4, 0xca, 0x60, 0x48, 0x2a, 0x4b,
2943                             0xa1, 0xa0, 0x3b, 0x3e, 0x65, 0x00, 0x8f, 0xc5,
2944                             0xda, 0x76, 0xb7, 0x0b, 0xf1, 0x69, 0x0d, 0xb4,
2945                             0xea, 0xe2, 0x9c, 0x5f, 0x1b, 0xad, 0xd0, 0x3c,
2946                             0x5c, 0xcf, 0x2a, 0x55, 0xd7, 0x05, 0xdd, 0xcd,
2947                             0x86, 0xd4, 0x49, 0x51, 0x1c, 0xeb, 0x7e, 0xc3,
2948                             0x0b, 0xf1, 0x2b, 0x1f, 0xa3, 0x5b, 0x91, 0x3f,
2949                             0x9f, 0x74, 0x7a, 0x8a, 0xfd, 0x1b, 0x13, 0x0e,
2950                             0x94, 0xbf, 0xf9, 0x4e, 0xff, 0xd0, 0x1a, 0x91,
2951                             0x73, 0x5c, 0xa1, 0x72, 0x6a, 0xcd, 0x0b, 0x19,
2952                             0x7c, 0x4e, 0x5b, 0x03, 0x39, 0x36, 0x97, 0xe1,
2953                             0x26, 0x82, 0x6f, 0xb6, 0xbb, 0xde, 0x8e, 0xcc,
2954                             0x1e, 0x08, 0x29, 0x85, 0x16, 0xe2, 0xc9, 0xed,
2955                             0x03, 0xff, 0x3c, 0x1b, 0x78, 0x60, 0xf6, 0xde,
2956                             0x76, 0xd4, 0xce, 0xcd, 0x94, 0xc8, 0x11, 0x98,
2957                             0x55, 0xef, 0x52, 0x97, 0xca, 0x67, 0xe9, 0xf3,
2958                             0xe7, 0xff, 0x72, 0xb1, 0xe9, 0x97, 0x85, 0xca,
2959                             0x0a, 0x7e, 0x77, 0x20, 0xc5, 0xb3, 0x6d, 0xc6,
2960                             0xd7, 0x2c, 0xac, 0x95, 0x74, 0xc8, 0xcb, 0xbc,
2961                             0x2f, 0x80, 0x1e, 0x23, 0xe5, 0x6f, 0xd3, 0x44,
2962                             0xb0, 0x7f, 0x22, 0x15, 0x4b, 0xeb, 0xa0, 0xf0,
2963                             0x8c, 0xe8, 0x89, 0x1e, 0x64, 0x3e, 0xd9, 0x95,
2964                             0xc9, 0x4d, 0x9a, 0x69, 0xc9, 0xf1, 0xb5, 0xf4,
2965                             0x99, 0x02, 0x7a, 0x78, 0x57, 0x2a, 0xee, 0xbd,
2966                             0x74, 0xd2, 0x0c, 0xc3, 0x98, 0x81, 0xc2, 0x13,
2967                             0xee, 0x77, 0x0b, 0x10, 0x10, 0xe4, 0xbe, 0xa7,
2968                             0x18, 0x84, 0x69, 0x77, 0xae, 0x11, 0x9f, 0x7a,
2969                             0x02, 0x3a, 0xb5, 0x8c, 0xca, 0x0a, 0xd7, 0x52,
2970                             0xaf, 0xe6, 0x56, 0xbb, 0x3c, 0x17, 0x25, 0x6a,
2971                             0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38,
2972                             0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e,
2973                             0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e,
2974                             0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad,
2975                             0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8,
2976                             0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c,
2977                             0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d,
2978                             0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f,
2979                             0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2,
2980                             0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea,
2981                             0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68 },
2982                 .rlen   = 512,
2983         }
2984 };
2985
2986 static struct cipher_testvec aes_xts_dec_tv_template[] = {
2987         /* http://grouper.ieee.org/groups/1619/email/pdf00086.pdf */
2988         { /* XTS-AES 1 */
2989                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2990                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2991                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2992                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2993                 .klen   = 32,
2994                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2995                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2996                 .input = { 0x91, 0x7c, 0xf6, 0x9e, 0xbd, 0x68, 0xb2, 0xec,
2997                            0x9b, 0x9f, 0xe9, 0xa3, 0xea, 0xdd, 0xa6, 0x92,
2998                            0xcd, 0x43, 0xd2, 0xf5, 0x95, 0x98, 0xed, 0x85,
2999                            0x8c, 0x02, 0xc2, 0x65, 0x2f, 0xbf, 0x92, 0x2e },
3000                 .ilen   = 32,
3001                 .result  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3002                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3003                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3004                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3005                 .rlen   = 32,
3006         }, { /* XTS-AES 2 */
3007                 .key    = { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
3008                             0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
3009                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
3010                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
3011                 .klen   = 32,
3012                 .iv     = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
3013                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3014                 .input  = { 0xc4, 0x54, 0x18, 0x5e, 0x6a, 0x16, 0x93, 0x6e,
3015                             0x39, 0x33, 0x40, 0x38, 0xac, 0xef, 0x83, 0x8b,
3016                             0xfb, 0x18, 0x6f, 0xff, 0x74, 0x80, 0xad, 0xc4,
3017                             0x28, 0x93, 0x82, 0xec, 0xd6, 0xd3, 0x94, 0xf0 },
3018                 .ilen   = 32,
3019                 .result = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
3020                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
3021                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
3022                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
3023                 .rlen   = 32,
3024         }, { /* XTS-AES 3 */
3025                 .key    = { 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
3026                             0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0,
3027                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
3028                             0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 },
3029                 .klen   = 32,
3030                 .iv     = { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00,
3031                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3032                 .input = { 0xaf, 0x85, 0x33, 0x6b, 0x59, 0x7a, 0xfc, 0x1a,
3033                             0x90, 0x0b, 0x2e, 0xb2, 0x1e, 0xc9, 0x49, 0xd2,
3034                             0x92, 0xdf, 0x4c, 0x04, 0x7e, 0x0b, 0x21, 0x53,
3035                             0x21, 0x86, 0xa5, 0x97, 0x1a, 0x22, 0x7a, 0x89 },
3036                 .ilen   = 32,
3037                 .result  = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
3038                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
3039                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
3040                             0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 },
3041                 .rlen   = 32,
3042         }, { /* XTS-AES 4 */
3043                 .key    = { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
3044                             0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
3045                             0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
3046                             0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95 },
3047                 .klen   = 32,
3048                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3049                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3050                 .input  = { 0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76,
3051                             0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2,
3052                             0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25,
3053                             0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c,
3054                             0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f,
3055                             0x83, 0x33, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00,
3056                             0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad,
3057                             0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12,
3058                             0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5,
3059                             0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5,
3060                             0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc,
3061                             0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce,
3062                             0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4,
3063                             0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84,
3064                             0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a,
3065                             0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65,
3066                             0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89,
3067                             0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51,
3068                             0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15,
3069                             0x88, 0xed, 0xe8, 0x21, 0x03, 0xa2, 0x52, 0xd8,
3070                             0xa7, 0x50, 0xe8, 0x76, 0x8d, 0xef, 0xff, 0xed,
3071                             0x91, 0x22, 0x81, 0x0a, 0xae, 0xb9, 0x9f, 0x91,
3072                             0x72, 0xaf, 0x82, 0xb6, 0x04, 0xdc, 0x4b, 0x8e,
3073                             0x51, 0xbc, 0xb0, 0x82, 0x35, 0xa6, 0xf4, 0x34,
3074                             0x13, 0x32, 0xe4, 0xca, 0x60, 0x48, 0x2a, 0x4b,
3075                             0xa1, 0xa0, 0x3b, 0x3e, 0x65, 0x00, 0x8f, 0xc5,
3076                             0xda, 0x76, 0xb7, 0x0b, 0xf1, 0x69, 0x0d, 0xb4,
3077                             0xea, 0xe2, 0x9c, 0x5f, 0x1b, 0xad, 0xd0, 0x3c,
3078                             0x5c, 0xcf, 0x2a, 0x55, 0xd7, 0x05, 0xdd, 0xcd,
3079                             0x86, 0xd4, 0x49, 0x51, 0x1c, 0xeb, 0x7e, 0xc3,
3080                             0x0b, 0xf1, 0x2b, 0x1f, 0xa3, 0x5b, 0x91, 0x3f,
3081                             0x9f, 0x74, 0x7a, 0x8a, 0xfd, 0x1b, 0x13, 0x0e,
3082                             0x94, 0xbf, 0xf9, 0x4e, 0xff, 0xd0, 0x1a, 0x91,
3083                             0x73, 0x5c, 0xa1, 0x72, 0x6a, 0xcd, 0x0b, 0x19,
3084                             0x7c, 0x4e, 0x5b, 0x03, 0x39, 0x36, 0x97, 0xe1,
3085                             0x26, 0x82, 0x6f, 0xb6, 0xbb, 0xde, 0x8e, 0xcc,
3086                             0x1e, 0x08, 0x29, 0x85, 0x16, 0xe2, 0xc9, 0xed,
3087                             0x03, 0xff, 0x3c, 0x1b, 0x78, 0x60, 0xf6, 0xde,
3088                             0x76, 0xd4, 0xce, 0xcd, 0x94, 0xc8, 0x11, 0x98,
3089                             0x55, 0xef, 0x52, 0x97, 0xca, 0x67, 0xe9, 0xf3,
3090                             0xe7, 0xff, 0x72, 0xb1, 0xe9, 0x97, 0x85, 0xca,
3091                             0x0a, 0x7e, 0x77, 0x20, 0xc5, 0xb3, 0x6d, 0xc6,
3092                             0xd7, 0x2c, 0xac, 0x95, 0x74, 0xc8, 0xcb, 0xbc,
3093                             0x2f, 0x80, 0x1e, 0x23, 0xe5, 0x6f, 0xd3, 0x44,
3094                             0xb0, 0x7f, 0x22, 0x15, 0x4b, 0xeb, 0xa0, 0xf0,
3095                             0x8c, 0xe8, 0x89, 0x1e, 0x64, 0x3e, 0xd9, 0x95,
3096                             0xc9, 0x4d, 0x9a, 0x69, 0xc9, 0xf1, 0xb5, 0xf4,
3097                             0x99, 0x02, 0x7a, 0x78, 0x57, 0x2a, 0xee, 0xbd,
3098                             0x74, 0xd2, 0x0c, 0xc3, 0x98, 0x81, 0xc2, 0x13,
3099                             0xee, 0x77, 0x0b, 0x10, 0x10, 0xe4, 0xbe, 0xa7,
3100                             0x18, 0x84, 0x69, 0x77, 0xae, 0x11, 0x9f, 0x7a,
3101                             0x02, 0x3a, 0xb5, 0x8c, 0xca, 0x0a, 0xd7, 0x52,
3102                             0xaf, 0xe6, 0x56, 0xbb, 0x3c, 0x17, 0x25, 0x6a,
3103                             0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38,
3104                             0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e,
3105                             0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e,
3106                             0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad,
3107                             0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8,
3108                             0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c,
3109                             0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d,
3110                             0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f,
3111                             0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2,
3112                             0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea,
3113                             0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68 },
3114                 .ilen   = 512,
3115                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3116                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3117                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3118                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
3119                             0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
3120                             0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
3121                             0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
3122                             0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
3123                             0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
3124                             0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
3125                             0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
3126                             0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
3127                             0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
3128                             0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
3129                             0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
3130                             0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
3131                             0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
3132                             0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
3133                             0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
3134                             0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
3135                             0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
3136                             0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
3137                             0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
3138                             0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
3139                             0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
3140                             0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
3141                             0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
3142                             0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
3143                             0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
3144                             0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
3145                             0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
3146                             0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
3147                             0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3148                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3149                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3150                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
3151                             0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
3152                             0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
3153                             0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
3154                             0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
3155                             0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
3156                             0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
3157                             0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
3158                             0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
3159                             0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
3160                             0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
3161                             0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
3162                             0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
3163                             0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
3164                             0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
3165                             0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
3166                             0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
3167                             0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
3168                             0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
3169                             0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
3170                             0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
3171                             0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
3172                             0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
3173                             0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
3174                             0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
3175                             0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
3176                             0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
3177                             0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
3178                             0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
3179                 .rlen   = 512,
3180         }
3181 };
3182
3183 /* Cast5 test vectors from RFC 2144 */
3184 #define CAST5_ENC_TEST_VECTORS  3
3185 #define CAST5_DEC_TEST_VECTORS  3
3186
3187 static struct cipher_testvec cast5_enc_tv_template[] = {
3188         {
3189                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
3190                             0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
3191                 .klen   = 16,
3192                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3193                 .ilen   = 8,
3194                 .result = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
3195                 .rlen   = 8,
3196         }, {
3197                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
3198                             0x23, 0x45 },
3199                 .klen   = 10,
3200                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3201                 .ilen   = 8,
3202                 .result = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
3203                 .rlen   = 8,
3204         }, {
3205                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x12 },
3206                 .klen   = 5,
3207                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3208                 .ilen   = 8,
3209                 .result = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
3210                 .rlen   = 8,
3211         },
3212 };
3213
3214 static struct cipher_testvec cast5_dec_tv_template[] = {
3215         {
3216                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
3217                             0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
3218                 .klen   = 16,
3219                 .input  = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
3220                 .ilen   = 8,
3221                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3222                 .rlen   = 8,
3223         }, {
3224                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
3225                             0x23, 0x45 },
3226                 .klen   = 10,
3227                 .input  = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
3228                 .ilen   = 8,
3229                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3230                 .rlen   = 8,
3231         }, {
3232                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x12 },
3233                 .klen   = 5,
3234                 .input  = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
3235                 .ilen   = 8,
3236                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3237                 .rlen   = 8,
3238         },
3239 };
3240
3241 /*
3242  * ARC4 test vectors from OpenSSL
3243  */
3244 #define ARC4_ENC_TEST_VECTORS   7
3245 #define ARC4_DEC_TEST_VECTORS   7
3246
3247 static struct cipher_testvec arc4_enc_tv_template[] = {
3248         {
3249                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3250                 .klen   = 8,
3251                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3252                 .ilen   = 8,
3253                 .result = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
3254                 .rlen   = 8,
3255         }, {
3256                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3257                 .klen   = 8,
3258                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3259                 .ilen   = 8,
3260                 .result = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
3261                 .rlen   = 8,
3262         }, {
3263                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3264                 .klen   = 8,
3265                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3266                 .ilen   = 8,
3267                 .result = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
3268                 .rlen   = 8,
3269         }, {
3270                 .key    = { 0xef, 0x01, 0x23, 0x45},
3271                 .klen   = 4,
3272                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3273                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3274                             0x00, 0x00, 0x00, 0x00 },
3275                 .ilen   = 20,
3276                 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
3277                             0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
3278                             0x36, 0xb6, 0x78, 0x58 },
3279                 .rlen   = 20,
3280         }, {
3281                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3282                 .klen   = 8,
3283                 .input  = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
3284                             0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
3285                             0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
3286                             0x12, 0x34, 0x56, 0x78 },
3287                 .ilen   = 28,
3288                 .result = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
3289                             0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
3290                             0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
3291                             0x40, 0x01, 0x1e, 0xcf },
3292                 .rlen   = 28,
3293         }, {
3294                 .key    = { 0xef, 0x01, 0x23, 0x45 },
3295                 .klen   = 4,
3296                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3297                             0x00, 0x00 },
3298                 .ilen   = 10,
3299                 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
3300                             0xbd, 0x61 },
3301                 .rlen   = 10,
3302         }, {
3303                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
3304                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3305                 .klen   = 16,
3306                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
3307                 .ilen   = 8,
3308                 .result = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
3309                 .rlen   = 8,
3310         },
3311 };
3312
3313 static struct cipher_testvec arc4_dec_tv_template[] = {
3314         {
3315                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3316                 .klen   = 8,
3317                 .input  = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
3318                 .ilen   = 8,
3319                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3320                 .rlen   = 8,
3321         }, {
3322                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3323                 .klen   = 8,
3324                 .input  = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
3325                 .ilen   = 8,
3326                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3327                 .rlen   = 8,
3328         }, {
3329                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3330                 .klen   = 8,
3331                 .input  = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
3332                 .ilen   = 8,
3333                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3334                 .rlen   = 8,
3335         }, {
3336                 .key    = { 0xef, 0x01, 0x23, 0x45},
3337                 .klen   = 4,
3338                 .input  = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
3339                             0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
3340                             0x36, 0xb6, 0x78, 0x58 },
3341                 .ilen   = 20,
3342                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3343                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3344                             0x00, 0x00, 0x00, 0x00 },
3345                 .rlen   = 20,
3346         }, {
3347                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
3348                 .klen   = 8,
3349                 .input  = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
3350                             0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
3351                             0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
3352                             0x40, 0x01, 0x1e, 0xcf },
3353                 .ilen   = 28,
3354                 .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
3355                             0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
3356                             0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
3357                             0x12, 0x34, 0x56, 0x78 },
3358                 .rlen   = 28,
3359         }, {
3360                 .key    = { 0xef, 0x01, 0x23, 0x45 },
3361                 .klen   = 4,
3362                 .input  = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
3363                             0xbd, 0x61 },
3364                 .ilen   = 10,
3365                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3366                             0x00, 0x00 },
3367                 .rlen   = 10,
3368         }, {
3369                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
3370                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3371                 .klen   = 16,
3372                 .input  = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
3373                 .ilen   = 8,
3374                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
3375                 .rlen   = 8,
3376         },
3377 };
3378
3379 /*
3380  * TEA test vectors
3381  */
3382 #define TEA_ENC_TEST_VECTORS    4
3383 #define TEA_DEC_TEST_VECTORS    4
3384
3385 static struct cipher_testvec tea_enc_tv_template[] = {
3386         {
3387                 .key    = { [0 ... 15] = 0x00 },
3388                 .klen   = 16,
3389                 .input  = { [0 ... 8] = 0x00 },
3390                 .ilen   = 8,
3391                 .result = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
3392                 .rlen   = 8,
3393         }, {
3394                 .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
3395                             0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
3396                 .klen   = 16,
3397                 .input  = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
3398                 .ilen   = 8,
3399                 .result = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
3400                 .rlen   = 8,
3401         }, {
3402                 .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
3403                             0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
3404                 .klen   = 16,
3405                 .input  = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
3406                             0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
3407                 .ilen   = 16,
3408                 .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
3409                             0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
3410                 .rlen   = 16,
3411         }, {
3412                 .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
3413                             0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
3414                 .klen   = 16,
3415                 .input  = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
3416                             0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
3417                             0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
3418                             0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
3419                 .ilen   = 32,
3420                 .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
3421                             0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
3422                             0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
3423                             0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
3424                 .rlen   = 32,
3425         }
3426 };
3427
3428 static struct cipher_testvec tea_dec_tv_template[] = {
3429         {
3430                 .key    = { [0 ... 15] = 0x00 },
3431                 .klen   = 16,
3432                 .input  = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
3433                 .ilen   = 8,
3434                 .result = { [0 ... 8] = 0x00 },
3435                 .rlen   = 8,
3436         }, {
3437                 .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
3438                             0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
3439                 .klen   = 16,
3440                 .input  = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
3441                 .ilen   = 8,
3442                 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
3443                 .rlen   = 8,
3444         }, {
3445                 .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
3446                             0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
3447                 .klen   = 16,
3448                 .input  = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
3449                             0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
3450                 .ilen   = 16,
3451                 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
3452                             0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
3453                 .rlen   = 16,
3454         }, {
3455                 .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
3456                             0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
3457                 .klen   = 16,
3458                 .input  = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
3459                             0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
3460                             0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
3461                             0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
3462                 .ilen   = 32,
3463                 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
3464                             0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
3465                             0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
3466                             0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
3467                 .rlen   = 32,
3468         }
3469 };
3470
3471 /*
3472  * XTEA test vectors
3473  */
3474 #define XTEA_ENC_TEST_VECTORS   4
3475 #define XTEA_DEC_TEST_VECTORS   4
3476
3477 static struct cipher_testvec xtea_enc_tv_template[] = {
3478         {
3479                 .key    = { [0 ... 15] = 0x00 },
3480                 .klen   = 16,
3481                 .input  = { [0 ... 8] = 0x00 },
3482                 .ilen   = 8,
3483                 .result = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 },
3484                 .rlen   = 8,
3485         }, {
3486                 .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
3487                             0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
3488                 .klen   = 16,
3489                 .input  = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
3490                 .ilen   = 8,
3491                 .result = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 },
3492                 .rlen   = 8,
3493         }, {
3494                 .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
3495                             0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
3496                 .klen   = 16,
3497                 .input  = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d,
3498                             0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
3499                 .ilen   = 16,
3500                 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 
3501                             0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
3502                 .rlen   = 16,
3503         }, {
3504                 .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
3505                             0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
3506                 .klen   = 16,
3507                 .input  = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
3508                             0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
3509                             0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
3510                             0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
3511                 .ilen   = 32,
3512                 .result = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a,
3513                             0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07,
3514                             0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4,
3515                             0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 },
3516                 .rlen   = 32,
3517         }
3518 };
3519
3520 static struct cipher_testvec xtea_dec_tv_template[] = {
3521         {
3522                 .key    = { [0 ... 15] = 0x00 },
3523                 .klen   = 16,
3524                 .input  = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 },
3525                 .ilen   = 8,
3526                 .result = { [0 ... 8] = 0x00 },
3527                 .rlen   = 8,
3528         }, {
3529                 .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
3530                             0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
3531                 .klen   = 16,
3532                 .input  = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 },
3533                 .ilen   = 8,
3534                 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
3535                 .rlen   = 8,
3536         }, {
3537                 .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
3538                             0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
3539                 .klen   = 16,
3540                 .input  = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d,
3541                             0x77, 0x4d, 0xd4, 0xb4, 0x87, 0x24, 0xe3, 0x9a },
3542                 .ilen   = 16,
3543                 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 
3544                             0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
3545                 .rlen   = 16,
3546         }, {
3547                 .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
3548                             0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
3549                 .klen   = 16,
3550                 .input  = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a,
3551                             0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07,
3552                             0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4,
3553                             0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 },
3554                 .ilen   = 32,
3555                 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
3556                             0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
3557                             0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
3558                             0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
3559                 .rlen   = 32,
3560         }
3561 };
3562
3563 /*
3564  * KHAZAD test vectors.
3565  */
3566 #define KHAZAD_ENC_TEST_VECTORS 5
3567 #define KHAZAD_DEC_TEST_VECTORS 5
3568
3569 static struct cipher_testvec khazad_enc_tv_template[] = {
3570         {
3571                 .key    = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3572                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3573                 .klen   = 16,
3574                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3575                 .ilen   = 8,
3576                 .result = { 0x49, 0xa4, 0xce, 0x32, 0xac, 0x19, 0x0e, 0x3f },
3577                 .rlen   = 8,
3578         }, {
3579                 .key    = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
3580                             0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
3581                 .klen   = 16,
3582                 .input  = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
3583                 .ilen   = 8,
3584                 .result = { 0x7e, 0x82, 0x12, 0xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
3585                 .rlen   = 8,
3586         }, {
3587                 .key    = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
3588                             0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
3589                 .klen   = 16,
3590                 .input  = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
3591                 .ilen   = 8,
3592                 .result = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
3593                 .rlen   = 8,
3594         }, {
3595                 .key    = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
3596                             0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3597                 .klen   = 16,
3598                 .input  = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3599                 .ilen   = 8,
3600                 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
3601                 .rlen   = 8,
3602         }, {
3603                 .key    = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
3604                             0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3605                 .klen   = 16,
3606                 .input  = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
3607                             0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3608                 .ilen   = 16,
3609                 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
3610                             0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
3611                 .rlen   = 16,
3612         },
3613 };
3614
3615 static struct cipher_testvec khazad_dec_tv_template[] = {
3616         {
3617                 .key    = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3618                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3619                 .klen   = 16,
3620                 .input  = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f },
3621                 .ilen   = 8,
3622                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3623                 .rlen   = 8,
3624         }, {
3625                 .key    = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
3626                             0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
3627                 .klen   = 16,
3628                 .input  = { 0X7e, 0X82, 0X12, 0Xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
3629                 .ilen   = 8,
3630                 .result = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
3631                 .rlen   = 8,
3632         }, {
3633                 .key    = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
3634                             0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
3635                 .klen   = 16,
3636                 .input  = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
3637                 .ilen   = 8,
3638                 .result = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
3639                 .rlen   = 8,
3640         }, {
3641                 .key    = { 0x2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
3642                             0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3643                 .klen   = 16,
3644                 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
3645                 .ilen   = 8,
3646                 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3647                 .rlen   = 8,
3648         }, {
3649                 .key    = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
3650                             0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3651                 .klen   = 16,
3652                 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
3653                             0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
3654                 .ilen   = 16,
3655                 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
3656                             0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
3657                 .rlen   = 16,
3658         },
3659 };
3660
3661 /*
3662  * Anubis test vectors.
3663  */
3664
3665 #define ANUBIS_ENC_TEST_VECTORS                 5
3666 #define ANUBIS_DEC_TEST_VECTORS                 5
3667 #define ANUBIS_CBC_ENC_TEST_VECTORS             2
3668 #define ANUBIS_CBC_DEC_TEST_VECTORS             2
3669
3670 static struct cipher_testvec anubis_enc_tv_template[] = {
3671         {
3672                 .key    = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3673                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3674                 .klen   = 16,
3675                 .input  = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3676                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3677                 .ilen   = 16,
3678                 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
3679                             0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
3680                 .rlen   = 16,
3681         }, {
3682
3683                 .key    = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
3684                             0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
3685                             0x03, 0x03, 0x03, 0x03 },
3686                 .klen   = 20,
3687                 .input  = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
3688                             0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
3689                 .ilen   = 16,
3690                 .result = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
3691                             0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
3692                 .rlen   = 16,
3693         }, {
3694                 .key    = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3695                             0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3696                             0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3697                             0x24, 0x24, 0x24, 0x24 },
3698                 .klen   = 28,
3699                 .input  = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3700                             0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
3701                 .ilen   = 16,
3702                 .result = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
3703                             0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
3704                 .rlen   = 16,
3705         }, {
3706                 .key    = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3707                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3708                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3709                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
3710                 .klen   = 32,
3711                 .input  = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3712                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
3713                 .ilen   = 16,
3714                 .result = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
3715                             0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
3716                 .rlen   = 16,
3717         }, {
3718                 .key    = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3719                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3720                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3721                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3722                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3723                 .klen   = 40,
3724                 .input  = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3725                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3726                 .ilen   = 16,
3727                 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
3728                             0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
3729                 .rlen   = 16,
3730         },
3731 };
3732
3733 static struct cipher_testvec anubis_dec_tv_template[] = {
3734         {
3735                 .key    = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3736                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3737                 .klen   = 16,
3738                 .input  = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
3739                             0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
3740                 .ilen   = 16,
3741                 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3742                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3743                 .rlen   = 16,
3744         }, {
3745
3746                 .key    = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
3747                             0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
3748                             0x03, 0x03, 0x03, 0x03 },
3749                 .klen   = 20,
3750                 .input  = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
3751                             0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
3752                 .ilen   = 16,
3753                 .result = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
3754                             0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
3755                 .rlen   = 16,
3756         }, {
3757                 .key    = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3758                             0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3759                             0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3760                             0x24, 0x24, 0x24, 0x24 },
3761                 .klen   = 28,
3762                 .input  = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
3763                             0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
3764                 .ilen   = 16,
3765                 .result = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
3766                             0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
3767                 .rlen   = 16,
3768         }, {
3769                 .key    = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3770                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3771                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3772                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
3773                 .klen   = 32,
3774                 .input  = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
3775                             0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
3776                 .ilen   = 16,
3777                 .result = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
3778                             0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
3779                 .rlen   = 16,
3780         }, {
3781                 .key    = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3782                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3783                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3784                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3785                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3786                 .input = {  0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
3787                             0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
3788                 .klen   = 40,
3789                 .ilen   = 16,
3790                 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3791                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3792                 .rlen   = 16,
3793         },
3794 };
3795
3796 static struct cipher_testvec anubis_cbc_enc_tv_template[] = {
3797         {
3798                 .key    = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3799                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3800                 .klen   = 16,
3801                 .input  = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3802                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3803                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3804                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3805                 .ilen   = 32,
3806                 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
3807                             0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
3808                             0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
3809                             0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
3810                 .rlen   = 32,
3811         }, {
3812                 .key    = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3813                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3814                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3815                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3816                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3817                 .klen   = 40,
3818                 .input  = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3819                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3820                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3821                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3822                 .ilen   = 32,
3823                 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
3824                             0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
3825                             0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
3826                             0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
3827                 .rlen   = 32,
3828         },
3829 };
3830
3831 static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
3832         {
3833                 .key    = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3834                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3835                 .klen   = 16,
3836                 .input  = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
3837                             0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
3838                             0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
3839                             0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
3840                 .ilen   = 32,
3841                 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3842                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3843                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
3844                             0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
3845                 .rlen   = 32,
3846         }, {
3847                 .key    = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3848                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3849                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3850                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3851                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3852                 .klen   = 40,
3853                 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
3854                             0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
3855                             0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
3856                             0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
3857                 .ilen   = 32,
3858                 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3859                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3860                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
3861                             0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
3862                 .rlen   = 32,
3863         },
3864 };
3865
3866 /* 
3867  * XETA test vectors 
3868  */
3869 #define XETA_ENC_TEST_VECTORS   4
3870 #define XETA_DEC_TEST_VECTORS   4
3871
3872 static struct cipher_testvec xeta_enc_tv_template[] = {
3873         {
3874                 .key    = { [0 ... 15] = 0x00 },
3875                 .klen   = 16,
3876                 .input  = { [0 ... 8] = 0x00 },
3877                 .ilen   = 8,
3878                 .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
3879                 .rlen   = 8,
3880         }, {
3881                 .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
3882                             0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
3883                 .klen   = 16,
3884                 .input  = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
3885                 .ilen   = 8,
3886                 .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
3887                 .rlen   = 8,
3888         }, {
3889                 .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
3890                             0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
3891                 .klen   = 16,
3892                 .input  = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 
3893                             0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
3894                 .ilen   = 16,
3895                 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 
3896                             0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
3897                 .rlen   = 16,
3898         }, {
3899                 .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
3900                             0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
3901                 .klen   = 16,
3902                 .input  = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
3903                             0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
3904                             0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
3905                             0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
3906                 .ilen   = 32,
3907                 .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 
3908                             0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 
3909                             0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 
3910                             0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
3911                 .rlen   = 32,
3912         }
3913 };
3914
3915 static struct cipher_testvec xeta_dec_tv_template[] = {
3916         {
3917                 .key    = { [0 ... 15] = 0x00 },
3918                 .klen   = 16,
3919                 .input  = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
3920                 .ilen   = 8,
3921                 .result = { [0 ... 8] = 0x00 },
3922                 .rlen   = 8,
3923         }, {
3924                 .key    = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
3925                             0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
3926                 .klen   = 16,
3927                 .input  = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
3928                 .ilen   = 8,
3929                 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
3930                 .rlen   = 8,
3931         }, {
3932                 .key    = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
3933                             0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
3934                 .klen   = 16,
3935                 .input  = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 
3936                             0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
3937                 .ilen   = 16,
3938                 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 
3939                             0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
3940                 .rlen   = 16,
3941         }, {
3942                 .key    = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
3943                             0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
3944                 .klen   = 16,
3945                 .input  = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 
3946                             0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 
3947                             0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 
3948                             0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
3949                 .ilen   = 32,
3950                 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 
3951                             0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
3952                             0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 
3953                             0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
3954                 .rlen   = 32,
3955         }
3956 };
3957
3958 /* 
3959  * FCrypt test vectors 
3960  */
3961 #define FCRYPT_ENC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_enc_tv_template)
3962 #define FCRYPT_DEC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_dec_tv_template)
3963
3964 static struct cipher_testvec fcrypt_pcbc_enc_tv_template[] = {
3965         { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
3966                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3967                 .klen   = 8,
3968                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3969                 .input  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3970                 .ilen   = 8,
3971                 .result = { 0x0E, 0x09, 0x00, 0xC7, 0x3E, 0xF7, 0xED, 0x41 },
3972                 .rlen   = 8,
3973         }, {
3974                 .key    = { 0x11, 0x44, 0x77, 0xAA, 0xDD, 0x00, 0x33, 0x66 },
3975                 .klen   = 8,
3976                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3977                 .input  = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 },
3978                 .ilen   = 8,
3979                 .result = { 0xD8, 0xED, 0x78, 0x74, 0x77, 0xEC, 0x06, 0x80 },
3980                 .rlen   = 8,
3981         }, { /* From Arla */
3982                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3983                 .klen   = 8,
3984                 .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3985                 .input  = "The quick brown fox jumps over the lazy dogs.\0\0",
3986                 .ilen   = 48,
3987                 .result = { 0x00, 0xf0, 0xe,  0x11, 0x75, 0xe6, 0x23, 0x82,
3988                             0xee, 0xac, 0x98, 0x62, 0x44, 0x51, 0xe4, 0x84,
3989                             0xc3, 0x59, 0xd8, 0xaa, 0x64, 0x60, 0xae, 0xf7,
3990                             0xd2, 0xd9, 0x13, 0x79, 0x72, 0xa3, 0x45, 0x03,
3991                             0x23, 0xb5, 0x62, 0xd7, 0x0c, 0xf5, 0x27, 0xd1,
3992                             0xf8, 0x91, 0x3c, 0xac, 0x44, 0x22, 0x92, 0xef },
3993                 .rlen   = 48,
3994         }, {
3995                 .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3996                 .klen   = 8,
3997                 .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3998                 .input  = "The quick brown fox jumps over the lazy dogs.\0\0",
3999                 .ilen   = 48,
4000                 .result = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
4001                             0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
4002                             0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
4003                             0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
4004                             0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
4005                             0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
4006                 .rlen   = 48,
4007         }, { /* split-page version */
4008                 .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4009                 .klen   = 8,
4010                 .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
4011                 .input  = "The quick brown fox jumps over the lazy dogs.\0\0",
4012                 .ilen   = 48,
4013                 .result = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
4014                             0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
4015                             0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
4016                             0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
4017                             0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
4018                             0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
4019                 .rlen   = 48,
4020                 .np     = 2,
4021                 .tap    = { 20, 28 },
4022         }
4023 };
4024
4025 static struct cipher_testvec fcrypt_pcbc_dec_tv_template[] = {
4026         { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
4027                 .key    = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
4028                 .klen   = 8,
4029                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
4030                 .input  = { 0x0E, 0x09, 0x00, 0xC7, 0x3E, 0xF7, 0xED, 0x41 },
4031                 .ilen   = 8,
4032                 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
4033                 .rlen   = 8,
4034         }, {
4035                 .key    = { 0x11, 0x44, 0x77, 0xAA, 0xDD, 0x00, 0x33, 0x66 },
4036                 .klen   = 8,
4037                 .iv     = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
4038                 .input  = { 0xD8, 0xED, 0x78, 0x74, 0x77, 0xEC, 0x06, 0x80 },
4039                 .ilen   = 8,
4040                 .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 },
4041                 .rlen   = 8,
4042         }, { /* From Arla */
4043                 .key    = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
4044                 .klen   = 8,
4045                 .iv     = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4046                 .input  = { 0x00, 0xf0, 0xe,  0x11, 0x75, 0xe6, 0x23, 0x82,
4047                             0xee, 0xac, 0x98, 0x62, 0x44, 0x51, 0xe4, 0x84,
4048                             0xc3, 0x59, 0xd8, 0xaa, 0x64, 0x60, 0xae, 0xf7,
4049                             0xd2, 0xd9, 0x13, 0x79, 0x72, 0xa3, 0x45, 0x03,
4050                             0x23, 0xb5, 0x62, 0xd7, 0x0c, 0xf5, 0x27, 0xd1,
4051                             0xf8, 0x91, 0x3c, 0xac, 0x44, 0x22, 0x92, 0xef },
4052                 .ilen   = 48,
4053                 .result = "The quick brown fox jumps over the lazy dogs.\0\0",
4054                 .rlen   = 48,
4055         }, {
4056                 .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4057                 .klen   = 8,
4058                 .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
4059                 .input  = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
4060                             0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
4061                             0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
4062                             0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
4063                             0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
4064                             0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
4065                 .ilen   = 48,
4066                 .result = "The quick brown fox jumps over the lazy dogs.\0\0",
4067                 .rlen   = 48,
4068         }, { /* split-page version */
4069                 .key    = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4070                 .klen   = 8,
4071                 .iv     = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
4072                 .input  = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
4073                             0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
4074                             0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
4075                             0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
4076                             0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
4077                             0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
4078                 .ilen   = 48,
4079                 .result = "The quick brown fox jumps over the lazy dogs.\0\0",
4080                 .rlen   = 48,
4081                 .np     = 2,
4082                 .tap    = { 20, 28 },
4083         }
4084 };
4085
4086 /*
4087  * CAMELLIA test vectors.
4088  */
4089 #define CAMELLIA_ENC_TEST_VECTORS 3
4090 #define CAMELLIA_DEC_TEST_VECTORS 3
4091 #define CAMELLIA_CBC_ENC_TEST_VECTORS 2
4092 #define CAMELLIA_CBC_DEC_TEST_VECTORS 2
4093
4094 static struct cipher_testvec camellia_enc_tv_template[] = {
4095         {
4096                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4097                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4098                 .klen   = 16,
4099                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4100                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4101                 .ilen   = 16,
4102                 .result = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
4103                             0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
4104                 .rlen   = 16,
4105         }, {
4106                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4107                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
4108                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
4109                 .klen   = 24,
4110                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4111                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4112                 .ilen   = 16,
4113                 .result = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
4114                             0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
4115                 .rlen   = 16,
4116         }, {
4117                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4118                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
4119                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4120                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
4121                 .klen   = 32,
4122                 .input  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4123                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4124                 .ilen   = 16,
4125                 .result = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
4126                             0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
4127                 .rlen   = 16,
4128         },
4129 };
4130
4131 static struct cipher_testvec camellia_dec_tv_template[] = {
4132         {
4133                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4134                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4135                 .klen   = 16,
4136                 .input  = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
4137                             0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
4138                 .ilen   = 16,
4139                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4140                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4141                 .rlen   = 16,
4142         }, {
4143                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4144                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
4145                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
4146                 .klen   = 24,
4147                 .input  = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
4148                             0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
4149                 .ilen   = 16,
4150                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4151                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4152                 .rlen   = 16,
4153         }, {
4154                 .key    = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4155                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
4156                             0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4157                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
4158                 .klen   = 32,
4159                 .input  = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
4160                             0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
4161                 .ilen   = 16,
4162                 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
4163                             0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
4164                 .rlen   = 16,
4165         },
4166 };
4167
4168 static struct cipher_testvec camellia_cbc_enc_tv_template[] = {
4169         {
4170                 .key    = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
4171                             0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
4172                 .klen   = 16,
4173                 .iv     = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
4174                             0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
4175                 .input  = { "Single block msg" },
4176                 .ilen   = 16,
4177                 .result = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
4178                             0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
4179                 .rlen   = 16,
4180         }, {
4181                 .key    = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
4182                             0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
4183                 .klen   = 16,
4184                 .iv     = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
4185                             0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
4186                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4187                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
4188                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
4189                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
4190                 .ilen   = 32,
4191                 .result = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
4192                             0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
4193                             0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
4194                             0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
4195                 .rlen   = 32,
4196         },
4197 };
4198
4199 static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
4200         {
4201                 .key    = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
4202                             0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
4203                 .klen   = 16,
4204                 .iv     = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
4205                             0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
4206                 .input  = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
4207                             0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
4208                 .ilen   = 16,
4209                 .result = { "Single block msg" },
4210                 .rlen   = 16,
4211         }, {
4212                 .key    = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
4213                             0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
4214                 .klen   = 16,
4215                 .iv     = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
4216                             0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
4217                 .input = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
4218                             0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
4219                             0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
4220                             0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
4221                 .ilen   = 32,
4222                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4223                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
4224                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
4225                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
4226                 .rlen   = 32,
4227         },
4228 };
4229
4230 /*
4231  * SEED test vectors
4232  */
4233 #define SEED_ENC_TEST_VECTORS   4
4234 #define SEED_DEC_TEST_VECTORS   4
4235
4236 static struct cipher_testvec seed_enc_tv_template[] = {
4237         {
4238                 .key    = { [0 ... 15] = 0x00 },
4239                 .klen   = 16,
4240                 .input  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4241                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
4242                 .ilen   = 16,
4243                 .result = { 0x5e, 0xba, 0xc6, 0xe0, 0x05, 0x4e, 0x16, 0x68,
4244                             0x19, 0xaf, 0xf1, 0xcc, 0x6d, 0x34, 0x6c, 0xdb },
4245                 .rlen   = 16,
4246         }, {
4247                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4248                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
4249                 .klen   = 16,
4250                 .input  = { [0 ... 15] = 0x00 },
4251                 .ilen   = 16,
4252                 .result = { 0xc1, 0x1f, 0x22, 0xf2, 0x01, 0x40, 0x50, 0x50,
4253                             0x84, 0x48, 0x35, 0x97, 0xe4, 0x37, 0x0f, 0x43 },
4254                 .rlen   = 16,
4255         }, {
4256                 .key    = { 0x47, 0x06, 0x48, 0x08, 0x51, 0xe6, 0x1b, 0xe8,
4257                             0x5d, 0x74, 0xbf, 0xb3, 0xfd, 0x95, 0x61, 0x85 },
4258                 .klen   = 16,
4259                 .input  = { 0x83, 0xa2, 0xf8, 0xa2, 0x88, 0x64, 0x1f, 0xb9,
4260                             0xa4, 0xe9, 0xa5, 0xcc, 0x2f, 0x13, 0x1c, 0x7d },
4261                 .ilen   = 16,
4262                 .result = { 0xee, 0x54, 0xd1, 0x3e, 0xbc, 0xae, 0x70, 0x6d,
4263                             0x22, 0x6b, 0xc3, 0x14, 0x2c, 0xd4, 0x0d, 0x4a },
4264                 .rlen   = 16,
4265         }, {
4266                 .key    = { 0x28, 0xdb, 0xc3, 0xbc, 0x49, 0xff, 0xd8, 0x7d,
4267                             0xcf, 0xa5, 0x09, 0xb1, 0x1d, 0x42, 0x2b, 0xe7 },
4268                 .klen   = 16,
4269                 .input  = { 0xb4, 0x1e, 0x6b, 0xe2, 0xeb, 0xa8, 0x4a, 0x14,
4270                             0x8e, 0x2e, 0xed, 0x84, 0x59, 0x3c, 0x5e, 0xc7 },
4271                 .ilen   = 16,
4272                 .result = { 0x9b, 0x9b, 0x7b, 0xfc, 0xd1, 0x81, 0x3c, 0xb9,
4273                             0x5d, 0x0b, 0x36, 0x18, 0xf4, 0x0f, 0x51, 0x22 },
4274                 .rlen   = 16,
4275         }
4276 };
4277
4278 static struct cipher_testvec seed_dec_tv_template[] = {
4279         {
4280                 .key    = { [0 ... 15] = 0x00 },
4281                 .klen   = 16,
4282                 .input  = { 0x5e, 0xba, 0xc6, 0xe0, 0x05, 0x4e, 0x16, 0x68,
4283                             0x19, 0xaf, 0xf1, 0xcc, 0x6d, 0x34, 0x6c, 0xdb },
4284                 .ilen   = 16,
4285                 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4286                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
4287                 .rlen   = 16,
4288         }, {
4289                 .key    = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4290                             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
4291                 .klen   = 16,
4292                 .input  = { 0xc1, 0x1f, 0x22, 0xf2, 0x01, 0x40, 0x50, 0x50,
4293                             0x84, 0x48, 0x35, 0x97, 0xe4, 0x37, 0x0f, 0x43 },
4294                 .ilen   = 16,
4295                 .result = { [0 ... 15] = 0x00 },
4296                 .rlen   = 16,
4297         }, {
4298                 .key    = { 0x47, 0x06, 0x48, 0x08, 0x51, 0xe6, 0x1b, 0xe8,
4299                             0x5d, 0x74, 0xbf, 0xb3, 0xfd, 0x95, 0x61, 0x85 },
4300                 .klen   = 16,
4301                 .input  = { 0xee, 0x54, 0xd1, 0x3e, 0xbc, 0xae, 0x70, 0x6d,
4302                             0x22, 0x6b, 0xc3, 0x14, 0x2c, 0xd4, 0x0d, 0x4a },
4303                 .ilen   = 16,
4304                 .result = { 0x83, 0xa2, 0xf8, 0xa2, 0x88, 0x64, 0x1f, 0xb9,
4305                             0xa4, 0xe9, 0xa5, 0xcc, 0x2f, 0x13, 0x1c, 0x7d },
4306                 .rlen   = 16,
4307         }, {
4308                 .key    = { 0x28, 0xdb, 0xc3, 0xbc, 0x49, 0xff, 0xd8, 0x7d,
4309                             0xcf, 0xa5, 0x09, 0xb1, 0x1d, 0x42, 0x2b, 0xe7 },
4310                 .klen   = 16,
4311                 .input  = { 0x9b, 0x9b, 0x7b, 0xfc, 0xd1, 0x81, 0x3c, 0xb9,
4312                             0x5d, 0x0b, 0x36, 0x18, 0xf4, 0x0f, 0x51, 0x22 },
4313                 .ilen   = 16,
4314                 .result = { 0xb4, 0x1e, 0x6b, 0xe2, 0xeb, 0xa8, 0x4a, 0x14,
4315                             0x8e, 0x2e, 0xed, 0x84, 0x59, 0x3c, 0x5e, 0xc7 },
4316                 .rlen   = 16,
4317         }
4318 };
4319
4320 /*
4321  * Compression stuff.
4322  */
4323 #define COMP_BUF_SIZE           512
4324
4325 struct comp_testvec {
4326         int inlen, outlen;
4327         char input[COMP_BUF_SIZE];
4328         char output[COMP_BUF_SIZE];
4329 };
4330
4331 /*
4332  * Deflate test vectors (null-terminated strings).
4333  * Params: winbits=11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
4334  */
4335 #define DEFLATE_COMP_TEST_VECTORS 2
4336 #define DEFLATE_DECOMP_TEST_VECTORS 2
4337
4338 static struct comp_testvec deflate_comp_tv_template[] = {
4339         {
4340                 .inlen  = 70,
4341                 .outlen = 38,
4342                 .input  = "Join us now and share the software "
4343                           "Join us now and share the software ",
4344                 .output = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
4345                             0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
4346                             0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
4347                             0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
4348                             0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
4349         }, {
4350                 .inlen  = 191,
4351                 .outlen = 122,
4352                 .input  = "This document describes a compression method based on the DEFLATE"
4353                           "compression algorithm.  This document defines the application of "
4354                           "the DEFLATE algorithm to the IP Payload Compression Protocol.",
4355                 .output = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
4356                             0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
4357                             0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
4358                             0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
4359                             0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
4360                             0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
4361                             0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
4362                             0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
4363                             0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
4364                             0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
4365                             0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
4366                             0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
4367                             0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
4368                             0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
4369                             0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
4370                             0xfa, 0x02 },
4371         },
4372 };
4373
4374 static struct comp_testvec deflate_decomp_tv_template[] = {
4375         {
4376                 .inlen  = 122,
4377                 .outlen = 191,
4378                 .input  = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
4379                             0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
4380                             0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
4381                             0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
4382                             0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
4383                             0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
4384                             0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
4385                             0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
4386                             0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
4387                             0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
4388                             0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
4389                             0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
4390                             0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
4391                             0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
4392                             0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
4393                             0xfa, 0x02 },
4394                 .output = "This document describes a compression method based on the DEFLATE"
4395                           "compression algorithm.  This document defines the application of "
4396                           "the DEFLATE algorithm to the IP Payload Compression Protocol.",
4397         }, {
4398                 .inlen  = 38,
4399                 .outlen = 70,
4400                 .input  = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
4401                             0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
4402                             0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
4403                             0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
4404                             0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
4405                 .output = "Join us now and share the software "
4406                           "Join us now and share the software ",
4407         },
4408 };
4409
4410 /*
4411  * Michael MIC test vectors from IEEE 802.11i
4412  */
4413 #define MICHAEL_MIC_TEST_VECTORS 6
4414
4415 static struct hash_testvec michael_mic_tv_template[] = {
4416         {
4417                 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
4418                 .ksize = 8,
4419                 .plaintext = { },
4420                 .psize = 0,
4421                 .digest = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 }
4422         },
4423         {
4424                 .key = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 },
4425                 .ksize = 8,
4426                 .plaintext = { 'M' },
4427                 .psize = 1,
4428                 .digest = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f }
4429         },
4430         {
4431                 .key = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f },
4432                 .ksize = 8,
4433                 .plaintext = { 'M', 'i' },
4434                 .psize = 2,
4435                 .digest = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 }
4436         },
4437         {
4438                 .key = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 },
4439                 .ksize = 8,
4440                 .plaintext = { 'M', 'i', 'c' },
4441                 .psize = 3,
4442                 .digest = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb }
4443         },
4444         {
4445                 .key = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb },
4446                 .ksize = 8,
4447                 .plaintext = { 'M', 'i', 'c', 'h' },
4448                 .psize = 4,
4449                 .digest = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 }
4450         },
4451         {
4452                 .key = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 },
4453                 .ksize = 8,
4454                 .plaintext = { 'M', 'i', 'c', 'h', 'a', 'e', 'l' },
4455                 .psize = 7,
4456                 .digest = { 0x0a, 0x94, 0x2b, 0x12, 0x4e, 0xca, 0xa5, 0x46 },
4457         }
4458 };
4459
4460 /*
4461  * CRC32C test vectors
4462  */
4463 #define CRC32C_TEST_VECTORS 14
4464
4465 static struct hash_testvec crc32c_tv_template[] = {
4466         {
4467                 .psize = 0,
4468                 .digest = { 0x00, 0x00, 0x00, 0x00 }
4469         },
4470         {
4471                 .key = { 0x87, 0xa9, 0xcb, 0xed },
4472                 .ksize = 4,
4473                 .psize = 0,
4474                 .digest = { 0x78, 0x56, 0x34, 0x12 },
4475         },
4476         {
4477                 .key = { 0xff, 0xff, 0xff, 0xff },
4478                 .ksize = 4,
4479                 .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
4480                                0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
4481                                0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
4482                                0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
4483                                0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28 },
4484                 .psize = 40,
4485                 .digest = { 0x7f, 0x15, 0x2c, 0x0e }
4486         },
4487         {
4488                 .key = { 0xff, 0xff, 0xff, 0xff },
4489                 .ksize = 4,
4490                 .plaintext = { 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
4491                                0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
4492                                0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
4493                                0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
4494                                0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50 },
4495                 .psize = 40,
4496                 .digest = { 0xf6, 0xeb, 0x80, 0xe9 }
4497         },
4498         {
4499                 .key = { 0xff, 0xff, 0xff, 0xff },
4500                 .ksize = 4,
4501                 .plaintext = { 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
4502                                0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
4503                                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
4504                                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
4505                                0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78 },
4506                 .psize = 40,
4507                 .digest = { 0xed, 0xbd, 0x74, 0xde }
4508         },
4509         {
4510                 .key = { 0xff, 0xff, 0xff, 0xff },
4511                 .ksize = 4,
4512                 .plaintext = { 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
4513                                0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
4514                                0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
4515                                0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
4516                                0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0 },
4517                 .psize = 40,
4518                 .digest = { 0x62, 0xc8, 0x79, 0xd5 }
4519         },
4520         {
4521                 .key = { 0xff, 0xff, 0xff, 0xff },
4522                 .ksize = 4,
4523                 .plaintext = { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
4524                                0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
4525                                0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
4526                                0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
4527                                0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8 },
4528                 .psize = 40,
4529                 .digest = { 0xd0, 0x9a, 0x97, 0xba }
4530         },
4531         {
4532                 .key = { 0xff, 0xff, 0xff, 0xff },
4533                 .ksize = 4,
4534                 .plaintext = { 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
4535                                0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
4536                                0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
4537                                0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
4538                                0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0 },
4539                 .psize = 40,
4540                 .digest = { 0x13, 0xd9, 0x29, 0x2b }
4541         },
4542         {
4543                 .key = { 0x80, 0xea, 0xd3, 0xf1 },
4544                 .ksize = 4,
4545                 .plaintext = { 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
4546                                0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
4547                                0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
4548                                0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
4549                                0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50 },
4550                 .psize = 40,
4551                 .digest = { 0x0c, 0xb5, 0xe2, 0xa2 }
4552         },
4553         {
4554                 .key = { 0xf3, 0x4a, 0x1d, 0x5d },
4555                 .ksize = 4,
4556                 .plaintext = { 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
4557                                0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
4558                                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
4559                                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
4560                                0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78 },
4561                 .psize = 40,
4562                 .digest = { 0xd1, 0x7f, 0xfb, 0xa6 }
4563         },
4564         {
4565                 .key = { 0x2e, 0x80, 0x04, 0x59 },
4566                 .ksize = 4,
4567                 .plaintext = { 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
4568                                0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
4569                                0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
4570                                0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
4571                                0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0 },
4572                 .psize = 40,
4573                 .digest = { 0x59, 0x33, 0xe6, 0x7a }
4574         },
4575         {
4576                 .key = { 0xa6, 0xcc, 0x19, 0x85 },
4577                 .ksize = 4,
4578                 .plaintext = { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
4579                                0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
4580                                0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
4581                                0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
4582                                0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8 },
4583                 .psize = 40,
4584                 .digest = { 0xbe, 0x03, 0x01, 0xd2 }
4585         },
4586         {
4587                 .key = { 0x41, 0xfc, 0xfe, 0x2d },
4588                 .ksize = 4,
4589                 .plaintext = { 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
4590                                0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
4591                                0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
4592                                0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
4593                                0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0 },
4594                 .psize = 40,
4595                 .digest = { 0x75, 0xd3, 0xc5, 0x24 }
4596         },
4597         {
4598                 .key = { 0xff, 0xff, 0xff, 0xff },
4599                 .ksize = 4,
4600                 .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
4601                                0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
4602                                0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
4603                                0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
4604                                0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
4605                                0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
4606                                0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
4607                                0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
4608                                0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
4609                                0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
4610                                0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
4611                                0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
4612                                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
4613                                0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
4614                                0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
4615                                0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
4616                                0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
4617                                0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
4618                                0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
4619                                0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0,
4620                                0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
4621                                0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
4622                                0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
4623                                0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
4624                                0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
4625                                0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
4626                                0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
4627                                0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
4628                                0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
4629                                0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0 },
4630                 .psize = 240,
4631                 .digest = { 0x75, 0xd3, 0xc5, 0x24 },
4632                 .np = 2,
4633                 .tap = { 31, 209 }
4634         },
4635 };
4636
4637 /*
4638  * Cipher speed tests
4639  */
4640 static struct cipher_speed aes_speed_template[] = {
4641         { .klen = 16, .blen = 16, },
4642         { .klen = 16, .blen = 64, },
4643         { .klen = 16, .blen = 256, },
4644         { .klen = 16, .blen = 1024, },
4645         { .klen = 16, .blen = 8192, },
4646         { .klen = 24, .blen = 16, },
4647         { .klen = 24, .blen = 64, },
4648         { .klen = 24, .blen = 256, },
4649         { .klen = 24, .blen = 1024, },
4650         { .klen = 24, .blen = 8192, },
4651         { .klen = 32, .blen = 16, },
4652         { .klen = 32, .blen = 64, },
4653         { .klen = 32, .blen = 256, },
4654         { .klen = 32, .blen = 1024, },
4655         { .klen = 32, .blen = 8192, },
4656
4657         /* End marker */
4658         {  .klen = 0, .blen = 0, }
4659 };
4660
4661 static struct cipher_speed aes_lrw_speed_template[] = {
4662         { .klen = 32, .blen = 16, },
4663         { .klen = 32, .blen = 64, },
4664         { .klen = 32, .blen = 256, },
4665         { .klen = 32, .blen = 1024, },
4666         { .klen = 32, .blen = 8192, },
4667         { .klen = 40, .blen = 16, },
4668         { .klen = 40, .blen = 64, },
4669         { .klen = 40, .blen = 256, },
4670         { .klen = 40, .blen = 1024, },
4671         { .klen = 40, .blen = 8192, },
4672         { .klen = 48, .blen = 16, },
4673         { .klen = 48, .blen = 64, },
4674         { .klen = 48, .blen = 256, },
4675         { .klen = 48, .blen = 1024, },
4676         { .klen = 48, .blen = 8192, },
4677
4678         /* End marker */
4679         {  .klen = 0, .blen = 0, }
4680 };
4681
4682 static struct cipher_speed aes_xts_speed_template[] = {
4683         { .klen = 32, .blen = 16, },
4684         { .klen = 32, .blen = 64, },
4685         { .klen = 32, .blen = 256, },
4686         { .klen = 32, .blen = 1024, },
4687         { .klen = 32, .blen = 8192, },
4688         { .klen = 48, .blen = 16, },
4689         { .klen = 48, .blen = 64, },
4690         { .klen = 48, .blen = 256, },
4691         { .klen = 48, .blen = 1024, },
4692         { .klen = 48, .blen = 8192, },
4693         { .klen = 64, .blen = 16, },
4694         { .klen = 64, .blen = 64, },
4695         { .klen = 64, .blen = 256, },
4696         { .klen = 64, .blen = 1024, },
4697         { .klen = 64, .blen = 8192, },
4698
4699         /* End marker */
4700         {  .klen = 0, .blen = 0, }
4701 };
4702
4703 static struct cipher_speed des3_ede_speed_template[] = {
4704         { .klen = 24, .blen = 16, },
4705         { .klen = 24, .blen = 64, },
4706         { .klen = 24, .blen = 256, },
4707         { .klen = 24, .blen = 1024, },
4708         { .klen = 24, .blen = 8192, },
4709
4710         /* End marker */
4711         {  .klen = 0, .blen = 0, }
4712 };
4713
4714 static struct cipher_speed twofish_speed_template[] = {
4715         { .klen = 16, .blen = 16, },
4716         { .klen = 16, .blen = 64, },
4717         { .klen = 16, .blen = 256, },
4718         { .klen = 16, .blen = 1024, },
4719         { .klen = 16, .blen = 8192, },
4720         { .klen = 24, .blen = 16, },
4721         { .klen = 24, .blen = 64, },
4722         { .klen = 24, .blen = 256, },
4723         { .klen = 24, .blen = 1024, },
4724         { .klen = 24, .blen = 8192, },
4725         { .klen = 32, .blen = 16, },
4726         { .klen = 32, .blen = 64, },
4727         { .klen = 32, .blen = 256, },
4728         { .klen = 32, .blen = 1024, },
4729         { .klen = 32, .blen = 8192, },
4730
4731         /* End marker */
4732         {  .klen = 0, .blen = 0, }
4733 };
4734
4735 static struct cipher_speed blowfish_speed_template[] = {
4736         /* Don't support blowfish keys > 256 bit in this test */
4737         { .klen = 8, .blen = 16, },
4738         { .klen = 8, .blen = 64, },
4739         { .klen = 8, .blen = 256, },
4740         { .klen = 8, .blen = 1024, },
4741         { .klen = 8, .blen = 8192, },
4742         { .klen = 32, .blen = 16, },
4743         { .klen = 32, .blen = 64, },
4744         { .klen = 32, .blen = 256, },
4745         { .klen = 32, .blen = 1024, },
4746         { .klen = 32, .blen = 8192, },
4747
4748         /* End marker */
4749         {  .klen = 0, .blen = 0, }
4750 };
4751
4752 static struct cipher_speed des_speed_template[] = {
4753         { .klen = 8, .blen = 16, },
4754         { .klen = 8, .blen = 64, },
4755         { .klen = 8, .blen = 256, },
4756         { .klen = 8, .blen = 1024, },
4757         { .klen = 8, .blen = 8192, },
4758
4759         /* End marker */
4760         {  .klen = 0, .blen = 0, }
4761 };
4762
4763 /*
4764  * Digest speed tests
4765  */
4766 static struct hash_speed generic_hash_speed_template[] = {
4767         { .blen = 16,   .plen = 16, },
4768         { .blen = 64,   .plen = 16, },
4769         { .blen = 64,   .plen = 64, },
4770         { .blen = 256,  .plen = 16, },
4771         { .blen = 256,  .plen = 64, },
4772         { .blen = 256,  .plen = 256, },
4773         { .blen = 1024, .plen = 16, },
4774         { .blen = 1024, .plen = 256, },
4775         { .blen = 1024, .plen = 1024, },
4776         { .blen = 2048, .plen = 16, },
4777         { .blen = 2048, .plen = 256, },
4778         { .blen = 2048, .plen = 1024, },
4779         { .blen = 2048, .plen = 2048, },
4780         { .blen = 4096, .plen = 16, },
4781         { .blen = 4096, .plen = 256, },
4782         { .blen = 4096, .plen = 1024, },
4783         { .blen = 4096, .plen = 4096, },
4784         { .blen = 8192, .plen = 16, },
4785         { .blen = 8192, .plen = 256, },
4786         { .blen = 8192, .plen = 1024, },
4787         { .blen = 8192, .plen = 4096, },
4788         { .blen = 8192, .plen = 8192, },
4789
4790         /* End marker */
4791         {  .blen = 0,   .plen = 0, }
4792 };
4793
4794 static struct cipher_speed camellia_speed_template[] = {
4795       { .klen = 16, .blen = 16, },
4796       { .klen = 16, .blen = 64, },
4797       { .klen = 16, .blen = 256, },
4798       { .klen = 16, .blen = 1024, },
4799       { .klen = 16, .blen = 8192, },
4800       { .klen = 24, .blen = 16, },
4801       { .klen = 24, .blen = 64, },
4802       { .klen = 24, .blen = 256, },
4803       { .klen = 24, .blen = 1024, },
4804       { .klen = 24, .blen = 8192, },
4805       { .klen = 32, .blen = 16, },
4806       { .klen = 32, .blen = 64, },
4807       { .klen = 32, .blen = 256, },
4808       { .klen = 32, .blen = 1024, },
4809       { .klen = 32, .blen = 8192, },
4810
4811       /* End marker */
4812       {  .klen = 0, .blen = 0, }
4813 };
4814
4815 #endif  /* _CRYPTO_TCRYPT_H */