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