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