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