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