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