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     7
2448 #define BF_DEC_TEST_VECTORS     7
2449 #define BF_CBC_ENC_TEST_VECTORS 2
2450 #define BF_CBC_DEC_TEST_VECTORS 2
2451 #define BF_CTR_ENC_TEST_VECTORS 2
2452 #define BF_CTR_DEC_TEST_VECTORS 2
2453
2454 static struct cipher_testvec bf_enc_tv_template[] = {
2455         { /* DES test vectors from OpenSSL */
2456                 .key    = "\x00\x00\x00\x00\x00\x00\x00\x00",
2457                 .klen   = 8,
2458                 .input  = "\x00\x00\x00\x00\x00\x00\x00\x00",
2459                 .ilen   = 8,
2460                 .result = "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
2461                 .rlen   = 8,
2462         }, {
2463                 .key    = "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
2464                 .klen   = 8,
2465                 .input  = "\x01\x23\x45\x67\x89\xab\xcd\xef",
2466                 .ilen   = 8,
2467                 .result = "\xa7\x90\x79\x51\x08\xea\x3c\xae",
2468                 .rlen   = 8,
2469         }, {
2470                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
2471                 .klen   = 8,
2472                 .input  = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2473                 .ilen   = 8,
2474                 .result = "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
2475                 .rlen   = 8,
2476         }, { /* Vary the keylength... */
2477                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
2478                           "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
2479                 .klen   = 16,
2480                 .input  = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2481                 .ilen   = 8,
2482                 .result = "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
2483                 .rlen   = 8,
2484         }, {
2485                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
2486                           "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
2487                           "\x00\x11\x22\x33\x44",
2488                 .klen   = 21,
2489                 .input  = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2490                 .ilen   = 8,
2491                 .result = "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
2492                 .rlen   = 8,
2493         }, { /* Generated with bf488 */
2494                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
2495                           "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
2496                           "\x00\x11\x22\x33\x44\x55\x66\x77"
2497                           "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
2498                           "\x58\x40\x23\x64\x1a\xba\x61\x76"
2499                           "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
2500                           "\xff\xff\xff\xff\xff\xff\xff\xff",
2501                 .klen   = 56,
2502                 .input  = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2503                 .ilen   = 8,
2504                 .result = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
2505                 .rlen   = 8,
2506         }, { /* Generated with Crypto++ */
2507                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2508                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2509                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2510                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2511                 .klen   = 32,
2512                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2513                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2514                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2515                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2516                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
2517                 .ilen   = 40,
2518                 .result = "\x96\x87\x3D\x0C\x7B\xFB\xBD\x1F"
2519                           "\xE3\xC1\x99\x6D\x39\xD4\xC2\x7D"
2520                           "\xD7\x87\xA1\xF2\xDF\x51\x71\x26"
2521                           "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40"
2522                           "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B",
2523                 .rlen   = 40,
2524         },
2525 };
2526
2527 static struct cipher_testvec bf_dec_tv_template[] = {
2528         { /* DES test vectors from OpenSSL */
2529                 .key    = "\x00\x00\x00\x00\x00\x00\x00\x00",
2530                 .klen   = 8,
2531                 .input  = "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
2532                 .ilen   = 8,
2533                 .result = "\x00\x00\x00\x00\x00\x00\x00\x00",
2534                 .rlen   = 8,
2535         }, {
2536                 .key    = "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
2537                 .klen   = 8,
2538                 .input  = "\xa7\x90\x79\x51\x08\xea\x3c\xae",
2539                 .ilen   = 8,
2540                 .result = "\x01\x23\x45\x67\x89\xab\xcd\xef",
2541                 .rlen   = 8,
2542         }, {
2543                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
2544                 .klen   = 8,
2545                 .input  = "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
2546                 .ilen   = 8,
2547                 .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2548                 .rlen   = 8,
2549         }, { /* Vary the keylength... */
2550                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
2551                           "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
2552                 .klen   = 16,
2553                 .input  = "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
2554                 .ilen   = 8,
2555                 .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2556                 .rlen   = 8,
2557         }, {
2558                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
2559                           "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
2560                           "\x00\x11\x22\x33\x44",
2561                 .klen   = 21,
2562                 .input  = "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
2563                 .ilen   = 8,
2564                 .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2565                 .rlen   = 8,
2566         }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
2567                 .key    = "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
2568                           "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
2569                           "\x00\x11\x22\x33\x44\x55\x66\x77"
2570                           "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
2571                           "\x58\x40\x23\x64\x1a\xba\x61\x76"
2572                           "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
2573                           "\xff\xff\xff\xff\xff\xff\xff\xff",
2574                 .klen   = 56,
2575                 .input  = "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
2576                 .ilen   = 8,
2577                 .result = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2578                 .rlen   = 8,
2579         }, { /* Generated with Crypto++ */
2580                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2581                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2582                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2583                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2584                 .klen   = 32,
2585                 .input  = "\x96\x87\x3D\x0C\x7B\xFB\xBD\x1F"
2586                           "\xE3\xC1\x99\x6D\x39\xD4\xC2\x7D"
2587                           "\xD7\x87\xA1\xF2\xDF\x51\x71\x26"
2588                           "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40"
2589                           "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B",
2590                 .ilen   = 40,
2591                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2592                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2593                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2594                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2595                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
2596                 .rlen   = 40,
2597         },
2598 };
2599
2600 static struct cipher_testvec bf_cbc_enc_tv_template[] = {
2601         { /* From OpenSSL */
2602                 .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
2603                           "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
2604                 .klen   = 16,
2605                 .iv     = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2606                 .input  = "\x37\x36\x35\x34\x33\x32\x31\x20"
2607                           "\x4e\x6f\x77\x20\x69\x73\x20\x74"
2608                           "\x68\x65\x20\x74\x69\x6d\x65\x20"
2609                           "\x66\x6f\x72\x20\x00\x00\x00\x00",
2610                 .ilen   = 32,
2611                 .result = "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
2612                           "\x05\xb1\x56\xe2\x74\x03\x97\x93"
2613                           "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
2614                           "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
2615                 .rlen   = 32,
2616         }, { /* Generated with Crypto++ */
2617                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2618                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2619                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2620                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2621                 .klen   = 32,
2622                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
2623                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2624                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2625                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2626                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2627                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
2628                 .ilen   = 40,
2629                 .result = "\xB4\xFE\xA5\xBB\x3D\x2C\x27\x06"
2630                           "\x06\x2B\x3A\x92\xB2\xF5\x5E\x62"
2631                           "\x84\xCD\xF7\x66\x7E\x41\x6C\x8E"
2632                           "\x1B\xD9\x02\xB6\x48\xB0\x87\x25"
2633                           "\x01\x9C\x93\x63\x51\x60\x82\xD2",
2634                 .rlen   = 40,
2635         },
2636 };
2637
2638 static struct cipher_testvec bf_cbc_dec_tv_template[] = {
2639         { /* From OpenSSL */
2640                 .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
2641                           "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
2642                 .klen   = 16,
2643                 .iv     = "\xfe\xdc\xba\x98\x76\x54\x32\x10",
2644                 .input  = "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
2645                           "\x05\xb1\x56\xe2\x74\x03\x97\x93"
2646                           "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
2647                           "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
2648                 .ilen   = 32,
2649                 .result = "\x37\x36\x35\x34\x33\x32\x31\x20"
2650                           "\x4e\x6f\x77\x20\x69\x73\x20\x74"
2651                           "\x68\x65\x20\x74\x69\x6d\x65\x20"
2652                           "\x66\x6f\x72\x20\x00\x00\x00\x00",
2653                 .rlen   = 32,
2654         }, { /* Generated with Crypto++ */
2655                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2656                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2657                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2658                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2659                 .klen   = 32,
2660                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
2661                 .input  = "\xB4\xFE\xA5\xBB\x3D\x2C\x27\x06"
2662                           "\x06\x2B\x3A\x92\xB2\xF5\x5E\x62"
2663                           "\x84\xCD\xF7\x66\x7E\x41\x6C\x8E"
2664                           "\x1B\xD9\x02\xB6\x48\xB0\x87\x25"
2665                           "\x01\x9C\x93\x63\x51\x60\x82\xD2",
2666                 .ilen   = 40,
2667                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2668                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2669                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2670                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2671                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
2672                 .rlen   = 40,
2673         },
2674 };
2675
2676 static struct cipher_testvec bf_ctr_enc_tv_template[] = {
2677         { /* Generated with Crypto++ */
2678                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2679                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2680                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2681                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2682                 .klen   = 32,
2683                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
2684                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2685                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2686                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2687                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2688                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
2689                 .ilen   = 40,
2690                 .result = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
2691                           "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
2692                           "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
2693                           "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
2694                           "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC",
2695                 .rlen   = 40,
2696         }, { /* Generated with Crypto++ */
2697                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2698                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2699                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2700                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2701                 .klen   = 32,
2702                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
2703                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2704                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2705                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2706                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2707                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2708                           "\x6D\x04\x9B",
2709                 .ilen   = 43,
2710                 .result = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
2711                           "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
2712                           "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
2713                           "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
2714                           "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC"
2715                           "\x3D\xA7\xE9",
2716                 .rlen   = 43,
2717         },
2718 };
2719
2720 static struct cipher_testvec bf_ctr_dec_tv_template[] = {
2721         { /* Generated with Crypto++ */
2722                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2723                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2724                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2725                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2726                 .klen   = 32,
2727                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
2728                 .input  = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
2729                           "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
2730                           "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
2731                           "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
2732                           "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC",
2733                 .ilen   = 40,
2734                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2735                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2736                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2737                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2738                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
2739                 .rlen   = 40,
2740         }, { /* Generated with Crypto++ */
2741                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2742                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2743                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2744                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2745                 .klen   = 32,
2746                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
2747                 .input  = "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
2748                           "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
2749                           "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
2750                           "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
2751                           "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC"
2752                           "\x3D\xA7\xE9",
2753                 .ilen   = 43,
2754                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2755                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2756                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2757                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2758                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2759                           "\x6D\x04\x9B",
2760                 .rlen   = 43,
2761         },
2762 };
2763
2764 /*
2765  * Twofish test vectors.
2766  */
2767 #define TF_ENC_TEST_VECTORS             4
2768 #define TF_DEC_TEST_VECTORS             4
2769 #define TF_CBC_ENC_TEST_VECTORS         5
2770 #define TF_CBC_DEC_TEST_VECTORS         5
2771 #define TF_CTR_ENC_TEST_VECTORS         2
2772 #define TF_CTR_DEC_TEST_VECTORS         2
2773 #define TF_LRW_ENC_TEST_VECTORS         8
2774 #define TF_LRW_DEC_TEST_VECTORS         8
2775 #define TF_XTS_ENC_TEST_VECTORS         5
2776 #define TF_XTS_DEC_TEST_VECTORS         5
2777
2778 static struct cipher_testvec tf_enc_tv_template[] = {
2779         {
2780                 .key    = zeroed_string,
2781                 .klen   = 16,
2782                 .input  = zeroed_string,
2783                 .ilen   = 16,
2784                 .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2785                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
2786                 .rlen   = 16,
2787         }, {
2788                 .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
2789                           "\xfe\xdc\xba\x98\x76\x54\x32\x10"
2790                           "\x00\x11\x22\x33\x44\x55\x66\x77",
2791                 .klen   = 24,
2792                 .input  = zeroed_string,
2793                 .ilen   = 16,
2794                 .result = "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
2795                           "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
2796                 .rlen   = 16,
2797         }, {
2798                 .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
2799                           "\xfe\xdc\xba\x98\x76\x54\x32\x10"
2800                           "\x00\x11\x22\x33\x44\x55\x66\x77"
2801                           "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
2802                 .klen   = 32,
2803                 .input  = zeroed_string,
2804                 .ilen   = 16,
2805                 .result = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
2806                           "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
2807                 .rlen   = 16,
2808         }, { /* Generated with Crypto++ */
2809                 .key    = "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C"
2810                           "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D"
2811                           "\x4A\x27\x04\xE1\x27\x04\xE1\xBE"
2812                           "\x9B\x78\xBE\x9B\x78\x55\x32\x0F",
2813                 .klen   = 32,
2814                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2815                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2816                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2817                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2818                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2819                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2820                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2821                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2822                 .ilen   = 64,
2823                 .result = "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF"
2824                           "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC"
2825                           "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D"
2826                           "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14"
2827                           "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5"
2828                           "\xDF\xFA\xC7\xE8\x09\x50\x76\x08"
2829                           "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05"
2830                           "\x89\xF6\x82\xF0\xD3\xDB\x06\x02",
2831                 .rlen   = 64,
2832         },
2833 };
2834
2835 static struct cipher_testvec tf_dec_tv_template[] = {
2836         {
2837                 .key    = zeroed_string,
2838                 .klen   = 16,
2839                 .input  = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2840                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
2841                 .ilen   = 16,
2842                 .result = zeroed_string,
2843                 .rlen   = 16,
2844         }, {
2845                 .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
2846                           "\xfe\xdc\xba\x98\x76\x54\x32\x10"
2847                           "\x00\x11\x22\x33\x44\x55\x66\x77",
2848                 .klen   = 24,
2849                 .input  = "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
2850                           "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
2851                 .ilen   = 16,
2852                 .result = zeroed_string,
2853                 .rlen   = 16,
2854         }, {
2855                 .key    = "\x01\x23\x45\x67\x89\xab\xcd\xef"
2856                           "\xfe\xdc\xba\x98\x76\x54\x32\x10"
2857                           "\x00\x11\x22\x33\x44\x55\x66\x77"
2858                           "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
2859                 .klen   = 32,
2860                 .input  = "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
2861                           "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
2862                 .ilen   = 16,
2863                 .result = zeroed_string,
2864                 .rlen   = 16,
2865         }, { /* Generated with Crypto++ */
2866                 .key    = "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C"
2867                           "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D"
2868                           "\x4A\x27\x04\xE1\x27\x04\xE1\xBE"
2869                           "\x9B\x78\xBE\x9B\x78\x55\x32\x0F",
2870                 .klen   = 32,
2871                 .input  = "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF"
2872                           "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC"
2873                           "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D"
2874                           "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14"
2875                           "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5"
2876                           "\xDF\xFA\xC7\xE8\x09\x50\x76\x08"
2877                           "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05"
2878                           "\x89\xF6\x82\xF0\xD3\xDB\x06\x02",
2879                 .ilen   = 64,
2880                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2881                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2882                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2883                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2884                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2885                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2886                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2887                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2888                 .rlen   = 64,
2889         },
2890 };
2891
2892 static struct cipher_testvec tf_cbc_enc_tv_template[] = {
2893         { /* Generated with Nettle */
2894                 .key    = zeroed_string,
2895                 .klen   = 16,
2896                 .iv     = zeroed_string,
2897                 .input  = zeroed_string,
2898                 .ilen   = 16,
2899                 .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2900                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
2901                 .rlen   = 16,
2902         }, {
2903                 .key    = zeroed_string,
2904                 .klen   = 16,
2905                 .iv     = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2906                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
2907                 .input  = zeroed_string,
2908                 .ilen   = 16,
2909                 .result = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
2910                           "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
2911                 .rlen   = 16,
2912         }, {
2913                 .key    = zeroed_string,
2914                 .klen   = 16,
2915                 .iv     = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
2916                           "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
2917                 .input  = zeroed_string,
2918                 .ilen   = 16,
2919                 .result = "\x05\xef\x8c\x61\xa8\x11\x58\x26"
2920                           "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
2921                 .rlen   = 16,
2922         }, {
2923                 .key    = zeroed_string,
2924                 .klen   = 16,
2925                 .iv     = zeroed_string,
2926                 .input  = zeroed_string,
2927                 .ilen   = 48,
2928                 .result = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2929                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
2930                           "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
2931                           "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
2932                           "\x05\xef\x8c\x61\xa8\x11\x58\x26"
2933                           "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
2934                 .rlen   = 48,
2935         }, { /* Generated with Crypto++ */
2936                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
2937                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
2938                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
2939                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
2940                 .klen   = 32,
2941                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
2942                           "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
2943                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
2944                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
2945                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
2946                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
2947                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
2948                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
2949                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
2950                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
2951                 .ilen   = 64,
2952                 .result = "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1"
2953                           "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5"
2954                           "\x26\x1B\x05\x0C\x05\x12\x3F\xC0"
2955                           "\xF9\x1C\x02\x28\x40\x96\x6F\xD0"
2956                           "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE"
2957                           "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC"
2958                           "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3"
2959                           "\xB1\xD3\x44\x65\xDF\xE7\x63\x38",
2960                 .rlen   = 64,
2961         },
2962 };
2963
2964 static struct cipher_testvec tf_cbc_dec_tv_template[] = {
2965         { /* Reverse of the first four above */
2966                 .key    = zeroed_string,
2967                 .klen   = 16,
2968                 .iv     = zeroed_string,
2969                 .input  = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2970                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
2971                 .ilen   = 16,
2972                 .result = zeroed_string,
2973                 .rlen   = 16,
2974         }, {
2975                 .key    = zeroed_string,
2976                 .klen   = 16,
2977                 .iv     = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2978                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
2979                 .input  = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
2980                           "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
2981                 .ilen   = 16,
2982                 .result = zeroed_string,
2983                 .rlen   = 16,
2984         }, {
2985                 .key    = zeroed_string,
2986                 .klen   = 16,
2987                 .iv     = "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
2988                           "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
2989                 .input  = "\x05\xef\x8c\x61\xa8\x11\x58\x26"
2990                           "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
2991                 .ilen   = 16,
2992                 .result = zeroed_string,
2993                 .rlen   = 16,
2994         }, {
2995                 .key    = zeroed_string,
2996                 .klen   = 16,
2997                 .iv     = zeroed_string,
2998                 .input  = "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
2999                           "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
3000                           "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
3001                           "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
3002                           "\x05\xef\x8c\x61\xa8\x11\x58\x26"
3003                           "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
3004                 .ilen   = 48,
3005                 .result = zeroed_string,
3006                 .rlen   = 48,
3007         }, { /* Generated with Crypto++ */
3008                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3009                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3010                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3011                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3012                 .klen   = 32,
3013                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3014                           "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3015                 .input  = "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1"
3016                           "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5"
3017                           "\x26\x1B\x05\x0C\x05\x12\x3F\xC0"
3018                           "\xF9\x1C\x02\x28\x40\x96\x6F\xD0"
3019                           "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE"
3020                           "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC"
3021                           "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3"
3022                           "\xB1\xD3\x44\x65\xDF\xE7\x63\x38",
3023                 .ilen   = 64,
3024                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3025                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3026                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3027                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3028                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3029                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3030                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3031                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
3032                 .rlen   = 64,
3033         },
3034 };
3035
3036 static struct cipher_testvec tf_ctr_enc_tv_template[] = {
3037         { /* Generated with Crypto++ */
3038                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3039                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3040                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3041                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3042                 .klen   = 32,
3043                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3044                           "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3045                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3046                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3047                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3048                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3049                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3050                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3051                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3052                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
3053                 .ilen   = 64,
3054                 .result = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3055                           "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3056                           "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3057                           "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3058                           "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3059                           "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3060                           "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3061                           "\x01\x41\x21\x12\x38\xAB\x52\x4F",
3062                 .rlen   = 64,
3063         }, { /* Generated with Crypto++ */
3064                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3065                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3066                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3067                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3068                 .klen   = 32,
3069                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3070                           "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3071                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3072                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3073                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3074                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3075                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3076                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3077                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3078                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
3079                           "\xC3\x37\xCE",
3080                 .ilen   = 67,
3081                 .result = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3082                           "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3083                           "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3084                           "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3085                           "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3086                           "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3087                           "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3088                           "\x01\x41\x21\x12\x38\xAB\x52\x4F"
3089                           "\xA8\x57\x20",
3090                 .rlen   = 67,
3091         },
3092 };
3093
3094 static struct cipher_testvec tf_ctr_dec_tv_template[] = {
3095         { /* Generated with Crypto++ */
3096                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3097                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3098                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3099                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3100                 .klen   = 32,
3101                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3102                           "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3103                 .input  = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3104                           "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3105                           "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3106                           "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3107                           "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3108                           "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3109                           "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3110                           "\x01\x41\x21\x12\x38\xAB\x52\x4F",
3111                 .ilen   = 64,
3112                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3113                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3114                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3115                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3116                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3117                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3118                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3119                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
3120                 .rlen   = 64,
3121         }, { /* Generated with Crypto++ */
3122                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
3123                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
3124                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
3125                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
3126                 .klen   = 32,
3127                 .iv     = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
3128                           "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
3129                 .input  = "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
3130                           "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
3131                           "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
3132                           "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
3133                           "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
3134                           "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
3135                           "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
3136                           "\x01\x41\x21\x12\x38\xAB\x52\x4F"
3137                           "\xA8\x57\x20",
3138                 .ilen   = 67,
3139                 .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
3140                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
3141                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
3142                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
3143                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
3144                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
3145                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
3146                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
3147                           "\xC3\x37\xCE",
3148                 .rlen   = 67,
3149         },
3150 };
3151
3152 static struct cipher_testvec tf_lrw_enc_tv_template[] = {
3153         /* Generated from AES-LRW test vectors */
3154         {
3155                 .key    = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
3156                           "\x4c\x26\x84\x14\xb5\x68\x01\x85"
3157                           "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
3158                           "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
3159                 .klen   = 32,
3160                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3161                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3162                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3163                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3164                 .ilen   = 16,
3165                 .result = "\xa1\x6c\x50\x69\x26\xa4\xef\x7b"
3166                           "\x7c\xc6\x91\xeb\x72\xdd\x9b\xee",
3167                 .rlen   = 16,
3168         }, {
3169                 .key    = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
3170                           "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
3171                           "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
3172                           "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
3173                 .klen   = 32,
3174                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3175                           "\x00\x00\x00\x00\x00\x00\x00\x02",
3176                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3177                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3178                 .ilen   = 16,
3179                 .result = "\xab\x72\x0a\xad\x3b\x0c\xf0\xc9"
3180                           "\x42\x2f\xf1\xae\xf1\x3c\xb1\xbd",
3181                 .rlen   = 16,
3182         }, {
3183                 .key    = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
3184                           "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
3185                           "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
3186                           "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
3187                 .klen   = 32,
3188                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3189                           "\x00\x00\x00\x02\x00\x00\x00\x00",
3190                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3191                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3192                 .ilen   = 16,
3193                 .result = "\x85\xa7\x56\x67\x08\xfa\x42\xe1"
3194                           "\x22\xe6\x82\xfc\xd9\xb4\xd7\xd4",
3195                 .rlen   = 16,
3196         }, {
3197                 .key    = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
3198                           "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
3199                           "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
3200                           "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
3201                           "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
3202                 .klen   = 40,
3203                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3204                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3205                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3206                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3207                 .ilen   = 16,
3208                 .result = "\xd2\xaf\x69\x35\x24\x1d\x0e\x1c"
3209                           "\x84\x8b\x05\xe4\xa2\x2f\x16\xf5",
3210                 .rlen   = 16,
3211         }, {
3212                 .key    = "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
3213                           "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
3214                           "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
3215                           "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
3216                           "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
3217                 .klen   = 40,
3218                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3219                           "\x00\x00\x00\x02\x00\x00\x00\x00",
3220                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3221                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3222                 .ilen   = 16,
3223                 .result = "\x4a\x23\x56\xd7\xff\x90\xd0\x9a"
3224                           "\x0d\x7c\x26\xfc\xf0\xf0\xf6\xe4",
3225                 .rlen   = 16,
3226         }, {
3227                 .key    = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
3228                           "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
3229                           "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
3230                           "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
3231                           "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
3232                           "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
3233                 .klen   = 48,
3234                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3235                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3236                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3237                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3238                 .ilen   = 16,
3239                 .result = "\x30\xaf\x26\x05\x9d\x5d\x0a\x58"
3240                           "\xe2\xe7\xce\x8a\xb2\x56\x6d\x76",
3241                 .rlen   = 16,
3242         }, {
3243                 .key    = "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
3244                           "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
3245                           "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
3246                           "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
3247                           "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
3248                           "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
3249                 .klen   = 48,
3250                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3251                           "\x00\x00\x00\x02\x00\x00\x00\x00",
3252                 .input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
3253                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3254                 .ilen   = 16,
3255                 .result = "\xdf\xcf\xdc\xd2\xe1\xcf\x86\x75"
3256                           "\x17\x66\x5e\x0c\x14\xa1\x3d\x40",
3257                 .rlen   = 16,
3258         }, {
3259                 .key    = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
3260                           "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
3261                           "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
3262                           "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
3263                           "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
3264                           "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
3265                 .klen   = 48,
3266                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3267                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3268                 .input  = "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
3269                           "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
3270                           "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
3271                           "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
3272                           "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
3273                           "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
3274                           "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
3275                           "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
3276                           "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
3277                           "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
3278                           "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
3279                           "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
3280                           "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
3281                           "\x4c\x96\x12\xed\x7c\x92\x03\x01"
3282                           "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
3283                           "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
3284                           "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
3285                           "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
3286                           "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
3287                           "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
3288                           "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
3289                           "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
3290                           "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
3291                           "\x76\x12\x73\x44\x1a\x56\xd7\x72"
3292                           "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
3293                           "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
3294                           "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
3295                           "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
3296                           "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
3297                           "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
3298                           "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
3299                           "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
3300                           "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
3301                           "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
3302                           "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
3303                           "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
3304                           "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
3305                           "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
3306                           "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
3307                           "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
3308                           "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
3309                           "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
3310                           "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
3311                           "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
3312                           "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
3313                           "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
3314                           "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
3315                           "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
3316                           "\x62\x73\x65\xfd\x46\x63\x25\x3d"
3317                           "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
3318                           "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
3319                           "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
3320                           "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
3321                           "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
3322                           "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
3323                           "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
3324                           "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
3325                           "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
3326                           "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
3327                           "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
3328                           "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
3329                           "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
3330                           "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
3331                           "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
3332                 .ilen   = 512,
3333                 .result = "\x30\x38\xeb\xaf\x12\x43\x1a\x89"
3334                           "\x62\xa2\x36\xe5\xcf\x77\x1e\xd9"
3335                           "\x08\xc3\x0d\xdd\x95\xab\x19\x96"
3336                           "\x27\x52\x41\xc3\xca\xfb\xf6\xee"
3337                           "\x40\x2d\xdf\xdd\x00\x0c\xb9\x0a"
3338                           "\x3a\xf0\xc0\xd1\xda\x63\x9e\x45"
3339                           "\x42\xe9\x29\xc0\xb4\x07\xb4\x31"
3340                           "\x66\x77\x72\xb5\xb6\xb3\x57\x46"
3341                           "\x34\x9a\xfe\x03\xaf\x6b\x36\x07"
3342                           "\x63\x8e\xc2\x5d\xa6\x0f\xb6\x7d"
3343                           "\xfb\x6d\x82\x51\xb6\x98\xd0\x71"
3344                           "\xe7\x10\x7a\xdf\xb2\xbd\xf1\x1d"
3345                           "\x72\x2b\x54\x13\xe3\x6d\x79\x37"
3346                           "\xa9\x39\x2c\xdf\x21\xab\x87\xd5"
3347                           "\xee\xef\x9a\x12\x50\x39\x2e\x1b"
3348                           "\x7d\xe6\x6a\x27\x48\xb9\xe7\xac"
3349                           "\xaa\xcd\x79\x5f\xf2\xf3\xa0\x08"
3350                           "\x6f\x2c\xf4\x0e\xd1\xb8\x89\x25"
3351                           "\x31\x9d\xef\xb1\x1d\x27\x55\x04"
3352                           "\xc9\x8c\xb7\x68\xdc\xb6\x67\x8a"
3353                           "\xdb\xcf\x22\xf2\x3b\x6f\xce\xbb"
3354                           "\x26\xbe\x4f\x27\x04\x42\xd1\x44"
3355                           "\x4c\x08\xa3\x95\x4c\x7f\x1a\xaf"
3356                           "\x1d\x28\x14\xfd\xb1\x1a\x34\x18"
3357                           "\xf5\x1e\x28\x69\x95\x6a\x5a\xba"
3358                           "\x8e\xb2\x58\x1d\x28\x17\x13\x3d"
3359                           "\x38\x7d\x14\x8d\xab\x5d\xf9\xe8"
3360                           "\x3c\x0f\x2b\x0d\x2b\x08\xb4\x4b"
3361                           "\x6b\x0d\xc8\xa7\x84\xc2\x3a\x1a"
3362                           "\xb7\xbd\xda\x92\x29\xb8\x5b\x5a"
3363                           "\x63\xa5\x99\x82\x09\x72\x8f\xc6"
3364                           "\xa4\x62\x24\x69\x8c\x2d\x26\x00"
3365                           "\x99\x83\x91\xd6\xc6\xcf\x57\x67"
3366                           "\x38\xea\xf2\xfc\x29\xe0\x73\x39"
3367                           "\xf9\x13\x94\x6d\xe2\x58\x28\x75"
3368                           "\x3e\xae\x71\x90\x07\x70\x1c\x38"
3369                           "\x5b\x4c\x1e\xb5\xa5\x3b\x20\xef"
3370                           "\xb1\x4c\x3e\x1a\x72\x62\xbb\x22"
3371                           "\x82\x09\xe3\x18\x3f\x4f\x48\xfc"
3372                           "\xdd\xac\xfc\xb6\x09\xdb\xd2\x7b"
3373                           "\xd6\xb7\x7e\x41\x2f\x14\xf5\x0e"
3374                           "\xc3\xac\x4a\xed\xe7\x82\xef\x31"
3375                           "\x1f\x1a\x51\x1e\x29\x60\xc8\x98"
3376                           "\x93\x51\x1d\x3d\x62\x59\x83\x82"
3377                           "\x0c\xf1\xd7\x8d\xac\x33\x44\x81"
3378                           "\x3c\x59\xb7\xd4\x5b\x65\x82\xc4"
3379                           "\xec\xdc\x24\xfd\x0e\x1a\x79\x94"
3380                           "\x34\xb0\x62\xfa\x98\x49\x26\x1f"
3381                           "\xf4\x9e\x40\x44\x5b\x1f\xf8\xbe"
3382                           "\x36\xff\xc6\xc6\x9d\xf2\xd6\xcc"
3383                           "\x63\x93\x29\xb9\x0b\x6d\xd7\x6c"
3384                           "\xdb\xf6\x21\x80\xf7\x5a\x37\x15"
3385                           "\x0c\xe3\x36\xc8\x74\x75\x20\x91"
3386                           "\xdf\x52\x2d\x0c\xe7\x45\xff\x46"
3387                           "\xb3\xf4\xec\xc2\xbd\xd3\x37\xb6"
3388                           "\x26\xa2\x5d\x7d\x61\xbf\x10\x46"
3389                           "\x57\x8d\x05\x96\x70\x0b\xd6\x41"
3390                           "\x5c\xe9\xd3\x54\x81\x39\x3a\xdd"
3391                           "\x5f\x92\x81\x6e\x35\x03\xd4\x72"
3392                           "\x3d\x5a\xe7\xb9\x3b\x0c\x84\x23"
3393                           "\x45\x5d\xec\x72\xc1\x52\xef\x2e"
3394                           "\x81\x00\xd3\xfe\x4c\x3c\x05\x61"
3395                           "\x80\x18\xc4\x6c\x03\xd3\xb7\xba"
3396                           "\x11\xd7\xb8\x6e\xea\xe1\x80\x30",
3397                 .rlen   = 512,
3398         },
3399 };
3400
3401 static struct cipher_testvec tf_lrw_dec_tv_template[] = {
3402         /* Generated from AES-LRW test vectors */
3403         /* same as enc vectors with input and result reversed */
3404         {
3405                 .key    = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
3406                           "\x4c\x26\x84\x14\xb5\x68\x01\x85"
3407                           "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
3408                           "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
3409                 .klen   = 32,
3410                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3411                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3412                 .input  = "\xa1\x6c\x50\x69\x26\xa4\xef\x7b"
3413                           "\x7c\xc6\x91\xeb\x72\xdd\x9b\xee",
3414                 .ilen   = 16,
3415                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3416                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3417                 .rlen   = 16,
3418         }, {
3419                 .key    = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
3420                           "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
3421                           "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
3422                           "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
3423                 .klen   = 32,
3424                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3425                           "\x00\x00\x00\x00\x00\x00\x00\x02",
3426                 .input  = "\xab\x72\x0a\xad\x3b\x0c\xf0\xc9"
3427                           "\x42\x2f\xf1\xae\xf1\x3c\xb1\xbd",
3428                 .ilen   = 16,
3429                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3430                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3431                 .rlen   = 16,
3432         }, {
3433                 .key    = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
3434                           "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
3435                           "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
3436                           "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
3437                 .klen   = 32,
3438                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3439                           "\x00\x00\x00\x02\x00\x00\x00\x00",
3440                 .input  = "\x85\xa7\x56\x67\x08\xfa\x42\xe1"
3441                           "\x22\xe6\x82\xfc\xd9\xb4\xd7\xd4",
3442                 .ilen   = 16,
3443                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3444                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3445                 .rlen   = 16,
3446         }, {
3447                 .key    = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
3448                           "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
3449                           "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
3450                           "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
3451                           "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
3452                 .klen   = 40,
3453                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3454                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3455                 .input  = "\xd2\xaf\x69\x35\x24\x1d\x0e\x1c"
3456                           "\x84\x8b\x05\xe4\xa2\x2f\x16\xf5",
3457                 .ilen   = 16,
3458                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3459                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3460                 .rlen   = 16,
3461         }, {
3462                 .key    = "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
3463                           "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
3464                           "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
3465                           "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
3466                           "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
3467                 .klen   = 40,
3468                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3469                           "\x00\x00\x00\x02\x00\x00\x00\x00",
3470                 .input  = "\x4a\x23\x56\xd7\xff\x90\xd0\x9a"
3471                           "\x0d\x7c\x26\xfc\xf0\xf0\xf6\xe4",
3472                 .ilen   = 16,
3473                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3474                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3475                 .rlen   = 16,
3476         }, {
3477                 .key    = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
3478                           "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
3479                           "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
3480                           "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
3481                           "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
3482                           "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
3483                 .klen   = 48,
3484                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3485                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3486                 .input  = "\x30\xaf\x26\x05\x9d\x5d\x0a\x58"
3487                           "\xe2\xe7\xce\x8a\xb2\x56\x6d\x76",
3488                 .ilen   = 16,
3489                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3490                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3491                 .rlen   = 16,
3492         }, {
3493                 .key    = "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
3494                           "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
3495                           "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
3496                           "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
3497                           "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
3498                           "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
3499                 .klen   = 48,
3500                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3501                           "\x00\x00\x00\x02\x00\x00\x00\x00",
3502                 .input  = "\xdf\xcf\xdc\xd2\xe1\xcf\x86\x75"
3503                           "\x17\x66\x5e\x0c\x14\xa1\x3d\x40",
3504                 .ilen   = 16,
3505                 .result = "\x30\x31\x32\x33\x34\x35\x36\x37"
3506                           "\x38\x39\x41\x42\x43\x44\x45\x46",
3507                 .rlen   = 16,
3508         }, {
3509                 .key    = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
3510                           "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
3511                           "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
3512                           "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
3513                           "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
3514                           "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
3515                 .klen   = 48,
3516                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3517                           "\x00\x00\x00\x00\x00\x00\x00\x01",
3518                 .input  = "\x30\x38\xeb\xaf\x12\x43\x1a\x89"
3519                           "\x62\xa2\x36\xe5\xcf\x77\x1e\xd9"
3520                           "\x08\xc3\x0d\xdd\x95\xab\x19\x96"
3521                           "\x27\x52\x41\xc3\xca\xfb\xf6\xee"
3522                           "\x40\x2d\xdf\xdd\x00\x0c\xb9\x0a"
3523                           "\x3a\xf0\xc0\xd1\xda\x63\x9e\x45"
3524                           "\x42\xe9\x29\xc0\xb4\x07\xb4\x31"
3525                           "\x66\x77\x72\xb5\xb6\xb3\x57\x46"
3526                           "\x34\x9a\xfe\x03\xaf\x6b\x36\x07"
3527                           "\x63\x8e\xc2\x5d\xa6\x0f\xb6\x7d"
3528                           "\xfb\x6d\x82\x51\xb6\x98\xd0\x71"
3529                           "\xe7\x10\x7a\xdf\xb2\xbd\xf1\x1d"
3530                           "\x72\x2b\x54\x13\xe3\x6d\x79\x37"
3531                           "\xa9\x39\x2c\xdf\x21\xab\x87\xd5"
3532                           "\xee\xef\x9a\x12\x50\x39\x2e\x1b"
3533                           "\x7d\xe6\x6a\x27\x48\xb9\xe7\xac"
3534                           "\xaa\xcd\x79\x5f\xf2\xf3\xa0\x08"
3535                           "\x6f\x2c\xf4\x0e\xd1\xb8\x89\x25"
3536                           "\x31\x9d\xef\xb1\x1d\x27\x55\x04"
3537                           "\xc9\x8c\xb7\x68\xdc\xb6\x67\x8a"
3538                           "\xdb\xcf\x22\xf2\x3b\x6f\xce\xbb"
3539                           "\x26\xbe\x4f\x27\x04\x42\xd1\x44"
3540                           "\x4c\x08\xa3\x95\x4c\x7f\x1a\xaf"
3541                           "\x1d\x28\x14\xfd\xb1\x1a\x34\x18"
3542                           "\xf5\x1e\x28\x69\x95\x6a\x5a\xba"
3543                           "\x8e\xb2\x58\x1d\x28\x17\x13\x3d"
3544                           "\x38\x7d\x14\x8d\xab\x5d\xf9\xe8"
3545                           "\x3c\x0f\x2b\x0d\x2b\x08\xb4\x4b"
3546                           "\x6b\x0d\xc8\xa7\x84\xc2\x3a\x1a"
3547                           "\xb7\xbd\xda\x92\x29\xb8\x5b\x5a"
3548                           "\x63\xa5\x99\x82\x09\x72\x8f\xc6"
3549                           "\xa4\x62\x24\x69\x8c\x2d\x26\x00"
3550                           "\x99\x83\x91\xd6\xc6\xcf\x57\x67"
3551                           "\x38\xea\xf2\xfc\x29\xe0\x73\x39"
3552                           "\xf9\x13\x94\x6d\xe2\x58\x28\x75"
3553                           "\x3e\xae\x71\x90\x07\x70\x1c\x38"
3554                           "\x5b\x4c\x1e\xb5\xa5\x3b\x20\xef"
3555                           "\xb1\x4c\x3e\x1a\x72\x62\xbb\x22"
3556                           "\x82\x09\xe3\x18\x3f\x4f\x48\xfc"
3557                           "\xdd\xac\xfc\xb6\x09\xdb\xd2\x7b"
3558                           "\xd6\xb7\x7e\x41\x2f\x14\xf5\x0e"
3559                           "\xc3\xac\x4a\xed\xe7\x82\xef\x31"
3560                           "\x1f\x1a\x51\x1e\x29\x60\xc8\x98"
3561                           "\x93\x51\x1d\x3d\x62\x59\x83\x82"
3562                           "\x0c\xf1\xd7\x8d\xac\x33\x44\x81"
3563                           "\x3c\x59\xb7\xd4\x5b\x65\x82\xc4"
3564                           "\xec\xdc\x24\xfd\x0e\x1a\x79\x94"
3565                           "\x34\xb0\x62\xfa\x98\x49\x26\x1f"
3566                           "\xf4\x9e\x40\x44\x5b\x1f\xf8\xbe"
3567                           "\x36\xff\xc6\xc6\x9d\xf2\xd6\xcc"
3568                           "\x63\x93\x29\xb9\x0b\x6d\xd7\x6c"
3569                           "\xdb\xf6\x21\x80\xf7\x5a\x37\x15"
3570                           "\x0c\xe3\x36\xc8\x74\x75\x20\x91"
3571                           "\xdf\x52\x2d\x0c\xe7\x45\xff\x46"
3572                           "\xb3\xf4\xec\xc2\xbd\xd3\x37\xb6"
3573                           "\x26\xa2\x5d\x7d\x61\xbf\x10\x46"
3574                           "\x57\x8d\x05\x96\x70\x0b\xd6\x41"
3575                           "\x5c\xe9\xd3\x54\x81\x39\x3a\xdd"
3576                           "\x5f\x92\x81\x6e\x35\x03\xd4\x72"
3577                           "\x3d\x5a\xe7\xb9\x3b\x0c\x84\x23"
3578                           "\x45\x5d\xec\x72\xc1\x52\xef\x2e"
3579                           "\x81\x00\xd3\xfe\x4c\x3c\x05\x61"
3580                           "\x80\x18\xc4\x6c\x03\xd3\xb7\xba"
3581                           "\x11\xd7\xb8\x6e\xea\xe1\x80\x30",
3582                 .ilen   = 512,
3583                 .result = "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
3584                           "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
3585                           "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
3586                           "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
3587                           "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
3588                           "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
3589                           "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
3590                           "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
3591                           "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
3592                           "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
3593                           "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
3594                           "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
3595                           "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
3596                           "\x4c\x96\x12\xed\x7c\x92\x03\x01"
3597                           "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
3598                           "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
3599                           "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
3600                           "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
3601                           "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
3602                           "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
3603                           "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
3604                           "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
3605                           "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
3606                           "\x76\x12\x73\x44\x1a\x56\xd7\x72"
3607                           "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
3608                           "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
3609                           "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
3610                           "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
3611                           "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
3612                           "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
3613                           "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
3614                           "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
3615                           "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
3616                           "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
3617                           "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
3618                           "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
3619                           "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
3620                           "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
3621                           "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
3622                           "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
3623                           "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
3624                           "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
3625                           "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
3626                           "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
3627                           "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
3628                           "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
3629                           "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
3630                           "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
3631                           "\x62\x73\x65\xfd\x46\x63\x25\x3d"
3632                           "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
3633                           "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
3634                           "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
3635                           "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
3636                           "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
3637                           "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
3638                           "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
3639                           "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
3640                           "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
3641                           "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
3642                           "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
3643                           "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
3644                           "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
3645                           "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
3646                           "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
3647                 .rlen   = 512,
3648         },
3649 };
3650
3651 static struct cipher_testvec tf_xts_enc_tv_template[] = {
3652         /* Generated from AES-XTS test vectors */
3653 {
3654                 .key    = "\x00\x00\x00\x00\x00\x00\x00\x00"
3655                           "\x00\x00\x00\x00\x00\x00\x00\x00"
3656                           "\x00\x00\x00\x00\x00\x00\x00\x00"
3657                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3658                 .klen   = 32,
3659                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3660                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3661                 .input  = "\x00\x00\x00\x00\x00\x00\x00\x00"
3662                           "\x00\x00\x00\x00\x00\x00\x00\x00"
3663                           "\x00\x00\x00\x00\x00\x00\x00\x00"
3664                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3665                 .ilen   = 32,
3666                 .result = "\x4b\xc9\x44\x4a\x11\xa3\xef\xac"
3667                           "\x30\x74\xe4\x44\x52\x77\x97\x43"
3668                           "\xa7\x60\xb2\x45\x2e\xf9\x00\x90"
3669                           "\x9f\xaa\xfd\x89\x6e\x9d\x4a\xe0",
3670                 .rlen   = 32,
3671         }, {
3672                 .key    = "\x11\x11\x11\x11\x11\x11\x11\x11"
3673                           "\x11\x11\x11\x11\x11\x11\x11\x11"
3674                           "\x22\x22\x22\x22\x22\x22\x22\x22"
3675                           "\x22\x22\x22\x22\x22\x22\x22\x22",
3676                 .klen   = 32,
3677                 .iv     = "\x33\x33\x33\x33\x33\x00\x00\x00"
3678                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3679                 .input  = "\x44\x44\x44\x44\x44\x44\x44\x44"
3680                           "\x44\x44\x44\x44\x44\x44\x44\x44"
3681                           "\x44\x44\x44\x44\x44\x44\x44\x44"
3682                           "\x44\x44\x44\x44\x44\x44\x44\x44",
3683                 .ilen   = 32,
3684                 .result = "\x57\x0e\x8f\xe5\x2a\x35\x61\x4f"
3685                           "\x32\xd3\xbd\x36\x05\x15\x44\x2c"
3686                           "\x58\x06\xf7\xf8\x00\xa8\xb6\xd5"
3687                           "\xc6\x28\x92\xdb\xd8\x34\xa2\xe9",
3688                 .rlen   = 32,
3689         }, {
3690                 .key    = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
3691                           "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
3692                           "\x22\x22\x22\x22\x22\x22\x22\x22"
3693                           "\x22\x22\x22\x22\x22\x22\x22\x22",
3694                 .klen   = 32,
3695                 .iv     = "\x33\x33\x33\x33\x33\x00\x00\x00"
3696                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3697                 .input  = "\x44\x44\x44\x44\x44\x44\x44\x44"
3698                           "\x44\x44\x44\x44\x44\x44\x44\x44"
3699                           "\x44\x44\x44\x44\x44\x44\x44\x44"
3700                           "\x44\x44\x44\x44\x44\x44\x44\x44",
3701                 .ilen   = 32,
3702                 .result = "\x96\x45\x8f\x8d\x7a\x75\xb1\xde"
3703                           "\x40\x0c\x89\x56\xf6\x4d\xa7\x07"
3704                           "\x38\xbb\x5b\xe9\xcd\x84\xae\xb2"
3705                           "\x7b\x6a\x62\xf4\x8c\xb5\x37\xea",
3706                 .rlen   = 32,
3707         }, {
3708                 .key    = "\x27\x18\x28\x18\x28\x45\x90\x45"
3709                           "\x23\x53\x60\x28\x74\x71\x35\x26"
3710                           "\x31\x41\x59\x26\x53\x58\x97\x93"
3711                           "\x23\x84\x62\x64\x33\x83\x27\x95",
3712                 .klen   = 32,
3713                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
3714                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3715                 .input  = "\x00\x01\x02\x03\x04\x05\x06\x07"
3716                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
3717                           "\x10\x11\x12\x13\x14\x15\x16\x17"
3718                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
3719                           "\x20\x21\x22\x23\x24\x25\x26\x27"
3720                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
3721                           "\x30\x31\x32\x33\x34\x35\x36\x37"
3722                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
3723                           "\x40\x41\x42\x43\x44\x45\x46\x47"
3724                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
3725                           "\x50\x51\x52\x53\x54\x55\x56\x57"
3726                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
3727                           "\x60\x61\x62\x63\x64\x65\x66\x67"
3728                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
3729                           "\x70\x71\x72\x73\x74\x75\x76\x77"
3730                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
3731                           "\x80\x81\x82\x83\x84\x85\x86\x87"
3732                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
3733                           "\x90\x91\x92\x93\x94\x95\x96\x97"
3734                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
3735                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
3736                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
3737                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
3738                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
3739                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
3740                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
3741                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
3742                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
3743                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
3744                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
3745                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
3746                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
3747                           "\x00\x01\x02\x03\x04\x05\x06\x07"
3748                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
3749                           "\x10\x11\x12\x13\x14\x15\x16\x17"
3750                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
3751                           "\x20\x21\x22\x23\x24\x25\x26\x27"
3752                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
3753                           "\x30\x31\x32\x33\x34\x35\x36\x37"
3754                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
3755                           "\x40\x41\x42\x43\x44\x45\x46\x47"
3756                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
3757                           "\x50\x51\x52\x53\x54\x55\x56\x57"
3758                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
3759                           "\x60\x61\x62\x63\x64\x65\x66\x67"
3760                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
3761                           "\x70\x71\x72\x73\x74\x75\x76\x77"
3762                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
3763                           "\x80\x81\x82\x83\x84\x85\x86\x87"
3764                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
3765                           "\x90\x91\x92\x93\x94\x95\x96\x97"
3766                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
3767                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
3768                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
3769                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
3770                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
3771                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
3772                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
3773                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
3774                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
3775                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
3776                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
3777                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
3778                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
3779                 .ilen   = 512,
3780                 .result = "\xa9\x78\xae\x1e\xea\xa2\x44\x4c"
3781                           "\xa2\x7a\x64\x1f\xaf\x46\xc1\xe0"
3782                           "\x6c\xb2\xf3\x92\x9a\xd6\x7d\x58"
3783                           "\xb8\x2d\xb9\x5d\x58\x07\x66\x50"
3784                           "\xea\x35\x35\x8c\xb2\x46\x61\x06"
3785                           "\x5d\x65\xfc\x57\x8f\x69\x74\xab"
3786                           "\x8a\x06\x69\xb5\x6c\xda\x66\xc7"
3787                           "\x52\x90\xbb\x8e\x6d\x8b\xb5\xa2"
3788                           "\x78\x1d\xc2\xa9\xc2\x73\x00\xc3"
3789                           "\x32\x36\x7c\x97\x6b\x4e\x8a\x50"
3790                           "\xe4\x91\x83\x96\x8f\xf4\x94\x1a"
3791                           "\xa6\x27\xe1\x33\xcb\x91\xc6\x5f"
3792                           "\x94\x75\xbc\xd7\x3e\x3e\x6f\x9e"
3793                           "\xa9\x31\x80\x5e\xe5\xdb\xc8\x53"
3794                           "\x01\x73\x68\x32\x25\x19\xfa\xfb"
3795                           "\xe4\xcf\xb9\x3e\xa2\xa0\x8f\x31"
3796                           "\xbf\x54\x06\x93\xa8\xb1\x0f\xb6"
3797                           "\x7c\x3c\xde\x6f\x0f\xfb\x0c\x11"
3798                           "\x39\x80\x39\x09\x97\x65\xf2\x83"
3799                           "\xae\xe6\xa1\x6f\x47\xb8\x49\xde"
3800                           "\x99\x36\x20\x7d\x97\x3b\xec\xfa"
3801                           "\xb4\x33\x6e\x7a\xc7\x46\x84\x49"
3802                           "\x91\xcd\xe1\x57\x0d\xed\x40\x08"
3803                           "\x13\xf1\x4e\x3e\xa4\xa4\x5c\xe6"
3804                           "\xd2\x0c\x20\x8f\x3e\xdf\x3f\x47"
3805                           "\x9a\x2f\xde\x6d\x66\xc9\x99\x4a"
3806                           "\x2d\x9e\x9d\x4b\x1a\x27\xa2\x12"
3807                           "\x99\xf0\xf8\xb1\xb6\xf6\x57\xc3"
3808                           "\xca\x1c\xa3\x8e\xed\x39\x28\xb5"
3809                           "\x10\x1b\x4b\x08\x42\x00\x4a\xd3"
3810                           "\xad\x5a\xc6\x8e\xc8\xbb\x95\xc4"
3811                           "\x4b\xaa\xfe\xd5\x42\xa8\xa3\x6d"
3812                           "\x3c\xf3\x34\x91\x2d\xb4\xdd\x20"
3813                           "\x0c\x90\x6d\xa3\x9b\x66\x9d\x24"
3814                           "\x02\xa6\xa9\x3f\x3f\x58\x5d\x47"
3815                           "\x24\x65\x63\x7e\xbd\x8c\xe6\x52"
3816                           "\x7d\xef\x33\x53\x63\xec\xaa\x0b"
3817                           "\x64\x15\xa9\xa6\x1f\x10\x00\x38"
3818                           "\x35\xa8\xe7\xbe\x23\x70\x22\xe0"
3819                           "\xd3\xb9\xe6\xfd\xe6\xaa\x03\x50"
3820                           "\xf3\x3c\x27\x36\x8b\xcc\xfe\x9c"
3821                           "\x9c\xa3\xb3\xe7\x68\x9b\xa2\x71"
3822                           "\xe0\x07\xd9\x1f\x68\x1f\xac\x5e"
3823                           "\x7a\x74\x85\xa9\x6a\x90\xab\x2c"
3824                           "\x38\x51\xbc\x1f\x43\x4a\x56\x1c"
3825                           "\xf8\x47\x03\x4e\x67\xa8\x1f\x99"
3826                           "\x04\x39\x73\x32\xb2\x86\x79\xe7"
3827                           "\x14\x28\x70\xb8\xe2\x7d\x69\x85"
3828                           "\xb6\x0f\xc5\xd0\xd0\x01\x5c\xe6"
3829                           "\x09\x0f\x75\xf7\xb6\x81\xd2\x11"
3830                           "\x20\x9c\xa1\xee\x11\x44\x79\xd0"
3831                           "\xb2\x34\x77\xda\x10\x9a\x6f\x6f"
3832                           "\xef\x7c\xd9\xdc\x35\xb7\x61\xdd"
3833                           "\xf1\xa4\xc6\x1c\xbf\x05\x22\xac"
3834                           "\xfe\x2f\x85\x00\x44\xdf\x33\x16"
3835                           "\x35\xb6\xa3\xd3\x70\xdf\x69\x35"
3836                           "\x6a\xc7\xb4\x99\x45\x27\xc8\x8e"
3837                           "\x5a\x14\x30\xd0\x55\x3e\x4f\x64"
3838                           "\x0d\x38\xe3\xdf\x8b\xa8\x93\x26"
3839                           "\x75\xae\xf6\xb5\x23\x0b\x17\x31"
3840                           "\xbf\x27\xb8\xb5\x94\x31\xa7\x8f"
3841                           "\x43\xc4\x46\x24\x22\x4f\x8f\x7e"
3842                           "\xe5\xf4\x6d\x1e\x0e\x18\x7a\xbb"
3843                           "\xa6\x8f\xfb\x49\x49\xd8\x7e\x5a",
3844                 .rlen   = 512,
3845         }, {
3846                 .key    = "\x27\x18\x28\x18\x28\x45\x90\x45"
3847                           "\x23\x53\x60\x28\x74\x71\x35\x26"
3848                           "\x62\x49\x77\x57\x24\x70\x93\x69"
3849                           "\x99\x59\x57\x49\x66\x96\x76\x27"
3850                           "\x31\x41\x59\x26\x53\x58\x97\x93"
3851                           "\x23\x84\x62\x64\x33\x83\x27\x95"
3852                           "\x02\x88\x41\x97\x16\x93\x99\x37"
3853                           "\x51\x05\x82\x09\x74\x94\x45\x92",
3854                 .klen   = 64,
3855                 .iv     = "\xff\x00\x00\x00\x00\x00\x00\x00"
3856                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3857                 .input  = "\x00\x01\x02\x03\x04\x05\x06\x07"
3858                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
3859                           "\x10\x11\x12\x13\x14\x15\x16\x17"
3860                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
3861                           "\x20\x21\x22\x23\x24\x25\x26\x27"
3862                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
3863                           "\x30\x31\x32\x33\x34\x35\x36\x37"
3864                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
3865                           "\x40\x41\x42\x43\x44\x45\x46\x47"
3866                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
3867                           "\x50\x51\x52\x53\x54\x55\x56\x57"
3868                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
3869                           "\x60\x61\x62\x63\x64\x65\x66\x67"
3870                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
3871                           "\x70\x71\x72\x73\x74\x75\x76\x77"
3872                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
3873                           "\x80\x81\x82\x83\x84\x85\x86\x87"
3874                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
3875                           "\x90\x91\x92\x93\x94\x95\x96\x97"
3876                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
3877                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
3878                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
3879                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
3880                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
3881                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
3882                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
3883                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
3884                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
3885                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
3886                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
3887                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
3888                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
3889                           "\x00\x01\x02\x03\x04\x05\x06\x07"
3890                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
3891                           "\x10\x11\x12\x13\x14\x15\x16\x17"
3892                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
3893                           "\x20\x21\x22\x23\x24\x25\x26\x27"
3894                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
3895                           "\x30\x31\x32\x33\x34\x35\x36\x37"
3896                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
3897                           "\x40\x41\x42\x43\x44\x45\x46\x47"
3898                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
3899                           "\x50\x51\x52\x53\x54\x55\x56\x57"
3900                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
3901                           "\x60\x61\x62\x63\x64\x65\x66\x67"
3902                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
3903                           "\x70\x71\x72\x73\x74\x75\x76\x77"
3904                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
3905                           "\x80\x81\x82\x83\x84\x85\x86\x87"
3906                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
3907                           "\x90\x91\x92\x93\x94\x95\x96\x97"
3908                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
3909                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
3910                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
3911                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
3912                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
3913                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
3914                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
3915                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
3916                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
3917                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
3918                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
3919                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
3920                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
3921                 .ilen   = 512,
3922                 .result = "\xd7\x4b\x93\x7d\x13\xa2\xa2\xe1"
3923                           "\x35\x39\x71\x88\x76\x1e\xc9\xea"
3924                           "\x86\xad\xf3\x14\x48\x3d\x5e\xe9"
3925                           "\xe9\x2d\xb2\x56\x59\x35\x9d\xec"
3926                           "\x84\xfa\x7e\x9d\x6d\x33\x36\x8f"
3927                           "\xce\xf4\xa9\x21\x0b\x5f\x96\xec"
3928                           "\xcb\xf9\x57\x68\x33\x88\x39\xbf"
3929                           "\x2f\xbb\x59\x03\xbd\x66\x8b\x11"
3930                           "\x11\x65\x51\x2e\xb8\x67\x05\xd1"
3931                           "\x27\x11\x5c\xd4\xcc\x97\xc2\xb3"
3932                           "\xa9\x55\xaf\x07\x56\xd1\xdc\xf5"
3933                           "\x85\xdc\x46\xe6\xf0\x24\xeb\x93"
3934                           "\x4d\xf0\x9b\xf5\x73\x1c\xda\x03"
3935                           "\x22\xc8\x3a\x4f\xb4\x19\x91\x09"
3936                           "\x54\x0b\xf6\xfe\x17\x3d\x1a\x53"
3937                           "\x72\x60\x79\xcb\x0e\x32\x8a\x77"
3938                           "\xd5\xed\xdb\x33\xd7\x62\x16\x69"
3939                           "\x63\xe0\xab\xb5\xf6\x9c\x5f\x3d"
3940                           "\x69\x35\x61\x86\xf8\x86\xb9\x89"
3941                           "\x6e\x59\x35\xac\xf6\x6b\x33\xa0"
3942                           "\xea\xef\x96\x62\xd8\xa9\xcf\x56"
3943                           "\xbf\xdb\x8a\xfd\xa1\x82\x77\x73"
3944                           "\x3d\x94\x4a\x49\x42\x6d\x08\x60"
3945                           "\xa1\xea\xab\xb6\x88\x13\x94\xb8"
3946                           "\x51\x98\xdb\x35\x85\xdf\xf6\xb9"
3947                           "\x8f\xcd\xdf\x80\xd3\x40\x2d\x72"
3948                           "\xb8\xb2\x6c\x02\x43\x35\x22\x2a"
3949                           "\x31\xed\xcd\x16\x19\xdf\x62\x0f"
3950                           "\x29\xcf\x87\x04\xec\x02\x4f\xe4"
3951                           "\xa2\xed\x73\xc6\x69\xd3\x7e\x89"
3952                           "\x0b\x76\x10\x7c\xd6\xf9\x6a\x25"
3953                           "\xed\xcc\x60\x5d\x61\x20\xc1\x97"
3954                           "\x56\x91\x57\x28\xbe\x71\x0d\xcd"
3955                           "\xde\xc4\x9e\x55\x91\xbe\xd1\x28"
3956                           "\x9b\x90\xeb\x73\xf3\x68\x51\xc6"
3957                           "\xdf\x82\xcc\xd8\x1f\xce\x5b\x27"
3958                           "\xc0\x60\x5e\x33\xd6\xa7\x20\xea"
3959                           "\xb2\x54\xc7\x5d\x6a\x3b\x67\x47"
3960                           "\xcf\xa0\xe3\xab\x86\xaf\xc1\x42"
3961                           "\xe6\xb0\x23\x4a\xaf\x53\xdf\xa0"
3962                           "\xad\x12\x32\x31\x03\xf7\x21\xbe"
3963                           "\x2d\xd5\x82\x42\xb6\x4a\x3d\xcd"
3964                           "\xd8\x81\x77\xa9\x49\x98\x6c\x09"
3965                           "\xc5\xa3\x61\x12\x62\x85\x6b\xcd"
3966                           "\xb3\xf4\x20\x0c\x41\xc4\x05\x37"
3967                           "\x46\x5f\xeb\x71\x8b\xf1\xaf\x6e"
3968                           "\xba\xf3\x50\x2e\xfe\xa8\x37\xeb"
3969                           "\xe8\x8c\x4f\xa4\x0c\xf1\x31\xc8"
3970                           "\x6e\x71\x4f\xa5\xd7\x97\x73\xe0"
3971                           "\x93\x4a\x2f\xda\x7b\xe0\x20\x54"
3972                           "\x1f\x8d\x85\x79\x0b\x7b\x5e\x75"
3973                           "\xb9\x07\x67\xcc\xc8\xe7\x21\x15"
3974                           "\xa7\xc8\x98\xff\x4b\x80\x1c\x12"
3975                           "\xa8\x54\xe1\x38\x52\xe6\x74\x81"
3976                           "\x97\x47\xa1\x41\x0e\xc0\x50\xe3"
3977                           "\x55\x0e\xc3\xa7\x70\x77\xce\x07"
3978                           "\xed\x8c\x88\xe6\xa1\x5b\x14\xec"
3979                           "\xe6\xde\x06\x6d\x74\xc5\xd9\xfa"
3980                           "\xe5\x2f\x5a\xff\xc8\x05\xee\x27"
3981                           "\x35\x61\xbf\x0b\x19\x78\x9b\xd2"
3982                           "\x04\xc7\x05\xb1\x79\xb4\xff\x5f"
3983                           "\xf3\xea\x67\x52\x78\xc2\xce\x70"
3984                           "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97"
3985                           "\x37\x30\xe1\x91\x8d\xb3\x2a\xff",
3986                 .rlen   = 512,
3987         },
3988 };
3989
3990 static struct cipher_testvec tf_xts_dec_tv_template[] = {
3991         /* Generated from AES-XTS test vectors */
3992         /* same as enc vectors with input and result reversed */
3993         {
3994                 .key    = "\x00\x00\x00\x00\x00\x00\x00\x00"
3995                           "\x00\x00\x00\x00\x00\x00\x00\x00"
3996                           "\x00\x00\x00\x00\x00\x00\x00\x00"
3997                           "\x00\x00\x00\x00\x00\x00\x00\x00",
3998                 .klen   = 32,
3999                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
4000                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4001                 .input  = "\x4b\xc9\x44\x4a\x11\xa3\xef\xac"
4002                           "\x30\x74\xe4\x44\x52\x77\x97\x43"
4003                           "\xa7\x60\xb2\x45\x2e\xf9\x00\x90"
4004                           "\x9f\xaa\xfd\x89\x6e\x9d\x4a\xe0",
4005                 .ilen   = 32,
4006                 .result = "\x00\x00\x00\x00\x00\x00\x00\x00"
4007                           "\x00\x00\x00\x00\x00\x00\x00\x00"
4008                           "\x00\x00\x00\x00\x00\x00\x00\x00"
4009                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4010                 .rlen   = 32,
4011         }, {
4012                 .key    = "\x11\x11\x11\x11\x11\x11\x11\x11"
4013                           "\x11\x11\x11\x11\x11\x11\x11\x11"
4014                           "\x22\x22\x22\x22\x22\x22\x22\x22"
4015                           "\x22\x22\x22\x22\x22\x22\x22\x22",
4016                 .klen   = 32,
4017                 .iv     = "\x33\x33\x33\x33\x33\x00\x00\x00"
4018                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4019                 .input  = "\x57\x0e\x8f\xe5\x2a\x35\x61\x4f"
4020                           "\x32\xd3\xbd\x36\x05\x15\x44\x2c"
4021                           "\x58\x06\xf7\xf8\x00\xa8\xb6\xd5"
4022                           "\xc6\x28\x92\xdb\xd8\x34\xa2\xe9",
4023                 .ilen   = 32,
4024                 .result = "\x44\x44\x44\x44\x44\x44\x44\x44"
4025                           "\x44\x44\x44\x44\x44\x44\x44\x44"
4026                           "\x44\x44\x44\x44\x44\x44\x44\x44"
4027                           "\x44\x44\x44\x44\x44\x44\x44\x44",
4028                 .rlen   = 32,
4029         }, {
4030                 .key    = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
4031                           "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
4032                           "\x22\x22\x22\x22\x22\x22\x22\x22"
4033                           "\x22\x22\x22\x22\x22\x22\x22\x22",
4034                 .klen   = 32,
4035                 .iv     = "\x33\x33\x33\x33\x33\x00\x00\x00"
4036                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4037                 .input  = "\x96\x45\x8f\x8d\x7a\x75\xb1\xde"
4038                           "\x40\x0c\x89\x56\xf6\x4d\xa7\x07"
4039                           "\x38\xbb\x5b\xe9\xcd\x84\xae\xb2"
4040                           "\x7b\x6a\x62\xf4\x8c\xb5\x37\xea",
4041                 .ilen   = 32,
4042                 .result = "\x44\x44\x44\x44\x44\x44\x44\x44"
4043                           "\x44\x44\x44\x44\x44\x44\x44\x44"
4044                           "\x44\x44\x44\x44\x44\x44\x44\x44"
4045                           "\x44\x44\x44\x44\x44\x44\x44\x44",
4046                 .rlen   = 32,
4047         }, {
4048                 .key    = "\x27\x18\x28\x18\x28\x45\x90\x45"
4049                           "\x23\x53\x60\x28\x74\x71\x35\x26"
4050                           "\x31\x41\x59\x26\x53\x58\x97\x93"
4051                           "\x23\x84\x62\x64\x33\x83\x27\x95",
4052                 .klen   = 32,
4053                 .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
4054                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4055                 .input  = "\xa9\x78\xae\x1e\xea\xa2\x44\x4c"
4056                           "\xa2\x7a\x64\x1f\xaf\x46\xc1\xe0"
4057                           "\x6c\xb2\xf3\x92\x9a\xd6\x7d\x58"
4058                           "\xb8\x2d\xb9\x5d\x58\x07\x66\x50"
4059                           "\xea\x35\x35\x8c\xb2\x46\x61\x06"
4060                           "\x5d\x65\xfc\x57\x8f\x69\x74\xab"
4061                           "\x8a\x06\x69\xb5\x6c\xda\x66\xc7"
4062                           "\x52\x90\xbb\x8e\x6d\x8b\xb5\xa2"
4063                           "\x78\x1d\xc2\xa9\xc2\x73\x00\xc3"
4064                           "\x32\x36\x7c\x97\x6b\x4e\x8a\x50"
4065                           "\xe4\x91\x83\x96\x8f\xf4\x94\x1a"
4066                           "\xa6\x27\xe1\x33\xcb\x91\xc6\x5f"
4067                           "\x94\x75\xbc\xd7\x3e\x3e\x6f\x9e"
4068                           "\xa9\x31\x80\x5e\xe5\xdb\xc8\x53"
4069                           "\x01\x73\x68\x32\x25\x19\xfa\xfb"
4070                           "\xe4\xcf\xb9\x3e\xa2\xa0\x8f\x31"
4071                           "\xbf\x54\x06\x93\xa8\xb1\x0f\xb6"
4072                           "\x7c\x3c\xde\x6f\x0f\xfb\x0c\x11"
4073                           "\x39\x80\x39\x09\x97\x65\xf2\x83"
4074                           "\xae\xe6\xa1\x6f\x47\xb8\x49\xde"
4075                           "\x99\x36\x20\x7d\x97\x3b\xec\xfa"
4076                           "\xb4\x33\x6e\x7a\xc7\x46\x84\x49"
4077                           "\x91\xcd\xe1\x57\x0d\xed\x40\x08"
4078                           "\x13\xf1\x4e\x3e\xa4\xa4\x5c\xe6"
4079                           "\xd2\x0c\x20\x8f\x3e\xdf\x3f\x47"
4080                           "\x9a\x2f\xde\x6d\x66\xc9\x99\x4a"
4081                           "\x2d\x9e\x9d\x4b\x1a\x27\xa2\x12"
4082                           "\x99\xf0\xf8\xb1\xb6\xf6\x57\xc3"
4083                           "\xca\x1c\xa3\x8e\xed\x39\x28\xb5"
4084                           "\x10\x1b\x4b\x08\x42\x00\x4a\xd3"
4085                           "\xad\x5a\xc6\x8e\xc8\xbb\x95\xc4"
4086                           "\x4b\xaa\xfe\xd5\x42\xa8\xa3\x6d"
4087                           "\x3c\xf3\x34\x91\x2d\xb4\xdd\x20"
4088                           "\x0c\x90\x6d\xa3\x9b\x66\x9d\x24"
4089                           "\x02\xa6\xa9\x3f\x3f\x58\x5d\x47"
4090                           "\x24\x65\x63\x7e\xbd\x8c\xe6\x52"
4091                           "\x7d\xef\x33\x53\x63\xec\xaa\x0b"
4092                           "\x64\x15\xa9\xa6\x1f\x10\x00\x38"
4093                           "\x35\xa8\xe7\xbe\x23\x70\x22\xe0"
4094                           "\xd3\xb9\xe6\xfd\xe6\xaa\x03\x50"
4095                           "\xf3\x3c\x27\x36\x8b\xcc\xfe\x9c"
4096                           "\x9c\xa3\xb3\xe7\x68\x9b\xa2\x71"
4097                           "\xe0\x07\xd9\x1f\x68\x1f\xac\x5e"
4098                           "\x7a\x74\x85\xa9\x6a\x90\xab\x2c"
4099                           "\x38\x51\xbc\x1f\x43\x4a\x56\x1c"
4100                           "\xf8\x47\x03\x4e\x67\xa8\x1f\x99"
4101                           "\x04\x39\x73\x32\xb2\x86\x79\xe7"
4102                           "\x14\x28\x70\xb8\xe2\x7d\x69\x85"
4103                           "\xb6\x0f\xc5\xd0\xd0\x01\x5c\xe6"
4104                           "\x09\x0f\x75\xf7\xb6\x81\xd2\x11"
4105                           "\x20\x9c\xa1\xee\x11\x44\x79\xd0"
4106                           "\xb2\x34\x77\xda\x10\x9a\x6f\x6f"
4107                           "\xef\x7c\xd9\xdc\x35\xb7\x61\xdd"
4108                           "\xf1\xa4\xc6\x1c\xbf\x05\x22\xac"
4109                           "\xfe\x2f\x85\x00\x44\xdf\x33\x16"
4110                           "\x35\xb6\xa3\xd3\x70\xdf\x69\x35"
4111                           "\x6a\xc7\xb4\x99\x45\x27\xc8\x8e"
4112                           "\x5a\x14\x30\xd0\x55\x3e\x4f\x64"
4113                           "\x0d\x38\xe3\xdf\x8b\xa8\x93\x26"
4114                           "\x75\xae\xf6\xb5\x23\x0b\x17\x31"
4115                           "\xbf\x27\xb8\xb5\x94\x31\xa7\x8f"
4116                           "\x43\xc4\x46\x24\x22\x4f\x8f\x7e"
4117                           "\xe5\xf4\x6d\x1e\x0e\x18\x7a\xbb"
4118                           "\xa6\x8f\xfb\x49\x49\xd8\x7e\x5a",
4119                 .ilen   = 512,
4120                 .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
4121                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
4122                           "\x10\x11\x12\x13\x14\x15\x16\x17"
4123                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
4124                           "\x20\x21\x22\x23\x24\x25\x26\x27"
4125                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
4126                           "\x30\x31\x32\x33\x34\x35\x36\x37"
4127                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
4128                           "\x40\x41\x42\x43\x44\x45\x46\x47"
4129                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
4130                           "\x50\x51\x52\x53\x54\x55\x56\x57"
4131                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
4132                           "\x60\x61\x62\x63\x64\x65\x66\x67"
4133                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
4134                           "\x70\x71\x72\x73\x74\x75\x76\x77"
4135                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
4136                           "\x80\x81\x82\x83\x84\x85\x86\x87"
4137                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
4138                           "\x90\x91\x92\x93\x94\x95\x96\x97"
4139                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
4140                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
4141                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
4142                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
4143                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
4144                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
4145                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
4146                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
4147                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
4148                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
4149                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
4150                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
4151                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
4152                           "\x00\x01\x02\x03\x04\x05\x06\x07"
4153                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
4154                           "\x10\x11\x12\x13\x14\x15\x16\x17"
4155                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
4156                           "\x20\x21\x22\x23\x24\x25\x26\x27"
4157                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
4158                           "\x30\x31\x32\x33\x34\x35\x36\x37"
4159                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
4160                           "\x40\x41\x42\x43\x44\x45\x46\x47"
4161                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
4162                           "\x50\x51\x52\x53\x54\x55\x56\x57"
4163                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
4164                           "\x60\x61\x62\x63\x64\x65\x66\x67"
4165                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
4166                           "\x70\x71\x72\x73\x74\x75\x76\x77"
4167                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
4168                           "\x80\x81\x82\x83\x84\x85\x86\x87"
4169                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
4170                           "\x90\x91\x92\x93\x94\x95\x96\x97"
4171                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
4172                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
4173                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
4174                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
4175                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
4176                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
4177                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
4178                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
4179                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
4180                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
4181                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
4182                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
4183                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
4184                 .rlen   = 512,
4185         }, {
4186                 .key    = "\x27\x18\x28\x18\x28\x45\x90\x45"
4187                           "\x23\x53\x60\x28\x74\x71\x35\x26"
4188                           "\x62\x49\x77\x57\x24\x70\x93\x69"
4189                           "\x99\x59\x57\x49\x66\x96\x76\x27"
4190                           "\x31\x41\x59\x26\x53\x58\x97\x93"
4191                           "\x23\x84\x62\x64\x33\x83\x27\x95"
4192                           "\x02\x88\x41\x97\x16\x93\x99\x37"
4193                           "\x51\x05\x82\x09\x74\x94\x45\x92",
4194                 .klen   = 64,
4195                 .iv     = "\xff\x00\x00\x00\x00\x00\x00\x00"
4196                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4197                 .input  = "\xd7\x4b\x93\x7d\x13\xa2\xa2\xe1"
4198                           "\x35\x39\x71\x88\x76\x1e\xc9\xea"
4199                           "\x86\xad\xf3\x14\x48\x3d\x5e\xe9"
4200                           "\xe9\x2d\xb2\x56\x59\x35\x9d\xec"
4201                           "\x84\xfa\x7e\x9d\x6d\x33\x36\x8f"
4202                           "\xce\xf4\xa9\x21\x0b\x5f\x96\xec"
4203                           "\xcb\xf9\x57\x68\x33\x88\x39\xbf"
4204                           "\x2f\xbb\x59\x03\xbd\x66\x8b\x11"
4205                           "\x11\x65\x51\x2e\xb8\x67\x05\xd1"
4206                           "\x27\x11\x5c\xd4\xcc\x97\xc2\xb3"
4207                           "\xa9\x55\xaf\x07\x56\xd1\xdc\xf5"
4208                           "\x85\xdc\x46\xe6\xf0\x24\xeb\x93"
4209                           "\x4d\xf0\x9b\xf5\x73\x1c\xda\x03"
4210                           "\x22\xc8\x3a\x4f\xb4\x19\x91\x09"
4211                           "\x54\x0b\xf6\xfe\x17\x3d\x1a\x53"
4212                           "\x72\x60\x79\xcb\x0e\x32\x8a\x77"
4213                           "\xd5\xed\xdb\x33\xd7\x62\x16\x69"
4214                           "\x63\xe0\xab\xb5\xf6\x9c\x5f\x3d"
4215                           "\x69\x35\x61\x86\xf8\x86\xb9\x89"
4216                           "\x6e\x59\x35\xac\xf6\x6b\x33\xa0"
4217                           "\xea\xef\x96\x62\xd8\xa9\xcf\x56"
4218                           "\xbf\xdb\x8a\xfd\xa1\x82\x77\x73"
4219                           "\x3d\x94\x4a\x49\x42\x6d\x08\x60"
4220                           "\xa1\xea\xab\xb6\x88\x13\x94\xb8"
4221                           "\x51\x98\xdb\x35\x85\xdf\xf6\xb9"
4222                           "\x8f\xcd\xdf\x80\xd3\x40\x2d\x72"
4223                           "\xb8\xb2\x6c\x02\x43\x35\x22\x2a"
4224                           "\x31\xed\xcd\x16\x19\xdf\x62\x0f"
4225                           "\x29\xcf\x87\x04\xec\x02\x4f\xe4"
4226                           "\xa2\xed\x73\xc6\x69\xd3\x7e\x89"
4227                           "\x0b\x76\x10\x7c\xd6\xf9\x6a\x25"
4228                           "\xed\xcc\x60\x5d\x61\x20\xc1\x97"
4229                           "\x56\x91\x57\x28\xbe\x71\x0d\xcd"
4230                           "\xde\xc4\x9e\x55\x91\xbe\xd1\x28"
4231                           "\x9b\x90\xeb\x73\xf3\x68\x51\xc6"
4232                           "\xdf\x82\xcc\xd8\x1f\xce\x5b\x27"
4233                           "\xc0\x60\x5e\x33\xd6\xa7\x20\xea"
4234                           "\xb2\x54\xc7\x5d\x6a\x3b\x67\x47"
4235                           "\xcf\xa0\xe3\xab\x86\xaf\xc1\x42"
4236                           "\xe6\xb0\x23\x4a\xaf\x53\xdf\xa0"
4237                           "\xad\x12\x32\x31\x03\xf7\x21\xbe"
4238                           "\x2d\xd5\x82\x42\xb6\x4a\x3d\xcd"
4239                           "\xd8\x81\x77\xa9\x49\x98\x6c\x09"
4240                           "\xc5\xa3\x61\x12\x62\x85\x6b\xcd"
4241                           "\xb3\xf4\x20\x0c\x41\xc4\x05\x37"
4242                           "\x46\x5f\xeb\x71\x8b\xf1\xaf\x6e"
4243                           "\xba\xf3\x50\x2e\xfe\xa8\x37\xeb"
4244                           "\xe8\x8c\x4f\xa4\x0c\xf1\x31\xc8"
4245                           "\x6e\x71\x4f\xa5\xd7\x97\x73\xe0"
4246                           "\x93\x4a\x2f\xda\x7b\xe0\x20\x54"
4247                           "\x1f\x8d\x85\x79\x0b\x7b\x5e\x75"
4248                           "\xb9\x07\x67\xcc\xc8\xe7\x21\x15"
4249                           "\xa7\xc8\x98\xff\x4b\x80\x1c\x12"
4250                           "\xa8\x54\xe1\x38\x52\xe6\x74\x81"
4251                           "\x97\x47\xa1\x41\x0e\xc0\x50\xe3"
4252                           "\x55\x0e\xc3\xa7\x70\x77\xce\x07"
4253                           "\xed\x8c\x88\xe6\xa1\x5b\x14\xec"
4254                           "\xe6\xde\x06\x6d\x74\xc5\xd9\xfa"
4255                           "\xe5\x2f\x5a\xff\xc8\x05\xee\x27"
4256                           "\x35\x61\xbf\x0b\x19\x78\x9b\xd2"
4257                           "\x04\xc7\x05\xb1\x79\xb4\xff\x5f"
4258                           "\xf3\xea\x67\x52\x78\xc2\xce\x70"
4259                           "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97"
4260                           "\x37\x30\xe1\x91\x8d\xb3\x2a\xff",
4261                 .ilen   = 512,
4262                 .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
4263                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
4264                           "\x10\x11\x12\x13\x14\x15\x16\x17"
4265                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
4266                           "\x20\x21\x22\x23\x24\x25\x26\x27"
4267                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
4268                           "\x30\x31\x32\x33\x34\x35\x36\x37"
4269                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
4270                           "\x40\x41\x42\x43\x44\x45\x46\x47"
4271                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
4272                           "\x50\x51\x52\x53\x54\x55\x56\x57"
4273                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
4274                           "\x60\x61\x62\x63\x64\x65\x66\x67"
4275                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
4276                           "\x70\x71\x72\x73\x74\x75\x76\x77"
4277                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
4278                           "\x80\x81\x82\x83\x84\x85\x86\x87"
4279                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
4280                           "\x90\x91\x92\x93\x94\x95\x96\x97"
4281                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
4282                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
4283                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
4284                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
4285                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
4286                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
4287                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
4288                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
4289                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
4290                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
4291                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
4292                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
4293                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
4294                           "\x00\x01\x02\x03\x04\x05\x06\x07"
4295                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
4296                           "\x10\x11\x12\x13\x14\x15\x16\x17"
4297                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
4298                           "\x20\x21\x22\x23\x24\x25\x26\x27"
4299                           "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
4300                           "\x30\x31\x32\x33\x34\x35\x36\x37"
4301                           "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
4302                           "\x40\x41\x42\x43\x44\x45\x46\x47"
4303                           "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
4304                           "\x50\x51\x52\x53\x54\x55\x56\x57"
4305                           "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
4306                           "\x60\x61\x62\x63\x64\x65\x66\x67"
4307                           "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
4308                           "\x70\x71\x72\x73\x74\x75\x76\x77"
4309                           "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
4310                           "\x80\x81\x82\x83\x84\x85\x86\x87"
4311                           "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
4312                           "\x90\x91\x92\x93\x94\x95\x96\x97"
4313                           "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
4314                           "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
4315                           "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
4316                           "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
4317                           "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
4318                           "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
4319                           "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
4320                           "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
4321                           "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
4322                           "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
4323                           "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
4324                           "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
4325                           "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
4326                 .rlen   = 512,
4327         },
4328 };
4329
4330 /*
4331  * Serpent test vectors.  These are backwards because Serpent writes
4332  * octet sequences in right-to-left mode.
4333  */
4334 #define SERPENT_ENC_TEST_VECTORS        5
4335 #define SERPENT_DEC_TEST_VECTORS        5
4336
4337 #define TNEPRES_ENC_TEST_VECTORS        4
4338 #define TNEPRES_DEC_TEST_VECTORS        4
4339
4340 #define SERPENT_CBC_ENC_TEST_VECTORS    1
4341 #define SERPENT_CBC_DEC_TEST_VECTORS    1
4342
4343 #define SERPENT_CTR_ENC_TEST_VECTORS    2
4344 #define SERPENT_CTR_DEC_TEST_VECTORS    2
4345
4346 #define SERPENT_LRW_ENC_TEST_VECTORS    8
4347 #define SERPENT_LRW_DEC_TEST_VECTORS    8
4348
4349 #define SERPENT_XTS_ENC_TEST_VECTORS    5
4350 #define SERPENT_XTS_DEC_TEST_VECTORS    5
4351
4352 static struct cipher_testvec serpent_enc_tv_template[] = {
4353         {
4354                 .input  = "\x00\x01\x02\x03\x04\x05\x06\x07"
4355                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
4356                 .ilen   = 16,
4357                 .result = "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
4358                           "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
4359                 .rlen   = 16,
4360         }, {
4361                 .key    = "\x00\x01\x02\x03\x04\x05\x06\x07"
4362                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
4363                 .klen   = 16,
4364                 .input  = "\x00\x01\x02\x03\x04\x05\x06\x07"
4365                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
4366                 .ilen   = 16,
4367                 .result = "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
4368                           "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
4369                 .rlen   = 16,
4370         }, {
4371                 .key    = "\x00\x01\x02\x03\x04\x05\x06\x07"
4372                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
4373                           "\x10\x11\x12\x13\x14\x15\x16\x17"
4374                           "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
4375                 .klen   = 32,
4376                 .input  = "\x00\x01\x02\x03\x04\x05\x06\x07"
4377                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
4378                 .ilen   = 16,
4379                 .result = "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
4380                           "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
4381                 .rlen   = 16,
4382         }, {
4383                 .key    = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
4384                 .klen   = 16,
4385                 .input  = zeroed_string,
4386                 .ilen   = 16,
4387                 .result = "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
4388                           "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
4389                 .rlen   = 16,
4390         }, { /* Generated with Crypto++ */
4391                 .key    = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
4392                           "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
4393                           "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
4394                           "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
4395                 .klen   = 32,
4396                 .input  = "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
4397                           "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
4398                           "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
4399                           "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
4400                           "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
4401                           "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
4402                           "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
4403                           "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
4404                           "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
4405                           "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
4406                           "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
4407                           "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
4408                           "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
4409                           "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
4410                           "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
4411                           "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
4412                           "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
4413                           "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
4414                 .ilen   = 144,
4415                 .result = "\xFB\xB0\x5D\xDE\xC0\xFE\xFC\xEB"
4416                           "\xB1\x80\x10\x43\xDE\x62\x70\xBD"
4417                           "\xFA\x8A\x93\xEA\x6B\xF7\xC5\xD7"
4418                           "\x0C\xD1\xBB\x29\x25\x14\x4C\x22"
4419                           "\x77\xA6\x38\x00\xDB\xB9\xE2\x07"
4420                           "\xD1\xAC\x82\xBA\xEA\x67\xAA\x39"
4421                           "\x99\x34\x89\x5B\x54\xE9\x12\x13"
4422                           "\x3B\x04\xE5\x12\x42\xC5\x79\xAB"
4423                           "\x0D\xC7\x3C\x58\x2D\xA3\x98\xF6"
4424                           "\xE4\x61\x9E\x17\x0B\xCE\xE8\xAA"
4425                           "\xB5\x6C\x1A\x3A\x67\x52\x81\x6A"
4426                           "\x04\xFF\x8A\x1B\x96\xFE\xE6\x87"
4427                           "\x3C\xD4\x39\x7D\x36\x9B\x03\xD5"
4428                           "\xB6\xA0\x75\x3C\x83\xE6\x1C\x73"
4429                           "\x9D\x74\x2B\x77\x53\x2D\xE5\xBD"
4430                           "\x69\xDA\x7A\x01\xF5\x6A\x70\x39"
4431                           "\x30\xD4\x2C\xF2\x8E\x06\x4B\x39"
4432                           "\xB3\x12\x1D\xB3\x17\x46\xE6\xD6",
4433                 .rlen   = 144,
4434         },
4435 };
4436
4437 static struct cipher_testvec tnepres_enc_tv_template[] = {
4438         { /* KeySize=128, PT=0, I=1 */
4439                 .input  = "\x00\x00\x00\x00\x00\x00\x00\x00"
4440                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4441                 .key    = "\x80\x00\x00\x00\x00\x00\x00\x00"
4442                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4443                 .klen   = 16,
4444                 .ilen   = 16,
4445                 .result = "\x49\xaf\xbf\xad\x9d\x5a\x34\x05"
4446                           "\x2c\xd8\xff\xa5\x98\x6b\xd2\xdd",
4447                 .rlen   = 16,
4448         }, { /* KeySize=192, PT=0, I=1 */
4449                 .key    = "\x80\x00\x00\x00\x00\x00\x00\x00"
4450                           "\x00\x00\x00\x00\x00\x00\x00\x00"
4451                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4452                 .klen   = 24,
4453                 .input  = "\x00\x00\x00\x00\x00\x00\x00\x00"
4454                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4455                 .ilen   = 16,
4456                 .result = "\xe7\x8e\x54\x02\xc7\x19\x55\x68"
4457                           "\xac\x36\x78\xf7\xa3\xf6\x0c\x66",
4458                 .rlen   = 16,
4459         }, { /* KeySize=256, PT=0, I=1 */
4460                 .key    = "\x80\x00\x00\x00\x00\x00\x00\x00"
4461                           "\x00\x00\x00\x00\x00\x00\x00\x00"
4462                           "\x00\x00\x00\x00\x00\x00\x00\x00"
4463                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4464                 .klen   = 32,
4465                 .input  = "\x00\x00\x00\x00\x00\x00\x00\x00"
4466                           "\x00\x00\x00\x00\x00\x00\x00\x00",
4467                 .ilen   = 16,
4468                 .result = "\xab\xed\x96\xe7\x66\xbf\x28\xcb"
4469                           "\xc0\xeb\xd2\x1a\x82\xef\x08\x19",
4470                 .rlen   = 16,
4471         }, { /* KeySize=256, I=257 */
4472                 .key    = "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18"
4473                           "\x17\x16\x15\x14\x13\x12\x11\x10"
4474                           "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
4475                           "\x07\x06\x05\x04\x03\x02\x01\x00",
4476                 .klen   = 32,
4477                 .input  = "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
4478                           "\x07\x06\x05\x04\x03\x02\x01\x00",
4479                 .ilen   = 16,
4480                 .result = "\x5c\xe7\x1c\x70\xd2\x88\x2e\x5b"
4481                           "\xb8\x32\xe4\x33\xf8\x9f\x26\xde",
4482                 .rlen   = 16,
4483         },
4484 };
4485
4486
4487 static struct cipher_testvec serpent_dec_tv_template[] = {
4488         {
4489                 .input  = "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
4490                           "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
4491                 .ilen   = 16,
4492                 .result = "\x00\x01\x02\x03\x04\x05\x06\x07"
4493                           "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
4494                 .rlen   = 16,
4495         }, {
4496                 .key    = "\x00\x01\x02\x03\x04\x05\x06\x07"