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