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