aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
blob: dd419d2862043c95001df58853d2799cc135d5dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
/*
 * NET4:	Implementation of BSD Unix domain sockets.
 *
 * Authors:	Alan Cox, <alan@lxorguk.ukuu.org.uk>
 *
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 *
 * Fixes:
 *		Linus Torvalds	:	Assorted bug cures.
 *		Niibe Yutaka	:	async I/O support.
 *		Carsten Paeth	:	PF_UNIX check, address fixes.
 *		Alan Cox	:	Limit size of allocated blocks.
 *		Alan Cox	:	Fixed the stupid socketpair bug.
 *		Alan Cox	:	BSD compatibility fine tuning.
 *		Alan Cox	:	Fixed a bug in connect when interrupted.
 *		Alan Cox	:	Sorted out a proper draft version of
 *					file descriptor passing hacked up from
 *					Mike Shaver's work.
 *		Marty Leisner	:	Fixes to fd passing
 *		Nick Nevin	:	recvmsg bugfix.
 *		Alan Cox	:	Started proper garbage collector
 *		Heiko EiBfeldt	:	Missing verify_area check
 *		Alan Cox	:	Started POSIXisms
 *		Andreas Schwab	:	Replace inode by dentry for proper
 *					reference counting
 *		Kirk Petersen	:	Made this a module
 *	    Christoph Rohland	:	Elegant non-blocking accept/connect algorithm.
 *					Lots of bug fixes.
 *	     Alexey Kuznetosv	:	Repaired (I hope) bugs introduces
 *					by above two patches.
 *	     Andrea Arcangeli	:	If possible we block in connect(2)
 *					if the max backlog of the listen socket
 *					is been reached. This won't break
 *					old apps and it will avoid huge amount
 *					of socks hashed (this for unix_gc()
 *					performances reasons).
 *					Security fix that limits the max
 *					number of socks to 2*max_files and
 *					the number of skb queueable in the
 *					dgram receiver.
 *		Artur Skawina   :	Hash function optimizations
 *	     Alexey Kuznetsov   :	Full scale SMP. Lot of bugs are introduced 8)
 *	      Malcolm Beattie   :	Set peercred for socketpair
 *	     Michal Ostrowski   :       Module initialization cleanup.
 *	     Arnaldo C. Melo	:	Remove MOD_{INC,DEC}_USE_COUNT,
 *	     				the core infrastructure is doing that
 *	     				for all net proto families now (2.5.69+)
 *
 *
 * Known differences from reference BSD that was tested:
 *
 *	[TO FIX]
 *	ECONNREFUSED is not returned from one end of a connected() socket to the
 *		other the moment one end closes.
 *	fstat() doesn't return st_dev=0, and give the blksize as high water mark
 *		and a fake inode identifier (nor the BSD first socket fstat twice bug).
 *	[NOT TO FIX]
 *	accept() returns a path name even if the connecting socket has closed
 *		in the meantime (BSD loses the path and gives up).
 *	accept() returns 0 length path for an unbound connector. BSD returns 16
 *		and a null first byte in the path (but not for gethost/peername - BSD bug ??)
 *	socketpair(...SOCK_RAW..) doesn't panic the kernel.
 *	BSD af_unix apparently has connect forgetting to block properly.
 *		(need to check this with the POSIX spec in detail)
 *
 * Differences from 2.0.0-11-... (ANK)
 *	Bug fixes and improvements.
 *		- client shutdown killed server socket.
 *		- removed all useless cli/sti pairs.
 *
 *	Semantic changes/extensions.
 *		- generic control message passing.
 *		- SCM_CREDENTIALS control message.
 *		- "Abstract" (not FS based) socket bindings.
 *		  Abstract names are sequences of bytes (not zero terminated)
 *		  started by 0, so that this name space does not intersect
 *		  with BSD names.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/dcache.h>
#include <linux/namei.h>
#include <linux/socket.h>
#include <linux/un.h>
#include <linux/fcntl.h>
#include <linux/termios.h>
#include <linux/sockios.h>
#include <linux/net.h>
#include <linux/in.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/tcp_states.h>
#include <net/af_unix.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <net/scm.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/rtnetlink.h>
#include <linux/mount.h>
#include <net/checksum.h>
#include <linux/security.h>

static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
static DEFINE_SPINLOCK(unix_table_lock);
static atomic_long_t unix_nr_socks;

#define unix_sockets_unbound	(&unix_socket_table[UNIX_HASH_SIZE])

#define UNIX_ABSTRACT(sk)	(unix_sk(sk)->addr->hash != UNIX_HASH_SIZE)

#ifdef CONFIG_SECURITY_NETWORK
static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb)
{
	memcpy(UNIXSID(skb), &scm->secid, sizeof(u32));
}

static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb)
{
	scm->secid = *UNIXSID(skb);
}
#else
static inline void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb)
{ }

static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb)
{ }
#endif /* CONFIG_SECURITY_NETWORK */

/*
 *  SMP locking strategy:
 *    hash table is protected with spinlock unix_table_lock
 *    each socket state is protected by separate spin lock.
 */

static inline unsigned unix_hash_fold(__wsum n)
{
	unsigned hash = (__force unsigned)n;
	hash ^= hash>>16;
	hash ^= hash>>8;
	return hash&(UNIX_HASH_SIZE-1);
}

#define unix_peer(sk) (unix_sk(sk)->peer)

static inline int unix_our_peer(struct sock *sk, struct sock *osk)
{
	return unix_peer(osk) == sk;
}

static inline int unix_may_send(struct sock *sk, struct sock *osk)
{
	return unix_peer(osk) == NULL || unix_our_peer(sk, osk);
}

static inline int unix_recvq_full(struct sock const *sk)
{
	return skb_queue_len(&sk->sk_receive_queue) > sk->sk_max_ack_backlog;
}

static struct sock *unix_peer_get(struct sock *s)
{
	struct sock *peer;

	unix_state_lock(s);
	peer = unix_peer(s);
	if (peer)
		sock_hold(peer);
	unix_state_unlock(s);
	return peer;
}

static inline void unix_release_addr(struct unix_address *addr)
{
	if (atomic_dec_and_test(&addr->refcnt))
		kfree(addr);
}

/*
 *	Check unix socket name:
 *		- should be not zero length.
 *	        - if started by not zero, should be NULL terminated (FS object)
 *		- if started by zero, it is abstract name.
 */

static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned *hashp)
{
	if (len <= sizeof(short) || len > sizeof(*sunaddr))
		return -EINVAL;
	if (!sunaddr || sunaddr->sun_family != AF_UNIX)
		return -EINVAL;
	if (sunaddr->sun_path[0]) {
		/*
		 * This may look like an off by one error but it is a bit more
		 * subtle. 108 is the longest valid AF_UNIX path for a binding.
		 * sun_path[108] doesnt as such exist.  However in kernel space
		 * we are guaranteed that it is a valid memory location in our
		 * kernel address buffer.
		 */
		((char *)sunaddr)[len] = 0;
		len = strlen(sunaddr->sun_path)+1+sizeof(short);
		return len;
	}

	*hashp = unix_hash_fold(csum_partial(sunaddr, len, 0));
	return len;
}

static void __unix_remove_socket(struct sock *sk)
{
	sk_del_node_init(sk);
}

static void __unix_insert_socket(struct hlist_head *list, struct sock *sk)
{
	WARN_ON(!sk_unhashed(sk));
	sk_add_node(sk, list);
}

static inline void unix_remove_socket(struct sock *sk)
{
	spin_lock(&unix_table_lock);
	__unix_remove_socket(sk);
	spin_unlock(&unix_table_lock);
}

static inline void unix_insert_socket(struct hlist_head *list, struct sock *sk)
{
	spin_lock(&unix_table_lock);
	__unix_insert_socket(list, sk);
	spin_unlock(&unix_table_lock);
}

static struct sock *__unix_find_socket_byname(struct net *net,
					      struct sockaddr_un *sunname,
					      int len, int type, unsigned hash)
{
	struct sock *s;
	struct hlist_node *node;

	sk_for_each(s, node, &unix_socket_table[hash ^ type]) {
		struct unix_sock *u = unix_sk(s);

		if (!net_eq(sock_net(s), net))
			continue;

		if (u->addr->len == len &&
		    !memcmp(u->addr->name, sunname, len))
			goto found;
	}
	s = NULL;
found:
	return s;
}

static inline struct sock *unix_find_socket_byname(struct net *net,
						   struct sockaddr_un *sunname,
						   int len, int type,
						   unsigned hash)
{
	struct sock *s;

	spin_lock(&unix_table_lock);
	s = __unix_find_socket_byname(net, sunname, len, type, hash);
	if (s)
		sock_hold(s);
	spin_unlock(&unix_table_lock);
	return s;
}

static struct sock *unix_find_socket_byinode(struct inode *i)
{
	struct sock *s;
	struct hlist_node *node;

	spin_lock(&unix_table_lock);
	sk_for_each(s, node,
		    &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) {
		struct dentry *dentry = unix_sk(s)->dentry;

		if (dentry && dentry->d_inode == i) {
			sock_hold(s);
			goto found;
		}
	}
	s = NULL;
found:
	spin_unlock(&unix_table_lock);
	return s;
}

static inline int unix_writable(struct sock *sk)
{
	return (atomic_read(&sk->sk_wmem_alloc) << 2) <= sk->sk_sndbuf;
}

static void unix_write_space(struct sock *sk)
{
	struct socket_wq *wq;

	rcu_read_lock();
	if (unix_writable(sk)) {
		wq = rcu_dereference(sk->sk_wq);
		if (wq_has_sleeper(wq))
			wake_up_interruptible_sync_poll(&wq->wait,
				POLLOUT | POLLWRNORM | POLLWRBAND);
		sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
	}
	rcu_read_unlock();
}

/* When dgram socket disconnects (or changes its peer), we clear its receive
 * queue of packets arrived from previous peer. First, it allows to do
 * flow control based only on wmem_alloc; second, sk connected to peer
 * may receive messages only from that peer. */
static void unix_dgram_disconnected(struct sock *sk, struct sock *other)
{
	if (!skb_queue_empty(&sk->sk_receive_queue)) {
		skb_queue_purge(&sk->sk_receive_queue);
		wake_up_interruptible_all(&unix_sk(sk)->peer_wait);

		/* If one link of bidirectional dgram pipe is disconnected,
		 * we signal error. Messages are lost. Do not make this,
		 * when peer was not connected to us.
		 */
		if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) {
			other->sk_err = ECONNRESET;
			other->sk_error_report(other);
		}
	}
}

static void unix_sock_destructor(struct sock *sk)
{
	struct unix_sock *u = unix_sk(sk);

	skb_queue_purge(&sk->sk_receive_queue);

	WARN_ON(atomic_read(&sk->sk_wmem_alloc));
	WARN_ON(!sk_unhashed(sk));
	WARN_ON(sk->sk_socket);
	if (!sock_flag(sk, SOCK_DEAD)) {
		printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk);
		return;
	}

	if (u->addr)
		unix_release_addr(u->addr);

	atomic_long_dec(&unix_nr_socks);
	local_bh_disable();
	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
	local_bh_enable();
#ifdef UNIX_REFCNT_DEBUG
	printk(KERN_DEBUG "UNIX %p is destroyed, %ld are still alive.\n", sk,
		atomic_long_read(&unix_nr_socks));
#endif
}

static int unix_release_sock(struct sock *sk, int embrion)
{
	struct unix_sock *u = unix_sk(sk);
	struct dentry *dentry;
	struct vfsmount *mnt;
	struct sock *skpair;
	struct sk_buff *skb;
	int state;

	unix_remove_socket(sk);

	/* Clear state */
	unix_state_lock(sk);
	sock_orphan(sk);
	sk->sk_shutdown = SHUTDOWN_MASK;
	dentry	     = u->dentry;
	u->dentry    = NULL;
	mnt	     = u->mnt;
	u->mnt	     = NULL;
	state = sk->sk_state;
	sk->sk_state = TCP_CLOSE;
	unix_state_unlock(sk);

	wake_up_interruptible_all(&u->peer_wait);

	skpair = unix_peer(sk);

	if (skpair != NULL) {
		if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {
			unix_state_lock(skpair);
			/* No more writes */
			skpair->sk_shutdown = SHUTDOWN_MASK;
			if (!skb_queue_empty(&sk->sk_receive_queue) || embrion)
				skpair->sk_err = ECONNRESET;
			unix_state_unlock(skpair);
			skpair->sk_state_change(skpair);
			sk_wake_async(skpair, SOCK_WAKE_WAITD, POLL_HUP);
		}
		sock_put(skpair); /* It may now die */
		unix_peer(sk) = NULL;
	}

	/* Try to flush out this socket. Throw out buffers at least */

	while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
		if (state == TCP_LISTEN)
			unix_release_sock(skb->sk, 1);
		/* passed fds are erased in the kfree_skb hook	      */
		kfree_skb(skb);
	}

	if (dentry) {
		dput(dentry);
		mntput(mnt);
	}

	sock_put(sk);

	/* ---- Socket is dead now and most probably destroyed ---- */

	/*
	 * Fixme: BSD difference: In BSD all sockets connected to use get
	 *	  ECONNRESET and we die on the spot. In Linux we behave
	 *	  like files and pipes do and wait for the last
	 *	  dereference.
	 *
	 * Can't we simply set sock->err?
	 *
	 *	  What the above comment does talk about? --ANK(980817)
	 */

	if (unix_tot_inflight)
		unix_gc();		/* Garbage collect fds */

	return 0;
}

static void init_peercred(struct sock *sk)
{
	put_pid(sk->sk_peer_pid);
	if (sk->sk_peer_cred)
		put_cred(sk->sk_peer_cred);
	sk->sk_peer_pid  = get_pid(task_tgid(current));
	sk->sk_peer_cred = get_current_cred();
}

static void copy_peercred(struct sock *sk, struct sock *peersk)
{
	put_pid(sk->sk_peer_pid);
	if (sk->sk_peer_cred)
		put_cred(sk->sk_peer_cred);
	sk->sk_peer_pid  = get_pid(peersk->sk_peer_pid);
	sk->sk_peer_cred = get_cred(peersk->sk_peer_cred);
}

static int unix_listen(struct socket *sock, int backlog)
{
	int err;
	struct sock *sk = sock->sk;
	struct unix_sock *u = unix_sk(sk);
	struct pid *old_pid = NULL;
	const struct cred *old_cred = NULL;

	err = -EOPNOTSUPP;
	if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET)
		goto out;	/* Only stream/seqpacket sockets accept */
	err = -EINVAL;
	if (!u->addr)
		goto out;	/* No listens on an unbound socket */
	unix_state_lock(sk);
	if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN)
		goto out_unlock;
	if (backlog > sk->sk_max_ack_backlog)
		wake_up_interruptible_all(&u->peer_wait);
	sk->sk_max_ack_backlog	= backlog;
	sk->sk_state		= TCP_LISTEN;
	/* set credentials so connect can copy them */
	init_peercred(sk);
	err = 0;

out_unlock:
	unix_state_unlock(sk);
	put_pid(old_pid);
	if (old_cred)
		put_cred(old_cred);
out:
	return err;
}

static int unix_release(struct socket *);
static int unix_bind(struct socket *, struct sockaddr *, int);
static int unix_stream_connect(struct socket *, struct sockaddr *,
			       int addr_len, int flags);
static int unix_socketpair(struct socket *, struct socket *);
static int unix_accept(struct socket *, struct socket *, int);
static int unix_getname(struct socket *, struct sockaddr *, int *, int);
static unsigned int unix_poll(struct file *, struct socket *, poll_table *);
static unsigned int unix_dgram_poll(struct file *, struct socket *,
				    poll_table *);
static int unix_ioctl(struct socket *, unsigned int, unsigned long);
static int unix_shutdown(struct socket *, int);
static int unix_stream_sendmsg(struct kiocb *, struct socket *,
			       struct msghdr *, size_t);
static int unix_stream_recvmsg(struct kiocb *, struct socket *,
			       struct msghdr *, size_t, int);
static int unix_dgram_sendmsg(struct kiocb *, struct socket *,
			      struct msghdr *, size_t);
static int unix_dgram_recvmsg(struct kiocb *, struct socket *,
			      struct msghdr *, size_t, int);
static int unix_dgram_connect(struct socket *, struct sockaddr *,
			      int, int);
static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *,
				  struct msghdr *, size_t);

static const struct proto_ops unix_stream_ops = {
	.family =	PF_UNIX,
	.owner =	THIS_MODULE,
	.release =	unix_release,
	.bind =		unix_bind,
	.connect =	unix_stream_connect,
	.socketpair =	unix_socketpair,
	.accept =	unix_accept,
	.getname =	unix_getname,
	.poll =		unix_poll,
	.ioctl =	unix_ioctl,
	.listen =	unix_listen,
	.shutdown =	unix_shutdown,
	.setsockopt =	sock_no_setsockopt,
	.getsockopt =	sock_no_getsockopt,
	.sendmsg =	unix_stream_sendmsg,
	.recvmsg =	unix_stream_recvmsg,
	.mmap =		sock_no_mmap,
	.sendpage =	sock_no_sendpage,
};

static const struct proto_ops unix_dgram_ops = {
	.family =	PF_UNIX,
	.owner =	THIS_MODULE,
	.release =	unix_release,
	.bind =		unix_bind,
	.connect =	unix_dgram_connect,
	.socketpair =	unix_socketpair,
	.accept =	sock_no_accept,
	.getname =	unix_getname,
	.poll =		unix_dgram_poll,
	.ioctl =	unix_ioctl,
	.listen =	sock_no_listen,
	.shutdown =	unix_shutdown,
	.setsockopt =	sock_no_setsockopt,
	.getsockopt =	sock_no_getsockopt,
	.sendmsg =	unix_dgram_sendmsg,
	.recvmsg =	unix_dgram_recvmsg,
	.mmap =		sock_no_mmap,
	.sendpage =	sock_no_sendpage,
};

static const struct proto_ops unix_seqpacket_ops = {
	.family =	PF_UNIX,
	.owner =	THIS_MODULE,
	.release =	unix_release,
	.bind =		unix_bind,
	.connect =	unix_stream_connect,
	.socketpair =	unix_socketpair,
	.accept =	unix_accept,
	.getname =	unix_getname,
	.poll =		unix_dgram_poll,
	.ioctl =	unix_ioctl,
	.listen =	unix_listen,
	.shutdown =	unix_shutdown,
	.setsockopt =	sock_no_setsockopt,
	.getsockopt =	sock_no_getsockopt,
	.sendmsg =	unix_seqpacket_sendmsg,
	.recvmsg =	unix_dgram_recvmsg,
	.mmap =		sock_no_mmap,
	.sendpage =	sock_no_sendpage,
};

static struct proto unix_proto = {
	.name			= "UNIX",
	.owner			= THIS_MODULE,
	.obj_size		= sizeof(struct unix_sock),
};

/*
 * AF_UNIX sockets do not interact with hardware, hence they
 * dont trigger interrupts - so it's safe for them to have
 * bh-unsafe locking for their sk_receive_queue.lock. Split off
 * this special lock-class by reinitializing the spinlock key:
 */
static struct lock_class_key af_unix_sk_receive_queue_lock_key;

static struct sock *unix_create1(struct net *net, struct socket *sock)
{
	struct sock *sk = NULL;
	struct unix_sock *u;

	atomic_long_inc(&unix_nr_socks);
	if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files())
		goto out;

	sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto);
	if (!sk)
		goto out;

	sock_init_data(sock, sk);
	lockdep_set_class(&sk->sk_receive_queue.lock,
				&af_unix_sk_receive_queue_lock_key);

	sk->sk_write_space	= unix_write_space;
	sk->sk_max_ack_backlog	= net->unx.sysctl_max_dgram_qlen;
	sk->sk_destruct		= unix_sock_destructor;
	u	  = unix_sk(sk);
	u->dentry = NULL;
	u->mnt	  = NULL;
	spin_lock_init(&u->lock);
	atomic_long_set(&u->inflight, 0);
	INIT_LIST_HEAD(&u->link);
	mutex_init(&u->readlock); /* single task reading lock */
	init_waitqueue_head(&u->peer_wait);
	unix_insert_socket(unix_sockets_unbound, sk);
out:
	if (sk == NULL)
		atomic_long_dec(&unix_nr_socks);
	else {
		local_bh_disable();
		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
		local_bh_enable();
	}
	return sk;
}

static int unix_create(struct net *net, struct socket *sock, int protocol,
		       int kern)
{
	if (protocol && protocol != PF_UNIX)
		return -EPROTONOSUPPORT;

	sock->state = SS_UNCONNECTED;

	switch (sock->type) {
	case SOCK_STREAM:
		sock->ops = &unix_stream_ops;
		break;
		/*
		 *	Believe it or not BSD has AF_UNIX, SOCK_RAW though
		 *	nothing uses it.
		 */
	case SOCK_RAW:
		sock->type = SOCK_DGRAM;
	case SOCK_DGRAM:
		sock->ops = &unix_dgram_ops;
		break;
	case SOCK_SEQPACKET:
		sock->ops = &unix_seqpacket_ops;
		break;
	default:
		return -ESOCKTNOSUPPORT;
	}

	return unix_create1(net, sock) ? 0 : -ENOMEM;
}

static int unix_release(struct socket *sock)
{
	struct sock *sk = sock->sk;

	if (!sk)
		return 0;

	sock->sk = NULL;

	return unix_release_sock(sk, 0);
}

static int unix_autobind(struct socket *sock)
{
	struct sock *sk = sock->sk;
	struct net *net = sock_net(sk);
	struct unix_sock *u = unix_sk(sk);
	static u32 ordernum = 1;
	struct unix_address *addr;
	int err;
	unsigned int retries = 0;

	mutex_lock(&u->readlock);

	err = 0;
	if (u->addr)
		goto out;

	err = -ENOMEM;
	addr = kzalloc(sizeof(*addr) + sizeof(short) + 16, GFP_KERNEL);
	if (!addr)
		goto out;

	addr->name->sun_family = AF_UNIX;
	atomic_set(&addr->refcnt, 1);

retry:
	addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short);
	addr->hash = unix_hash_fold(csum_partial(addr->name, addr->len, 0));

	spin_lock(&unix_table_lock);
	ordernum = (ordernum+1)&0xFFFFF;

	if (__unix_find_socket_byname(net, addr->name, addr->len, sock->type,
				      addr->hash)) {
		spin_unlock(&unix_table_lock);
		/*
		 * __unix_find_socket_byname() may take long time if many names
		 * are already in use.
		 */
		cond_resched();
		/* Give up if all names seems to be in use. */
		if (retries++ == 0xFFFFF) {
			err = -ENOSPC;
			kfree(addr);
			goto out;
		}
		goto retry;
	}
	addr->hash ^= sk->sk_type;

	__unix_remove_socket(sk);
	u->addr = addr;
	__unix_insert_socket(&unix_socket_table[addr->hash], sk);
	spin_unlock(&unix_table_lock);
	err = 0;

out:	mutex_unlock(&u->readlock);
	return err;
}

static struct sock *unix_find_other(struct net *net,
				    struct sockaddr_un *sunname, int len,
				    int type, unsigned hash, int *error)
{
	struct sock *u;
	struct path path;
	int err = 0;

	if (sunname->sun_path[0]) {
		struct inode *inode;
		err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
		if (err)
			goto fail;
		inode = path.dentry->d_inode;
		err = inode_permission(inode, MAY_WRITE);
		if (err)
			goto put_fail;

		err = -ECONNREFUSED;
		if (!S_ISSOCK(inode->i_mode))
			goto put_fail;
		u = unix_find_socket_byinode(inode);
		if (!u)
			goto put_fail;

		if (u->sk_type == type)
			touch_atime(path.mnt, path.dentry);

		path_put(&path);

		err = -EPROTOTYPE;
		if (u->sk_type != type) {
			sock_put(u);
			goto fail;
		}
	} else {
		err = -ECONNREFUSED;
		u = unix_find_socket_byname(net, sunname, len, type, hash);
		if (u) {
			struct dentry *dentry;
			dentry = unix_sk(u)->dentry;
			if (dentry)
				touch_atime(unix_sk(u)->mnt, dentry);
		} else
			goto fail;
	}
	return u;

put_fail:
	path_put(&path);
fail:
	*error = err;
	return NULL;
}


static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
	struct sock *sk = sock->sk;
	struct net *net = sock_net(sk);
	struct unix_sock *u = unix_sk(sk);
	struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
	struct dentry *dentry = NULL;
	struct nameidata nd;
	int err;
	unsigned hash;
	struct unix_address *addr;
	struct hlist_head *list;

	err = -EINVAL;
	if (sunaddr->sun_family != AF_UNIX)
		goto out;

	if (addr_len == sizeof(short)) {
		err = unix_autobind(sock);
		goto out;
	}

	err = unix_mkname(sunaddr, addr_len, &hash);
	if (err < 0)
		goto out;
	addr_len = err;

	mutex_lock(&u->readlock);

	err = -EINVAL;
	if (u->addr)
		goto out_up;

	err = -ENOMEM;
	addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL);
	if (!addr)
		goto out_up;

	memcpy(addr->name, sunaddr, addr_len);
	addr->len = addr_len;
	addr->hash = hash ^ sk->sk_type;
	atomic_set(&addr->refcnt, 1);

	if (sunaddr->sun_path[0]) {
		unsigned int mode;
		err = 0;
		/*
		 * Get the parent directory, calculate the hash for last
		 * component.
		 */
		err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd);
		if (err)
			goto out_mknod_parent;

		dentry = lookup_create(&nd, 0);
		err = PTR_ERR(dentry);
		if (IS_ERR(dentry))
			goto out_mknod_unlock;

		/*
		 * All right, let's create it.
		 */
		mode = S_IFSOCK |
		       (SOCK_INODE(sock)->i_mode & ~current_umask());
		err = mnt_want_write(nd.path.mnt);
		if (err)
			goto out_mknod_dput;
		err = security_path_mknod(&nd.path, dentry, mode, 0);
		if (err)
			goto out_mknod_drop_write;
		err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0);
out_mknod_drop_write:
		mnt_drop_write(nd.path.mnt);
		if (err)
			goto out_mknod_dput;
		mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
		dput(nd.path.dentry);
		nd.path.dentry = dentry;

		addr->hash = UNIX_HASH_SIZE;
	}

	spin_lock(&unix_table_lock);

	if (!sunaddr->sun_path[0]) {
		err = -EADDRINUSE;
		if (__unix_find_socket_byname(net, sunaddr, addr_len,
					      sk->sk_type, hash)) {
			unix_release_addr(addr);
			goto out_unlock;
		}

		list = &unix_socket_table[addr->hash];
	} else {
		list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)];
		u->dentry = nd.path.dentry;
		u->mnt    = nd.path.mnt;
	}

	err = 0;
	__unix_remove_socket(sk);
	u->addr = addr;
	__unix_insert_socket(list, sk);

out_unlock:
	spin_unlock(&unix_table_lock);
out_up:
	mutex_unlock(&u->readlock);
out:
	return err;

out_mknod_dput:
	dput(dentry);
out_mknod_unlock:
	mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
	path_put(&nd.path);
out_mknod_parent:
	if (err == -EEXIST)
		err = -EADDRINUSE;
	unix_release_addr(addr);
	goto out_up;
}

static void unix_state_double_lock(struct sock *sk1, struct sock *sk2)
{
	if (unlikely(sk1 == sk2) || !sk2) {
		unix_state_lock(sk1);
		return;
	}
	if (sk1 < sk2) {
		unix_state_lock(sk1);
		unix_state_lock_nested(sk2);
	} else {
		unix_state_lock(sk2);
		unix_state_lock_nested(sk1);
	}
}

static void unix_state_double_unlock(struct sock *sk1, struct sock *sk2)
{
	if (unlikely(sk1 == sk2) || !sk2) {
		unix_state_unlock(sk1);
		return;
	}
	unix_state_unlock(sk1);
	unix_state_unlock(sk2);
}

static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
			      int alen, int flags)
{
	struct sock *sk = sock->sk;
	struct net *net = sock_net(sk);
	struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
	struct sock *other;
	unsigned hash;
	int err;

	if (addr->sa_family != AF_UNSPEC) {
		err = unix_mkname(sunaddr, alen, &hash);
		if (err < 0)
			goto out;
		alen = err;

		if (test_bit(SOCK_PASSCRED, &sock->flags) &&
		    !unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0)
			goto out;

restart:
		other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
		if (!other)
			goto out;

		unix_state_double_lock(sk, other);

		/* Apparently VFS overslept socket death. Retry. */
		if (sock_flag(other, SOCK_DEAD)) {
			unix_state_double_unlock(sk, other);
			sock_put(other);
			goto restart;
		}

		err = -EPERM;
		if (!unix_may_send(sk, other))
			goto out_unlock;

		err = security_unix_may_send(sk->sk_socket, other->sk_socket);
		if (err)
			goto out_unlock;

	} else {
		/*
		 *	1003.1g breaking connected state with AF_UNSPEC
		 */
		other = NULL;
		unix_state_double_lock(sk, other);
	}

	/*
	 * If it was connected, reconnect.
	 */
	if (unix_peer(sk)) {
		struct sock *old_peer = unix_peer(sk);
		unix_peer(sk) = other;
		unix_state_double_unlock(sk, other);

		if (other != old_peer)
			unix_dgram_disconnected(sk, old_peer);
		sock_put(old_peer);
	} else {
		unix_peer(sk) = other;
		unix_state_double_unlock(sk, other);
	}
	return 0;

out_unlock:
	unix_state_double_unlock(sk, other);
	sock_put(other);
out:
	return err;
}

static long unix_wait_for_peer(struct sock *other, long timeo)
{
	struct unix_sock *u = unix_sk(other);
	int sched;
	DEFINE_WAIT(wait);

	prepare_to_wait_exclusive(&u->peer_wait, &wait, TASK_INTERRUPTIBLE);

	sched = !sock_flag(other, SOCK_DEAD) &&
		!(other->sk_shutdown & RCV_SHUTDOWN) &&
		unix_recvq_full(other);

	unix_state_unlock(other);

	if (sched)
		timeo = schedule_timeout(timeo);

	finish_wait(&u->peer_wait, &wait);
	return timeo;
}

static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
			       int addr_len, int flags)
{
	struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
	struct sock *sk = sock->sk;
	struct net *net = sock_net(sk);
	struct unix_sock *u = unix_sk(sk), *newu, *otheru;
	struct sock *newsk = NULL;
	struct sock *other = NULL;
	struct sk_buff *skb = NULL;
	unsigned hash;
	int st;
	int err;
	long timeo;

	err = unix_mkname(sunaddr, addr_len, &hash);
	if (err < 0)
		goto out;
	addr_len = err;

	if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr &&
	    (err = unix_autobind(sock)) != 0)
		goto out;

	timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);

	/* First of all allocate resources.
	   If we will make it after state is locked,
	   we will have to recheck all again in any case.
	 */

	err = -ENOMEM;

	/* create new sock for complete connection */
	newsk = unix_create1(sock_net(sk), NULL);
	if (newsk == NULL)
		goto out;

	/* Allocate skb for sending to listening sock */
	skb = sock_wmalloc(newsk, 1, 0, GFP_KERNEL);
	if (skb == NULL)
		goto out;

restart:
	/*  Find listening sock. */
	other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash, &err);
	if (!other)
		goto out;

	/* Latch state of peer */
	unix_state_lock(other);

	/* Apparently VFS overslept socket death. Retry. */
	if (sock_flag(other, SOCK_DEAD)) {
		unix_state_unlock(other);
		sock_put(other);
		goto restart;
	}

	err = -ECONNREFUSED;
	if (other->sk_state != TCP_LISTEN)
		goto out_unlock;
	if (other->sk_shutdown & RCV_SHUTDOWN)
		goto out_unlock;

	if (unix_recvq_full(other)) {
		err = -EAGAIN;
		if (!timeo)
			goto out_unlock;

		timeo = unix_wait_for_peer(other, timeo);

		err = sock_intr_errno(timeo);
		if (signal_pending(current))
			goto out;
		sock_put(other);
		goto restart;
	}

	/* Latch our state.

	   It is tricky place. We need to grab write lock and cannot
	   drop lock on peer. It is dangerous because deadlock is
	   possible. Connect to self case and simultaneous
	   attempt to connect are eliminated by checking socket
	   state. other is TCP_LISTEN, if sk is TCP_LISTEN we
	   check this before attempt to grab lock.

	   Well, and we have to recheck the state after socket locked.
	 */
	st = sk->sk_state;

	switch (st) {
	case TCP_CLOSE:
		/* This is ok... continue with connect */
		break;
	case TCP_ESTABLISHED:
		/* Socket is already connected */
		err = -EISCONN;
		goto out_unlock;
	default:
		err = -EINVAL;
		goto out_unlock;
	}

	unix_state_lock_nested(sk);

	if (sk->sk_state != st) {
		unix_state_unlock(sk);
		unix_state_unlock(other);
		sock_put(other);
		goto restart;
	}

	err = security_unix_stream_connect(sk, other, newsk);
	if (err) {
		unix_state_unlock(sk);
		goto out_unlock;
	}

	/* The way is open! Fastly set all the necessary fields... */

	sock_hold(sk);
	unix_peer(newsk)	= sk;
	newsk->sk_state		= TCP_ESTABLISHED;
	newsk->sk_type		= sk->sk_type;
	init_peercred(newsk);
	newu = unix_sk(newsk);
	newsk->sk_wq		= &newu->peer_wq;
	otheru = unix_sk(other);

	/* copy address information from listening to new sock*/
	if (otheru->addr) {
		atomic_inc(&otheru->addr->refcnt);
		newu->addr = otheru->addr;
	}
	if (otheru->dentry) {
		newu->dentry	= dget(otheru->dentry);
		newu->mnt	= mntget(otheru->mnt);
	}

	/* Set credentials */
	copy_peercred(sk, other);

	sock->state	= SS_CONNECTED;
	sk->sk_state	= TCP_ESTABLISHED;
	sock_hold(newsk);

	smp_mb__after_atomic_inc();	/* sock_hold() does an atomic_inc() */
	unix_peer(sk)	= newsk;

	unix_state_unlock(sk);

	/* take ten and and send info to listening sock */
	spin_lock(&other->sk_receive_queue.lock);
	__skb_queue_tail(&other->sk_receive_queue, skb);
	spin_unlock(&other->sk_receive_queue.lock);
	unix_state_unlock(other);
	other->sk_data_ready(other, 0);
	sock_put(other);
	return 0;

out_unlock:
	if (other)
		unix_state_unlock(other);

out:
	kfree_skb(skb);
	if (newsk)
		unix_release_sock(newsk, 0);
	if (other)
		sock_put(other);
	return err;
}

static int unix_socketpair(struct socket *socka, struct socket *sockb)
{
	struct sock *ska = socka->sk, *skb = sockb->sk;

	/* Join our sockets back to back */
	sock_hold(ska);
	sock_hold(skb);
	unix_peer(ska) = skb;
	unix_peer(skb) = ska;
	init_peercred(ska);
	init_peercred(skb);

	if (ska->sk_type != SOCK_DGRAM) {
		ska->sk_state = TCP_ESTABLISHED;
		skb->sk_state = TCP_ESTABLISHED;
		socka->state  = SS_CONNECTED;
		sockb->state  = SS_CONNECTED;
	}
	return 0;
}

static int unix_accept(struct socket *sock, struct socket *newsock, int flags)
{
	struct sock *sk = sock->sk;
	struct sock *tsk;
	struct sk_buff *skb;
	int err;

	err = -EOPNOTSUPP;
	if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET)
		goto out;

	err = -EINVAL;
	if (sk->sk_state != TCP_LISTEN)
		goto out;

	/* If socket state is TCP_LISTEN it cannot change (for now...),
	 * so that no locks are necessary.
	 */

	skb = skb_recv_datagram(sk, 0, flags&O_NONBLOCK, &err);
	if (!skb) {
		/* This means receive shutdown. */
		if (err == 0)
			err = -EINVAL;
		goto out;
	}

	tsk = skb->sk;
	skb_free_datagram(sk, skb);
	wake_up_interruptible(&unix_sk(sk)->peer_wait);

	/* attach accepted sock to socket */
	unix_state_lock(tsk);
	newsock->state = SS_CONNECTED;
	sock_graft(tsk, newsock);
	unix_state_unlock(tsk);
	return 0;

out:
	return err;
}


static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer)
{
	struct sock *sk = sock->sk;
	struct unix_sock *u;
	DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, uaddr);
	int err = 0;

	if (peer) {
		sk = unix_peer_get(sk);

		err = -ENOTCONN;
		if (!sk)
			goto out;
		err = 0;
	} else {
		sock_hold(sk);
	}

	u = unix_sk(sk);
	unix_state_lock(sk);
	if (!u->addr) {
		sunaddr->sun_family = AF_UNIX;
		sunaddr->sun_path[0] = 0;
		*uaddr_len = sizeof(short);
	} else {
		struct unix_address *addr = u->addr;

		*uaddr_len = addr->len;
		memcpy(sunaddr, addr->name, *uaddr_len);
	}
	unix_state_unlock(sk);
	sock_put(sk);
out:
	return err;
}

static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb)
{
	int i;

	scm->fp = UNIXCB(skb).fp;
	UNIXCB(skb).fp = NULL;

	for (i = scm->fp->count-1; i >= 0; i--)
		unix_notinflight(scm->fp->fp[i]);
}

static void unix_destruct_scm(struct sk_buff *skb)
{
	struct scm_cookie scm;
	memset(&scm, 0, sizeof(scm));
	scm.pid  = UNIXCB(skb).pid;
	scm.cred = UNIXCB(skb).cred;
	if (UNIXCB(skb).fp)
		unix_detach_fds(&scm, skb);

	/* Alas, it calls VFS */
	/* So fscking what? fput() had been SMP-safe since the last Summer */
	scm_destroy(&scm);
	sock_wfree(skb);
}

#define MAX_RECURSION_LEVEL 4

static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
{
	int i;
	unsigned char max_level = 0;
	int unix_sock_count = 0;

	for (i = scm->fp->count - 1; i >= 0; i--) {
		struct sock *sk = unix_get_socket(scm->fp->fp[i]);

		if (sk) {
			unix_sock_count++;
			max_level = max(max_level,
					unix_sk(sk)->recursion_level);
		}
	}
	if (unlikely(max_level > MAX_RECURSION_LEVEL))
		return -ETOOMANYREFS;

	/*
	 * Need to duplicate file references for the sake of garbage
	 * collection.  Otherwise a socket in the fps might become a
	 * candidate for GC while the skb is not yet queued.
	 */
	UNIXCB(skb).fp = scm_fp_dup(scm->fp);
	if (!UNIXCB(skb).fp)
		return -ENOMEM;

	if (unix_sock_count) {
		for (i = scm->fp->count - 1; i >= 0; i--)
			unix_inflight(scm->fp->fp[i]);
	}
	return max_level;
}

static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds)
{
	int err = 0;
	UNIXCB(skb).pid  = get_pid(scm->pid);
	UNIXCB(skb).cred = get_cred(scm->cred);
	UNIXCB(skb).fp = NULL;
	if (scm->fp && send_fds)
		err = unix_attach_fds(scm, skb);

	skb->destructor = unix_destruct_scm;
	return err;
}

/*
 *	Send AF_UNIX data.
 */

static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
			      struct msghdr *msg, size_t len)
{
	struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
	struct sock *sk = sock->sk;
	struct net *net = sock_net(sk);
	struct unix_sock *u = unix_sk(sk);
	struct sockaddr_un *sunaddr = msg->msg_name;
	struct sock *other = NULL;
	int namelen = 0; /* fake GCC */
	int err;
	unsigned hash;
	struct sk_buff *skb;
	long timeo;
	struct scm_cookie tmp_scm;
	int max_level;

	if (NULL == siocb->scm)
		siocb->scm = &tmp_scm;
	wait_for_unix_gc();
	err = scm_send(sock, msg, siocb->scm);
	if (err < 0)
		return err;

	err = -EOPNOTSUPP;
	if (msg->msg_flags&MSG_OOB)
		goto out;

	if (msg->msg_namelen) {
		err = unix_mkname(sunaddr, msg->msg_namelen, &hash);
		if (err < 0)
			goto out;
		namelen = err;
	} else {
		sunaddr = NULL;
		err = -ENOTCONN;
		other = unix_peer_get(sk);
		if (!other)
			goto out;
	}

	if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr
	    && (err = unix_autobind(sock)) != 0)
		goto out;

	err = -EMSGSIZE;
	if (len > sk->sk_sndbuf - 32)
		goto out;

	skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err);
	if (skb == NULL)
		goto out;

	err = unix_scm_to_skb(siocb->scm, skb, true);
	if (err < 0)
		goto out_free;
	max_level = err + 1;
	unix_get_secdata(siocb->scm, skb);

	skb_reset_transport_header(skb);
	err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
	if (err)
		goto out_free;

	timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);

restart:
	if (!other) {
		err = -ECONNRESET;
		if (sunaddr == NULL)
			goto out_free;

		other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
					hash, &err);
		if (other == NULL)
			goto out_free;
	}

	unix_state_lock(other);
	err = -EPERM;
	if (!unix_may_send(sk, other))
		goto out_unlock;

	if (sock_flag(other, SOCK_DEAD)) {
		/*
		 *	Check with 1003.1g - what should
		 *	datagram error
		 */
		unix_state_unlock(other);
		sock_put(other);

		err = 0;
		unix_state_lock(sk);
		if (unix_peer(sk) == other) {
			unix_peer(sk) = NULL;
			unix_state_unlock(sk);

			unix_dgram_disconnected(sk, other);
			sock_put(other);
			err = -ECONNREFUSED;
		} else {
			unix_state_unlock(sk);
		}

		other = NULL;
		if (err)
			goto out_free;
		goto restart;
	}

	err = -EPIPE;
	if (other->sk_shutdown & RCV_SHUTDOWN)
		goto out_unlock;

	if (sk->sk_type != SOCK_SEQPACKET) {
		err = security_unix_may_send(sk->sk_socket, other->sk_socket);
		if (err)
			goto out_unlock;
	}

	if (unix_peer(other) != sk && unix_recvq_full(other)) {
		if (!timeo) {
			err = -EAGAIN;
			goto out_unlock;
		}

		timeo = unix_wait_for_peer(other, timeo);

		err = sock_intr_errno(timeo);
		if (signal_pending(current))
			goto out_free;

		goto restart;
	}

	if (sock_flag(other, SOCK_RCVTSTAMP))
		__net_timestamp(skb);
	skb_queue_tail(&other->sk_receive_queue, skb);
	if (max_level > unix_sk(other)->recursion_level)
		unix_sk(other)->recursion_level = max_level;
	unix_state_unlock(other);
	other->sk_data_ready(other, len);
	sock_put(other);
	scm_destroy(siocb->scm);
	return len;

out_unlock:
	unix_state_unlock(other);
out_free:
	kfree_skb(skb);
out:
	if (other)
		sock_put(other);
	scm_destroy(siocb->scm);
	return err;
}


static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
			       struct msghdr *msg, size_t len)
{
	struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
	struct sock *sk = sock->sk;
	struct sock *other = NULL;
	struct sockaddr_un *sunaddr = msg->msg_name;
	int err, size;
	struct sk_buff *skb;
	int sent = 0;
	struct scm_cookie tmp_scm;
	bool fds_sent = false;
	int max_level;

	if (NULL == siocb->scm)
		siocb->scm = &tmp_scm;
	wait_for_unix_gc();
	err = scm_send(sock, msg, siocb->scm);
	if (err < 0)
		return err;

	err = -EOPNOTSUPP;
	if (msg->msg_flags&MSG_OOB)
		goto out_err;

	if (msg->msg_namelen) {
		err = sk->sk_state == TCP_ESTABLISHED ? -EISCONN : -EOPNOTSUPP;
		goto out_err;
	} else {
		sunaddr = NULL;
		err = -ENOTCONN;
		other = unix_peer(sk);
		if (!other)
			goto out_err;
	}

	if (sk->sk_shutdown & SEND_SHUTDOWN)
		goto pipe_err;

	while (sent < len) {
		/*
		 *	Optimisation for the fact that under 0.01% of X
		 *	messages typically need breaking up.
		 */

		size = len-sent;

		/* Keep two messages in the pipe so it schedules better */
		if (size > ((sk->sk_sndbuf >> 1) - 64))
			size = (sk->sk_sndbuf >> 1) - 64;

		if (size > SKB_MAX_ALLOC)
			size = SKB_MAX_ALLOC;

		/*
		 *	Grab a buffer
		 */

		skb = sock_alloc_send_skb(sk, size, msg->msg_flags&MSG_DONTWAIT,
					  &err);

		if (skb == NULL)
			goto out_err;

		/*
		 *	If you pass two values to the sock_alloc_send_skb
		 *	it tries to grab the large buffer with GFP_NOFS
		 *	(which can fail easily), and if it fails grab the
		 *	fallback size buffer which is under a page and will
		 *	succeed. [Alan]
		 */
		size = min_t(int, size, skb_tailroom(skb));


		/* Only send the fds in the first buffer */
		err = unix_scm_to_skb(siocb->scm, skb, !fds_sent);
		if (err < 0) {
			kfree_skb(skb);
			goto out_err;
		}
		max_level = err + 1;
		fds_sent = true;

		err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
		if (err) {
			kfree_skb(skb);
			goto out_err;
		}

		unix_state_lock(other);

		if (sock_flag(other, SOCK_DEAD) ||
		    (other->sk_shutdown & RCV_SHUTDOWN))
			goto pipe_err_free;

		skb_queue_tail(&other->sk_receive_queue, skb);
		if (max_level > unix_sk(other)->recursion_level)
			unix_sk(other)->recursion_level = max_level;
		unix_state_unlock(other);
		other->sk_data_ready(other, size);
		sent += size;
	}

	scm_destroy(siocb->scm);
	siocb->scm = NULL;

	return sent;

pipe_err_free:
	unix_state_unlock(other);
	kfree_skb(skb);
pipe_err:
	if (sent == 0 && !(msg->msg_flags&MSG_NOSIGNAL))
		send_sig(SIGPIPE, current, 0);
	err = -EPIPE;
out_err:
	scm_destroy(siocb->scm);
	siocb->scm = NULL;
	return sent ? : err;
}

static int unix_seqpacket_sendmsg(struct kiocb *kiocb, struct socket *sock,
				  struct msghdr *msg, size_t len)
{
	int err;
	struct sock *sk = sock->sk;

	err = sock_error(sk);
	if (err)
		return err;

	if (sk->sk_state != TCP_ESTABLISHED)
		return -ENOTCONN;

	if (msg->msg_namelen)
		msg->msg_namelen = 0;

	return unix_dgram_sendmsg(kiocb, sock, msg, len);
}

static void unix_copy_addr(struct msghdr *msg, struct sock *sk)
{
	struct unix_sock *u = unix_sk(sk);

	msg->msg_namelen = 0;
	if (u->addr) {
		msg->msg_namelen = u->addr->len;
		memcpy(msg->msg_name, u->addr->name, u->addr->len);
	}
}

static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
			      struct msghdr *msg, size_t size,
			      int flags)
{
	struct sock_iocb *siocb = kiocb_to_siocb(iocb);
	struct scm_cookie tmp_scm;
	struct sock *sk = sock->sk;
	struct unix_sock *u = unix_sk(sk);
	int noblock = flags & MSG_DONTWAIT;
	struct sk_buff *skb;
	int err;

	err = -EOPNOTSUPP;
	if (flags&MSG_OOB)
		goto out;

	msg->msg_namelen = 0;

	mutex_lock(&u->readlock);

	skb = skb_recv_datagram(sk, flags, noblock, &err);
	if (!skb) {
		unix_state_lock(sk);
		/* Signal EOF on disconnected non-blocking SEQPACKET socket. */
		if (sk->sk_type == SOCK_SEQPACKET && err == -EAGAIN &&
		    (sk->sk_shutdown & RCV_SHUTDOWN))
			err = 0;
		unix_state_unlock(sk);
		goto out_unlock;
	}

	wake_up_interruptible_sync_poll(&u->peer_wait,
					POLLOUT | POLLWRNORM | POLLWRBAND);

	if (msg->msg_name)
		unix_copy_addr(msg, skb->sk);

	if (size > skb->len)
		size = skb->len;
	else if (size < skb->len)
		msg->msg_flags |= MSG_TRUNC;

	err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, size);
	if (err)
		goto out_free;

	if (sock_flag(sk, SOCK_RCVTSTAMP))
		__sock_recv_timestamp(msg, sk, skb);

	if (!siocb->scm) {
		siocb->scm = &tmp_scm;
		memset(&tmp_scm, 0, sizeof(tmp_scm));
	}
	scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
	unix_set_secdata(siocb->scm, skb);

	if (!(flags & MSG_PEEK)) {
		if (UNIXCB(skb).fp)
			unix_detach_fds(siocb->scm, skb);
	} else {
		/* It is questionable: on PEEK we could:
		   - do not return fds - good, but too simple 8)
		   - return fds, and do not return them on read (old strategy,
		     apparently wrong)
		   - clone fds (I chose it for now, it is the most universal
		     solution)

		   POSIX 1003.1g does not actually define this clearly
		   at all. POSIX 1003.1g doesn't define a lot of things
		   clearly however!

		*/
		if (UNIXCB(skb).fp)
			siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp);
	}
	err = size;

	scm_recv(sock, msg, siocb->scm, flags);

out_free:
	skb_free_datagram(sk, skb);
out_unlock:
	mutex_unlock(&u->readlock);
out:
	return err;
}

/*
 *	Sleep until data has arrive. But check for races..
 */

static long unix_stream_data_wait(struct sock *sk, long timeo)
{
	DEFINE_WAIT(wait);

	unix_state_lock(sk);

	for (;;) {
		prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);

		if (!skb_queue_empty(&sk->sk_receive_queue) ||
		    sk->sk_err ||
		    (sk->sk_shutdown & RCV_SHUTDOWN) ||
		    signal_pending(current) ||
		    !timeo)
			break;

		set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
		unix_state_unlock(sk);
		timeo = schedule_timeout(timeo);
		unix_state_lock(sk);
		clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
	}

	finish_wait(sk_sleep(sk), &wait);
	unix_state_unlock(sk);
	return timeo;
}



static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
			       struct msghdr *msg, size_t size,
			       int flags)
{
	struct sock_iocb *siocb = kiocb_to_siocb(iocb);
	struct scm_cookie tmp_scm;
	struct sock *sk = sock->sk;
	struct unix_sock *u = unix_sk(sk);
	struct sockaddr_un *sunaddr = msg->msg_name;
	int copied = 0;
	int check_creds = 0;
	int target;
	int err = 0;
	long timeo;

	err = -EINVAL;
	if (sk->sk_state != TCP_ESTABLISHED)
		goto out;

	err = -EOPNOTSUPP;
	if (flags&MSG_OOB)
		goto out;

	target = sock_rcvlowat(sk, flags&MSG_WAITALL, size);
	timeo = sock_rcvtimeo(sk, flags&MSG_DONTWAIT);

	msg->msg_namelen = 0;

	/* Lock the socket to prevent queue disordering
	 * while sleeps in memcpy_tomsg
	 */

	if (!siocb->scm) {
		siocb->scm = &tmp_scm;
		memset(&tmp_scm, 0, sizeof(tmp_scm));
	}

	mutex_lock(&u->readlock);

	do {
		int chunk;
		struct sk_buff *skb;

		unix_state_lock(sk);
		skb = skb_dequeue(&sk->sk_receive_queue);
		if (skb == NULL) {
			unix_sk(sk)->recursion_level = 0;
			if (copied >= target)
				goto unlock;

			/*
			 *	POSIX 1003.1g mandates this order.
			 */

			err = sock_error(sk);
			if (err)
				goto unlock;
			if (sk->sk_shutdown & RCV_SHUTDOWN)
				goto unlock;

			unix_state_unlock(sk);
			err = -EAGAIN;
			if (!timeo)
				break;
			mutex_unlock(&u->readlock);

			timeo = unix_stream_data_wait(sk, timeo);

			if (signal_pending(current)) {
				err = sock_intr_errno(timeo);
				goto out;
			}
			mutex_lock(&u->readlock);
			continue;
 unlock:
			unix_state_unlock(sk);
			break;
		}
		unix_state_unlock(sk);

		if (check_creds) {
			/* Never glue messages from different writers */
			if ((UNIXCB(skb).pid  != siocb->scm->pid) ||
			    (UNIXCB(skb).cred != siocb->scm->cred)) {
				skb_queue_head(&sk->sk_receive_queue, skb);
				break;
			}
		} else {
			/* Copy credentials */
			scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
			check_creds = 1;
		}

		/* Copy address just once */
		if (sunaddr) {
			unix_copy_addr(msg, skb->sk);
			sunaddr = NULL;
		}

		chunk = min_t(unsigned int, skb->len, size);
		if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) {
			skb_queue_head(&sk->sk_receive_queue, skb);
			if (copied == 0)
				copied = -EFAULT;
			break;
		}
		copied += chunk;
		size -= chunk;

		/* Mark read part of skb as used */
		if (!(flags & MSG_PEEK)) {
			skb_pull(skb, chunk);

			if (UNIXCB(skb).fp)
				unix_detach_fds(siocb->scm, skb);

			/* put the skb back if we didn't use it up.. */
			if (skb->len) {
				skb_queue_head(&sk->sk_receive_queue, skb);
				break;
			}

			consume_skb(skb);

			if (siocb->scm->fp)
				break;
		} else {
			/* It is questionable, see note in unix_dgram_recvmsg.
			 */
			if (UNIXCB(skb).fp)
				siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp);

			/* put message back and return */
			skb_queue_head(&sk->sk_receive_queue, skb);
			break;
		}
	} while (size);

	mutex_unlock(&u->readlock);
	scm_recv(sock, msg, siocb->scm, flags);
out:
	return copied ? : err;
}

static int unix_shutdown(struct socket *sock, int mode)
{
	struct sock *sk = sock->sk;
	struct sock *other;

	mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN);

	if (mode) {
		unix_state_lock(sk);
		sk->sk_shutdown |= mode;
		other = unix_peer(sk);
		if (other)
			sock_hold(other);
		unix_state_unlock(sk);
		sk->sk_state_change(sk);

		if (other &&
			(sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET)) {

			int peer_mode = 0;

			if (mode&RCV_SHUTDOWN)
				peer_mode |= SEND_SHUTDOWN;
			if (mode&SEND_SHUTDOWN)
				peer_mode |= RCV_SHUTDOWN;
			unix_state_lock(other);
			other->sk_shutdown |= peer_mode;
			unix_state_unlock(other);
			other->sk_state_change(other);
			if (peer_mode == SHUTDOWN_MASK)
				sk_wake_async(other, SOCK_WAKE_WAITD, POLL_HUP);
			else if (peer_mode & RCV_SHUTDOWN)
				sk_wake_async(other, SOCK_WAKE_WAITD, POLL_IN);
		}
		if (other)
			sock_put(other);
	}
	return 0;
}

static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
	struct sock *sk = sock->sk;
	long amount = 0;
	int err;

	switch (cmd) {
	case SIOCOUTQ:
		amount = sk_wmem_alloc_get(sk);
		err = put_user(amount, (int __user *)arg);
		break;
	case SIOCINQ:
		{
			struct sk_buff *skb;

			if (sk->sk_state == TCP_LISTEN) {
				err = -EINVAL;
				break;
			}

			spin_lock(&sk->sk_receive_queue.lock);
			if (sk->sk_type == SOCK_STREAM ||
			    sk->sk_type == SOCK_SEQPACKET) {
				skb_queue_walk(&sk->sk_receive_queue, skb)
					amount += skb->len;
			} else {
				skb = skb_peek(&sk->sk_receive_queue);
				if (skb)
					amount = skb->len;
			}
			spin_unlock(&sk->sk_receive_queue.lock);
			err = put_user(amount, (int __user *)arg);
			break;
		}

	default:
		err = -ENOIOCTLCMD;
		break;
	}
	return err;
}

static unsigned int unix_poll(struct file *file, struct socket *sock, poll_table *wait)
{
	struct sock *sk = sock->sk;
	unsigned int mask;

	sock_poll_wait(file, sk_sleep(sk), wait);
	mask = 0;

	/* exceptional events? */
	if (sk->sk_err)
		mask |= POLLERR;
	if (sk->sk_shutdown == SHUTDOWN_MASK)
		mask |= POLLHUP;
	if (sk->sk_shutdown & RCV_SHUTDOWN)
		mask |= POLLRDHUP | POLLIN | POLLRDNORM;

	/* readable? */
	if (!skb_queue_empty(&sk->sk_receive_queue))
		mask |= POLLIN | POLLRDNORM;

	/* Connection-based need to check for termination and startup */
	if ((sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) &&
	    sk->sk_state == TCP_CLOSE)
		mask |= POLLHUP;

	/*
	 * we set writable also when the other side has shut down the
	 * connection. This prevents stuck sockets.
	 */
	if (unix_writable(sk))
		mask |= POLLOUT | POLLWRNORM | POLLWRBAND;

	return mask;
}

static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
				    poll_table *wait)
{
	struct sock *sk = sock->sk, *other;
	unsigned int mask, writable;

	sock_poll_wait(file, sk_sleep(sk), wait);
	mask = 0;

	/* exceptional events? */
	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
		mask |= POLLERR;
	if (sk->sk_shutdown & RCV_SHUTDOWN)
		mask |= POLLRDHUP | POLLIN | POLLRDNORM;
	if (sk->sk_shutdown == SHUTDOWN_MASK)
		mask |= POLLHUP;

	/* readable? */
	if (!skb_queue_empty(&sk->sk_receive_queue))
		mask |= POLLIN | POLLRDNORM;

	/* Connection-based need to check for termination and startup */
	if (sk->sk_type == SOCK_SEQPACKET) {
		if (sk->sk_state == TCP_CLOSE)
			mask |= POLLHUP;
		/* connection hasn't started yet? */
		if (sk->sk_state == TCP_SYN_SENT)
			return mask;
	}

	/* No write status requested, avoid expensive OUT tests. */
	if (wait && !(wait->key & (POLLWRBAND | POLLWRNORM | POLLOUT)))
		return mask;

	writable = unix_writable(sk);
	other = unix_peer_get(sk);
	if (other) {
		if (unix_peer(other) != sk) {
			sock_poll_wait(file, &unix_sk(other)->peer_wait, wait);
			if (unix_recvq_full(other))
				writable = 0;
		}
		sock_put(other);
	}

	if (writable)
		mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
	else
		set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);

	return mask;
}

#ifdef CONFIG_PROC_FS
static struct sock *first_unix_socket(int *i)
{
	for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
		if (!hlist_empty(&unix_socket_table[*i]))
			return __sk_head(&unix_socket_table[*i]);
	}
	return NULL;
}

static struct sock *next_unix_socket(int *i, struct sock *s)
{
	struct sock *next = sk_next(s);
	/* More in this chain? */
	if (next)
		return next;
	/* Look for next non-empty chain. */
	for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
		if (!hlist_empty(&unix_socket_table[*i]))
			return __sk_head(&unix_socket_table[*i]);
	}
	return NULL;
}

struct unix_iter_state {
	struct seq_net_private p;
	int i;
};

static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
{
	struct unix_iter_state *iter = seq->private;
	loff_t off = 0;
	struct sock *s;

	for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
		if (sock_net(s) != seq_file_net(seq))
			continue;
		if (off == pos)
			return s;
		++off;
	}
	return NULL;
}

static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
	__acquires(unix_table_lock)
{
	spin_lock(&unix_table_lock);
	return *pos ? unix_seq_idx(seq, *pos - 1) : SEQ_START_TOKEN;
}

static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
	struct unix_iter_state *iter = seq->private;
	struct sock *sk = v;
	++*pos;

	if (v == SEQ_START_TOKEN)
		sk = first_unix_socket(&iter->i);
	else
		sk = next_unix_socket(&iter->i, sk);
	while (sk && (sock_net(sk) != seq_file_net(seq)))
		sk = next_unix_socket(&iter->i, sk);
	return sk;
}

static void unix_seq_stop(struct seq_file *seq, void *v)
	__releases(unix_table_lock)
{
	spin_unlock(&unix_table_lock);
}

static int unix_seq_show(struct seq_file *seq, void *v)
{

	if (v == SEQ_START_TOKEN)
		seq_puts(seq, "Num       RefCount Protocol Flags    Type St "
			 "Inode Path\n");
	else {
		struct sock *s = v;
		struct unix_sock *u = unix_sk(s);
		unix_state_lock(s);

		seq_printf(seq, "%p: %08X %08X %08X %04X %02X %5lu",
			s,
			atomic_read(&s->sk_refcnt),
			0,
			s->sk_state == TCP_LISTEN ? __SO_ACCEPTCON : 0,
			s->sk_type,
			s->sk_socket ?
			(s->sk_state == TCP_ESTABLISHED ? SS_CONNECTED : SS_UNCONNECTED) :
			(s->sk_state == TCP_ESTABLISHED ? SS_CONNECTING : SS_DISCONNECTING),
			sock_i_ino(s));

		if (u->addr) {
			int i, len;
			seq_putc(seq, ' ');

			i = 0;
			len = u->addr->len - sizeof(short);
			if (!UNIX_ABSTRACT(s))
				len--;
			else {
				seq_putc(seq, '@');
				i++;
			}
			for ( ; i < len; i++)
				seq_putc(seq, u->addr->name->sun_path[i]);
		}
		unix_state_unlock(s);
		seq_putc(seq, '\n');
	}

	return 0;
}

static const struct seq_operations unix_seq_ops = {
	.start  = unix_seq_start,
	.next   = unix_seq_next,
	.stop   = unix_seq_stop,
	.show   = unix_seq_show,
};

static int unix_seq_open(struct inode *inode, struct file *file)
{
	return seq_open_net(inode, file, &unix_seq_ops,
			    sizeof(struct unix_iter_state));
}

static const struct file_operations unix_seq_fops = {
	.owner		= THIS_MODULE,
	.open		= unix_seq_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= seq_release_net,
};

#endif

static const struct net_proto_family unix_family_ops = {
	.family = PF_UNIX,
	.create = unix_create,
	.owner	= THIS_MODULE,
};


static int __net_init unix_net_init(struct net *net)
{
	int error = -ENOMEM;

	net->unx.sysctl_max_dgram_qlen = 10;
	if (unix_sysctl_register(net))
		goto out;

#ifdef CONFIG_PROC_FS
	if (!proc_net_fops_create(net, "unix", 0, &unix_seq_fops)) {
		unix_sysctl_unregister(net);
		goto out;
	}
#endif
	error = 0;
out:
	return error;
}

static void __net_exit unix_net_exit(struct net *net)
{
	unix_sysctl_unregister(net);
	proc_net_remove(net, "unix");
}

static struct pernet_operations unix_net_ops = {
	.init = unix_net_init,
	.exit = unix_net_exit,
};

static int __init af_unix_init(void)
{
	int rc = -1;
	struct sk_buff *dummy_skb;

	BUILD_BUG_ON(sizeof(struct unix_skb_parms) > sizeof(dummy_skb->cb));

	rc = proto_register(&unix_proto, 1);
	if (rc != 0) {
		printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
		       __func__);
		goto out;
	}

	sock_register(&unix_family_ops);
	register_pernet_subsys(&unix_net_ops);
out:
	return rc;
}

static void __exit af_unix_exit(void)
{
	sock_unregister(PF_UNIX);
	proto_unregister(&unix_proto);
	unregister_pernet_subsys(&unix_net_ops);
}

/* Earlier than device_initcall() so that other drivers invoking
   request_module() don't end up in a loop when modprobe tries
   to use a UNIX socket. But later than subsys_initcall() because
   we depend on stuff initialised there */
fs_initcall(af_unix_init);
module_exit(af_unix_exit);

MODULE_LICENSE("GPL");
MODULE_ALIAS_NETPROTO(PF_UNIX);
26' href='#n9026'>9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486
/*
 * Algorithm testing framework and tests.
 *
 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
 * Copyright (c) 2007 Nokia Siemens Networks
 * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
 *
 * Updated RFC4106 AES-GCM testing. Some test vectors were taken from
 * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/
 * gcm/gcm-test-vectors.tar.gz
 *     Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
 *              Adrian Hoban <adrian.hoban@intel.com>
 *              Gabriele Paoloni <gabriele.paoloni@intel.com>
 *              Tadeusz Struk (tadeusz.struk@intel.com)
 *     Copyright (c) 2010, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 */
#ifndef _CRYPTO_TESTMGR_H
#define _CRYPTO_TESTMGR_H

#include <linux/netlink.h>
#include <linux/zlib.h>

#include <crypto/compress.h>

#define MAX_DIGEST_SIZE		64
#define MAX_TAP			8

#define MAX_KEYLEN		56
#define MAX_IVLEN		32

struct hash_testvec {
	/* only used with keyed hash algorithms */
	char *key;
	char *plaintext;
	char *digest;
	unsigned char tap[MAX_TAP];
	unsigned char psize;
	unsigned char np;
	unsigned char ksize;
};

struct cipher_testvec {
	char *key;
	char *iv;
	char *input;
	char *result;
	unsigned short tap[MAX_TAP];
	int np;
	unsigned char fail;
	unsigned char wk; /* weak key flag */
	unsigned char klen;
	unsigned short ilen;
	unsigned short rlen;
};

struct aead_testvec {
	char *key;
	char *iv;
	char *input;
	char *assoc;
	char *result;
	unsigned char tap[MAX_TAP];
	unsigned char atap[MAX_TAP];
	int np;
	int anp;
	unsigned char fail;
	unsigned char novrfy;	/* ccm dec verification failure expected */
	unsigned char wk; /* weak key flag */
	unsigned char klen;
	unsigned short ilen;
	unsigned short alen;
	unsigned short rlen;
};

struct cprng_testvec {
	char *key;
	char *dt;
	char *v;
	char *result;
	unsigned char klen;
	unsigned short dtlen;
	unsigned short vlen;
	unsigned short rlen;
	unsigned short loops;
};

static char zeroed_string[48];

/*
 * MD4 test vectors from RFC1320
 */
#define MD4_TEST_VECTORS	7

static struct hash_testvec md4_tv_template [] = {
	{
		.plaintext = "",
		.digest	= "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31"
			  "\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0",
	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46"
			  "\x24\x5e\x05\xfb\xdb\xd6\xfb\x24",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xa4\x48\x01\x7a\xaf\x21\xd8\x52"
			  "\x5f\xc1\x0a\xe8\x7a\xa6\x72\x9d",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\xd9\x13\x0a\x81\x64\x54\x9f\xe8"
			"\x18\x87\x48\x06\xe1\xc7\x01\x4b",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd"
			  "\xee\xa8\xed\x63\xdf\x41\x2d\xa9",
		.np	= 2,
		.tap	= { 13, 13 },
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\x04\x3f\x85\x82\xf2\x41\xdb\x35"
			  "\x1c\xe6\x27\xe1\x53\xe7\xf0\xe4",
	}, {
		.plaintext = "123456789012345678901234567890123456789012345678901234567890123"
			   "45678901234567890",
		.psize	= 80,
		.digest	= "\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19"
			  "\x9c\x3e\x7b\x16\x4f\xcc\x05\x36",
	},
};

/*
 * MD5 test vectors from RFC1321
 */
#define MD5_TEST_VECTORS	7

static struct hash_testvec md5_tv_template[] = {
	{
		.digest	= "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
			  "\xe9\x80\x09\x98\xec\xf8\x42\x7e",
	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
			  "\x31\xc3\x99\xe2\x69\x77\x26\x61",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
			  "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
			  "\x52\x5a\x2f\x31\xaa\xf1\x61\xd0",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
			  "\x7d\xfb\x49\x6c\xca\x67\xe1\x3b",
		.np	= 2,
		.tap	= {13, 13}
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
			  "\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f",
	}, {
		.plaintext = "12345678901234567890123456789012345678901234567890123456789012"
			   "345678901234567890",
		.psize	= 80,
		.digest	= "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
			  "\xac\x49\xda\x2e\x21\x07\xb6\x7a",
	}

};

/*
 * RIPEMD-128 test vectors from ISO/IEC 10118-3:2004(E)
 */
#define RMD128_TEST_VECTORS     10

static struct hash_testvec rmd128_tv_template[] = {
	{
		.digest	= "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e"
			  "\xcb\x61\x0f\x18\xf6\xb3\x8b\x46",
	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7"
			  "\xcf\xc7\x85\xe7\x2f\x57\x8d\x33",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xc1\x4a\x12\x19\x9c\x66\xe4\xba"
			  "\x84\x63\x6b\x0f\x69\x14\x4c\x77",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x9e\x32\x7b\x3d\x6e\x52\x30\x62"
			  "\xaf\xc1\x13\x2d\x7d\xf9\xd1\xb8",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xfd\x2a\xa6\x07\xf7\x1d\xc8\xf5"
			  "\x10\x71\x49\x22\xb3\x71\x83\x4e",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
			     "fghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xd1\xe9\x59\xeb\x17\x9c\x91\x1f"
			  "\xae\xa4\x62\x4c\x60\xc5\xc7\x02",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			     "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x3f\x45\xef\x19\x47\x32\xc2\xdb"
			  "\xb2\xc4\xa2\xc7\x69\x79\x5f\xa3",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighij"
			     "hijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\xa1\xaa\x06\x89\xd0\xfa\xfa\x2d"
			  "\xdc\x22\xe8\x8b\x49\x13\x3a\x06",
		.np	= 2,
		.tap	= { 28, 28 },
	}, {
		.plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
			     "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
			     "lmnopqrsmnopqrstnopqrstu",
		.psize	= 112,
		.digest	= "\xd4\xec\xc9\x13\xe1\xdf\x77\x6b"
			  "\xf4\x8d\xe9\xd5\x5b\x1f\x25\x46",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijk",
		.psize	= 32,
		.digest	= "\x13\xfc\x13\xe8\xef\xff\x34\x7d"
			  "\xe1\x93\xff\x46\xdb\xac\xcf\xd4",
	}
};

/*
 * RIPEMD-160 test vectors from ISO/IEC 10118-3:2004(E)
 */
#define RMD160_TEST_VECTORS     10

static struct hash_testvec rmd160_tv_template[] = {
	{
		.digest	= "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
			  "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31",
	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae"
			  "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04"
			  "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
			  "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb"
			  "\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
			     "fghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed"
			  "\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			     "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb"
			  "\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighij"
			     "hijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05"
			  "\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b",
		.np	= 2,
		.tap	= { 28, 28 },
	}, {
		.plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
			     "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
			     "lmnopqrsmnopqrstnopqrstu",
		.psize	= 112,
		.digest	= "\x6f\x3f\xa3\x9b\x6b\x50\x3c\x38\x4f\x91"
			  "\x9a\x49\xa7\xaa\x5c\x2c\x08\xbd\xfb\x45",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijk",
		.psize	= 32,
		.digest	= "\x94\xc2\x64\x11\x54\x04\xe6\x33\x79\x0d"
			  "\xfc\xc8\x7b\x58\x7d\x36\x77\x06\x7d\x9f",
	}
};

/*
 * RIPEMD-256 test vectors
 */
#define RMD256_TEST_VECTORS     8

static struct hash_testvec rmd256_tv_template[] = {
	{
		.digest	= "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18"
			  "\x77\xfc\x52\xd6\x4d\x30\xe3\x7a"
			  "\x2d\x97\x74\xfb\x1e\x5d\x02\x63"
			  "\x80\xae\x01\x68\xe3\xc5\x52\x2d",
	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9"
			  "\x0a\x91\xba\xb7\x0a\x1e\xba\x0c"
			  "\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf"
			  "\xcd\x88\x3a\x91\x34\x69\x29\x25",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xaf\xbd\x6e\x22\x8b\x9d\x8c\xbb"
			  "\xce\xf5\xca\x2d\x03\xe6\xdb\xa1"
			  "\x0a\xc0\xbc\x7d\xcb\xe4\x68\x0e"
			  "\x1e\x42\xd2\xe9\x75\x45\x9b\x65",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x87\xe9\x71\x75\x9a\x1c\xe4\x7a"
			  "\x51\x4d\x5c\x91\x4c\x39\x2c\x90"
			  "\x18\xc7\xc4\x6b\xc1\x44\x65\x55"
			  "\x4a\xfc\xdf\x54\xa5\x07\x0c\x0e",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\x64\x9d\x30\x34\x75\x1e\xa2\x16"
			  "\x77\x6b\xf9\xa1\x8a\xcc\x81\xbc"
			  "\x78\x96\x11\x8a\x51\x97\x96\x87"
			  "\x82\xdd\x1f\xd9\x7d\x8d\x51\x33",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
			     "fghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\x57\x40\xa4\x08\xac\x16\xb7\x20"
			  "\xb8\x44\x24\xae\x93\x1c\xbb\x1f"
			  "\xe3\x63\xd1\xd0\xbf\x40\x17\xf1"
			  "\xa8\x9f\x7e\xa6\xde\x77\xa0\xb8",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			     "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x06\xfd\xcc\x7a\x40\x95\x48\xaa"
			  "\xf9\x13\x68\xc0\x6a\x62\x75\xb5"
			  "\x53\xe3\xf0\x99\xbf\x0e\xa4\xed"
			  "\xfd\x67\x78\xdf\x89\xa8\x90\xdd",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighij"
			     "hijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x38\x43\x04\x55\x83\xaa\xc6\xc8"
			  "\xc8\xd9\x12\x85\x73\xe7\xa9\x80"
			  "\x9a\xfb\x2a\x0f\x34\xcc\xc3\x6e"
			  "\xa9\xe7\x2f\x16\xf6\x36\x8e\x3f",
		.np	= 2,
		.tap	= { 28, 28 },
	}
};

/*
 * RIPEMD-320 test vectors
 */
#define RMD320_TEST_VECTORS     8

static struct hash_testvec rmd320_tv_template[] = {
	{
		.digest	= "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1"
			  "\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25"
			  "\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e"
			  "\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8",
	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5"
			  "\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57"
			  "\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54"
			  "\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xde\x4c\x01\xb3\x05\x4f\x89\x30\xa7\x9d"
			  "\x09\xae\x73\x8e\x92\x30\x1e\x5a\x17\x08"
			  "\x5b\xef\xfd\xc1\xb8\xd1\x16\x71\x3e\x74"
			  "\xf8\x2f\xa9\x42\xd6\x4c\xdb\xc4\x68\x2d",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x3a\x8e\x28\x50\x2e\xd4\x5d\x42\x2f\x68"
			  "\x84\x4f\x9d\xd3\x16\xe7\xb9\x85\x33\xfa"
			  "\x3f\x2a\x91\xd2\x9f\x84\xd4\x25\xc8\x8d"
			  "\x6b\x4e\xff\x72\x7d\xf6\x6a\x7c\x01\x97",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xca\xbd\xb1\x81\x0b\x92\x47\x0a\x20\x93"
			  "\xaa\x6b\xce\x05\x95\x2c\x28\x34\x8c\xf4"
			  "\x3f\xf6\x08\x41\x97\x51\x66\xbb\x40\xed"
			  "\x23\x40\x04\xb8\x82\x44\x63\xe6\xb0\x09",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
			     "fghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xed\x54\x49\x40\xc8\x6d\x67\xf2\x50\xd2"
			  "\x32\xc3\x0b\x7b\x3e\x57\x70\xe0\xc6\x0c"
			  "\x8c\xb9\xa4\xca\xfe\x3b\x11\x38\x8a\xf9"
			  "\x92\x0e\x1b\x99\x23\x0b\x84\x3c\x86\xa4",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			     "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x55\x78\x88\xaf\x5f\x6d\x8e\xd6\x2a\xb6"
			  "\x69\x45\xc6\xd2\xa0\xa4\x7e\xcd\x53\x41"
			  "\xe9\x15\xeb\x8f\xea\x1d\x05\x24\x95\x5f"
			  "\x82\x5d\xc7\x17\xe4\xa0\x08\xab\x2d\x42",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighij"
			     "hijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\xd0\x34\xa7\x95\x0c\xf7\x22\x02\x1b\xa4"
			  "\xb8\x4d\xf7\x69\xa5\xde\x20\x60\xe2\x59"
			  "\xdf\x4c\x9b\xb4\xa4\x26\x8c\x0e\x93\x5b"
			  "\xbc\x74\x70\xa9\x69\xc9\xd0\x72\xa1\xac",
		.np	= 2,
		.tap	= { 28, 28 },
	}
};

/*
 * SHA1 test vectors  from from FIPS PUB 180-1
 * Long vector from CAVS 5.0
 */
#define SHA1_TEST_VECTORS	3

static struct hash_testvec sha1_tv_template[] = {
	{
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e"
			  "\x25\x71\x78\x50\xc2\x6c\x9c\xd0\xd8\x9d",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x84\x98\x3e\x44\x1c\x3b\xd2\x6e\xba\xae"
			  "\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1",
		.np	= 2,
		.tap	= { 28, 28 }
	}, {
		.plaintext = "\xec\x29\x56\x12\x44\xed\xe7\x06"
			     "\xb6\xeb\x30\xa1\xc3\x71\xd7\x44"
			     "\x50\xa1\x05\xc3\xf9\x73\x5f\x7f"
			     "\xa9\xfe\x38\xcf\x67\xf3\x04\xa5"
			     "\x73\x6a\x10\x6e\x92\xe1\x71\x39"
			     "\xa6\x81\x3b\x1c\x81\xa4\xf3\xd3"
			     "\xfb\x95\x46\xab\x42\x96\xfa\x9f"
			     "\x72\x28\x26\xc0\x66\x86\x9e\xda"
			     "\xcd\x73\xb2\x54\x80\x35\x18\x58"
			     "\x13\xe2\x26\x34\xa9\xda\x44\x00"
			     "\x0d\x95\xa2\x81\xff\x9f\x26\x4e"
			     "\xcc\xe0\xa9\x31\x22\x21\x62\xd0"
			     "\x21\xcc\xa2\x8d\xb5\xf3\xc2\xaa"
			     "\x24\x94\x5a\xb1\xe3\x1c\xb4\x13"
			     "\xae\x29\x81\x0f\xd7\x94\xca\xd5"
			     "\xdf\xaf\x29\xec\x43\xcb\x38\xd1"
			     "\x98\xfe\x4a\xe1\xda\x23\x59\x78"
			     "\x02\x21\x40\x5b\xd6\x71\x2a\x53"
			     "\x05\xda\x4b\x1b\x73\x7f\xce\x7c"
			     "\xd2\x1c\x0e\xb7\x72\x8d\x08\x23"
			     "\x5a\x90\x11",
		.psize	= 163,
		.digest	= "\x97\x01\x11\xc4\xe7\x7b\xcc\x88\xcc\x20"
			  "\x45\x9c\x02\xb6\x9b\x4a\xa8\xf5\x82\x17",
		.np	= 4,
		.tap	= { 63, 64, 31, 5 }
	}
};


/*
 * SHA224 test vectors from from FIPS PUB 180-2
 */
#define SHA224_TEST_VECTORS     2

static struct hash_testvec sha224_tv_template[] = {
	{
		.plaintext = "abc",
		.psize  = 3,
		.digest = "\x23\x09\x7D\x22\x34\x05\xD8\x22"
			  "\x86\x42\xA4\x77\xBD\xA2\x55\xB3"
			  "\x2A\xAD\xBC\xE4\xBD\xA0\xB3\xF7"
			  "\xE3\x6C\x9D\xA7",
	}, {
		.plaintext =
		"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize  = 56,
		.digest = "\x75\x38\x8B\x16\x51\x27\x76\xCC"
			  "\x5D\xBA\x5D\xA1\xFD\x89\x01\x50"
			  "\xB0\xC6\x45\x5C\xB4\xF5\x8B\x19"
			  "\x52\x52\x25\x25",
		.np     = 2,
		.tap    = { 28, 28 }
	}
};

/*
 * SHA256 test vectors from from NIST
 */
#define SHA256_TEST_VECTORS	2

static struct hash_testvec sha256_tv_template[] = {
	{
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xba\x78\x16\xbf\x8f\x01\xcf\xea"
			  "\x41\x41\x40\xde\x5d\xae\x22\x23"
			  "\xb0\x03\x61\xa3\x96\x17\x7a\x9c"
			  "\xb4\x10\xff\x61\xf2\x00\x15\xad",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x24\x8d\x6a\x61\xd2\x06\x38\xb8"
			  "\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
			  "\xa3\x3c\xe4\x59\x64\xff\x21\x67"
			  "\xf6\xec\xed\xd4\x19\xdb\x06\xc1",
		.np	= 2,
		.tap	= { 28, 28 }
	},
};

/*
 * SHA384 test vectors from from NIST and kerneli
 */
#define SHA384_TEST_VECTORS	4

static struct hash_testvec sha384_tv_template[] = {
	{
		.plaintext= "abc",
		.psize	= 3,
		.digest	= "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b"
			  "\xb5\xa0\x3d\x69\x9a\xc6\x50\x07"
			  "\x27\x2c\x32\xab\x0e\xde\xd1\x63"
			  "\x1a\x8b\x60\x5a\x43\xff\x5b\xed"
			  "\x80\x86\x07\x2b\xa1\xe7\xcc\x23"
			  "\x58\xba\xec\xa1\x34\xc8\x25\xa7",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x33\x91\xfd\xdd\xfc\x8d\xc7\x39"
			  "\x37\x07\xa6\x5b\x1b\x47\x09\x39"
			  "\x7c\xf8\xb1\xd1\x62\xaf\x05\xab"
			  "\xfe\x8f\x45\x0d\xe5\xf3\x6b\xc6"
			  "\xb0\x45\x5a\x85\x20\xbc\x4e\x6f"
			  "\x5f\xe9\x5b\x1f\xe3\xc8\x45\x2b",
	}, {
		.plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
			   "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
		.psize	= 112,
		.digest	= "\x09\x33\x0c\x33\xf7\x11\x47\xe8"
			  "\x3d\x19\x2f\xc7\x82\xcd\x1b\x47"
			  "\x53\x11\x1b\x17\x3b\x3b\x05\xd2"
			  "\x2f\xa0\x80\x86\xe3\xb0\xf7\x12"
			  "\xfc\xc7\xc7\x1a\x55\x7e\x2d\xb9"
			  "\x66\xc3\xe9\xfa\x91\x74\x60\x39",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
			   "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
		.psize	= 104,
		.digest	= "\x3d\x20\x89\x73\xab\x35\x08\xdb"
			  "\xbd\x7e\x2c\x28\x62\xba\x29\x0a"
			  "\xd3\x01\x0e\x49\x78\xc1\x98\xdc"
			  "\x4d\x8f\xd0\x14\xe5\x82\x82\x3a"
			  "\x89\xe1\x6f\x9b\x2a\x7b\xbc\x1a"
			  "\xc9\x38\xe2\xd1\x99\xe8\xbe\xa4",
		.np	= 4,
		.tap	= { 26, 26, 26, 26 }
	},
};

/*
 * SHA512 test vectors from from NIST and kerneli
 */
#define SHA512_TEST_VECTORS	4

static struct hash_testvec sha512_tv_template[] = {
	{
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xdd\xaf\x35\xa1\x93\x61\x7a\xba"
			  "\xcc\x41\x73\x49\xae\x20\x41\x31"
			  "\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2"
			  "\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
			  "\x21\x92\x99\x2a\x27\x4f\xc1\xa8"
			  "\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
			  "\x45\x4d\x44\x23\x64\x3c\xe8\x0e"
			  "\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x20\x4a\x8f\xc6\xdd\xa8\x2f\x0a"
			  "\x0c\xed\x7b\xeb\x8e\x08\xa4\x16"
			  "\x57\xc1\x6e\xf4\x68\xb2\x28\xa8"
			  "\x27\x9b\xe3\x31\xa7\x03\xc3\x35"
			  "\x96\xfd\x15\xc1\x3b\x1b\x07\xf9"
			  "\xaa\x1d\x3b\xea\x57\x78\x9c\xa0"
			  "\x31\xad\x85\xc7\xa7\x1d\xd7\x03"
			  "\x54\xec\x63\x12\x38\xca\x34\x45",
	}, {
		.plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
			   "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
		.psize	= 112,
		.digest	= "\x8e\x95\x9b\x75\xda\xe3\x13\xda"
			  "\x8c\xf4\xf7\x28\x14\xfc\x14\x3f"
			  "\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1"
			  "\x72\x99\xae\xad\xb6\x88\x90\x18"
			  "\x50\x1d\x28\x9e\x49\x00\xf7\xe4"
			  "\x33\x1b\x99\xde\xc4\xb5\x43\x3a"
			  "\xc7\xd3\x29\xee\xb6\xdd\x26\x54"
			  "\x5e\x96\xe5\x5b\x87\x4b\xe9\x09",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
			   "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
		.psize	= 104,
		.digest	= "\x93\x0d\x0c\xef\xcb\x30\xff\x11"
			  "\x33\xb6\x89\x81\x21\xf1\xcf\x3d"
			  "\x27\x57\x8a\xfc\xaf\xe8\x67\x7c"
			  "\x52\x57\xcf\x06\x99\x11\xf7\x5d"
			  "\x8f\x58\x31\xb5\x6e\xbf\xda\x67"
			  "\xb2\x78\xe6\x6d\xff\x8b\x84\xfe"
			  "\x2b\x28\x70\xf7\x42\xa5\x80\xd8"
			  "\xed\xb4\x19\x87\x23\x28\x50\xc9",
		.np	= 4,
		.tap	= { 26, 26, 26, 26 }
	},
};


/*
 * WHIRLPOOL test vectors from Whirlpool package
 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
 * submission
 */
#define WP512_TEST_VECTORS	8

static struct hash_testvec wp512_tv_template[] = {
	{
		.plaintext = "",
		.psize	= 0,
		.digest	= "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
			  "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
			  "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
			  "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
			  "\x3E\x83\xBE\x69\x8B\x28\x8F\xEB"
			  "\xCF\x88\xE3\xE0\x3C\x4F\x07\x57"
			  "\xEA\x89\x64\xE5\x9B\x63\xD9\x37"
			  "\x08\xB1\x38\xCC\x42\xA6\x6E\xB3",


	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
			  "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
			  "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
			  "\x73\xC4\x50\x01\xD0\x08\x7B\x42"
			  "\xD1\x1B\xC6\x45\x41\x3A\xEF\xF6"
			  "\x3A\x42\x39\x1A\x39\x14\x5A\x59"
			  "\x1A\x92\x20\x0D\x56\x01\x95\xE5"
			  "\x3B\x47\x85\x84\xFD\xAE\x23\x1A",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
			  "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
			  "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
			  "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C"
			  "\x71\x81\xEE\xBD\xB6\xC5\x7E\x27"
			  "\x7D\x0E\x34\x95\x71\x14\xCB\xD6"
			  "\xC7\x97\xFC\x9D\x95\xD8\xB5\x82"
			  "\xD2\x25\x29\x20\x76\xD4\xEE\xF5",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
			  "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
			  "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
			  "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B"
			  "\x84\x21\x55\x76\x59\xEF\x55\xC1"
			  "\x06\xB4\xB5\x2A\xC5\xA4\xAA\xA6"
			  "\x92\xED\x92\x00\x52\x83\x8F\x33"
			  "\x62\xE8\x6D\xBD\x37\xA8\x90\x3E",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
			  "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
			  "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
			  "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B"
			  "\x08\xBF\x2A\x92\x51\xC3\x0B\x6A"
			  "\x0B\x8A\xAE\x86\x17\x7A\xB4\xA6"
			  "\xF6\x8F\x67\x3E\x72\x07\x86\x5D"
			  "\x5D\x98\x19\xA3\xDB\xA4\xEB\x3B",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			   "abcdefghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
			  "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
			  "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
			  "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E"
			  "\x08\xEB\xA2\x66\x29\x12\x9D\x8F"
			  "\xB7\xCB\x57\x21\x1B\x92\x81\xA6"
			  "\x55\x17\xCC\x87\x9D\x7B\x96\x21"
			  "\x42\xC6\x5F\x5A\x7A\xF0\x14\x67",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			   "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
			  "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
			  "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
			  "\x54\x9C\x4A\xFA\xDB\x60\x14\x29"
			  "\x4D\x5B\xD8\xDF\x2A\x6C\x44\xE5"
			  "\x38\xCD\x04\x7B\x26\x81\xA5\x1A"
			  "\x2C\x60\x48\x1E\x88\xC5\xA2\x0B"
			  "\x2C\x2A\x80\xCF\x3A\x9A\x08\x3B",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijk",
		.psize	= 32,
		.digest	= "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
			  "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
			  "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
			  "\x07\xC5\x62\xF9\x88\xE9\x5C\x69"
			  "\x16\xBD\xC8\x03\x1B\xC5\xBE\x1B"
			  "\x7B\x94\x76\x39\xFE\x05\x0B\x56"
			  "\x93\x9B\xAA\xA0\xAD\xFF\x9A\xE6"
			  "\x74\x5B\x7B\x18\x1C\x3B\xE3\xFD",
	},
};

#define WP384_TEST_VECTORS	8

static struct hash_testvec wp384_tv_template[] = {
	{
		.plaintext = "",
		.psize	= 0,
		.digest	= "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
			  "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
			  "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
			  "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7"
			  "\x3E\x83\xBE\x69\x8B\x28\x8F\xEB"
			  "\xCF\x88\xE3\xE0\x3C\x4F\x07\x57",


	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
			  "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
			  "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
			  "\x73\xC4\x50\x01\xD0\x08\x7B\x42"
			  "\xD1\x1B\xC6\x45\x41\x3A\xEF\xF6"
			  "\x3A\x42\x39\x1A\x39\x14\x5A\x59",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
			  "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
			  "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
			  "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C"
			  "\x71\x81\xEE\xBD\xB6\xC5\x7E\x27"
			  "\x7D\x0E\x34\x95\x71\x14\xCB\xD6",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
			  "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
			  "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
			  "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B"
			  "\x84\x21\x55\x76\x59\xEF\x55\xC1"
			  "\x06\xB4\xB5\x2A\xC5\xA4\xAA\xA6",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
			  "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
			  "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
			  "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B"
			  "\x08\xBF\x2A\x92\x51\xC3\x0B\x6A"
			  "\x0B\x8A\xAE\x86\x17\x7A\xB4\xA6",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			   "abcdefghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
			  "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
			  "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
			  "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E"
			  "\x08\xEB\xA2\x66\x29\x12\x9D\x8F"
			  "\xB7\xCB\x57\x21\x1B\x92\x81\xA6",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			   "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
			  "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
			  "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
			  "\x54\x9C\x4A\xFA\xDB\x60\x14\x29"
			  "\x4D\x5B\xD8\xDF\x2A\x6C\x44\xE5"
			  "\x38\xCD\x04\x7B\x26\x81\xA5\x1A",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijk",
		.psize	= 32,
		.digest	= "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
			  "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
			  "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
			  "\x07\xC5\x62\xF9\x88\xE9\x5C\x69"
			  "\x16\xBD\xC8\x03\x1B\xC5\xBE\x1B"
			  "\x7B\x94\x76\x39\xFE\x05\x0B\x56",
	},
};

#define WP256_TEST_VECTORS	8

static struct hash_testvec wp256_tv_template[] = {
	{
		.plaintext = "",
		.psize	= 0,
		.digest	= "\x19\xFA\x61\xD7\x55\x22\xA4\x66"
			  "\x9B\x44\xE3\x9C\x1D\x2E\x17\x26"
			  "\xC5\x30\x23\x21\x30\xD4\x07\xF8"
			  "\x9A\xFE\xE0\x96\x49\x97\xF7\xA7",


	}, {
		.plaintext = "a",
		.psize	= 1,
		.digest	= "\x8A\xCA\x26\x02\x79\x2A\xEC\x6F"
			  "\x11\xA6\x72\x06\x53\x1F\xB7\xD7"
			  "\xF0\xDF\xF5\x94\x13\x14\x5E\x69"
			  "\x73\xC4\x50\x01\xD0\x08\x7B\x42",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\x4E\x24\x48\xA4\xC6\xF4\x86\xBB"
			  "\x16\xB6\x56\x2C\x73\xB4\x02\x0B"
			  "\xF3\x04\x3E\x3A\x73\x1B\xCE\x72"
			  "\x1A\xE1\xB3\x03\xD9\x7E\x6D\x4C",
	}, {
		.plaintext = "message digest",
		.psize	= 14,
		.digest	= "\x37\x8C\x84\xA4\x12\x6E\x2D\xC6"
			  "\xE5\x6D\xCC\x74\x58\x37\x7A\xAC"
			  "\x83\x8D\x00\x03\x22\x30\xF5\x3C"
			  "\xE1\xF5\x70\x0C\x0F\xFB\x4D\x3B",
	}, {
		.plaintext = "abcdefghijklmnopqrstuvwxyz",
		.psize	= 26,
		.digest	= "\xF1\xD7\x54\x66\x26\x36\xFF\xE9"
			  "\x2C\x82\xEB\xB9\x21\x2A\x48\x4A"
			  "\x8D\x38\x63\x1E\xAD\x42\x38\xF5"
			  "\x44\x2E\xE1\x3B\x80\x54\xE4\x1B",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
			   "abcdefghijklmnopqrstuvwxyz0123456789",
		.psize	= 62,
		.digest	= "\xDC\x37\xE0\x08\xCF\x9E\xE6\x9B"
			  "\xF1\x1F\x00\xED\x9A\xBA\x26\x90"
			  "\x1D\xD7\xC2\x8C\xDE\xC0\x66\xCC"
			  "\x6A\xF4\x2E\x40\xF8\x2F\x3A\x1E",
	}, {
		.plaintext = "1234567890123456789012345678901234567890"
			   "1234567890123456789012345678901234567890",
		.psize	= 80,
		.digest	= "\x46\x6E\xF1\x8B\xAB\xB0\x15\x4D"
			  "\x25\xB9\xD3\x8A\x64\x14\xF5\xC0"
			  "\x87\x84\x37\x2B\xCC\xB2\x04\xD6"
			  "\x54\x9C\x4A\xFA\xDB\x60\x14\x29",
	}, {
		.plaintext = "abcdbcdecdefdefgefghfghighijhijk",
		.psize	= 32,
		.digest	= "\x2A\x98\x7E\xA4\x0F\x91\x70\x61"
			  "\xF5\xD6\xF0\xA0\xE4\x64\x4F\x48"
			  "\x8A\x7A\x5A\x52\xDE\xEE\x65\x62"
			  "\x07\xC5\x62\xF9\x88\xE9\x5C\x69",
	},
};

/*
 * TIGER test vectors from Tiger website
 */
#define TGR192_TEST_VECTORS	6

static struct hash_testvec tgr192_tv_template[] = {
	{
		.plaintext = "",
		.psize	= 0,
		.digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
			  "\x16\x16\x6e\x76\xb1\xbb\x92\x5f"
			  "\xf3\x73\xde\x2d\x49\x58\x4e\x7a",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
			  "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf"
			  "\x93\x5f\x7b\x95\x1c\x13\x29\x51",
	}, {
		.plaintext = "Tiger",
		.psize	= 5,
		.digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
			  "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec"
			  "\x37\x79\x0c\x11\x6f\x9d\x2b\xdf",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
		.psize	= 64,
		.digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
			  "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e"
			  "\xb5\x86\x44\x50\x34\xa5\xa3\x86",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
		.psize	= 64,
		.digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
			  "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9"
			  "\x57\x89\x65\x65\x97\x5f\x91\x97",
	}, {
		.plaintext = "Tiger - A Fast New Hash Function, "
			   "by Ross Anderson and Eli Biham, "
			   "proceedings of Fast Software Encryption 3, "
			   "Cambridge, 1996.",
		.psize  = 125,
		.digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
			  "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24"
			  "\xdd\x68\x15\x1d\x50\x39\x74\xfc",
	},
};

#define TGR160_TEST_VECTORS	6

static struct hash_testvec tgr160_tv_template[] = {
	{
		.plaintext = "",
		.psize	= 0,
		.digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
			  "\x16\x16\x6e\x76\xb1\xbb\x92\x5f"
			  "\xf3\x73\xde\x2d",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
			  "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf"
			  "\x93\x5f\x7b\x95",
	}, {
		.plaintext = "Tiger",
		.psize	= 5,
		.digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
			  "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec"
			  "\x37\x79\x0c\x11",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
		.psize	= 64,
		.digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
			  "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e"
			  "\xb5\x86\x44\x50",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
		.psize	= 64,
		.digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
			  "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9"
			  "\x57\x89\x65\x65",
	}, {
		.plaintext = "Tiger - A Fast New Hash Function, "
			   "by Ross Anderson and Eli Biham, "
			   "proceedings of Fast Software Encryption 3, "
			   "Cambridge, 1996.",
		.psize  = 125,
		.digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
			  "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24"
			  "\xdd\x68\x15\x1d",
	},
};

#define TGR128_TEST_VECTORS	6

static struct hash_testvec tgr128_tv_template[] = {
	{
		.plaintext = "",
		.psize	= 0,
		.digest = "\x24\xf0\x13\x0c\x63\xac\x93\x32"
			  "\x16\x16\x6e\x76\xb1\xbb\x92\x5f",
	}, {
		.plaintext = "abc",
		.psize	= 3,
		.digest = "\xf2\x58\xc1\xe8\x84\x14\xab\x2a"
			  "\x52\x7a\xb5\x41\xff\xc5\xb8\xbf",
	}, {
		.plaintext = "Tiger",
		.psize	= 5,
		.digest = "\x9f\x00\xf5\x99\x07\x23\x00\xdd"
			  "\x27\x6a\xbb\x38\xc8\xeb\x6d\xec",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
		.psize	= 64,
		.digest = "\x87\xfb\x2a\x90\x83\x85\x1c\xf7"
			  "\x47\x0d\x2c\xf8\x10\xe6\xdf\x9e",
	}, {
		.plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
		.psize	= 64,
		.digest = "\x46\x7d\xb8\x08\x63\xeb\xce\x48"
			  "\x8d\xf1\xcd\x12\x61\x65\x5d\xe9",
	}, {
		.plaintext = "Tiger - A Fast New Hash Function, "
			   "by Ross Anderson and Eli Biham, "
			   "proceedings of Fast Software Encryption 3, "
			   "Cambridge, 1996.",
		.psize  = 125,
		.digest = "\x3d\x9a\xeb\x03\xd1\xbd\x1a\x63"
			  "\x57\xb2\x77\x4d\xfd\x6d\x5b\x24",
	},
};

#define GHASH_TEST_VECTORS 1

static struct hash_testvec ghash_tv_template[] =
{
	{

		.key	= "\xdf\xa6\xbf\x4d\xed\x81\xdb\x03\xff\xca\xff\x95\xf8\x30\xf0\x61",
		.ksize	= 16,
		.plaintext = "\x95\x2b\x2a\x56\xa5\x60\x04a\xc0\xb3\x2b\x66\x56\xa0\x5b\x40\xb6",
		.psize	= 16,
		.digest	= "\xda\x53\xeb\x0a\xd2\xc5\x5b\xb6"
			  "\x4f\xc4\x80\x2c\xc3\xfe\xda\x60",
	},
};

/*
 * HMAC-MD5 test vectors from RFC2202
 * (These need to be fixed to not use strlen).
 */
#define HMAC_MD5_TEST_VECTORS	7

static struct hash_testvec hmac_md5_tv_template[] =
{
	{
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
		.ksize	= 16,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\x92\x94\x72\x7a\x36\x38\xbb\x1c"
			  "\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03"
			  "\xea\xa8\x6e\x31\x0a\x5d\xb7\x38",
		.np	= 2,
		.tap	= {14, 14}
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
		.ksize	= 16,
		.plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
		.psize	= 50,
		.digest	= "\x56\xbe\x34\x52\x1d\x14\x4c\x88"
			  "\xdb\xb8\xc7\x33\xf0\xe8\xb3\xf6",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
		.ksize	= 25,
		.plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
		.psize	= 50,
		.digest	= "\x69\x7e\xaf\x0a\xca\x3a\x3a\xea"
			  "\x3a\x75\x16\x47\x46\xff\xaa\x79",
	}, {
		.key	= "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
		.ksize	= 16,
		.plaintext = "Test With Truncation",
		.psize	= 20,
		.digest	= "\x56\x46\x1e\xf2\x34\x2e\xdc\x00"
			  "\xf9\xba\xb9\x95\x69\x0e\xfd\x4c",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
		.psize	= 54,
		.digest	= "\x6b\x1a\xb7\xfe\x4b\xd7\xbf\x8f"
			  "\x0b\x62\xe6\xce\x61\xb9\xd0\xcd",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
			   "Block-Size Data",
		.psize	= 73,
		.digest	= "\x6f\x63\x0f\xad\x67\xcd\xa0\xee"
			  "\x1f\xb1\xf5\x62\xdb\x3a\xa5\x3e",
	},
};

/*
 * HMAC-RIPEMD128 test vectors from RFC2286
 */
#define HMAC_RMD128_TEST_VECTORS	7

static struct hash_testvec hmac_rmd128_tv_template[] = {
	{
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
		.ksize	= 16,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\xfb\xf6\x1f\x94\x92\xaa\x4b\xbf"
			  "\x81\xc1\x72\xe8\x4e\x07\x34\xdb",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\x87\x5f\x82\x88\x62\xb6\xb3\x34"
			  "\xb4\x27\xc5\x5f\x9f\x7f\xf0\x9b",
		.np	= 2,
		.tap	= { 14, 14 },
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
		.ksize	= 16,
		.plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
		.psize	= 50,
		.digest	= "\x09\xf0\xb2\x84\x6d\x2f\x54\x3d"
			  "\xa3\x63\xcb\xec\x8d\x62\xa3\x8d",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
		.ksize	= 25,
		.plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
		.psize	= 50,
		.digest	= "\xbd\xbb\xd7\xcf\x03\xe4\x4b\x5a"
			  "\xa6\x0a\xf8\x15\xbe\x4d\x22\x94",
	}, {
		.key	= "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
		.ksize	= 16,
		.plaintext = "Test With Truncation",
		.psize	= 20,
		.digest	= "\xe7\x98\x08\xf2\x4b\x25\xfd\x03"
			  "\x1c\x15\x5f\x0d\x55\x1d\x9a\x3a",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
		.psize	= 54,
		.digest	= "\xdc\x73\x29\x28\xde\x98\x10\x4a"
			  "\x1f\x59\xd3\x73\xc1\x50\xac\xbb",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
			   "Block-Size Data",
		.psize	= 73,
		.digest	= "\x5c\x6b\xec\x96\x79\x3e\x16\xd4"
			  "\x06\x90\xc2\x37\x63\x5f\x30\xc5",
	},
};

/*
 * HMAC-RIPEMD160 test vectors from RFC2286
 */
#define HMAC_RMD160_TEST_VECTORS	7

static struct hash_testvec hmac_rmd160_tv_template[] = {
	{
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
		.ksize	= 20,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\x24\xcb\x4b\xd6\x7d\x20\xfc\x1a\x5d\x2e"
			  "\xd7\x73\x2d\xcc\x39\x37\x7f\x0a\x56\x68",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\xdd\xa6\xc0\x21\x3a\x48\x5a\x9e\x24\xf4"
			  "\x74\x20\x64\xa7\xf0\x33\xb4\x3c\x40\x69",
		.np	= 2,
		.tap	= { 14, 14 },
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
		.ksize	= 20,
		.plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
		.psize	= 50,
		.digest	= "\xb0\xb1\x05\x36\x0d\xe7\x59\x96\x0a\xb4"
			  "\xf3\x52\x98\xe1\x16\xe2\x95\xd8\xe7\xc1",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
		.ksize	= 25,
		.plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
		.psize	= 50,
		.digest	= "\xd5\xca\x86\x2f\x4d\x21\xd5\xe6\x10\xe1"
			  "\x8b\x4c\xf1\xbe\xb9\x7a\x43\x65\xec\xf4",
	}, {
		.key	= "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
		.ksize	= 20,
		.plaintext = "Test With Truncation",
		.psize	= 20,
		.digest	= "\x76\x19\x69\x39\x78\xf9\x1d\x90\x53\x9a"
			  "\xe7\x86\x50\x0f\xf3\xd8\xe0\x51\x8e\x39",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
		.psize	= 54,
		.digest	= "\x64\x66\xca\x07\xac\x5e\xac\x29\xe1\xbd"
			  "\x52\x3e\x5a\xda\x76\x05\xb7\x91\xfd\x8b",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
			   "Block-Size Data",
		.psize	= 73,
		.digest	= "\x69\xea\x60\x79\x8d\x71\x61\x6c\xce\x5f"
			  "\xd0\x87\x1e\x23\x75\x4c\xd7\x5d\x5a\x0a",
	},
};

/*
 * HMAC-SHA1 test vectors from RFC2202
 */
#define HMAC_SHA1_TEST_VECTORS	7

static struct hash_testvec hmac_sha1_tv_template[] = {
	{
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
		.ksize	= 20,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\xb6\x17\x31\x86\x55\x05\x72\x64"
			  "\xe2\x8b\xc0\xb6\xfb\x37\x8c\x8e\xf1"
			  "\x46\xbe",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74"
			  "\x16\xd5\xf1\x84\xdf\x9c\x25\x9a\x7c\x79",
		.np	= 2,
		.tap	= { 14, 14 }
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
		.ksize	= 20,
		.plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
		.psize	= 50,
		.digest	= "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3"
			  "\x9a\xf4\x8a\xa1\x7b\x4f\x63\xf1\x75\xd3",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
		.ksize	= 25,
		.plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
		.psize	= 50,
		.digest	= "\x4c\x90\x07\xf4\x02\x62\x50\xc6\xbc\x84"
			  "\x14\xf9\xbf\x50\xc8\x6c\x2d\x72\x35\xda",
	}, {
		.key	= "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
		.ksize	= 20,
		.plaintext = "Test With Truncation",
		.psize	= 20,
		.digest	= "\x4c\x1a\x03\x42\x4b\x55\xe0\x7f\xe7\xf2"
			  "\x7b\xe1\xd5\x8b\xb9\x32\x4a\x9a\x5a\x04",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
		.psize	= 54,
		.digest	= "\xaa\x4a\xe5\xe1\x52\x72\xd0\x0e\x95\x70"
			  "\x56\x37\xce\x8a\x3b\x55\xed\x40\x21\x12",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
			   "Block-Size Data",
		.psize	= 73,
		.digest	= "\xe8\xe9\x9d\x0f\x45\x23\x7d\x78\x6d\x6b"
			  "\xba\xa7\x96\x5c\x78\x08\xbb\xff\x1a\x91",
	},
};


/*
 * SHA224 HMAC test vectors from RFC4231
 */
#define HMAC_SHA224_TEST_VECTORS    4

static struct hash_testvec hmac_sha224_tv_template[] = {
	{
		.key    = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			"\x0b\x0b\x0b\x0b",
		.ksize  = 20,
		/*  ("Hi There") */
		.plaintext = "\x48\x69\x20\x54\x68\x65\x72\x65",
		.psize  = 8,
		.digest = "\x89\x6f\xb1\x12\x8a\xbb\xdf\x19"
			"\x68\x32\x10\x7c\xd4\x9d\xf3\x3f"
			"\x47\xb4\xb1\x16\x99\x12\xba\x4f"
			"\x53\x68\x4b\x22",
	}, {
		.key    = "Jefe",
		.ksize  = 4,
		/* ("what do ya want for nothing?") */
		.plaintext = "\x77\x68\x61\x74\x20\x64\x6f\x20"
			"\x79\x61\x20\x77\x61\x6e\x74\x20"
			"\x66\x6f\x72\x20\x6e\x6f\x74\x68"
			"\x69\x6e\x67\x3f",
		.psize  = 28,
		.digest = "\xa3\x0e\x01\x09\x8b\xc6\xdb\xbf"
			"\x45\x69\x0f\x3a\x7e\x9e\x6d\x0f"
			"\x8b\xbe\xa2\xa3\x9e\x61\x48\x00"
			"\x8f\xd0\x5e\x44",
		.np = 4,
		.tap    = { 7, 7, 7, 7 }
	}, {
		.key    = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa",
		.ksize  = 131,
		/* ("Test Using Larger Than Block-Size Key - Hash Key First") */
		.plaintext = "\x54\x65\x73\x74\x20\x55\x73\x69"
			"\x6e\x67\x20\x4c\x61\x72\x67\x65"
			"\x72\x20\x54\x68\x61\x6e\x20\x42"
			"\x6c\x6f\x63\x6b\x2d\x53\x69\x7a"
			"\x65\x20\x4b\x65\x79\x20\x2d\x20"
			"\x48\x61\x73\x68\x20\x4b\x65\x79"
			"\x20\x46\x69\x72\x73\x74",
		.psize  = 54,
		.digest = "\x95\xe9\xa0\xdb\x96\x20\x95\xad"
			"\xae\xbe\x9b\x2d\x6f\x0d\xbc\xe2"
			"\xd4\x99\xf1\x12\xf2\xd2\xb7\x27"
			"\x3f\xa6\x87\x0e",
	}, {
		.key    = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa",
		.ksize  = 131,
		/* ("This is a test using a larger than block-size key and a")
		(" larger than block-size data. The key needs to be")
			(" hashed before being used by the HMAC algorithm.") */
		.plaintext = "\x54\x68\x69\x73\x20\x69\x73\x20"
			"\x61\x20\x74\x65\x73\x74\x20\x75"
			"\x73\x69\x6e\x67\x20\x61\x20\x6c"
			"\x61\x72\x67\x65\x72\x20\x74\x68"
			"\x61\x6e\x20\x62\x6c\x6f\x63\x6b"
			"\x2d\x73\x69\x7a\x65\x20\x6b\x65"
			"\x79\x20\x61\x6e\x64\x20\x61\x20"
			"\x6c\x61\x72\x67\x65\x72\x20\x74"
			"\x68\x61\x6e\x20\x62\x6c\x6f\x63"
			"\x6b\x2d\x73\x69\x7a\x65\x20\x64"
			"\x61\x74\x61\x2e\x20\x54\x68\x65"
			"\x20\x6b\x65\x79\x20\x6e\x65\x65"
			"\x64\x73\x20\x74\x6f\x20\x62\x65"
			"\x20\x68\x61\x73\x68\x65\x64\x20"
			"\x62\x65\x66\x6f\x72\x65\x20\x62"
			"\x65\x69\x6e\x67\x20\x75\x73\x65"
			"\x64\x20\x62\x79\x20\x74\x68\x65"
			"\x20\x48\x4d\x41\x43\x20\x61\x6c"
			"\x67\x6f\x72\x69\x74\x68\x6d\x2e",
		.psize  = 152,
		.digest = "\x3a\x85\x41\x66\xac\x5d\x9f\x02"
			"\x3f\x54\xd5\x17\xd0\xb3\x9d\xbd"
			"\x94\x67\x70\xdb\x9c\x2b\x95\xc9"
			"\xf6\xf5\x65\xd1",
	},
};

/*
 * HMAC-SHA256 test vectors from
 * draft-ietf-ipsec-ciph-sha-256-01.txt
 */
#define HMAC_SHA256_TEST_VECTORS	10

static struct hash_testvec hmac_sha256_tv_template[] = {
	{
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18"
			  "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
		.ksize	= 32,
		.plaintext = "abc",
		.psize	= 3,
		.digest	= "\xa2\x1b\x1f\x5d\x4c\xf4\xf7\x3a"
			  "\x4d\xd9\x39\x75\x0f\x7a\x06\x6a"
			  "\x7f\x98\xcc\x13\x1c\xb1\x6a\x66"
			  "\x92\x75\x90\x21\xcf\xab\x81\x81",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18"
			  "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
		.ksize	= 32,
		.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize	= 56,
		.digest	= "\x10\x4f\xdc\x12\x57\x32\x8f\x08"
			  "\x18\x4b\xa7\x31\x31\xc5\x3c\xae"
			  "\xe6\x98\xe3\x61\x19\x42\x11\x49"
			  "\xea\x8c\x71\x24\x56\x69\x7d\x30",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18"
			  "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
		.ksize	= 32,
		.plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
			   "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
		.psize	= 112,
		.digest	= "\x47\x03\x05\xfc\x7e\x40\xfe\x34"
			  "\xd3\xee\xb3\xe7\x73\xd9\x5a\xab"
			  "\x73\xac\xf0\xfd\x06\x04\x47\xa5"
			  "\xeb\x45\x95\xbf\x33\xa9\xd1\xa3",
	}, {
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			"\x0b\x0b\x0b\x0b\x0b\x0b",
		.ksize	= 32,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\x19\x8a\x60\x7e\xb4\x4b\xfb\xc6"
			  "\x99\x03\xa0\xf1\xcf\x2b\xbd\xc5"
			  "\xba\x0a\xa3\xf3\xd9\xae\x3c\x1c"
			  "\x7a\x3b\x16\x96\xa0\xb6\x8c\xf7",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e"
			  "\x6a\x04\x24\x26\x08\x95\x75\xc7"
			  "\x5a\x00\x3f\x08\x9d\x27\x39\x83"
			  "\x9d\xec\x58\xb9\x64\xec\x38\x43",
		.np	= 2,
		.tap	= { 14, 14 }
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
		.ksize	= 32,
		.plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
			"\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
		.psize	= 50,
		.digest	= "\xcd\xcb\x12\x20\xd1\xec\xcc\xea"
			  "\x91\xe5\x3a\xba\x30\x92\xf9\x62"
			  "\xe5\x49\xfe\x6c\xe9\xed\x7f\xdc"
			  "\x43\x19\x1f\xbd\xe4\x5c\x30\xb0",
	}, {
		.key	= "\x01\x02\x03\x04\x05\x06\x07\x08"
			  "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
			  "\x11\x12\x13\x14\x15\x16\x17\x18"
			  "\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20"
			  "\x21\x22\x23\x24\x25",
		.ksize	= 37,
		.plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
			"\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
		.psize	= 50,
		.digest	= "\xd4\x63\x3c\x17\xf6\xfb\x8d\x74"
			  "\x4c\x66\xde\xe0\xf8\xf0\x74\x55"
			  "\x6e\xc4\xaf\x55\xef\x07\x99\x85"
			  "\x41\x46\x8e\xb4\x9b\xd2\xe9\x17",
	}, {
		.key	= "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
			"\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c"
			"\x0c\x0c\x0c\x0c\x0c\x0c",
		.ksize	= 32,
		.plaintext = "Test With Truncation",
		.psize	= 20,
		.digest	= "\x75\x46\xaf\x01\x84\x1f\xc0\x9b"
			  "\x1a\xb9\xc3\x74\x9a\x5f\x1c\x17"
			  "\xd4\xf5\x89\x66\x8a\x58\x7b\x27"
			  "\x00\xa9\xc9\x7c\x11\x93\xcf\x42",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
		.psize	= 54,
		.digest	= "\x69\x53\x02\x5e\xd9\x6f\x0c\x09"
			  "\xf8\x0a\x96\xf7\x8e\x65\x38\xdb"
			  "\xe2\xe7\xb8\x20\xe3\xdd\x97\x0e"
			  "\x7d\xdd\x39\x09\x1b\x32\x35\x2f",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa",
		.ksize	= 80,
		.plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
			   "One Block-Size Data",
		.psize	= 73,
		.digest	= "\x63\x55\xac\x22\xe8\x90\xd0\xa3"
			  "\xc8\x48\x1a\x5c\xa4\x82\x5b\xc8"
			  "\x84\xd3\xe7\xa1\xff\x98\xa2\xfc"
			  "\x2a\xc7\xd8\xe0\x64\xc3\xb2\xe6",
	},
};

#define XCBC_AES_TEST_VECTORS 6

static struct hash_testvec aes_xcbc128_tv_template[] = {
	{
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = zeroed_string,
		.digest = "\x75\xf0\x25\x1d\x52\x8a\xc0\x1c"
			  "\x45\x73\xdf\xd5\x84\xd7\x9f\x29",
		.psize	= 0,
		.ksize	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = "\x00\x01\x02",
		.digest	= "\x5b\x37\x65\x80\xae\x2f\x19\xaf"
			  "\xe7\x21\x9c\xee\xf1\x72\x75\x6f",
		.psize	= 3,
		.ksize	= 16,
	} , {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
			     "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.digest = "\xd2\xa2\x46\xfa\x34\x9b\x68\xa7"
			  "\x99\x98\xa4\x39\x4f\xf7\xa2\x63",
		.psize	= 16,
		.ksize	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
			     "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			     "\x10\x11\x12\x13",
		.digest = "\x47\xf5\x1b\x45\x64\x96\x62\x15"
			  "\xb8\x98\x5c\x63\x05\x5e\xd3\x08",
		.tap	= { 10, 10 },
		.psize	= 20,
		.np	= 2,
		.ksize	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
			     "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			     "\x10\x11\x12\x13\x14\x15\x16\x17"
			     "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.digest = "\xf5\x4f\x0e\xc8\xd2\xb9\xf3\xd3"
			  "\x68\x07\x73\x4b\xd5\x28\x3f\xd4",
		.psize	= 32,
		.ksize	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = "\x00\x01\x02\x03\x04\x05\x06\x07"
			     "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			     "\x10\x11\x12\x13\x14\x15\x16\x17"
			     "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			     "\x20\x21",
		.digest = "\xbe\xcb\xb3\xbc\xcd\xb5\x18\xa3"
			  "\x06\x77\xd5\x48\x1f\xb6\xb4\xd8",
		.tap	= { 17, 17 },
		.psize	= 34,
		.np	= 2,
		.ksize	= 16,
	}
};

#define VMAC_AES_TEST_VECTORS	8
static char vmac_string1[128] = {'\x01', '\x01', '\x01', '\x01',
				'\x02', '\x03', '\x02', '\x02',
				'\x02', '\x04', '\x01', '\x07',
				'\x04', '\x01', '\x04', '\x03',};
static char vmac_string2[128] = {'a', 'b', 'c',};
static char vmac_string3[128] = {'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				'a', 'b', 'c', 'a', 'b', 'c',
				};

static struct hash_testvec aes_vmac128_tv_template[] = {
	{
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = NULL,
		.digest	= "\x07\x58\x80\x35\x77\xa4\x7b\x54",
		.psize	= 0,
		.ksize	= 16,
	}, {
		.key    = "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = vmac_string1,
		.digest = "\xce\xf5\x3c\xd3\xae\x68\x8c\xa1",
		.psize  = 128,
		.ksize  = 16,
	}, {
		.key    = "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = vmac_string2,
		.digest = "\xc9\x27\xb0\x73\x81\xbd\x14\x2d",
		.psize  = 128,
		.ksize  = 16,
	}, {
		.key    = "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.plaintext = vmac_string3,
		.digest = "\x8d\x1a\x95\x8c\x98\x47\x0b\x19",
		.psize  = 128,
		.ksize  = 16,
	}, {
		.key	= "abcdefghijklmnop",
		.plaintext = NULL,
		.digest	= "\x3b\x89\xa1\x26\x9e\x55\x8f\x84",
		.psize	= 0,
		.ksize	= 16,
	}, {
		.key    = "abcdefghijklmnop",
		.plaintext = vmac_string1,
		.digest = "\xab\x5e\xab\xb0\xf6\x8d\x74\xc2",
		.psize  = 128,
		.ksize  = 16,
	}, {
		.key    = "abcdefghijklmnop",
		.plaintext = vmac_string2,
		.digest = "\x11\x15\x68\x42\x3d\x7b\x09\xdf",
		.psize  = 128,
		.ksize  = 16,
	}, {
		.key    = "abcdefghijklmnop",
		.plaintext = vmac_string3,
		.digest = "\x8b\x32\x8f\xe1\xed\x8f\xfa\xd4",
		.psize  = 128,
		.ksize  = 16,
	},
};

/*
 * SHA384 HMAC test vectors from RFC4231
 */

#define HMAC_SHA384_TEST_VECTORS	4

static struct hash_testvec hmac_sha384_tv_template[] = {
	{
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			  "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			  "\x0b\x0b\x0b\x0b",
		.ksize	= 20,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\xaf\xd0\x39\x44\xd8\x48\x95\x62"
			  "\x6b\x08\x25\xf4\xab\x46\x90\x7f"
			  "\x15\xf9\xda\xdb\xe4\x10\x1e\xc6"
			  "\x82\xaa\x03\x4c\x7c\xeb\xc5\x9c"
			  "\xfa\xea\x9e\xa9\x07\x6e\xde\x7f"
			  "\x4a\xf1\x52\xe8\xb2\xfa\x9c\xb6",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\xaf\x45\xd2\xe3\x76\x48\x40\x31"
			  "\x61\x7f\x78\xd2\xb5\x8a\x6b\x1b"
			  "\x9c\x7e\xf4\x64\xf5\xa0\x1b\x47"
			  "\xe4\x2e\xc3\x73\x63\x22\x44\x5e"
			  "\x8e\x22\x40\xca\x5e\x69\xe2\xc7"
			  "\x8b\x32\x39\xec\xfa\xb2\x16\x49",
		.np	= 4,
		.tap	= { 7, 7, 7, 7 }
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa",
		.ksize	= 131,
		.plaintext = "Test Using Larger Than Block-Siz"
			   "e Key - Hash Key First",
		.psize	= 54,
		.digest	= "\x4e\xce\x08\x44\x85\x81\x3e\x90"
			  "\x88\xd2\xc6\x3a\x04\x1b\xc5\xb4"
			  "\x4f\x9e\xf1\x01\x2a\x2b\x58\x8f"
			  "\x3c\xd1\x1f\x05\x03\x3a\xc4\xc6"
			  "\x0c\x2e\xf6\xab\x40\x30\xfe\x82"
			  "\x96\x24\x8d\xf1\x63\xf4\x49\x52",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa",
		.ksize	= 131,
		.plaintext = "This is a test u"
			   "sing a larger th"
			   "an block-size ke"
			   "y and a larger t"
			   "han block-size d"
			   "ata. The key nee"
			   "ds to be hashed "
			   "before being use"
			   "d by the HMAC al"
			   "gorithm.",
		.psize	= 152,
		.digest	= "\x66\x17\x17\x8e\x94\x1f\x02\x0d"
			  "\x35\x1e\x2f\x25\x4e\x8f\xd3\x2c"
			  "\x60\x24\x20\xfe\xb0\xb8\xfb\x9a"
			  "\xdc\xce\xbb\x82\x46\x1e\x99\xc5"
			  "\xa6\x78\xcc\x31\xe7\x99\x17\x6d"
			  "\x38\x60\xe6\x11\x0c\x46\x52\x3e",
	},
};

/*
 * SHA512 HMAC test vectors from RFC4231
 */

#define HMAC_SHA512_TEST_VECTORS	4

static struct hash_testvec hmac_sha512_tv_template[] = {
	{
		.key	= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			  "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
			  "\x0b\x0b\x0b\x0b",
		.ksize	= 20,
		.plaintext = "Hi There",
		.psize	= 8,
		.digest	= "\x87\xaa\x7c\xde\xa5\xef\x61\x9d"
			  "\x4f\xf0\xb4\x24\x1a\x1d\x6c\xb0"
			  "\x23\x79\xf4\xe2\xce\x4e\xc2\x78"
			  "\x7a\xd0\xb3\x05\x45\xe1\x7c\xde"
			  "\xda\xa8\x33\xb7\xd6\xb8\xa7\x02"
			  "\x03\x8b\x27\x4e\xae\xa3\xf4\xe4"
			  "\xbe\x9d\x91\x4e\xeb\x61\xf1\x70"
			  "\x2e\x69\x6c\x20\x3a\x12\x68\x54",
	}, {
		.key	= "Jefe",
		.ksize	= 4,
		.plaintext = "what do ya want for nothing?",
		.psize	= 28,
		.digest	= "\x16\x4b\x7a\x7b\xfc\xf8\x19\xe2"
			  "\xe3\x95\xfb\xe7\x3b\x56\xe0\xa3"
			  "\x87\xbd\x64\x22\x2e\x83\x1f\xd6"
			  "\x10\x27\x0c\xd7\xea\x25\x05\x54"
			  "\x97\x58\xbf\x75\xc0\x5a\x99\x4a"
			  "\x6d\x03\x4f\x65\xf8\xf0\xe6\xfd"
			  "\xca\xea\xb1\xa3\x4d\x4a\x6b\x4b"
			  "\x63\x6e\x07\x0a\x38\xbc\xe7\x37",
		.np	= 4,
		.tap	= { 7, 7, 7, 7 }
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			  "\xaa\xaa\xaa",
		.ksize	= 131,
		.plaintext = "Test Using Large"
			   "r Than Block-Siz"
			   "e Key - Hash Key"
			   " First",
		.psize	= 54,
		.digest	= "\x80\xb2\x42\x63\xc7\xc1\xa3\xeb"
			"\xb7\x14\x93\xc1\xdd\x7b\xe8\xb4"
			"\x9b\x46\xd1\xf4\x1b\x4a\xee\xc1"
			"\x12\x1b\x01\x37\x83\xf8\xf3\x52"
			"\x6b\x56\xd0\x37\xe0\x5f\x25\x98"
			"\xbd\x0f\xd2\x21\x5d\x6a\x1e\x52"
			"\x95\xe6\x4f\x73\xf6\x3f\x0a\xec"
			"\x8b\x91\x5a\x98\x5d\x78\x65\x98",
	}, {
		.key	= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
			"\xaa\xaa\xaa",
		.ksize	= 131,
		.plaintext =
			  "This is a test u"
			  "sing a larger th"
			  "an block-size ke"
			  "y and a larger t"
			  "han block-size d"
			  "ata. The key nee"
			  "ds to be hashed "
			  "before being use"
			  "d by the HMAC al"
			  "gorithm.",
		.psize	= 152,
		.digest	= "\xe3\x7b\x6a\x77\x5d\xc8\x7d\xba"
			"\xa4\xdf\xa9\xf9\x6e\x5e\x3f\xfd"
			"\xde\xbd\x71\xf8\x86\x72\x89\x86"
			"\x5d\xf5\xa3\x2d\x20\xcd\xc9\x44"
			"\xb6\x02\x2c\xac\x3c\x49\x82\xb1"
			"\x0d\x5e\xeb\x55\xc3\xe4\xde\x15"
			"\x13\x46\x76\xfb\x6d\xe0\x44\x60"
			"\x65\xc9\x74\x40\xfa\x8c\x6a\x58",
	},
};

/*
 * DES test vectors.
 */
#define DES_ENC_TEST_VECTORS		10
#define DES_DEC_TEST_VECTORS		4
#define DES_CBC_ENC_TEST_VECTORS	5
#define DES_CBC_DEC_TEST_VECTORS	4
#define DES3_EDE_ENC_TEST_VECTORS	3
#define DES3_EDE_DEC_TEST_VECTORS	3
#define DES3_EDE_CBC_ENC_TEST_VECTORS	1
#define DES3_EDE_CBC_DEC_TEST_VECTORS	1

static struct cipher_testvec des_enc_tv_template[] = {
	{ /* From Applied Cryptography */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7",
		.ilen	= 8,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
		.rlen	= 8,
	}, { /* Same key, different plaintext block */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x22\x33\x44\x55\x66\x77\x88\x99",
		.ilen	= 8,
		.result	= "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
		.rlen	= 8,
	}, { /* Sbox test from NBS */
		.key	= "\x7c\xa1\x10\x45\x4a\x1a\x6e\x57",
		.klen	= 8,
		.input	= "\x01\xa1\xd6\xd0\x39\x77\x67\x42",
		.ilen	= 8,
		.result	= "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
		.rlen	= 8,
	}, { /* Three blocks */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\x22\x33\x44\x55\x66\x77\x88\x99"
			  "\xca\xfe\xba\xbe\xfe\xed\xbe\xef",
		.ilen	= 24,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
			  "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90",
		.rlen	= 24,
	}, { /* Weak key */
		.fail	= 1,
		.wk	= 1,
		.key	= "\x01\x01\x01\x01\x01\x01\x01\x01",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7",
		.ilen	= 8,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
		.rlen	= 8,
	}, { /* Two blocks -- for testing encryption across pages */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\x22\x33\x44\x55\x66\x77\x88\x99",
		.ilen	= 16,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
		.rlen	= 16,
		.np	= 2,
		.tap	= { 8, 8 }
	}, { /* Four blocks -- for testing encryption with chunking */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\x22\x33\x44\x55\x66\x77\x88\x99"
			  "\xca\xfe\xba\xbe\xfe\xed\xbe\xef"
			  "\x22\x33\x44\x55\x66\x77\x88\x99",
		.ilen	= 32,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
			  "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90"
			  "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
		.rlen	= 32,
		.np	= 3,
		.tap	= { 14, 10, 8 }
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\x22\x33\x44\x55\x66\x77\x88\x99"
			  "\xca\xfe\xba\xbe\xfe\xed\xbe\xef",
		.ilen	= 24,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b"
			  "\xb4\x99\x26\xf7\x1f\xe1\xd4\x90",
		.rlen	= 24,
		.np	= 4,
		.tap	= { 2, 1, 3, 18 }
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\x22\x33\x44\x55\x66\x77\x88\x99",
		.ilen	= 16,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\xf7\x9c\x89\x2a\x33\x8f\x4a\x8b",
		.rlen	= 16,
		.np	= 5,
		.tap	= { 2, 2, 2, 2, 8 }
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xe7",
		.ilen	= 8,
		.result	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
		.rlen	= 8,
		.np	= 8,
		.tap	= { 1, 1, 1, 1, 1, 1, 1, 1 }
	},
};

static struct cipher_testvec des_dec_tv_template[] = {
	{ /* From Applied Cryptography */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d",
		.ilen	= 8,
		.result	= "\x01\x23\x45\x67\x89\xab\xcd\xe7",
		.rlen	= 8,
	}, { /* Sbox test from NBS */
		.key	= "\x7c\xa1\x10\x45\x4a\x1a\x6e\x57",
		.klen	= 8,
		.input	= "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
		.ilen	= 8,
		.result	= "\x01\xa1\xd6\xd0\x39\x77\x67\x42",
		.rlen	= 8,
	}, { /* Two blocks, for chunking test */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
		.ilen	= 16,
		.result	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\xa3\x99\x7b\xca\xaf\x69\xa0\xf5",
		.rlen	= 16,
		.np	= 2,
		.tap	= { 8, 8 }
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.input	= "\xc9\x57\x44\x25\x6a\x5e\xd3\x1d"
			  "\x69\x0f\x5b\x0d\x9a\x26\x93\x9b",
		.ilen	= 16,
		.result	= "\x01\x23\x45\x67\x89\xab\xcd\xe7"
			  "\xa3\x99\x7b\xca\xaf\x69\xa0\xf5",
		.rlen	= 16,
		.np	= 3,
		.tap	= { 3, 12, 1 }
	},
};

static struct cipher_testvec des_cbc_enc_tv_template[] = {
	{ /* From OpenSSL */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.input	= "\x37\x36\x35\x34\x33\x32\x31\x20"
			  "\x4e\x6f\x77\x20\x69\x73\x20\x74"
			  "\x68\x65\x20\x74\x69\x6d\x65\x20",
		.ilen	= 24,
		.result	= "\xcc\xd1\x73\xff\xab\x20\x39\xf4"
			  "\xac\xd8\xae\xfd\xdf\xd8\xa1\xeb"
			  "\x46\x8e\x91\x15\x78\x88\xba\x68",
		.rlen	= 24,
	}, { /* FIPS Pub 81 */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\x12\x34\x56\x78\x90\xab\xcd\xef",
		.input	= "\x4e\x6f\x77\x20\x69\x73\x20\x74",
		.ilen	= 8,
		.result	= "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
		.rlen	= 8,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
		.input	= "\x68\x65\x20\x74\x69\x6d\x65\x20",
		.ilen	= 8,
		.result	= "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
		.rlen	= 8,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
		.input	= "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
		.ilen	= 8,
		.result	= "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
		.rlen	= 8,
	}, { /* Copy of openssl vector for chunk testing */
	     /* From OpenSSL */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.input	= "\x37\x36\x35\x34\x33\x32\x31\x20"
			  "\x4e\x6f\x77\x20\x69\x73\x20\x74"
			  "\x68\x65\x20\x74\x69\x6d\x65\x20",
		.ilen	= 24,
		.result	= "\xcc\xd1\x73\xff\xab\x20\x39\xf4"
			  "\xac\xd8\xae\xfd\xdf\xd8\xa1\xeb"
			  "\x46\x8e\x91\x15\x78\x88\xba\x68",
		.rlen	= 24,
		.np	= 2,
		.tap	= { 13, 11 }
	},
};

static struct cipher_testvec des_cbc_dec_tv_template[] = {
	{ /* FIPS Pub 81 */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\x12\x34\x56\x78\x90\xab\xcd\xef",
		.input	= "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
		.ilen	= 8,
		.result	= "\x4e\x6f\x77\x20\x69\x73\x20\x74",
		.rlen	= 8,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\xe5\xc7\xcd\xde\x87\x2b\xf2\x7c",
		.input	= "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
		.ilen	= 8,
		.result	= "\x68\x65\x20\x74\x69\x6d\x65\x20",
		.rlen	= 8,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
		.input	= "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
		.ilen	= 8,
		.result	= "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
		.rlen	= 8,
	}, { /* Copy of above, for chunk testing */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.klen	= 8,
		.iv	= "\x43\xe9\x34\x00\x8c\x38\x9c\x0f",
		.input	= "\x68\x37\x88\x49\x9a\x7c\x05\xf6",
		.ilen	= 8,
		.result	= "\x66\x6f\x72\x20\x61\x6c\x6c\x20",
		.rlen	= 8,
		.np	= 2,
		.tap	= { 4, 4 }
	},
};

static struct cipher_testvec des3_ede_enc_tv_template[] = {
	{ /* These are from openssl */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\x55\x55\x55\x55\x55\x55\x55\x55"
			  "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.klen	= 24,
		.input	= "\x73\x6f\x6d\x65\x64\x61\x74\x61",
		.ilen	= 8,
		.result	= "\x18\xd7\x48\xe5\x63\x62\x05\x72",
		.rlen	= 8,
	}, {
		.key	= "\x03\x52\x02\x07\x67\x20\x82\x17"
			  "\x86\x02\x87\x66\x59\x08\x21\x98"
			  "\x64\x05\x6a\xbd\xfe\xa9\x34\x57",
		.klen	= 24,
		.input	= "\x73\x71\x75\x69\x67\x67\x6c\x65",
		.ilen	= 8,
		.result	= "\xc0\x7d\x2a\x0f\xa5\x66\xfa\x30",
		.rlen	= 8,
	}, {
		.key	= "\x10\x46\x10\x34\x89\x98\x80\x20"
			  "\x91\x07\xd0\x15\x89\x19\x01\x01"
			  "\x19\x07\x92\x10\x98\x1a\x01\x01",
		.klen	= 24,
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00",
		.ilen	= 8,
		.result	= "\xe1\xef\x62\xc3\x32\xfe\x82\x5b",
		.rlen	= 8,
	},
};

static struct cipher_testvec des3_ede_dec_tv_template[] = {
	{ /* These are from openssl */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\x55\x55\x55\x55\x55\x55\x55\x55"
			  "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.klen	= 24,
		.input	= "\x18\xd7\x48\xe5\x63\x62\x05\x72",
		.ilen	= 8,
		.result	= "\x73\x6f\x6d\x65\x64\x61\x74\x61",
		.rlen	= 8,
	}, {
		.key	= "\x03\x52\x02\x07\x67\x20\x82\x17"
			  "\x86\x02\x87\x66\x59\x08\x21\x98"
			  "\x64\x05\x6a\xbd\xfe\xa9\x34\x57",
		.klen	= 24,
		.input	= "\xc0\x7d\x2a\x0f\xa5\x66\xfa\x30",
		.ilen	= 8,
		.result	= "\x73\x71\x75\x69\x67\x67\x6c\x65",
		.rlen	= 8,
	}, {
		.key	= "\x10\x46\x10\x34\x89\x98\x80\x20"
			  "\x91\x07\xd0\x15\x89\x19\x01\x01"
			  "\x19\x07\x92\x10\x98\x1a\x01\x01",
		.klen	= 24,
		.input	= "\xe1\xef\x62\xc3\x32\xfe\x82\x5b",
		.ilen	= 8,
		.result	= "\x00\x00\x00\x00\x00\x00\x00\x00",
		.rlen	= 8,
	},
};

static struct cipher_testvec des3_ede_cbc_enc_tv_template[] = {
	{ /* Generated from openssl */
		.key	= "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24"
			  "\x44\x4D\x99\x5A\x12\xD6\x40\xC0"
			  "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8",
		.klen	= 24,
		.iv	= "\x7D\x33\x88\x93\x0F\x93\xB2\x42",
		.input	= "\x6f\x54\x20\x6f\x61\x4d\x79\x6e"
			  "\x53\x20\x63\x65\x65\x72\x73\x74"
			  "\x54\x20\x6f\x6f\x4d\x20\x6e\x61"
			  "\x20\x79\x65\x53\x72\x63\x74\x65"
			  "\x20\x73\x6f\x54\x20\x6f\x61\x4d"
			  "\x79\x6e\x53\x20\x63\x65\x65\x72"
			  "\x73\x74\x54\x20\x6f\x6f\x4d\x20"
			  "\x6e\x61\x20\x79\x65\x53\x72\x63"
			  "\x74\x65\x20\x73\x6f\x54\x20\x6f"
			  "\x61\x4d\x79\x6e\x53\x20\x63\x65"
			  "\x65\x72\x73\x74\x54\x20\x6f\x6f"
			  "\x4d\x20\x6e\x61\x20\x79\x65\x53"
			  "\x72\x63\x74\x65\x20\x73\x6f\x54"
			  "\x20\x6f\x61\x4d\x79\x6e\x53\x20"
			  "\x63\x65\x65\x72\x73\x74\x54\x20"
			  "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79",
		.ilen	= 128,
		.result	= "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4"
			  "\x67\x17\x21\xc7\x6e\x8a\xd5\x49"
			  "\x74\xb3\x49\x05\xc5\x1c\xd0\xed"
			  "\x12\x56\x5c\x53\x96\xb6\x00\x7d"
			  "\x90\x48\xfc\xf5\x8d\x29\x39\xcc"
			  "\x8a\xd5\x35\x18\x36\x23\x4e\xd7"
			  "\x76\xd1\xda\x0c\x94\x67\xbb\x04"
			  "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea"
			  "\x22\x64\x47\xaa\x8f\x75\x13\xbf"
			  "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a"
			  "\x71\x63\x2e\x89\x7b\x1e\x12\xca"
			  "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a"
			  "\xd6\xf9\x21\x31\x62\x44\x45\xa6"
			  "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc"
			  "\x9d\xde\xa5\x70\xe9\x42\x45\x8a"
			  "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19",
		.rlen	= 128,
	},
};

static struct cipher_testvec des3_ede_cbc_dec_tv_template[] = {
	{ /* Generated from openssl */
		.key	= "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24"
			  "\x44\x4D\x99\x5A\x12\xD6\x40\xC0"
			  "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8",
		.klen	= 24,
		.iv	= "\x7D\x33\x88\x93\x0F\x93\xB2\x42",
		.input	= "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4"
			  "\x67\x17\x21\xc7\x6e\x8a\xd5\x49"
			  "\x74\xb3\x49\x05\xc5\x1c\xd0\xed"
			  "\x12\x56\x5c\x53\x96\xb6\x00\x7d"
			  "\x90\x48\xfc\xf5\x8d\x29\x39\xcc"
			  "\x8a\xd5\x35\x18\x36\x23\x4e\xd7"
			  "\x76\xd1\xda\x0c\x94\x67\xbb\x04"
			  "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea"
			  "\x22\x64\x47\xaa\x8f\x75\x13\xbf"
			  "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a"
			  "\x71\x63\x2e\x89\x7b\x1e\x12\xca"
			  "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a"
			  "\xd6\xf9\x21\x31\x62\x44\x45\xa6"
			  "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc"
			  "\x9d\xde\xa5\x70\xe9\x42\x45\x8a"
			  "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19",
		.ilen	= 128,
		.result	= "\x6f\x54\x20\x6f\x61\x4d\x79\x6e"
			  "\x53\x20\x63\x65\x65\x72\x73\x74"
			  "\x54\x20\x6f\x6f\x4d\x20\x6e\x61"
			  "\x20\x79\x65\x53\x72\x63\x74\x65"
			  "\x20\x73\x6f\x54\x20\x6f\x61\x4d"
			  "\x79\x6e\x53\x20\x63\x65\x65\x72"
			  "\x73\x74\x54\x20\x6f\x6f\x4d\x20"
			  "\x6e\x61\x20\x79\x65\x53\x72\x63"
			  "\x74\x65\x20\x73\x6f\x54\x20\x6f"
			  "\x61\x4d\x79\x6e\x53\x20\x63\x65"
			  "\x65\x72\x73\x74\x54\x20\x6f\x6f"
			  "\x4d\x20\x6e\x61\x20\x79\x65\x53"
			  "\x72\x63\x74\x65\x20\x73\x6f\x54"
			  "\x20\x6f\x61\x4d\x79\x6e\x53\x20"
			  "\x63\x65\x65\x72\x73\x74\x54\x20"
			  "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79",
		.rlen	= 128,
	},
};

/*
 * Blowfish test vectors.
 */
#define BF_ENC_TEST_VECTORS	7
#define BF_DEC_TEST_VECTORS	7
#define BF_CBC_ENC_TEST_VECTORS	2
#define BF_CBC_DEC_TEST_VECTORS	2
#define BF_CTR_ENC_TEST_VECTORS	2
#define BF_CTR_DEC_TEST_VECTORS	2

static struct cipher_testvec bf_enc_tv_template[] = {
	{ /* DES test vectors from OpenSSL */
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 8,
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00",
		.ilen	= 8,
		.result	= "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
		.rlen	= 8,
	}, {
		.key	= "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
		.klen	= 8,
		.input	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.ilen	= 8,
		.result	= "\xa7\x90\x79\x51\x08\xea\x3c\xae",
		.rlen	= 8,
	}, {
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
		.klen	= 8,
		.input	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.ilen	= 8,
		.result	= "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
		.rlen	= 8,
	}, { /* Vary the keylength... */
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
			  "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
		.klen	= 16,
		.input	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.ilen	= 8,
		.result	= "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
		.rlen	= 8,
	}, {
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
			  "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
			  "\x00\x11\x22\x33\x44",
		.klen	= 21,
		.input	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.ilen	= 8,
		.result	= "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
		.rlen	= 8,
	}, { /* Generated with bf488 */
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
			  "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
			  "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
			  "\x58\x40\x23\x64\x1a\xba\x61\x76"
			  "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
			  "\xff\xff\xff\xff\xff\xff\xff\xff",
		.klen	= 56,
		.input	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.ilen	= 8,
		.result	= "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
		.rlen	= 8,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
		.ilen	= 40,
		.result	= "\x96\x87\x3D\x0C\x7B\xFB\xBD\x1F"
			  "\xE3\xC1\x99\x6D\x39\xD4\xC2\x7D"
			  "\xD7\x87\xA1\xF2\xDF\x51\x71\x26"
			  "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40"
			  "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B",
		.rlen	= 40,
	},
};

static struct cipher_testvec bf_dec_tv_template[] = {
	{ /* DES test vectors from OpenSSL */
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 8,
		.input	= "\x4e\xf9\x97\x45\x61\x98\xdd\x78",
		.ilen	= 8,
		.result	= "\x00\x00\x00\x00\x00\x00\x00\x00",
		.rlen	= 8,
	}, {
		.key	= "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e",
		.klen	= 8,
		.input	= "\xa7\x90\x79\x51\x08\xea\x3c\xae",
		.ilen	= 8,
		.result	= "\x01\x23\x45\x67\x89\xab\xcd\xef",
		.rlen	= 8,
	}, {
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
		.klen	= 8,
		.input	= "\xe8\x7a\x24\x4e\x2c\xc8\x5e\x82",
		.ilen	= 8,
		.result	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.rlen	= 8,
	}, { /* Vary the keylength... */
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
			  "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f",
		.klen	= 16,
		.input	= "\x93\x14\x28\x87\xee\x3b\xe1\x5c",
		.ilen	= 8,
		.result	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.rlen	= 8,
	}, {
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
			  "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
			  "\x00\x11\x22\x33\x44",
		.klen	= 21,
		.input	= "\xe6\xf5\x1e\xd7\x9b\x9d\xb2\x1f",
		.ilen	= 8,
		.result	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.rlen	= 8,
	}, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
		.key	= "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87"
			  "\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
			  "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x04\x68\x91\x04\xc2\xfd\x3b\x2f"
			  "\x58\x40\x23\x64\x1a\xba\x61\x76"
			  "\x1f\x1f\x1f\x1f\x0e\x0e\x0e\x0e"
			  "\xff\xff\xff\xff\xff\xff\xff\xff",
		.klen	= 56,
		.input	= "\xc0\x45\x04\x01\x2e\x4e\x1f\x53",
		.ilen	= 8,
		.result	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.rlen	= 8,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.input	= "\x96\x87\x3D\x0C\x7B\xFB\xBD\x1F"
			  "\xE3\xC1\x99\x6D\x39\xD4\xC2\x7D"
			  "\xD7\x87\xA1\xF2\xDF\x51\x71\x26"
			  "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40"
			  "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B",
		.ilen	= 40,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
		.rlen	= 40,
	},
};

static struct cipher_testvec bf_cbc_enc_tv_template[] = {
	{ /* From OpenSSL */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
		.klen	= 16,
		.iv	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.input	= "\x37\x36\x35\x34\x33\x32\x31\x20"
			  "\x4e\x6f\x77\x20\x69\x73\x20\x74"
			  "\x68\x65\x20\x74\x69\x6d\x65\x20"
			  "\x66\x6f\x72\x20\x00\x00\x00\x00",
		.ilen	= 32,
		.result	= "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
			  "\x05\xb1\x56\xe2\x74\x03\x97\x93"
			  "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
			  "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
		.rlen	= 32,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
		.ilen	= 40,
		.result	= "\xB4\xFE\xA5\xBB\x3D\x2C\x27\x06"
			  "\x06\x2B\x3A\x92\xB2\xF5\x5E\x62"
			  "\x84\xCD\xF7\x66\x7E\x41\x6C\x8E"
			  "\x1B\xD9\x02\xB6\x48\xB0\x87\x25"
			  "\x01\x9C\x93\x63\x51\x60\x82\xD2",
		.rlen	= 40,
	},
};

static struct cipher_testvec bf_cbc_dec_tv_template[] = {
	{ /* From OpenSSL */
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87",
		.klen	= 16,
		.iv	= "\xfe\xdc\xba\x98\x76\x54\x32\x10",
		.input	= "\x6b\x77\xb4\xd6\x30\x06\xde\xe6"
			  "\x05\xb1\x56\xe2\x74\x03\x97\x93"
			  "\x58\xde\xb9\xe7\x15\x46\x16\xd9"
			  "\x59\xf1\x65\x2b\xd5\xff\x92\xcc",
		.ilen	= 32,
		.result	= "\x37\x36\x35\x34\x33\x32\x31\x20"
			  "\x4e\x6f\x77\x20\x69\x73\x20\x74"
			  "\x68\x65\x20\x74\x69\x6d\x65\x20"
			  "\x66\x6f\x72\x20\x00\x00\x00\x00",
		.rlen	= 32,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
		.input	= "\xB4\xFE\xA5\xBB\x3D\x2C\x27\x06"
			  "\x06\x2B\x3A\x92\xB2\xF5\x5E\x62"
			  "\x84\xCD\xF7\x66\x7E\x41\x6C\x8E"
			  "\x1B\xD9\x02\xB6\x48\xB0\x87\x25"
			  "\x01\x9C\x93\x63\x51\x60\x82\xD2",
		.ilen	= 40,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
		.rlen	= 40,
	},
};

static struct cipher_testvec bf_ctr_enc_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
		.ilen	= 40,
		.result	= "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
			  "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
			  "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
			  "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
			  "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC",
		.rlen	= 40,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B",
		.ilen	= 43,
		.result	= "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
			  "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
			  "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
			  "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
			  "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC"
			  "\x3D\xA7\xE9",
		.rlen	= 43,
	},
};

static struct cipher_testvec bf_ctr_dec_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
		.input	= "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
			  "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
			  "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
			  "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
			  "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC",
		.ilen	= 40,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9",
		.rlen	= 40,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F",
		.input	= "\xC7\xA3\xDF\xB9\x05\xF4\x9E\x8D"
			  "\x9E\xDF\x38\x18\x83\x07\xEF\xC1"
			  "\x93\x3C\xAA\xAA\xFE\x06\x42\xCC"
			  "\x0D\x70\x86\x5A\x44\xAD\x85\x17"
			  "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC"
			  "\x3D\xA7\xE9",
		.ilen	= 43,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B",
		.rlen	= 43,
	},
};

/*
 * Twofish test vectors.
 */
#define TF_ENC_TEST_VECTORS		4
#define TF_DEC_TEST_VECTORS		4
#define TF_CBC_ENC_TEST_VECTORS		5
#define TF_CBC_DEC_TEST_VECTORS		5
#define TF_CTR_ENC_TEST_VECTORS		2
#define TF_CTR_DEC_TEST_VECTORS		2
#define TF_LRW_ENC_TEST_VECTORS		8
#define TF_LRW_DEC_TEST_VECTORS		8
#define TF_XTS_ENC_TEST_VECTORS		5
#define TF_XTS_DEC_TEST_VECTORS		5

static struct cipher_testvec tf_enc_tv_template[] = {
	{
		.key	= zeroed_string,
		.klen	= 16,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
		.rlen	= 16,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\xfe\xdc\xba\x98\x76\x54\x32\x10"
			  "\x00\x11\x22\x33\x44\x55\x66\x77",
		.klen	= 24,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
			  "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
		.rlen	= 16,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\xfe\xdc\xba\x98\x76\x54\x32\x10"
			  "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.klen	= 32,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
			  "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
		.rlen	= 16,
	}, { /* Generated with Crypto++ */
		.key	= "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C"
			  "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D"
			  "\x4A\x27\x04\xE1\x27\x04\xE1\xBE"
			  "\x9B\x78\xBE\x9B\x78\x55\x32\x0F",
		.klen	= 32,
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
		.ilen	= 64,
		.result	= "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF"
			  "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC"
			  "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D"
			  "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14"
			  "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5"
			  "\xDF\xFA\xC7\xE8\x09\x50\x76\x08"
			  "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05"
			  "\x89\xF6\x82\xF0\xD3\xDB\x06\x02",
		.rlen	= 64,
	},
};

static struct cipher_testvec tf_dec_tv_template[] = {
	{
		.key	= zeroed_string,
		.klen	= 16,
		.input	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\xfe\xdc\xba\x98\x76\x54\x32\x10"
			  "\x00\x11\x22\x33\x44\x55\x66\x77",
		.klen	= 24,
		.input	= "\xcf\xd1\xd2\xe5\xa9\xbe\x9c\xdf"
			  "\x50\x1f\x13\xb8\x92\xbd\x22\x48",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= "\x01\x23\x45\x67\x89\xab\xcd\xef"
			  "\xfe\xdc\xba\x98\x76\x54\x32\x10"
			  "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.klen	= 32,
		.input	= "\x37\x52\x7b\xe0\x05\x23\x34\xb8"
			  "\x9f\x0c\xfc\xca\xe8\x7c\xfa\x20",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, { /* Generated with Crypto++ */
		.key	= "\x3F\x85\x62\x3F\x1C\xF9\xD6\x1C"
			  "\xF9\xD6\xB3\x90\x6D\x4A\x90\x6D"
			  "\x4A\x27\x04\xE1\x27\x04\xE1\xBE"
			  "\x9B\x78\xBE\x9B\x78\x55\x32\x0F",
		.klen	= 32,
		.input	= "\x88\xCB\x1E\xC2\xAF\x8A\x97\xFF"
			  "\xF6\x90\x46\x9C\x4A\x0F\x08\xDC"
			  "\xDE\xAB\xAD\xFA\xFC\xA8\xC2\x3D"
			  "\xE0\xE4\x8B\x3F\xD5\xA3\xF7\x14"
			  "\x34\x9E\xB6\x08\xB2\xDD\xA8\xF5"
			  "\xDF\xFA\xC7\xE8\x09\x50\x76\x08"
			  "\xA2\xB6\x6A\x59\xC0\x2B\x6D\x05"
			  "\x89\xF6\x82\xF0\xD3\xDB\x06\x02",
		.ilen	= 64,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
		.rlen	= 64,
	},
};

static struct cipher_testvec tf_cbc_enc_tv_template[] = {
	{ /* Generated with Nettle */
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= zeroed_string,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
		.rlen	= 16,
	}, {
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
			  "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
		.rlen	= 16,
	}, {
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
			  "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\x05\xef\x8c\x61\xa8\x11\x58\x26"
			  "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
		.rlen	= 16,
	}, {
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= zeroed_string,
		.input	= zeroed_string,
		.ilen	= 48,
		.result	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
			  "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
			  "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
			  "\x05\xef\x8c\x61\xa8\x11\x58\x26"
			  "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
		.rlen	= 48,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
		.ilen	= 64,
		.result	= "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1"
			  "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5"
			  "\x26\x1B\x05\x0C\x05\x12\x3F\xC0"
			  "\xF9\x1C\x02\x28\x40\x96\x6F\xD0"
			  "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE"
			  "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC"
			  "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3"
			  "\xB1\xD3\x44\x65\xDF\xE7\x63\x38",
		.rlen	= 64,
	},
};

static struct cipher_testvec tf_cbc_dec_tv_template[] = {
	{ /* Reverse of the first four above */
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= zeroed_string,
		.input	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a",
		.input	= "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
			  "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
			  "\x86\xcb\x08\x6b\x78\x9f\x54\x19",
		.input	= "\x05\xef\x8c\x61\xa8\x11\x58\x26"
			  "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= zeroed_string,
		.klen	= 16,
		.iv	= zeroed_string,
		.input	= "\x9f\x58\x9f\x5c\xf6\x12\x2c\x32"
			  "\xb6\xbf\xec\x2f\x2a\xe8\xc3\x5a"
			  "\xd4\x91\xdb\x16\xe7\xb1\xc3\x9e"
			  "\x86\xcb\x08\x6b\x78\x9f\x54\x19"
			  "\x05\xef\x8c\x61\xa8\x11\x58\x26"
			  "\x34\xba\x5c\xb7\x10\x6a\xa6\x41",
		.ilen	= 48,
		.result	= zeroed_string,
		.rlen	= 48,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\xC8\xFF\xF2\x53\xA6\x27\x09\xD1"
			  "\x33\x38\xC2\xC0\x0C\x14\x7E\xB5"
			  "\x26\x1B\x05\x0C\x05\x12\x3F\xC0"
			  "\xF9\x1C\x02\x28\x40\x96\x6F\xD0"
			  "\x3D\x32\xDF\xDA\x56\x00\x6E\xEE"
			  "\x5B\x2A\x72\x9D\xC2\x4D\x19\xBC"
			  "\x8C\x53\xFA\x87\x6F\xDD\x81\xA3"
			  "\xB1\xD3\x44\x65\xDF\xE7\x63\x38",
		.ilen	= 64,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
		.rlen	= 64,
	},
};

static struct cipher_testvec tf_ctr_enc_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
		.ilen	= 64,
		.result	= "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
			  "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
			  "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
			  "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
			  "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
			  "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
			  "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
			  "\x01\x41\x21\x12\x38\xAB\x52\x4F",
		.rlen	= 64,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE",
		.ilen	= 67,
		.result	= "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
			  "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
			  "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
			  "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
			  "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
			  "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
			  "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
			  "\x01\x41\x21\x12\x38\xAB\x52\x4F"
			  "\xA8\x57\x20",
		.rlen	= 67,
	},
};

static struct cipher_testvec tf_ctr_dec_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
			  "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
			  "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
			  "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
			  "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
			  "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
			  "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
			  "\x01\x41\x21\x12\x38\xAB\x52\x4F",
		.ilen	= 64,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C",
		.rlen	= 64,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\xDF\xDD\x69\xFA\xB0\x2E\xFD\xFE"
			  "\x70\x9E\xC5\x4B\xC9\xD4\xA1\x30"
			  "\x26\x9B\x89\xA1\xEE\x43\xE0\x52"
			  "\x55\x17\x4E\xC7\x0E\x33\x1F\xF1"
			  "\x9F\x8D\x40\x9F\x24\xFD\x92\xA0"
			  "\xBC\x8F\x35\xDD\x67\x38\xD8\xAA"
			  "\xCF\xF8\x48\xCA\xFB\xE4\x5C\x60"
			  "\x01\x41\x21\x12\x38\xAB\x52\x4F"
			  "\xA8\x57\x20",
		.ilen	= 67,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE",
		.rlen	= 67,
	},
};

static struct cipher_testvec tf_lrw_enc_tv_template[] = {
	/* Generated from AES-LRW test vectors */
	{
		.key	= "\x45\x62\xac\x25\xf8\x28\x17\x6d"
			  "\x4c\x26\x84\x14\xb5\x68\x01\x85"
			  "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
			  "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\xa1\x6c\x50\x69\x26\xa4\xef\x7b"
			  "\x7c\xc6\x91\xeb\x72\xdd\x9b\xee",
		.rlen	= 16,
	}, {
		.key	= "\x59\x70\x47\x14\xf5\x57\x47\x8c"
			  "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
			  "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
			  "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x02",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\xab\x72\x0a\xad\x3b\x0c\xf0\xc9"
			  "\x42\x2f\xf1\xae\xf1\x3c\xb1\xbd",
		.rlen	= 16,
	}, {
		.key	= "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
			  "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
			  "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
			  "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x85\xa7\x56\x67\x08\xfa\x42\xe1"
			  "\x22\xe6\x82\xfc\xd9\xb4\xd7\xd4",
		.rlen	= 16,
	}, {
		.key	= "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
			  "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
			  "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
			  "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
			  "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\xd2\xaf\x69\x35\x24\x1d\x0e\x1c"
			  "\x84\x8b\x05\xe4\xa2\x2f\x16\xf5",
		.rlen	= 16,
	}, {
		.key	= "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
			  "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
			  "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
			  "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
			  "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x4a\x23\x56\xd7\xff\x90\xd0\x9a"
			  "\x0d\x7c\x26\xfc\xf0\xf0\xf6\xe4",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x30\xaf\x26\x05\x9d\x5d\x0a\x58"
			  "\xe2\xe7\xce\x8a\xb2\x56\x6d\x76",
		.rlen	= 16,
	}, {
		.key	= "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
			  "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
			  "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
			  "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
			  "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
			  "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\xdf\xcf\xdc\xd2\xe1\xcf\x86\x75"
			  "\x17\x66\x5e\x0c\x14\xa1\x3d\x40",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
			  "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
			  "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
			  "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
			  "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
			  "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
			  "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
			  "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
			  "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
			  "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
			  "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
			  "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
			  "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
			  "\x4c\x96\x12\xed\x7c\x92\x03\x01"
			  "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
			  "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
			  "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
			  "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
			  "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
			  "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
			  "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
			  "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
			  "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
			  "\x76\x12\x73\x44\x1a\x56\xd7\x72"
			  "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
			  "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
			  "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
			  "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
			  "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
			  "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
			  "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
			  "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
			  "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
			  "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
			  "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
			  "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
			  "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
			  "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
			  "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
			  "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
			  "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
			  "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
			  "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
			  "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
			  "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
			  "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
			  "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
			  "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
			  "\x62\x73\x65\xfd\x46\x63\x25\x3d"
			  "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
			  "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
			  "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
			  "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
			  "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
			  "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
			  "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
			  "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
			  "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
			  "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
			  "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
			  "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
			  "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
			  "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
			  "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
		.ilen	= 512,
		.result	= "\x30\x38\xeb\xaf\x12\x43\x1a\x89"
			  "\x62\xa2\x36\xe5\xcf\x77\x1e\xd9"
			  "\x08\xc3\x0d\xdd\x95\xab\x19\x96"
			  "\x27\x52\x41\xc3\xca\xfb\xf6\xee"
			  "\x40\x2d\xdf\xdd\x00\x0c\xb9\x0a"
			  "\x3a\xf0\xc0\xd1\xda\x63\x9e\x45"
			  "\x42\xe9\x29\xc0\xb4\x07\xb4\x31"
			  "\x66\x77\x72\xb5\xb6\xb3\x57\x46"
			  "\x34\x9a\xfe\x03\xaf\x6b\x36\x07"
			  "\x63\x8e\xc2\x5d\xa6\x0f\xb6\x7d"
			  "\xfb\x6d\x82\x51\xb6\x98\xd0\x71"
			  "\xe7\x10\x7a\xdf\xb2\xbd\xf1\x1d"
			  "\x72\x2b\x54\x13\xe3\x6d\x79\x37"
			  "\xa9\x39\x2c\xdf\x21\xab\x87\xd5"
			  "\xee\xef\x9a\x12\x50\x39\x2e\x1b"
			  "\x7d\xe6\x6a\x27\x48\xb9\xe7\xac"
			  "\xaa\xcd\x79\x5f\xf2\xf3\xa0\x08"
			  "\x6f\x2c\xf4\x0e\xd1\xb8\x89\x25"
			  "\x31\x9d\xef\xb1\x1d\x27\x55\x04"
			  "\xc9\x8c\xb7\x68\xdc\xb6\x67\x8a"
			  "\xdb\xcf\x22\xf2\x3b\x6f\xce\xbb"
			  "\x26\xbe\x4f\x27\x04\x42\xd1\x44"
			  "\x4c\x08\xa3\x95\x4c\x7f\x1a\xaf"
			  "\x1d\x28\x14\xfd\xb1\x1a\x34\x18"
			  "\xf5\x1e\x28\x69\x95\x6a\x5a\xba"
			  "\x8e\xb2\x58\x1d\x28\x17\x13\x3d"
			  "\x38\x7d\x14\x8d\xab\x5d\xf9\xe8"
			  "\x3c\x0f\x2b\x0d\x2b\x08\xb4\x4b"
			  "\x6b\x0d\xc8\xa7\x84\xc2\x3a\x1a"
			  "\xb7\xbd\xda\x92\x29\xb8\x5b\x5a"
			  "\x63\xa5\x99\x82\x09\x72\x8f\xc6"
			  "\xa4\x62\x24\x69\x8c\x2d\x26\x00"
			  "\x99\x83\x91\xd6\xc6\xcf\x57\x67"
			  "\x38\xea\xf2\xfc\x29\xe0\x73\x39"
			  "\xf9\x13\x94\x6d\xe2\x58\x28\x75"
			  "\x3e\xae\x71\x90\x07\x70\x1c\x38"
			  "\x5b\x4c\x1e\xb5\xa5\x3b\x20\xef"
			  "\xb1\x4c\x3e\x1a\x72\x62\xbb\x22"
			  "\x82\x09\xe3\x18\x3f\x4f\x48\xfc"
			  "\xdd\xac\xfc\xb6\x09\xdb\xd2\x7b"
			  "\xd6\xb7\x7e\x41\x2f\x14\xf5\x0e"
			  "\xc3\xac\x4a\xed\xe7\x82\xef\x31"
			  "\x1f\x1a\x51\x1e\x29\x60\xc8\x98"
			  "\x93\x51\x1d\x3d\x62\x59\x83\x82"
			  "\x0c\xf1\xd7\x8d\xac\x33\x44\x81"
			  "\x3c\x59\xb7\xd4\x5b\x65\x82\xc4"
			  "\xec\xdc\x24\xfd\x0e\x1a\x79\x94"
			  "\x34\xb0\x62\xfa\x98\x49\x26\x1f"
			  "\xf4\x9e\x40\x44\x5b\x1f\xf8\xbe"
			  "\x36\xff\xc6\xc6\x9d\xf2\xd6\xcc"
			  "\x63\x93\x29\xb9\x0b\x6d\xd7\x6c"
			  "\xdb\xf6\x21\x80\xf7\x5a\x37\x15"
			  "\x0c\xe3\x36\xc8\x74\x75\x20\x91"
			  "\xdf\x52\x2d\x0c\xe7\x45\xff\x46"
			  "\xb3\xf4\xec\xc2\xbd\xd3\x37\xb6"
			  "\x26\xa2\x5d\x7d\x61\xbf\x10\x46"
			  "\x57\x8d\x05\x96\x70\x0b\xd6\x41"
			  "\x5c\xe9\xd3\x54\x81\x39\x3a\xdd"
			  "\x5f\x92\x81\x6e\x35\x03\xd4\x72"
			  "\x3d\x5a\xe7\xb9\x3b\x0c\x84\x23"
			  "\x45\x5d\xec\x72\xc1\x52\xef\x2e"
			  "\x81\x00\xd3\xfe\x4c\x3c\x05\x61"
			  "\x80\x18\xc4\x6c\x03\xd3\xb7\xba"
			  "\x11\xd7\xb8\x6e\xea\xe1\x80\x30",
		.rlen	= 512,
	},
};

static struct cipher_testvec tf_lrw_dec_tv_template[] = {
	/* Generated from AES-LRW test vectors */
	/* same as enc vectors with input and result reversed */
	{
		.key	= "\x45\x62\xac\x25\xf8\x28\x17\x6d"
			  "\x4c\x26\x84\x14\xb5\x68\x01\x85"
			  "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
			  "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\xa1\x6c\x50\x69\x26\xa4\xef\x7b"
			  "\x7c\xc6\x91\xeb\x72\xdd\x9b\xee",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\x59\x70\x47\x14\xf5\x57\x47\x8c"
			  "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
			  "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
			  "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x02",
		.input	= "\xab\x72\x0a\xad\x3b\x0c\xf0\xc9"
			  "\x42\x2f\xf1\xae\xf1\x3c\xb1\xbd",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
			  "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
			  "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
			  "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x85\xa7\x56\x67\x08\xfa\x42\xe1"
			  "\x22\xe6\x82\xfc\xd9\xb4\xd7\xd4",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
			  "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
			  "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
			  "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
			  "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\xd2\xaf\x69\x35\x24\x1d\x0e\x1c"
			  "\x84\x8b\x05\xe4\xa2\x2f\x16\xf5",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
			  "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
			  "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
			  "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
			  "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x4a\x23\x56\xd7\xff\x90\xd0\x9a"
			  "\x0d\x7c\x26\xfc\xf0\xf0\xf6\xe4",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\xaf\x26\x05\x9d\x5d\x0a\x58"
			  "\xe2\xe7\xce\x8a\xb2\x56\x6d\x76",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
			  "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
			  "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
			  "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
			  "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
			  "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\xdf\xcf\xdc\xd2\xe1\xcf\x86\x75"
			  "\x17\x66\x5e\x0c\x14\xa1\x3d\x40",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x38\xeb\xaf\x12\x43\x1a\x89"
			  "\x62\xa2\x36\xe5\xcf\x77\x1e\xd9"
			  "\x08\xc3\x0d\xdd\x95\xab\x19\x96"
			  "\x27\x52\x41\xc3\xca\xfb\xf6\xee"
			  "\x40\x2d\xdf\xdd\x00\x0c\xb9\x0a"
			  "\x3a\xf0\xc0\xd1\xda\x63\x9e\x45"
			  "\x42\xe9\x29\xc0\xb4\x07\xb4\x31"
			  "\x66\x77\x72\xb5\xb6\xb3\x57\x46"
			  "\x34\x9a\xfe\x03\xaf\x6b\x36\x07"
			  "\x63\x8e\xc2\x5d\xa6\x0f\xb6\x7d"
			  "\xfb\x6d\x82\x51\xb6\x98\xd0\x71"
			  "\xe7\x10\x7a\xdf\xb2\xbd\xf1\x1d"
			  "\x72\x2b\x54\x13\xe3\x6d\x79\x37"
			  "\xa9\x39\x2c\xdf\x21\xab\x87\xd5"
			  "\xee\xef\x9a\x12\x50\x39\x2e\x1b"
			  "\x7d\xe6\x6a\x27\x48\xb9\xe7\xac"
			  "\xaa\xcd\x79\x5f\xf2\xf3\xa0\x08"
			  "\x6f\x2c\xf4\x0e\xd1\xb8\x89\x25"
			  "\x31\x9d\xef\xb1\x1d\x27\x55\x04"
			  "\xc9\x8c\xb7\x68\xdc\xb6\x67\x8a"
			  "\xdb\xcf\x22\xf2\x3b\x6f\xce\xbb"
			  "\x26\xbe\x4f\x27\x04\x42\xd1\x44"
			  "\x4c\x08\xa3\x95\x4c\x7f\x1a\xaf"
			  "\x1d\x28\x14\xfd\xb1\x1a\x34\x18"
			  "\xf5\x1e\x28\x69\x95\x6a\x5a\xba"
			  "\x8e\xb2\x58\x1d\x28\x17\x13\x3d"
			  "\x38\x7d\x14\x8d\xab\x5d\xf9\xe8"
			  "\x3c\x0f\x2b\x0d\x2b\x08\xb4\x4b"
			  "\x6b\x0d\xc8\xa7\x84\xc2\x3a\x1a"
			  "\xb7\xbd\xda\x92\x29\xb8\x5b\x5a"
			  "\x63\xa5\x99\x82\x09\x72\x8f\xc6"
			  "\xa4\x62\x24\x69\x8c\x2d\x26\x00"
			  "\x99\x83\x91\xd6\xc6\xcf\x57\x67"
			  "\x38\xea\xf2\xfc\x29\xe0\x73\x39"
			  "\xf9\x13\x94\x6d\xe2\x58\x28\x75"
			  "\x3e\xae\x71\x90\x07\x70\x1c\x38"
			  "\x5b\x4c\x1e\xb5\xa5\x3b\x20\xef"
			  "\xb1\x4c\x3e\x1a\x72\x62\xbb\x22"
			  "\x82\x09\xe3\x18\x3f\x4f\x48\xfc"
			  "\xdd\xac\xfc\xb6\x09\xdb\xd2\x7b"
			  "\xd6\xb7\x7e\x41\x2f\x14\xf5\x0e"
			  "\xc3\xac\x4a\xed\xe7\x82\xef\x31"
			  "\x1f\x1a\x51\x1e\x29\x60\xc8\x98"
			  "\x93\x51\x1d\x3d\x62\x59\x83\x82"
			  "\x0c\xf1\xd7\x8d\xac\x33\x44\x81"
			  "\x3c\x59\xb7\xd4\x5b\x65\x82\xc4"
			  "\xec\xdc\x24\xfd\x0e\x1a\x79\x94"
			  "\x34\xb0\x62\xfa\x98\x49\x26\x1f"
			  "\xf4\x9e\x40\x44\x5b\x1f\xf8\xbe"
			  "\x36\xff\xc6\xc6\x9d\xf2\xd6\xcc"
			  "\x63\x93\x29\xb9\x0b\x6d\xd7\x6c"
			  "\xdb\xf6\x21\x80\xf7\x5a\x37\x15"
			  "\x0c\xe3\x36\xc8\x74\x75\x20\x91"
			  "\xdf\x52\x2d\x0c\xe7\x45\xff\x46"
			  "\xb3\xf4\xec\xc2\xbd\xd3\x37\xb6"
			  "\x26\xa2\x5d\x7d\x61\xbf\x10\x46"
			  "\x57\x8d\x05\x96\x70\x0b\xd6\x41"
			  "\x5c\xe9\xd3\x54\x81\x39\x3a\xdd"
			  "\x5f\x92\x81\x6e\x35\x03\xd4\x72"
			  "\x3d\x5a\xe7\xb9\x3b\x0c\x84\x23"
			  "\x45\x5d\xec\x72\xc1\x52\xef\x2e"
			  "\x81\x00\xd3\xfe\x4c\x3c\x05\x61"
			  "\x80\x18\xc4\x6c\x03\xd3\xb7\xba"
			  "\x11\xd7\xb8\x6e\xea\xe1\x80\x30",
		.ilen	= 512,
		.result	= "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
			  "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
			  "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
			  "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
			  "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
			  "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
			  "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
			  "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
			  "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
			  "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
			  "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
			  "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
			  "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
			  "\x4c\x96\x12\xed\x7c\x92\x03\x01"
			  "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
			  "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
			  "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
			  "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
			  "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
			  "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
			  "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
			  "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
			  "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
			  "\x76\x12\x73\x44\x1a\x56\xd7\x72"
			  "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
			  "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
			  "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
			  "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
			  "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
			  "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
			  "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
			  "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
			  "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
			  "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
			  "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
			  "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
			  "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
			  "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
			  "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
			  "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
			  "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
			  "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
			  "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
			  "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
			  "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
			  "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
			  "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
			  "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
			  "\x62\x73\x65\xfd\x46\x63\x25\x3d"
			  "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
			  "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
			  "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
			  "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
			  "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
			  "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
			  "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
			  "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
			  "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
			  "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
			  "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
			  "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
			  "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
			  "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
			  "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
		.rlen	= 512,
	},
};

static struct cipher_testvec tf_xts_enc_tv_template[] = {
	/* Generated from AES-XTS test vectors */
{
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.ilen	= 32,
		.result	= "\x4b\xc9\x44\x4a\x11\xa3\xef\xac"
			  "\x30\x74\xe4\x44\x52\x77\x97\x43"
			  "\xa7\x60\xb2\x45\x2e\xf9\x00\x90"
			  "\x9f\xaa\xfd\x89\x6e\x9d\x4a\xe0",
		.rlen	= 32,
	}, {
		.key	= "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.ilen	= 32,
		.result	= "\x57\x0e\x8f\xe5\x2a\x35\x61\x4f"
			  "\x32\xd3\xbd\x36\x05\x15\x44\x2c"
			  "\x58\x06\xf7\xf8\x00\xa8\xb6\xd5"
			  "\xc6\x28\x92\xdb\xd8\x34\xa2\xe9",
		.rlen	= 32,
	}, {
		.key	= "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
			  "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.ilen	= 32,
		.result	= "\x96\x45\x8f\x8d\x7a\x75\xb1\xde"
			  "\x40\x0c\x89\x56\xf6\x4d\xa7\x07"
			  "\x38\xbb\x5b\xe9\xcd\x84\xae\xb2"
			  "\x7b\x6a\x62\xf4\x8c\xb5\x37\xea",
		.rlen	= 32,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.ilen	= 512,
		.result	= "\xa9\x78\xae\x1e\xea\xa2\x44\x4c"
			  "\xa2\x7a\x64\x1f\xaf\x46\xc1\xe0"
			  "\x6c\xb2\xf3\x92\x9a\xd6\x7d\x58"
			  "\xb8\x2d\xb9\x5d\x58\x07\x66\x50"
			  "\xea\x35\x35\x8c\xb2\x46\x61\x06"
			  "\x5d\x65\xfc\x57\x8f\x69\x74\xab"
			  "\x8a\x06\x69\xb5\x6c\xda\x66\xc7"
			  "\x52\x90\xbb\x8e\x6d\x8b\xb5\xa2"
			  "\x78\x1d\xc2\xa9\xc2\x73\x00\xc3"
			  "\x32\x36\x7c\x97\x6b\x4e\x8a\x50"
			  "\xe4\x91\x83\x96\x8f\xf4\x94\x1a"
			  "\xa6\x27\xe1\x33\xcb\x91\xc6\x5f"
			  "\x94\x75\xbc\xd7\x3e\x3e\x6f\x9e"
			  "\xa9\x31\x80\x5e\xe5\xdb\xc8\x53"
			  "\x01\x73\x68\x32\x25\x19\xfa\xfb"
			  "\xe4\xcf\xb9\x3e\xa2\xa0\x8f\x31"
			  "\xbf\x54\x06\x93\xa8\xb1\x0f\xb6"
			  "\x7c\x3c\xde\x6f\x0f\xfb\x0c\x11"
			  "\x39\x80\x39\x09\x97\x65\xf2\x83"
			  "\xae\xe6\xa1\x6f\x47\xb8\x49\xde"
			  "\x99\x36\x20\x7d\x97\x3b\xec\xfa"
			  "\xb4\x33\x6e\x7a\xc7\x46\x84\x49"
			  "\x91\xcd\xe1\x57\x0d\xed\x40\x08"
			  "\x13\xf1\x4e\x3e\xa4\xa4\x5c\xe6"
			  "\xd2\x0c\x20\x8f\x3e\xdf\x3f\x47"
			  "\x9a\x2f\xde\x6d\x66\xc9\x99\x4a"
			  "\x2d\x9e\x9d\x4b\x1a\x27\xa2\x12"
			  "\x99\xf0\xf8\xb1\xb6\xf6\x57\xc3"
			  "\xca\x1c\xa3\x8e\xed\x39\x28\xb5"
			  "\x10\x1b\x4b\x08\x42\x00\x4a\xd3"
			  "\xad\x5a\xc6\x8e\xc8\xbb\x95\xc4"
			  "\x4b\xaa\xfe\xd5\x42\xa8\xa3\x6d"
			  "\x3c\xf3\x34\x91\x2d\xb4\xdd\x20"
			  "\x0c\x90\x6d\xa3\x9b\x66\x9d\x24"
			  "\x02\xa6\xa9\x3f\x3f\x58\x5d\x47"
			  "\x24\x65\x63\x7e\xbd\x8c\xe6\x52"
			  "\x7d\xef\x33\x53\x63\xec\xaa\x0b"
			  "\x64\x15\xa9\xa6\x1f\x10\x00\x38"
			  "\x35\xa8\xe7\xbe\x23\x70\x22\xe0"
			  "\xd3\xb9\xe6\xfd\xe6\xaa\x03\x50"
			  "\xf3\x3c\x27\x36\x8b\xcc\xfe\x9c"
			  "\x9c\xa3\xb3\xe7\x68\x9b\xa2\x71"
			  "\xe0\x07\xd9\x1f\x68\x1f\xac\x5e"
			  "\x7a\x74\x85\xa9\x6a\x90\xab\x2c"
			  "\x38\x51\xbc\x1f\x43\x4a\x56\x1c"
			  "\xf8\x47\x03\x4e\x67\xa8\x1f\x99"
			  "\x04\x39\x73\x32\xb2\x86\x79\xe7"
			  "\x14\x28\x70\xb8\xe2\x7d\x69\x85"
			  "\xb6\x0f\xc5\xd0\xd0\x01\x5c\xe6"
			  "\x09\x0f\x75\xf7\xb6\x81\xd2\x11"
			  "\x20\x9c\xa1\xee\x11\x44\x79\xd0"
			  "\xb2\x34\x77\xda\x10\x9a\x6f\x6f"
			  "\xef\x7c\xd9\xdc\x35\xb7\x61\xdd"
			  "\xf1\xa4\xc6\x1c\xbf\x05\x22\xac"
			  "\xfe\x2f\x85\x00\x44\xdf\x33\x16"
			  "\x35\xb6\xa3\xd3\x70\xdf\x69\x35"
			  "\x6a\xc7\xb4\x99\x45\x27\xc8\x8e"
			  "\x5a\x14\x30\xd0\x55\x3e\x4f\x64"
			  "\x0d\x38\xe3\xdf\x8b\xa8\x93\x26"
			  "\x75\xae\xf6\xb5\x23\x0b\x17\x31"
			  "\xbf\x27\xb8\xb5\x94\x31\xa7\x8f"
			  "\x43\xc4\x46\x24\x22\x4f\x8f\x7e"
			  "\xe5\xf4\x6d\x1e\x0e\x18\x7a\xbb"
			  "\xa6\x8f\xfb\x49\x49\xd8\x7e\x5a",
		.rlen	= 512,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x62\x49\x77\x57\x24\x70\x93\x69"
			  "\x99\x59\x57\x49\x66\x96\x76\x27"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95"
			  "\x02\x88\x41\x97\x16\x93\x99\x37"
			  "\x51\x05\x82\x09\x74\x94\x45\x92",
		.klen	= 64,
		.iv	= "\xff\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.ilen	= 512,
		.result	= "\xd7\x4b\x93\x7d\x13\xa2\xa2\xe1"
			  "\x35\x39\x71\x88\x76\x1e\xc9\xea"
			  "\x86\xad\xf3\x14\x48\x3d\x5e\xe9"
			  "\xe9\x2d\xb2\x56\x59\x35\x9d\xec"
			  "\x84\xfa\x7e\x9d\x6d\x33\x36\x8f"
			  "\xce\xf4\xa9\x21\x0b\x5f\x96\xec"
			  "\xcb\xf9\x57\x68\x33\x88\x39\xbf"
			  "\x2f\xbb\x59\x03\xbd\x66\x8b\x11"
			  "\x11\x65\x51\x2e\xb8\x67\x05\xd1"
			  "\x27\x11\x5c\xd4\xcc\x97\xc2\xb3"
			  "\xa9\x55\xaf\x07\x56\xd1\xdc\xf5"
			  "\x85\xdc\x46\xe6\xf0\x24\xeb\x93"
			  "\x4d\xf0\x9b\xf5\x73\x1c\xda\x03"
			  "\x22\xc8\x3a\x4f\xb4\x19\x91\x09"
			  "\x54\x0b\xf6\xfe\x17\x3d\x1a\x53"
			  "\x72\x60\x79\xcb\x0e\x32\x8a\x77"
			  "\xd5\xed\xdb\x33\xd7\x62\x16\x69"
			  "\x63\xe0\xab\xb5\xf6\x9c\x5f\x3d"
			  "\x69\x35\x61\x86\xf8\x86\xb9\x89"
			  "\x6e\x59\x35\xac\xf6\x6b\x33\xa0"
			  "\xea\xef\x96\x62\xd8\xa9\xcf\x56"
			  "\xbf\xdb\x8a\xfd\xa1\x82\x77\x73"
			  "\x3d\x94\x4a\x49\x42\x6d\x08\x60"
			  "\xa1\xea\xab\xb6\x88\x13\x94\xb8"
			  "\x51\x98\xdb\x35\x85\xdf\xf6\xb9"
			  "\x8f\xcd\xdf\x80\xd3\x40\x2d\x72"
			  "\xb8\xb2\x6c\x02\x43\x35\x22\x2a"
			  "\x31\xed\xcd\x16\x19\xdf\x62\x0f"
			  "\x29\xcf\x87\x04\xec\x02\x4f\xe4"
			  "\xa2\xed\x73\xc6\x69\xd3\x7e\x89"
			  "\x0b\x76\x10\x7c\xd6\xf9\x6a\x25"
			  "\xed\xcc\x60\x5d\x61\x20\xc1\x97"
			  "\x56\x91\x57\x28\xbe\x71\x0d\xcd"
			  "\xde\xc4\x9e\x55\x91\xbe\xd1\x28"
			  "\x9b\x90\xeb\x73\xf3\x68\x51\xc6"
			  "\xdf\x82\xcc\xd8\x1f\xce\x5b\x27"
			  "\xc0\x60\x5e\x33\xd6\xa7\x20\xea"
			  "\xb2\x54\xc7\x5d\x6a\x3b\x67\x47"
			  "\xcf\xa0\xe3\xab\x86\xaf\xc1\x42"
			  "\xe6\xb0\x23\x4a\xaf\x53\xdf\xa0"
			  "\xad\x12\x32\x31\x03\xf7\x21\xbe"
			  "\x2d\xd5\x82\x42\xb6\x4a\x3d\xcd"
			  "\xd8\x81\x77\xa9\x49\x98\x6c\x09"
			  "\xc5\xa3\x61\x12\x62\x85\x6b\xcd"
			  "\xb3\xf4\x20\x0c\x41\xc4\x05\x37"
			  "\x46\x5f\xeb\x71\x8b\xf1\xaf\x6e"
			  "\xba\xf3\x50\x2e\xfe\xa8\x37\xeb"
			  "\xe8\x8c\x4f\xa4\x0c\xf1\x31\xc8"
			  "\x6e\x71\x4f\xa5\xd7\x97\x73\xe0"
			  "\x93\x4a\x2f\xda\x7b\xe0\x20\x54"
			  "\x1f\x8d\x85\x79\x0b\x7b\x5e\x75"
			  "\xb9\x07\x67\xcc\xc8\xe7\x21\x15"
			  "\xa7\xc8\x98\xff\x4b\x80\x1c\x12"
			  "\xa8\x54\xe1\x38\x52\xe6\x74\x81"
			  "\x97\x47\xa1\x41\x0e\xc0\x50\xe3"
			  "\x55\x0e\xc3\xa7\x70\x77\xce\x07"
			  "\xed\x8c\x88\xe6\xa1\x5b\x14\xec"
			  "\xe6\xde\x06\x6d\x74\xc5\xd9\xfa"
			  "\xe5\x2f\x5a\xff\xc8\x05\xee\x27"
			  "\x35\x61\xbf\x0b\x19\x78\x9b\xd2"
			  "\x04\xc7\x05\xb1\x79\xb4\xff\x5f"
			  "\xf3\xea\x67\x52\x78\xc2\xce\x70"
			  "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97"
			  "\x37\x30\xe1\x91\x8d\xb3\x2a\xff",
		.rlen	= 512,
	},
};

static struct cipher_testvec tf_xts_dec_tv_template[] = {
	/* Generated from AES-XTS test vectors */
	/* same as enc vectors with input and result reversed */
	{
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x4b\xc9\x44\x4a\x11\xa3\xef\xac"
			  "\x30\x74\xe4\x44\x52\x77\x97\x43"
			  "\xa7\x60\xb2\x45\x2e\xf9\x00\x90"
			  "\x9f\xaa\xfd\x89\x6e\x9d\x4a\xe0",
		.ilen	= 32,
		.result	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.rlen	= 32,
	}, {
		.key	= "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x57\x0e\x8f\xe5\x2a\x35\x61\x4f"
			  "\x32\xd3\xbd\x36\x05\x15\x44\x2c"
			  "\x58\x06\xf7\xf8\x00\xa8\xb6\xd5"
			  "\xc6\x28\x92\xdb\xd8\x34\xa2\xe9",
		.ilen	= 32,
		.result	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.rlen	= 32,
	}, {
		.key	= "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
			  "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x96\x45\x8f\x8d\x7a\x75\xb1\xde"
			  "\x40\x0c\x89\x56\xf6\x4d\xa7\x07"
			  "\x38\xbb\x5b\xe9\xcd\x84\xae\xb2"
			  "\x7b\x6a\x62\xf4\x8c\xb5\x37\xea",
		.ilen	= 32,
		.result	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.rlen	= 32,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\xa9\x78\xae\x1e\xea\xa2\x44\x4c"
			  "\xa2\x7a\x64\x1f\xaf\x46\xc1\xe0"
			  "\x6c\xb2\xf3\x92\x9a\xd6\x7d\x58"
			  "\xb8\x2d\xb9\x5d\x58\x07\x66\x50"
			  "\xea\x35\x35\x8c\xb2\x46\x61\x06"
			  "\x5d\x65\xfc\x57\x8f\x69\x74\xab"
			  "\x8a\x06\x69\xb5\x6c\xda\x66\xc7"
			  "\x52\x90\xbb\x8e\x6d\x8b\xb5\xa2"
			  "\x78\x1d\xc2\xa9\xc2\x73\x00\xc3"
			  "\x32\x36\x7c\x97\x6b\x4e\x8a\x50"
			  "\xe4\x91\x83\x96\x8f\xf4\x94\x1a"
			  "\xa6\x27\xe1\x33\xcb\x91\xc6\x5f"
			  "\x94\x75\xbc\xd7\x3e\x3e\x6f\x9e"
			  "\xa9\x31\x80\x5e\xe5\xdb\xc8\x53"
			  "\x01\x73\x68\x32\x25\x19\xfa\xfb"
			  "\xe4\xcf\xb9\x3e\xa2\xa0\x8f\x31"
			  "\xbf\x54\x06\x93\xa8\xb1\x0f\xb6"
			  "\x7c\x3c\xde\x6f\x0f\xfb\x0c\x11"
			  "\x39\x80\x39\x09\x97\x65\xf2\x83"
			  "\xae\xe6\xa1\x6f\x47\xb8\x49\xde"
			  "\x99\x36\x20\x7d\x97\x3b\xec\xfa"
			  "\xb4\x33\x6e\x7a\xc7\x46\x84\x49"
			  "\x91\xcd\xe1\x57\x0d\xed\x40\x08"
			  "\x13\xf1\x4e\x3e\xa4\xa4\x5c\xe6"
			  "\xd2\x0c\x20\x8f\x3e\xdf\x3f\x47"
			  "\x9a\x2f\xde\x6d\x66\xc9\x99\x4a"
			  "\x2d\x9e\x9d\x4b\x1a\x27\xa2\x12"
			  "\x99\xf0\xf8\xb1\xb6\xf6\x57\xc3"
			  "\xca\x1c\xa3\x8e\xed\x39\x28\xb5"
			  "\x10\x1b\x4b\x08\x42\x00\x4a\xd3"
			  "\xad\x5a\xc6\x8e\xc8\xbb\x95\xc4"
			  "\x4b\xaa\xfe\xd5\x42\xa8\xa3\x6d"
			  "\x3c\xf3\x34\x91\x2d\xb4\xdd\x20"
			  "\x0c\x90\x6d\xa3\x9b\x66\x9d\x24"
			  "\x02\xa6\xa9\x3f\x3f\x58\x5d\x47"
			  "\x24\x65\x63\x7e\xbd\x8c\xe6\x52"
			  "\x7d\xef\x33\x53\x63\xec\xaa\x0b"
			  "\x64\x15\xa9\xa6\x1f\x10\x00\x38"
			  "\x35\xa8\xe7\xbe\x23\x70\x22\xe0"
			  "\xd3\xb9\xe6\xfd\xe6\xaa\x03\x50"
			  "\xf3\x3c\x27\x36\x8b\xcc\xfe\x9c"
			  "\x9c\xa3\xb3\xe7\x68\x9b\xa2\x71"
			  "\xe0\x07\xd9\x1f\x68\x1f\xac\x5e"
			  "\x7a\x74\x85\xa9\x6a\x90\xab\x2c"
			  "\x38\x51\xbc\x1f\x43\x4a\x56\x1c"
			  "\xf8\x47\x03\x4e\x67\xa8\x1f\x99"
			  "\x04\x39\x73\x32\xb2\x86\x79\xe7"
			  "\x14\x28\x70\xb8\xe2\x7d\x69\x85"
			  "\xb6\x0f\xc5\xd0\xd0\x01\x5c\xe6"
			  "\x09\x0f\x75\xf7\xb6\x81\xd2\x11"
			  "\x20\x9c\xa1\xee\x11\x44\x79\xd0"
			  "\xb2\x34\x77\xda\x10\x9a\x6f\x6f"
			  "\xef\x7c\xd9\xdc\x35\xb7\x61\xdd"
			  "\xf1\xa4\xc6\x1c\xbf\x05\x22\xac"
			  "\xfe\x2f\x85\x00\x44\xdf\x33\x16"
			  "\x35\xb6\xa3\xd3\x70\xdf\x69\x35"
			  "\x6a\xc7\xb4\x99\x45\x27\xc8\x8e"
			  "\x5a\x14\x30\xd0\x55\x3e\x4f\x64"
			  "\x0d\x38\xe3\xdf\x8b\xa8\x93\x26"
			  "\x75\xae\xf6\xb5\x23\x0b\x17\x31"
			  "\xbf\x27\xb8\xb5\x94\x31\xa7\x8f"
			  "\x43\xc4\x46\x24\x22\x4f\x8f\x7e"
			  "\xe5\xf4\x6d\x1e\x0e\x18\x7a\xbb"
			  "\xa6\x8f\xfb\x49\x49\xd8\x7e\x5a",
		.ilen	= 512,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.rlen	= 512,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x62\x49\x77\x57\x24\x70\x93\x69"
			  "\x99\x59\x57\x49\x66\x96\x76\x27"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95"
			  "\x02\x88\x41\x97\x16\x93\x99\x37"
			  "\x51\x05\x82\x09\x74\x94\x45\x92",
		.klen	= 64,
		.iv	= "\xff\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\xd7\x4b\x93\x7d\x13\xa2\xa2\xe1"
			  "\x35\x39\x71\x88\x76\x1e\xc9\xea"
			  "\x86\xad\xf3\x14\x48\x3d\x5e\xe9"
			  "\xe9\x2d\xb2\x56\x59\x35\x9d\xec"
			  "\x84\xfa\x7e\x9d\x6d\x33\x36\x8f"
			  "\xce\xf4\xa9\x21\x0b\x5f\x96\xec"
			  "\xcb\xf9\x57\x68\x33\x88\x39\xbf"
			  "\x2f\xbb\x59\x03\xbd\x66\x8b\x11"
			  "\x11\x65\x51\x2e\xb8\x67\x05\xd1"
			  "\x27\x11\x5c\xd4\xcc\x97\xc2\xb3"
			  "\xa9\x55\xaf\x07\x56\xd1\xdc\xf5"
			  "\x85\xdc\x46\xe6\xf0\x24\xeb\x93"
			  "\x4d\xf0\x9b\xf5\x73\x1c\xda\x03"
			  "\x22\xc8\x3a\x4f\xb4\x19\x91\x09"
			  "\x54\x0b\xf6\xfe\x17\x3d\x1a\x53"
			  "\x72\x60\x79\xcb\x0e\x32\x8a\x77"
			  "\xd5\xed\xdb\x33\xd7\x62\x16\x69"
			  "\x63\xe0\xab\xb5\xf6\x9c\x5f\x3d"
			  "\x69\x35\x61\x86\xf8\x86\xb9\x89"
			  "\x6e\x59\x35\xac\xf6\x6b\x33\xa0"
			  "\xea\xef\x96\x62\xd8\xa9\xcf\x56"
			  "\xbf\xdb\x8a\xfd\xa1\x82\x77\x73"
			  "\x3d\x94\x4a\x49\x42\x6d\x08\x60"
			  "\xa1\xea\xab\xb6\x88\x13\x94\xb8"
			  "\x51\x98\xdb\x35\x85\xdf\xf6\xb9"
			  "\x8f\xcd\xdf\x80\xd3\x40\x2d\x72"
			  "\xb8\xb2\x6c\x02\x43\x35\x22\x2a"
			  "\x31\xed\xcd\x16\x19\xdf\x62\x0f"
			  "\x29\xcf\x87\x04\xec\x02\x4f\xe4"
			  "\xa2\xed\x73\xc6\x69\xd3\x7e\x89"
			  "\x0b\x76\x10\x7c\xd6\xf9\x6a\x25"
			  "\xed\xcc\x60\x5d\x61\x20\xc1\x97"
			  "\x56\x91\x57\x28\xbe\x71\x0d\xcd"
			  "\xde\xc4\x9e\x55\x91\xbe\xd1\x28"
			  "\x9b\x90\xeb\x73\xf3\x68\x51\xc6"
			  "\xdf\x82\xcc\xd8\x1f\xce\x5b\x27"
			  "\xc0\x60\x5e\x33\xd6\xa7\x20\xea"
			  "\xb2\x54\xc7\x5d\x6a\x3b\x67\x47"
			  "\xcf\xa0\xe3\xab\x86\xaf\xc1\x42"
			  "\xe6\xb0\x23\x4a\xaf\x53\xdf\xa0"
			  "\xad\x12\x32\x31\x03\xf7\x21\xbe"
			  "\x2d\xd5\x82\x42\xb6\x4a\x3d\xcd"
			  "\xd8\x81\x77\xa9\x49\x98\x6c\x09"
			  "\xc5\xa3\x61\x12\x62\x85\x6b\xcd"
			  "\xb3\xf4\x20\x0c\x41\xc4\x05\x37"
			  "\x46\x5f\xeb\x71\x8b\xf1\xaf\x6e"
			  "\xba\xf3\x50\x2e\xfe\xa8\x37\xeb"
			  "\xe8\x8c\x4f\xa4\x0c\xf1\x31\xc8"
			  "\x6e\x71\x4f\xa5\xd7\x97\x73\xe0"
			  "\x93\x4a\x2f\xda\x7b\xe0\x20\x54"
			  "\x1f\x8d\x85\x79\x0b\x7b\x5e\x75"
			  "\xb9\x07\x67\xcc\xc8\xe7\x21\x15"
			  "\xa7\xc8\x98\xff\x4b\x80\x1c\x12"
			  "\xa8\x54\xe1\x38\x52\xe6\x74\x81"
			  "\x97\x47\xa1\x41\x0e\xc0\x50\xe3"
			  "\x55\x0e\xc3\xa7\x70\x77\xce\x07"
			  "\xed\x8c\x88\xe6\xa1\x5b\x14\xec"
			  "\xe6\xde\x06\x6d\x74\xc5\xd9\xfa"
			  "\xe5\x2f\x5a\xff\xc8\x05\xee\x27"
			  "\x35\x61\xbf\x0b\x19\x78\x9b\xd2"
			  "\x04\xc7\x05\xb1\x79\xb4\xff\x5f"
			  "\xf3\xea\x67\x52\x78\xc2\xce\x70"
			  "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97"
			  "\x37\x30\xe1\x91\x8d\xb3\x2a\xff",
		.ilen	= 512,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.rlen	= 512,
	},
};

/*
 * Serpent test vectors.  These are backwards because Serpent writes
 * octet sequences in right-to-left mode.
 */
#define SERPENT_ENC_TEST_VECTORS	5
#define SERPENT_DEC_TEST_VECTORS	5

#define TNEPRES_ENC_TEST_VECTORS	4
#define TNEPRES_DEC_TEST_VECTORS	4

#define SERPENT_CBC_ENC_TEST_VECTORS	1
#define SERPENT_CBC_DEC_TEST_VECTORS	1

#define SERPENT_CTR_ENC_TEST_VECTORS	2
#define SERPENT_CTR_DEC_TEST_VECTORS	2

#define SERPENT_LRW_ENC_TEST_VECTORS	8
#define SERPENT_LRW_DEC_TEST_VECTORS	8

#define SERPENT_XTS_ENC_TEST_VECTORS	5
#define SERPENT_XTS_DEC_TEST_VECTORS	5

static struct cipher_testvec serpent_enc_tv_template[] = {
	{
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.ilen	= 16,
		.result	= "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
			  "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.klen	= 16,
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.ilen	= 16,
		.result	= "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
			  "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.klen	= 32,
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.ilen	= 16,
		.result	= "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
			  "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
		.rlen	= 16,
	}, {
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
		.klen	= 16,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
			  "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
		.rlen	= 16,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
		.ilen	= 144,
		.result	= "\xFB\xB0\x5D\xDE\xC0\xFE\xFC\xEB"
			  "\xB1\x80\x10\x43\xDE\x62\x70\xBD"
			  "\xFA\x8A\x93\xEA\x6B\xF7\xC5\xD7"
			  "\x0C\xD1\xBB\x29\x25\x14\x4C\x22"
			  "\x77\xA6\x38\x00\xDB\xB9\xE2\x07"
			  "\xD1\xAC\x82\xBA\xEA\x67\xAA\x39"
			  "\x99\x34\x89\x5B\x54\xE9\x12\x13"
			  "\x3B\x04\xE5\x12\x42\xC5\x79\xAB"
			  "\x0D\xC7\x3C\x58\x2D\xA3\x98\xF6"
			  "\xE4\x61\x9E\x17\x0B\xCE\xE8\xAA"
			  "\xB5\x6C\x1A\x3A\x67\x52\x81\x6A"
			  "\x04\xFF\x8A\x1B\x96\xFE\xE6\x87"
			  "\x3C\xD4\x39\x7D\x36\x9B\x03\xD5"
			  "\xB6\xA0\x75\x3C\x83\xE6\x1C\x73"
			  "\x9D\x74\x2B\x77\x53\x2D\xE5\xBD"
			  "\x69\xDA\x7A\x01\xF5\x6A\x70\x39"
			  "\x30\xD4\x2C\xF2\x8E\x06\x4B\x39"
			  "\xB3\x12\x1D\xB3\x17\x46\xE6\xD6",
		.rlen	= 144,
	},
};

static struct cipher_testvec tnepres_enc_tv_template[] = {
	{ /* KeySize=128, PT=0, I=1 */
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.key    = "\x80\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen   = 16,
		.ilen	= 16,
		.result	= "\x49\xaf\xbf\xad\x9d\x5a\x34\x05"
			  "\x2c\xd8\xff\xa5\x98\x6b\xd2\xdd",
		.rlen	= 16,
	}, { /* KeySize=192, PT=0, I=1 */
		.key	= "\x80\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 24,
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.ilen	= 16,
		.result	= "\xe7\x8e\x54\x02\xc7\x19\x55\x68"
			  "\xac\x36\x78\xf7\xa3\xf6\x0c\x66",
		.rlen	= 16,
	}, { /* KeySize=256, PT=0, I=1 */
		.key	= "\x80\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 32,
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.ilen	= 16,
		.result	= "\xab\xed\x96\xe7\x66\xbf\x28\xcb"
			  "\xc0\xeb\xd2\x1a\x82\xef\x08\x19",
		.rlen	= 16,
	}, { /* KeySize=256, I=257 */
		.key	= "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18"
			  "\x17\x16\x15\x14\x13\x12\x11\x10"
			  "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
			  "\x07\x06\x05\x04\x03\x02\x01\x00",
		.klen	= 32,
		.input	= "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
			  "\x07\x06\x05\x04\x03\x02\x01\x00",
		.ilen	= 16,
		.result	= "\x5c\xe7\x1c\x70\xd2\x88\x2e\x5b"
			  "\xb8\x32\xe4\x33\xf8\x9f\x26\xde",
		.rlen	= 16,
	},
};


static struct cipher_testvec serpent_dec_tv_template[] = {
	{
		.input	= "\x12\x07\xfc\xce\x9b\xd0\xd6\x47"
			  "\x6a\xe9\x8f\xbe\xd1\x43\xa0\xe2",
		.ilen	= 16,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.klen	= 16,
		.input	= "\x4c\x7d\x8a\x32\x80\x72\xa2\x2c"
			  "\x82\x3e\x4a\x1f\x3a\xcd\xa1\x6d",
		.ilen	= 16,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.klen	= 32,
		.input	= "\xde\x26\x9f\xf8\x33\xe4\x32\xb8"
			  "\x5b\x2e\x88\xd2\x70\x1c\xe7\x5c",
		.ilen	= 16,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.rlen	= 16,
	}, {
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
		.klen	= 16,
		.input	= "\xdd\xd2\x6b\x98\xa5\xff\xd8\x2c"
			  "\x05\x34\x5a\x9d\xad\xbf\xaf\x49",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.input	= "\xFB\xB0\x5D\xDE\xC0\xFE\xFC\xEB"
			  "\xB1\x80\x10\x43\xDE\x62\x70\xBD"
			  "\xFA\x8A\x93\xEA\x6B\xF7\xC5\xD7"
			  "\x0C\xD1\xBB\x29\x25\x14\x4C\x22"
			  "\x77\xA6\x38\x00\xDB\xB9\xE2\x07"
			  "\xD1\xAC\x82\xBA\xEA\x67\xAA\x39"
			  "\x99\x34\x89\x5B\x54\xE9\x12\x13"
			  "\x3B\x04\xE5\x12\x42\xC5\x79\xAB"
			  "\x0D\xC7\x3C\x58\x2D\xA3\x98\xF6"
			  "\xE4\x61\x9E\x17\x0B\xCE\xE8\xAA"
			  "\xB5\x6C\x1A\x3A\x67\x52\x81\x6A"
			  "\x04\xFF\x8A\x1B\x96\xFE\xE6\x87"
			  "\x3C\xD4\x39\x7D\x36\x9B\x03\xD5"
			  "\xB6\xA0\x75\x3C\x83\xE6\x1C\x73"
			  "\x9D\x74\x2B\x77\x53\x2D\xE5\xBD"
			  "\x69\xDA\x7A\x01\xF5\x6A\x70\x39"
			  "\x30\xD4\x2C\xF2\x8E\x06\x4B\x39"
			  "\xB3\x12\x1D\xB3\x17\x46\xE6\xD6",
		.ilen	= 144,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
		.rlen	= 144,
	},
};

static struct cipher_testvec tnepres_dec_tv_template[] = {
	{
		.input	= "\x41\xcc\x6b\x31\x59\x31\x45\x97"
			  "\x6d\x6f\xbb\x38\x4b\x37\x21\x28",
		.ilen	= 16,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.klen	= 16,
		.input	= "\xea\xf4\xd7\xfc\xd8\x01\x34\x47"
			  "\x81\x45\x0b\xfa\x0c\xd6\xad\x6e",
		.ilen	= 16,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.klen	= 32,
		.input	= "\x64\xa9\x1a\x37\xed\x9f\xe7\x49"
			  "\xa8\x4e\x76\xd6\xf5\x0d\x78\xee",
		.ilen	= 16,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.rlen	= 16,
	}, { /* KeySize=128, I=121 */
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80",
		.klen	= 16,
		.input	= "\x3d\xda\xbf\xc0\x06\xda\xab\x06"
			  "\x46\x2a\xf4\xef\x81\x54\x4e\x26",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	},
};

static struct cipher_testvec serpent_cbc_enc_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
		.ilen	= 144,
		.result	= "\x80\xCF\x11\x41\x1A\xB9\x4B\x9C"
			  "\xFF\xB7\x6C\xEA\xF0\xAF\x77\x6E"
			  "\x71\x75\x95\x9D\x4E\x1C\xCF\xAD"
			  "\x81\x34\xE9\x8F\xAE\x5A\x91\x1C"
			  "\x38\x63\x35\x7E\x79\x18\x0A\xE8"
			  "\x67\x06\x76\xD5\xFF\x22\x2F\xDA"
			  "\xB6\x2D\x57\x13\xB6\x3C\xBC\x97"
			  "\xFE\x53\x75\x35\x97\x7F\x51\xEA"
			  "\xDF\x5D\xE8\x9D\xCC\xD9\xAE\xE7"
			  "\x62\x67\xFF\x04\xC2\x18\x22\x5F"
			  "\x2E\x06\xC1\xE2\x26\xCD\xC6\x1E"
			  "\xE5\x2C\x4E\x87\x23\xDD\xF0\x41"
			  "\x08\xA5\xB4\x3E\x07\x1E\x0B\xBB"
			  "\x72\x84\xF8\x0A\x3F\x38\x5E\x91"
			  "\x15\x26\xE1\xDB\xA4\x3D\x74\xD2"
			  "\x41\x1E\x3F\xA9\xC6\x7D\x2A\xAB"
			  "\x27\xDF\x89\x1D\x86\x3E\xF7\x5A"
			  "\xF6\xE3\x0F\xC7\x6B\x4C\x96\x7C",
		.rlen	= 144,
	},
};

static struct cipher_testvec serpent_cbc_dec_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x80\xCF\x11\x41\x1A\xB9\x4B\x9C"
			  "\xFF\xB7\x6C\xEA\xF0\xAF\x77\x6E"
			  "\x71\x75\x95\x9D\x4E\x1C\xCF\xAD"
			  "\x81\x34\xE9\x8F\xAE\x5A\x91\x1C"
			  "\x38\x63\x35\x7E\x79\x18\x0A\xE8"
			  "\x67\x06\x76\xD5\xFF\x22\x2F\xDA"
			  "\xB6\x2D\x57\x13\xB6\x3C\xBC\x97"
			  "\xFE\x53\x75\x35\x97\x7F\x51\xEA"
			  "\xDF\x5D\xE8\x9D\xCC\xD9\xAE\xE7"
			  "\x62\x67\xFF\x04\xC2\x18\x22\x5F"
			  "\x2E\x06\xC1\xE2\x26\xCD\xC6\x1E"
			  "\xE5\x2C\x4E\x87\x23\xDD\xF0\x41"
			  "\x08\xA5\xB4\x3E\x07\x1E\x0B\xBB"
			  "\x72\x84\xF8\x0A\x3F\x38\x5E\x91"
			  "\x15\x26\xE1\xDB\xA4\x3D\x74\xD2"
			  "\x41\x1E\x3F\xA9\xC6\x7D\x2A\xAB"
			  "\x27\xDF\x89\x1D\x86\x3E\xF7\x5A"
			  "\xF6\xE3\x0F\xC7\x6B\x4C\x96\x7C",
		.ilen	= 144,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
		.rlen	= 144,
	},
};

static struct cipher_testvec serpent_ctr_enc_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
		.ilen	= 144,
		.result	= "\x84\x68\xEC\xF2\x1C\x88\x20\xCA"
			  "\x37\x69\xE3\x3A\x22\x85\x48\x46"
			  "\x70\xAA\x25\xB4\xCD\x8B\x04\x4E"
			  "\x8D\x15\x2B\x98\xDF\x7B\x6D\xB9"
			  "\xE0\x4A\x73\x00\x65\xB6\x1A\x0D"
			  "\x5C\x60\xDF\x34\xDC\x60\x4C\xDF"
			  "\xB5\x1F\x26\x8C\xDA\xC1\x11\xA8"
			  "\x80\xFA\x37\x7A\x89\xAA\xAE\x7B"
			  "\x92\x6E\xB9\xDC\xC9\x62\x4F\x88"
			  "\x0A\x5D\x97\x2F\x6B\xAC\x03\x7C"
			  "\x22\xF6\x55\x5A\xFA\x35\xA5\x17"
			  "\xA1\x5C\x5E\x2B\x63\x2D\xB9\x91"
			  "\x3E\x83\x26\x00\x4E\xD5\xBE\xCE"
			  "\x79\xC4\x3D\xFC\x70\xA0\xAD\x96"
			  "\xBA\x58\x2A\x1C\xDF\xC2\x3A\xA5"
			  "\x7C\xB5\x12\x89\xED\xBF\xB6\x09"
			  "\x13\x4F\x7D\x61\x3C\x5C\x27\xFC"
			  "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9",
		.rlen	= 144,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A"
			  "\xF1\x65\xFC",
		.ilen	= 147,
		.result	= "\x84\x68\xEC\xF2\x1C\x88\x20\xCA"
			  "\x37\x69\xE3\x3A\x22\x85\x48\x46"
			  "\x70\xAA\x25\xB4\xCD\x8B\x04\x4E"
			  "\x8D\x15\x2B\x98\xDF\x7B\x6D\xB9"
			  "\xE0\x4A\x73\x00\x65\xB6\x1A\x0D"
			  "\x5C\x60\xDF\x34\xDC\x60\x4C\xDF"
			  "\xB5\x1F\x26\x8C\xDA\xC1\x11\xA8"
			  "\x80\xFA\x37\x7A\x89\xAA\xAE\x7B"
			  "\x92\x6E\xB9\xDC\xC9\x62\x4F\x88"
			  "\x0A\x5D\x97\x2F\x6B\xAC\x03\x7C"
			  "\x22\xF6\x55\x5A\xFA\x35\xA5\x17"
			  "\xA1\x5C\x5E\x2B\x63\x2D\xB9\x91"
			  "\x3E\x83\x26\x00\x4E\xD5\xBE\xCE"
			  "\x79\xC4\x3D\xFC\x70\xA0\xAD\x96"
			  "\xBA\x58\x2A\x1C\xDF\xC2\x3A\xA5"
			  "\x7C\xB5\x12\x89\xED\xBF\xB6\x09"
			  "\x13\x4F\x7D\x61\x3C\x5C\x27\xFC"
			  "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9"
			  "\xE6\xD0\x97",
		.rlen	= 147,
	},
};

static struct cipher_testvec serpent_ctr_dec_tv_template[] = {
	{ /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x84\x68\xEC\xF2\x1C\x88\x20\xCA"
			  "\x37\x69\xE3\x3A\x22\x85\x48\x46"
			  "\x70\xAA\x25\xB4\xCD\x8B\x04\x4E"
			  "\x8D\x15\x2B\x98\xDF\x7B\x6D\xB9"
			  "\xE0\x4A\x73\x00\x65\xB6\x1A\x0D"
			  "\x5C\x60\xDF\x34\xDC\x60\x4C\xDF"
			  "\xB5\x1F\x26\x8C\xDA\xC1\x11\xA8"
			  "\x80\xFA\x37\x7A\x89\xAA\xAE\x7B"
			  "\x92\x6E\xB9\xDC\xC9\x62\x4F\x88"
			  "\x0A\x5D\x97\x2F\x6B\xAC\x03\x7C"
			  "\x22\xF6\x55\x5A\xFA\x35\xA5\x17"
			  "\xA1\x5C\x5E\x2B\x63\x2D\xB9\x91"
			  "\x3E\x83\x26\x00\x4E\xD5\xBE\xCE"
			  "\x79\xC4\x3D\xFC\x70\xA0\xAD\x96"
			  "\xBA\x58\x2A\x1C\xDF\xC2\x3A\xA5"
			  "\x7C\xB5\x12\x89\xED\xBF\xB6\x09"
			  "\x13\x4F\x7D\x61\x3C\x5C\x27\xFC"
			  "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9",
		.ilen	= 144,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A",
		.rlen	= 144,
	}, { /* Generated with Crypto++ */
		.key	= "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9"
			  "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A"
			  "\x27\x04\xE1\x27\x04\xE1\xBE\x9B"
			  "\x78\xBE\x9B\x78\x55\x32\x0F\x55",
		.klen	= 32,
		.iv	= "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F"
			  "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64",
		.input	= "\x84\x68\xEC\xF2\x1C\x88\x20\xCA"
			  "\x37\x69\xE3\x3A\x22\x85\x48\x46"
			  "\x70\xAA\x25\xB4\xCD\x8B\x04\x4E"
			  "\x8D\x15\x2B\x98\xDF\x7B\x6D\xB9"
			  "\xE0\x4A\x73\x00\x65\xB6\x1A\x0D"
			  "\x5C\x60\xDF\x34\xDC\x60\x4C\xDF"
			  "\xB5\x1F\x26\x8C\xDA\xC1\x11\xA8"
			  "\x80\xFA\x37\x7A\x89\xAA\xAE\x7B"
			  "\x92\x6E\xB9\xDC\xC9\x62\x4F\x88"
			  "\x0A\x5D\x97\x2F\x6B\xAC\x03\x7C"
			  "\x22\xF6\x55\x5A\xFA\x35\xA5\x17"
			  "\xA1\x5C\x5E\x2B\x63\x2D\xB9\x91"
			  "\x3E\x83\x26\x00\x4E\xD5\xBE\xCE"
			  "\x79\xC4\x3D\xFC\x70\xA0\xAD\x96"
			  "\xBA\x58\x2A\x1C\xDF\xC2\x3A\xA5"
			  "\x7C\xB5\x12\x89\xED\xBF\xB6\x09"
			  "\x13\x4F\x7D\x61\x3C\x5C\x27\xFC"
			  "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9"
			  "\xE6\xD0\x97",
		.ilen	= 147,
		.result	= "\x56\xED\x84\x1B\x8F\x26\xBD\x31"
			  "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3"
			  "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15"
			  "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87"
			  "\x1E\x92\x29\xC0\x34\xCB\x62\xF9"
			  "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48"
			  "\xDF\x76\x0D\x81\x18\xAF\x23\xBA"
			  "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C"
			  "\xC3\x37\xCE\x65\xFC\x70\x07\x9E"
			  "\x12\xA9\x40\xD7\x4B\xE2\x79\x10"
			  "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F"
			  "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1"
			  "\x68\xFF\x73\x0A\xA1\x15\xAC\x43"
			  "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5"
			  "\x29\xC0\x57\xEE\x62\xF9\x90\x04"
			  "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76"
			  "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8"
			  "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A"
			  "\xF1\x65\xFC",
		.rlen	= 147,
	},
};

static struct cipher_testvec serpent_lrw_enc_tv_template[] = {
	/* Generated from AES-LRW test vectors */
	{
		.key	= "\x45\x62\xac\x25\xf8\x28\x17\x6d"
			  "\x4c\x26\x84\x14\xb5\x68\x01\x85"
			  "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
			  "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x6f\xbf\xd4\xa4\x5d\x71\x16\x79"
			  "\x63\x9c\xa6\x8e\x40\xbe\x0d\x8a",
		.rlen	= 16,
	}, {
		.key	= "\x59\x70\x47\x14\xf5\x57\x47\x8c"
			  "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
			  "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
			  "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x02",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\xfd\xb2\x66\x98\x80\x96\x55\xad"
			  "\x08\x94\x54\x9c\x21\x7c\x69\xe3",
		.rlen	= 16,
	}, {
		.key	= "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
			  "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
			  "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
			  "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x14\x5e\x3d\x70\xc0\x6e\x9c\x34"
			  "\x5b\x5e\xcf\x0f\xe4\x8c\x21\x5c",
		.rlen	= 16,
	}, {
		.key	= "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
			  "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
			  "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
			  "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
			  "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x25\x39\xaa\xa5\xf0\x65\xc8\xdc"
			  "\x5d\x45\x95\x30\x8f\xff\x2f\x1b",
		.rlen	= 16,
	}, {
		.key	= "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
			  "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
			  "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
			  "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
			  "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x0c\x20\x20\x63\xd6\x8b\xfc\x8f"
			  "\xc0\xe2\x17\xbb\xd2\x59\x6f\x26",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\xc1\x35\x2e\x53\xf0\x96\x4d\x9c"
			  "\x2e\x18\xe6\x99\xcd\xd3\x15\x68",
		.rlen	= 16,
	}, {
		.key	= "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
			  "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
			  "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
			  "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
			  "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
			  "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen	= 16,
		.result	= "\x86\x0a\xc6\xa9\x1a\x9f\xe7\xe6"
			  "\x64\x3b\x33\xd6\xd5\x84\xd6\xdf",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
			  "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
			  "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
			  "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
			  "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
			  "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
			  "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
			  "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
			  "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
			  "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
			  "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
			  "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
			  "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
			  "\x4c\x96\x12\xed\x7c\x92\x03\x01"
			  "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
			  "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
			  "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
			  "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
			  "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
			  "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
			  "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
			  "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
			  "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
			  "\x76\x12\x73\x44\x1a\x56\xd7\x72"
			  "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
			  "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
			  "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
			  "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
			  "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
			  "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
			  "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
			  "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
			  "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
			  "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
			  "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
			  "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
			  "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
			  "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
			  "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
			  "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
			  "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
			  "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
			  "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
			  "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
			  "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
			  "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
			  "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
			  "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
			  "\x62\x73\x65\xfd\x46\x63\x25\x3d"
			  "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
			  "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
			  "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
			  "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
			  "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
			  "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
			  "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
			  "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
			  "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
			  "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
			  "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
			  "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
			  "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
			  "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
			  "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
		.ilen	= 512,
		.result	= "\xe3\x5a\x38\x0f\x4d\x92\x3a\x74"
			  "\x15\xb1\x50\x8c\x9a\xd8\x99\x1d"
			  "\x82\xec\xf1\x5f\x03\x6d\x02\x58"
			  "\x90\x67\xfc\xdd\x8d\xe1\x38\x08"
			  "\x7b\xc9\x9b\x4b\x04\x09\x50\x15"
			  "\xce\xab\xda\x33\x30\x20\x12\xfa"
			  "\x83\xc4\xa6\x9a\x2e\x7d\x90\xd9"
			  "\xa6\xa6\x67\x43\xb4\xa7\xa8\x5c"
			  "\xbb\x6a\x49\x2b\x8b\xf8\xd0\x22"
			  "\xe5\x9e\xba\xe8\x8c\x67\xb8\x5b"
			  "\x60\xbc\xf5\xa4\x95\x4e\x66\xe5"
			  "\x6d\x8e\xa9\xf6\x65\x2e\x04\xf5"
			  "\xba\xb5\xdb\x88\xc2\xf6\x7a\x4b"
			  "\x89\x58\x7c\x9a\xae\x26\xe8\xb7"
			  "\xb7\x28\xcc\xd6\xcc\xa5\x98\x4d"
			  "\xb9\x91\xcb\xb4\xe4\x8b\x96\x47"
			  "\x5f\x03\x8b\xdd\x94\xd1\xee\x12"
			  "\xa7\x83\x80\xf2\xc1\x15\x74\x4f"
			  "\x49\xf9\xb0\x7e\x6f\xdc\x73\x2f"
			  "\xe2\xcf\xe0\x1b\x34\xa5\xa0\x52"
			  "\xfb\x3c\x5d\x85\x91\xe6\x6d\x98"
			  "\x04\xd6\xdd\x4c\x00\x64\xd9\x54"
			  "\x5c\x3c\x08\x1d\x4c\x06\x9f\xb8"
			  "\x1c\x4d\x8d\xdc\xa4\x3c\xb9\x3b"
			  "\x9e\x85\xce\xc3\xa8\x4a\x0c\xd9"
			  "\x04\xc3\x6f\x17\x66\xa9\x1f\x59"
			  "\xd9\xe2\x19\x36\xa3\x88\xb8\x0b"
			  "\x0f\x4a\x4d\xf8\xc8\x6f\xd5\x43"
			  "\xeb\xa0\xab\x1f\x61\xc0\x06\xeb"
			  "\x93\xb7\xb8\x6f\x0d\xbd\x07\x49"
			  "\xb3\xac\x5d\xcf\x31\xa0\x27\x26"
			  "\x21\xbe\x94\x2e\x19\xea\xf4\xee"
			  "\xb5\x13\x89\xf7\x94\x0b\xef\x59"
			  "\x44\xc5\x78\x8b\x3c\x3b\x71\x20"
			  "\xf9\x35\x0c\x70\x74\xdc\x5b\xc2"
			  "\xb4\x11\x0e\x2c\x61\xa1\x52\x46"
			  "\x18\x11\x16\xc6\x86\x44\xa7\xaf"
			  "\xd5\x0c\x7d\xa6\x9e\x25\x2d\x1b"
			  "\x9a\x8f\x0f\xf8\x6a\x61\xa0\xea"
			  "\x3f\x0e\x90\xd6\x8f\x83\x30\x64"
			  "\xb5\x51\x2d\x08\x3c\xcd\x99\x36"
			  "\x96\xd4\xb1\xb5\x48\x30\xca\x48"
			  "\xf7\x11\xa8\xf5\x97\x8a\x6a\x6d"
			  "\x12\x33\x2f\xc0\xe8\xda\xec\x8a"
			  "\xe1\x88\x72\x63\xde\x20\xa3\xe1"
			  "\x8e\xac\x84\x37\x35\xf5\xf7\x3f"
			  "\x00\x02\x0e\xe4\xc1\x53\x68\x3f"
			  "\xaa\xd5\xac\x52\x3d\x20\x2f\x4d"
			  "\x7c\x83\xd0\xbd\xaa\x97\x35\x36"
			  "\x98\x88\x59\x5d\xe7\x24\xe3\x90"
			  "\x9d\x30\x47\xa7\xc3\x60\x35\xf4"
			  "\xd5\xdb\x0e\x4d\x44\xc1\x81\x8b"
			  "\xfd\xbd\xc3\x2b\xba\x68\xfe\x8d"
			  "\x49\x5a\x3c\x8a\xa3\x01\xae\x25"
			  "\x42\xab\xd2\x87\x1b\x35\xd6\xd2"
			  "\xd7\x70\x1c\x1f\x72\xd1\xe1\x39"
			  "\x1c\x58\xa2\xb4\xd0\x78\x55\x72"
			  "\x76\x59\xea\xd9\xd7\x6e\x63\x8b"
			  "\xcc\x9b\xa7\x74\x89\xfc\xa3\x68"
			  "\x86\x28\xd1\xbb\x54\x8d\x66\xad"
			  "\x2a\x92\xf9\x4e\x04\x3d\xae\xfd"
			  "\x1b\x2b\x7f\xc3\x2f\x1a\x78\x0a"
			  "\x5c\xc6\x84\xfe\x7c\xcb\x26\xfd"
			  "\xd9\x51\x0f\xd7\x94\x2f\xc5\xa7",
		.rlen	= 512,
	},
};

static struct cipher_testvec serpent_lrw_dec_tv_template[] = {
	/* Generated from AES-LRW test vectors */
	/* same as enc vectors with input and result reversed */
	{
		.key	= "\x45\x62\xac\x25\xf8\x28\x17\x6d"
			  "\x4c\x26\x84\x14\xb5\x68\x01\x85"
			  "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
			  "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x6f\xbf\xd4\xa4\x5d\x71\x16\x79"
			  "\x63\x9c\xa6\x8e\x40\xbe\x0d\x8a",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\x59\x70\x47\x14\xf5\x57\x47\x8c"
			  "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
			  "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
			  "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x02",
		.input	= "\xfd\xb2\x66\x98\x80\x96\x55\xad"
			  "\x08\x94\x54\x9c\x21\x7c\x69\xe3",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
			  "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
			  "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
			  "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x14\x5e\x3d\x70\xc0\x6e\x9c\x34"
			  "\x5b\x5e\xcf\x0f\xe4\x8c\x21\x5c",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
			  "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
			  "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
			  "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
			  "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\x25\x39\xaa\xa5\xf0\x65\xc8\xdc"
			  "\x5d\x45\x95\x30\x8f\xff\x2f\x1b",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\x8a\xd4\xee\x10\x2f\xbd\x81\xff"
			  "\xf8\x86\xce\xac\x93\xc5\xad\xc6"
			  "\xa0\x19\x07\xc0\x9d\xf7\xbb\xdd"
			  "\x52\x13\xb2\xb7\xf0\xff\x11\xd8"
			  "\xd6\x08\xd0\xcd\x2e\xb1\x17\x6f",
		.klen	= 40,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x0c\x20\x20\x63\xd6\x8b\xfc\x8f"
			  "\xc0\xe2\x17\xbb\xd2\x59\x6f\x26",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\xc1\x35\x2e\x53\xf0\x96\x4d\x9c"
			  "\x2e\x18\xe6\x99\xcd\xd3\x15\x68",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xfb\x76\x15\xb2\x3d\x80\x89\x1d"
			  "\xd4\x70\x98\x0b\xc7\x95\x84\xc8"
			  "\xb2\xfb\x64\xce\x60\x97\x87\x8d"
			  "\x17\xfc\xe4\x5a\x49\xe8\x30\xb7"
			  "\x6e\x78\x17\xe7\x2d\x5e\x12\xd4"
			  "\x60\x64\x04\x7a\xf1\x2f\x9e\x0c",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input	= "\x86\x0a\xc6\xa9\x1a\x9f\xe7\xe6"
			  "\x64\x3b\x33\xd6\xd5\x84\xd6\xdf",
		.ilen	= 16,
		.result	= "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.rlen	= 16,
	}, {
		.key	= "\xf8\xd4\x76\xff\xd6\x46\xee\x6c"
			  "\x23\x84\xcb\x1c\x77\xd6\x19\x5d"
			  "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21"
			  "\xa7\x9c\x21\xf8\xcb\x90\x02\x89"
			  "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1"
			  "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e",
		.klen	= 48,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input	= "\xe3\x5a\x38\x0f\x4d\x92\x3a\x74"
			  "\x15\xb1\x50\x8c\x9a\xd8\x99\x1d"
			  "\x82\xec\xf1\x5f\x03\x6d\x02\x58"
			  "\x90\x67\xfc\xdd\x8d\xe1\x38\x08"
			  "\x7b\xc9\x9b\x4b\x04\x09\x50\x15"
			  "\xce\xab\xda\x33\x30\x20\x12\xfa"
			  "\x83\xc4\xa6\x9a\x2e\x7d\x90\xd9"
			  "\xa6\xa6\x67\x43\xb4\xa7\xa8\x5c"
			  "\xbb\x6a\x49\x2b\x8b\xf8\xd0\x22"
			  "\xe5\x9e\xba\xe8\x8c\x67\xb8\x5b"
			  "\x60\xbc\xf5\xa4\x95\x4e\x66\xe5"
			  "\x6d\x8e\xa9\xf6\x65\x2e\x04\xf5"
			  "\xba\xb5\xdb\x88\xc2\xf6\x7a\x4b"
			  "\x89\x58\x7c\x9a\xae\x26\xe8\xb7"
			  "\xb7\x28\xcc\xd6\xcc\xa5\x98\x4d"
			  "\xb9\x91\xcb\xb4\xe4\x8b\x96\x47"
			  "\x5f\x03\x8b\xdd\x94\xd1\xee\x12"
			  "\xa7\x83\x80\xf2\xc1\x15\x74\x4f"
			  "\x49\xf9\xb0\x7e\x6f\xdc\x73\x2f"
			  "\xe2\xcf\xe0\x1b\x34\xa5\xa0\x52"
			  "\xfb\x3c\x5d\x85\x91\xe6\x6d\x98"
			  "\x04\xd6\xdd\x4c\x00\x64\xd9\x54"
			  "\x5c\x3c\x08\x1d\x4c\x06\x9f\xb8"
			  "\x1c\x4d\x8d\xdc\xa4\x3c\xb9\x3b"
			  "\x9e\x85\xce\xc3\xa8\x4a\x0c\xd9"
			  "\x04\xc3\x6f\x17\x66\xa9\x1f\x59"
			  "\xd9\xe2\x19\x36\xa3\x88\xb8\x0b"
			  "\x0f\x4a\x4d\xf8\xc8\x6f\xd5\x43"
			  "\xeb\xa0\xab\x1f\x61\xc0\x06\xeb"
			  "\x93\xb7\xb8\x6f\x0d\xbd\x07\x49"
			  "\xb3\xac\x5d\xcf\x31\xa0\x27\x26"
			  "\x21\xbe\x94\x2e\x19\xea\xf4\xee"
			  "\xb5\x13\x89\xf7\x94\x0b\xef\x59"
			  "\x44\xc5\x78\x8b\x3c\x3b\x71\x20"
			  "\xf9\x35\x0c\x70\x74\xdc\x5b\xc2"
			  "\xb4\x11\x0e\x2c\x61\xa1\x52\x46"
			  "\x18\x11\x16\xc6\x86\x44\xa7\xaf"
			  "\xd5\x0c\x7d\xa6\x9e\x25\x2d\x1b"
			  "\x9a\x8f\x0f\xf8\x6a\x61\xa0\xea"
			  "\x3f\x0e\x90\xd6\x8f\x83\x30\x64"
			  "\xb5\x51\x2d\x08\x3c\xcd\x99\x36"
			  "\x96\xd4\xb1\xb5\x48\x30\xca\x48"
			  "\xf7\x11\xa8\xf5\x97\x8a\x6a\x6d"
			  "\x12\x33\x2f\xc0\xe8\xda\xec\x8a"
			  "\xe1\x88\x72\x63\xde\x20\xa3\xe1"
			  "\x8e\xac\x84\x37\x35\xf5\xf7\x3f"
			  "\x00\x02\x0e\xe4\xc1\x53\x68\x3f"
			  "\xaa\xd5\xac\x52\x3d\x20\x2f\x4d"
			  "\x7c\x83\xd0\xbd\xaa\x97\x35\x36"
			  "\x98\x88\x59\x5d\xe7\x24\xe3\x90"
			  "\x9d\x30\x47\xa7\xc3\x60\x35\xf4"
			  "\xd5\xdb\x0e\x4d\x44\xc1\x81\x8b"
			  "\xfd\xbd\xc3\x2b\xba\x68\xfe\x8d"
			  "\x49\x5a\x3c\x8a\xa3\x01\xae\x25"
			  "\x42\xab\xd2\x87\x1b\x35\xd6\xd2"
			  "\xd7\x70\x1c\x1f\x72\xd1\xe1\x39"
			  "\x1c\x58\xa2\xb4\xd0\x78\x55\x72"
			  "\x76\x59\xea\xd9\xd7\x6e\x63\x8b"
			  "\xcc\x9b\xa7\x74\x89\xfc\xa3\x68"
			  "\x86\x28\xd1\xbb\x54\x8d\x66\xad"
			  "\x2a\x92\xf9\x4e\x04\x3d\xae\xfd"
			  "\x1b\x2b\x7f\xc3\x2f\x1a\x78\x0a"
			  "\x5c\xc6\x84\xfe\x7c\xcb\x26\xfd"
			  "\xd9\x51\x0f\xd7\x94\x2f\xc5\xa7",
		.ilen	= 512,
		.result	= "\x05\x11\xb7\x18\xab\xc6\x2d\xac"
			  "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c"
			  "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8"
			  "\x50\x38\x1f\x71\x49\xb6\x57\xd6"
			  "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90"
			  "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6"
			  "\xad\x1e\x9e\x20\x5f\x38\xbe\x04"
			  "\xda\x10\x8e\xed\xa2\xa4\x87\xab"
			  "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c"
			  "\xc9\xac\x42\x31\x95\x7c\xc9\x04"
			  "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6"
			  "\x15\xd7\x3f\x4f\x2f\x66\x69\x03"
			  "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65"
			  "\x4c\x96\x12\xed\x7c\x92\x03\x01"
			  "\x6f\xbc\x35\x93\xac\xf1\x27\xf1"
			  "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50"
			  "\x89\xa4\x8e\x66\x44\x85\xcc\xfd"
			  "\x33\x14\x70\xe3\x96\xb2\xc3\xd3"
			  "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5"
			  "\x2d\x64\x75\xdd\xb4\x54\xe6\x74"
			  "\x8c\xd3\x9d\x9e\x86\xab\x51\x53"
			  "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40"
			  "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5"
			  "\x76\x12\x73\x44\x1a\x56\xd7\x72"
			  "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda"
			  "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd"
			  "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60"
			  "\x1a\xe2\x70\x85\x58\xc2\x1b\x09"
			  "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9"
			  "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8"
			  "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8"
			  "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10"
			  "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1"
			  "\x90\x3e\x76\x4a\x74\xa4\x21\x2c"
			  "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e"
			  "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f"
			  "\x8d\x23\x31\x74\x84\xeb\x88\x6e"
			  "\xcc\xb9\xbc\x22\x83\x19\x07\x22"
			  "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78"
			  "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5"
			  "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41"
			  "\x3c\xce\x8f\x42\x60\x71\xa7\x75"
			  "\x08\x40\x65\x8a\x82\xbf\xf5\x43"
			  "\x71\x96\xa9\x4d\x44\x8a\x20\xbe"
			  "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65"
			  "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9"
			  "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4"
			  "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a"
			  "\x62\x73\x65\xfd\x46\x63\x25\x3d"
			  "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf"
			  "\x24\xf3\xb4\xac\x64\xba\xdf\x4b"
			  "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7"
			  "\xc5\x68\x77\x84\x32\x2b\xcc\x85"
			  "\x74\x96\xf0\x12\x77\x61\xb9\xeb"
			  "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8"
			  "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24"
			  "\xda\x39\x87\x45\xc0\x2b\xbb\x01"
			  "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce"
			  "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6"
			  "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32"
			  "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45"
			  "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6"
			  "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4"
			  "\x21\xc4\xc2\x75\x67\x89\x37\x0a",
		.rlen	= 512,
	},
};

static struct cipher_testvec serpent_xts_enc_tv_template[] = {
	/* Generated from AES-XTS test vectors */
	{
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.ilen	= 32,
		.result	= "\xe1\x08\xb8\x1d\x2c\xf5\x33\x64"
			  "\xc8\x12\x04\xc7\xb3\x70\xe8\xc4"
			  "\x6a\x31\xc5\xf3\x00\xca\xb9\x16"
			  "\xde\xe2\x77\x66\xf7\xfe\x62\x08",
		.rlen	= 32,
	}, {
		.key	= "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.ilen	= 32,
		.result	= "\x1a\x0a\x09\x5f\xcd\x07\x07\x98"
			  "\x41\x86\x12\xaf\xb3\xd7\x68\x13"
			  "\xed\x81\xcd\x06\x87\x43\x1a\xbb"
			  "\x13\x3d\xd6\x1e\x2b\xe1\x77\xbe",
		.rlen	= 32,
	}, {
		.key	= "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
			  "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.ilen	= 32,
		.result	= "\xf9\x9b\x28\xb8\x5c\xaf\x8c\x61"
			  "\xb6\x1c\x81\x8f\x2c\x87\x60\x89"
			  "\x0d\x8d\x7a\xe8\x60\x48\xcc\x86"
			  "\xc1\x68\x45\xaa\x00\xe9\x24\xc5",
		.rlen	= 32,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.ilen	= 512,
		.result	= "\xfe\x47\x4a\xc8\x60\x7e\xb4\x8b"
			  "\x0d\x10\xf4\xb0\x0d\xba\xf8\x53"
			  "\x65\x6e\x38\x4b\xdb\xaa\xb1\x9e"
			  "\x28\xca\xb0\x22\xb3\x85\x75\xf4"
			  "\x00\x5c\x75\x14\x06\xd6\x25\x82"
			  "\xe6\xcb\x08\xf7\x29\x90\x23\x8e"
			  "\xa4\x68\x57\xe4\xf0\xd8\x32\xf3"
			  "\x80\x51\x67\xb5\x0b\x85\x69\xe8"
			  "\x19\xfe\xc4\xc7\x3e\xea\x90\xd3"
			  "\x8f\xa3\xf2\x0a\xac\x17\x4b\xa0"
			  "\x63\x5a\x16\x0f\xf0\xce\x66\x1f"
			  "\x2c\x21\x07\xf1\xa4\x03\xa3\x44"
			  "\x41\x61\x87\x5d\x6b\xb3\xef\xd4"
			  "\xfc\xaa\x32\x7e\x55\x58\x04\x41"
			  "\xc9\x07\x33\xc6\xa2\x68\xd6\x5a"
			  "\x55\x79\x4b\x6f\xcf\x89\xb9\x19"
			  "\xe5\x54\x13\x15\xb2\x1a\xfa\x15"
			  "\xc2\xf0\x06\x59\xfa\xa0\x25\x05"
			  "\x58\xfa\x43\x91\x16\x85\x40\xbb"
			  "\x0d\x34\x4d\xc5\x1e\x20\xd5\x08"
			  "\xcd\x22\x22\x41\x11\x9f\x6c\x7c"
			  "\x8d\x57\xc9\xba\x57\xe8\x2c\xf7"
			  "\xa0\x42\xa8\xde\xfc\xa3\xca\x98"
			  "\x4b\x43\xb1\xce\x4b\xbf\x01\x67"
			  "\x6e\x29\x60\xbd\x10\x14\x84\x82"
			  "\x83\x82\x0c\x63\x73\x92\x02\x7c"
			  "\x55\x37\x20\x80\x17\x51\xc8\xbc"
			  "\x46\x02\xcb\x38\x07\x6d\xe2\x85"
			  "\xaa\x29\xaf\x24\x58\x0d\xf0\x75"
			  "\x08\x0a\xa5\x34\x25\x16\xf3\x74"
			  "\xa7\x0b\x97\xbe\xc1\xa9\xdc\x29"
			  "\x1a\x0a\x56\xc1\x1a\x91\x97\x8c"
			  "\x0b\xc7\x16\xed\x5a\x22\xa6\x2e"
			  "\x8c\x2b\x4f\x54\x76\x47\x53\x8e"
			  "\xe8\x00\xec\x92\xb9\x55\xe6\xa2"
			  "\xf3\xe2\x4f\x6a\x66\x60\xd0\x87"
			  "\xe6\xd1\xcc\xe3\x6a\xc5\x2d\x21"
			  "\xcc\x9d\x6a\xb6\x75\xaa\xe2\x19"
			  "\x21\x9f\xa1\x5e\x4c\xfd\x72\xf9"
			  "\x94\x4e\x63\xc7\xae\xfc\xed\x47"
			  "\xe2\xfe\x7a\x63\x77\xfe\x97\x82"
			  "\xb1\x10\x6e\x36\x1d\xe1\xc4\x80"
			  "\xec\x69\x41\xec\xa7\x8a\xe0\x2f"
			  "\xe3\x49\x26\xa2\x41\xb2\x08\x0f"
			  "\x28\xb4\xa7\x39\xa1\x99\x2d\x1e"
			  "\x43\x42\x35\xd0\xcf\xec\x77\x67"
			  "\xb2\x3b\x9e\x1c\x35\xde\x4f\x5e"
			  "\x73\x3f\x5d\x6f\x07\x4b\x2e\x50"
			  "\xab\x6c\x6b\xff\xea\x00\x67\xaa"
			  "\x0e\x82\x32\xdd\x3d\xb5\xe5\x76"
			  "\x2b\x77\x3f\xbe\x12\x75\xfb\x92"
			  "\xc6\x89\x67\x4d\xca\xf7\xd4\x50"
			  "\xc0\x74\x47\xcc\xd9\x0a\xd4\xc6"
			  "\x3b\x17\x2e\xe3\x35\xbb\x53\xb5"
			  "\x86\xad\x51\xcc\xd5\x96\xb8\xdc"
			  "\x03\x57\xe6\x98\x52\x2f\x61\x62"
			  "\xc4\x5c\x9c\x36\x71\x07\xfb\x94"
			  "\xe3\x02\xc4\x2b\x08\x75\xc7\x35"
			  "\xfb\x2e\x88\x7b\xbb\x67\x00\xe1"
			  "\xc9\xdd\x99\xb2\x13\x53\x1a\x4e"
			  "\x76\x87\x19\x04\x1a\x2f\x38\x3e"
			  "\xef\x91\x64\x1d\x18\x07\x4e\x31"
			  "\x88\x21\x7c\xb0\xa5\x12\x4c\x3c"
			  "\xb0\x20\xbd\xda\xdf\xf9\x7c\xdd",
		.rlen	= 512,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x62\x49\x77\x57\x24\x70\x93\x69"
			  "\x99\x59\x57\x49\x66\x96\x76\x27"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95"
			  "\x02\x88\x41\x97\x16\x93\x99\x37"
			  "\x51\x05\x82\x09\x74\x94\x45\x92",
		.klen	= 64,
		.iv	= "\xff\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.ilen	= 512,
		.result	= "\x2b\xc9\xb4\x6b\x10\x94\xa9\x32"
			  "\xaa\xb0\x20\xc6\x44\x3d\x74\x1f"
			  "\x75\x01\xa7\xf6\xf5\xf7\x62\x1b"
			  "\x80\x1b\x82\xcb\x01\x59\x91\x7f"
			  "\x80\x3a\x98\xf0\xd2\xca\xc4\xc3"
			  "\x34\xfd\xe6\x11\xf9\x33\x45\x12"
			  "\x48\xc5\x8c\x25\xf1\xc5\xc5\x23"
			  "\xd3\x44\xb4\x73\xd5\x04\xc0\xb7"
			  "\xca\x2f\xf5\xcd\xc5\xb4\xdd\xb0"
			  "\xf4\x60\xe8\xfb\xc6\x9c\xc5\x78"
			  "\xcd\xec\x7d\xdc\x19\x9c\x72\x64"
			  "\x63\x0b\x38\x2e\x76\xdd\x2d\x36"
			  "\x49\xb0\x1d\xea\x78\x9e\x00\xca"
			  "\x20\xcc\x1b\x1e\x98\x74\xab\xed"
			  "\x79\xf7\xd0\x6c\xd8\x93\x80\x29"
			  "\xac\xa5\x5e\x34\xa9\xab\xa0\x55"
			  "\x9a\xea\xaa\x95\x4d\x7b\xfe\x46"
			  "\x26\x8a\xfd\x88\xa2\xa8\xa6\xae"
			  "\x25\x42\x17\xbf\x76\x8f\x1c\x3d"
			  "\xec\x9a\xda\x64\x96\xb5\x61\xff"
			  "\x99\xeb\x12\x96\x85\x82\x9d\xd5"
			  "\x81\x85\x14\xa8\x59\xac\x8c\x94"
			  "\xbb\x3b\x85\x2b\xdf\xb3\x0c\xba"
			  "\x82\xc6\x4d\xca\x86\xea\x53\x28"
			  "\x4c\xe0\x4e\x31\xe3\x73\x2f\x79"
			  "\x9d\x42\xe1\x03\xe3\x8b\xc4\xff"
			  "\x05\xca\x81\x7b\xda\xa2\xde\x63"
			  "\x3a\x10\xbe\xc2\xac\x32\xc4\x05"
			  "\x47\x7e\xef\x67\xe2\x5f\x5b\xae"
			  "\xed\xf1\x70\x34\x16\x9a\x07\x7b"
			  "\xf2\x25\x2b\xb0\xf8\x3c\x15\x9a"
			  "\xa6\x59\x55\x5f\xc1\xf4\x1e\xcd"
			  "\x93\x1f\x06\xba\xd4\x9a\x22\x69"
			  "\xfa\x8e\x95\x0d\xf3\x23\x59\x2c"
			  "\xfe\x00\xba\xf0\x0e\xbc\x6d\xd6"
			  "\x62\xf0\x7a\x0e\x83\x3e\xdb\x32"
			  "\xfd\x43\x7d\xda\x42\x51\x87\x43"
			  "\x9d\xf9\xef\xf4\x30\x97\xf8\x09"
			  "\x88\xfc\x3f\x93\x70\xc1\x4a\xec"
			  "\x27\x5f\x11\xac\x71\xc7\x48\x46"
			  "\x2f\xf9\xdf\x8d\x9f\xf7\x2e\x56"
			  "\x0d\x4e\xb0\x32\x76\xce\x86\x81"
			  "\xcd\xdf\xe4\x00\xbf\xfd\x5f\x24"
			  "\xaf\xf7\x9a\xde\xff\x18\xac\x14"
			  "\x90\xc5\x01\x39\x34\x0f\x24\xf3"
			  "\x13\x2f\x5e\x4f\x30\x9a\x36\x40"
			  "\xec\xea\xbc\xcd\x9e\x0e\x5b\x23"
			  "\x50\x88\x97\x40\x69\xb1\x37\xf5"
			  "\xc3\x15\xf9\x3f\xb7\x79\x64\xe8"
			  "\x7b\x10\x20\xb9\x2b\x46\x83\x5b"
			  "\xd8\x39\xfc\xe4\xfa\x88\x52\xf2"
			  "\x72\xb0\x97\x4e\x89\xb3\x48\x00"
			  "\xc1\x16\x73\x50\x77\xba\xa6\x65"
			  "\x20\x2d\xb0\x02\x27\x89\xda\x99"
			  "\x45\xfb\xe9\xd3\x1d\x39\x2f\xd6"
			  "\x2a\xda\x09\x12\x11\xaf\xe6\x57"
			  "\x01\x04\x8a\xff\x86\x8b\xac\xf8"
			  "\xee\xe4\x1c\x98\x5b\xcf\x6b\x76"
			  "\xa3\x0e\x33\x74\x40\x18\x39\x72"
			  "\x66\x50\x31\xfd\x70\xdf\xe8\x51"
			  "\x96\x21\x36\xb2\x9b\xfa\x85\xd1"
			  "\x30\x05\xc8\x92\x98\x80\xff\x7a"
			  "\xaf\x43\x0b\xc5\x20\x41\x92\x20"
			  "\xd4\xa0\x91\x98\x11\x5f\x4d\xb1",
		.rlen	= 512,
	},
};

static struct cipher_testvec serpent_xts_dec_tv_template[] = {
	/* Generated from AES-XTS test vectors */
	/* same as enc vectors with input and result reversed */
	{
		.key	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\xe1\x08\xb8\x1d\x2c\xf5\x33\x64"
			  "\xc8\x12\x04\xc7\xb3\x70\xe8\xc4"
			  "\x6a\x31\xc5\xf3\x00\xca\xb9\x16"
			  "\xde\xe2\x77\x66\xf7\xfe\x62\x08",
		.ilen	= 32,
		.result	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.rlen	= 32,
	}, {
		.key	= "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x11\x11\x11\x11\x11\x11\x11\x11"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x1a\x0a\x09\x5f\xcd\x07\x07\x98"
			  "\x41\x86\x12\xaf\xb3\xd7\x68\x13"
			  "\xed\x81\xcd\x06\x87\x43\x1a\xbb"
			  "\x13\x3d\xd6\x1e\x2b\xe1\x77\xbe",
		.ilen	= 32,
		.result	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.rlen	= 32,
	}, {
		.key	= "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8"
			  "\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
			  "\x22\x22\x22\x22\x22\x22\x22\x22"
			  "\x22\x22\x22\x22\x22\x22\x22\x22",
		.klen	= 32,
		.iv	= "\x33\x33\x33\x33\x33\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\xf9\x9b\x28\xb8\x5c\xaf\x8c\x61"
			  "\xb6\x1c\x81\x8f\x2c\x87\x60\x89"
			  "\x0d\x8d\x7a\xe8\x60\x48\xcc\x86"
			  "\xc1\x68\x45\xaa\x00\xe9\x24\xc5",
		.ilen	= 32,
		.result	= "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44"
			  "\x44\x44\x44\x44\x44\x44\x44\x44",
		.rlen	= 32,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95",
		.klen	= 32,
		.iv	= "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\xfe\x47\x4a\xc8\x60\x7e\xb4\x8b"
			  "\x0d\x10\xf4\xb0\x0d\xba\xf8\x53"
			  "\x65\x6e\x38\x4b\xdb\xaa\xb1\x9e"
			  "\x28\xca\xb0\x22\xb3\x85\x75\xf4"
			  "\x00\x5c\x75\x14\x06\xd6\x25\x82"
			  "\xe6\xcb\x08\xf7\x29\x90\x23\x8e"
			  "\xa4\x68\x57\xe4\xf0\xd8\x32\xf3"
			  "\x80\x51\x67\xb5\x0b\x85\x69\xe8"
			  "\x19\xfe\xc4\xc7\x3e\xea\x90\xd3"
			  "\x8f\xa3\xf2\x0a\xac\x17\x4b\xa0"
			  "\x63\x5a\x16\x0f\xf0\xce\x66\x1f"
			  "\x2c\x21\x07\xf1\xa4\x03\xa3\x44"
			  "\x41\x61\x87\x5d\x6b\xb3\xef\xd4"
			  "\xfc\xaa\x32\x7e\x55\x58\x04\x41"
			  "\xc9\x07\x33\xc6\xa2\x68\xd6\x5a"
			  "\x55\x79\x4b\x6f\xcf\x89\xb9\x19"
			  "\xe5\x54\x13\x15\xb2\x1a\xfa\x15"
			  "\xc2\xf0\x06\x59\xfa\xa0\x25\x05"
			  "\x58\xfa\x43\x91\x16\x85\x40\xbb"
			  "\x0d\x34\x4d\xc5\x1e\x20\xd5\x08"
			  "\xcd\x22\x22\x41\x11\x9f\x6c\x7c"
			  "\x8d\x57\xc9\xba\x57\xe8\x2c\xf7"
			  "\xa0\x42\xa8\xde\xfc\xa3\xca\x98"
			  "\x4b\x43\xb1\xce\x4b\xbf\x01\x67"
			  "\x6e\x29\x60\xbd\x10\x14\x84\x82"
			  "\x83\x82\x0c\x63\x73\x92\x02\x7c"
			  "\x55\x37\x20\x80\x17\x51\xc8\xbc"
			  "\x46\x02\xcb\x38\x07\x6d\xe2\x85"
			  "\xaa\x29\xaf\x24\x58\x0d\xf0\x75"
			  "\x08\x0a\xa5\x34\x25\x16\xf3\x74"
			  "\xa7\x0b\x97\xbe\xc1\xa9\xdc\x29"
			  "\x1a\x0a\x56\xc1\x1a\x91\x97\x8c"
			  "\x0b\xc7\x16\xed\x5a\x22\xa6\x2e"
			  "\x8c\x2b\x4f\x54\x76\x47\x53\x8e"
			  "\xe8\x00\xec\x92\xb9\x55\xe6\xa2"
			  "\xf3\xe2\x4f\x6a\x66\x60\xd0\x87"
			  "\xe6\xd1\xcc\xe3\x6a\xc5\x2d\x21"
			  "\xcc\x9d\x6a\xb6\x75\xaa\xe2\x19"
			  "\x21\x9f\xa1\x5e\x4c\xfd\x72\xf9"
			  "\x94\x4e\x63\xc7\xae\xfc\xed\x47"
			  "\xe2\xfe\x7a\x63\x77\xfe\x97\x82"
			  "\xb1\x10\x6e\x36\x1d\xe1\xc4\x80"
			  "\xec\x69\x41\xec\xa7\x8a\xe0\x2f"
			  "\xe3\x49\x26\xa2\x41\xb2\x08\x0f"
			  "\x28\xb4\xa7\x39\xa1\x99\x2d\x1e"
			  "\x43\x42\x35\xd0\xcf\xec\x77\x67"
			  "\xb2\x3b\x9e\x1c\x35\xde\x4f\x5e"
			  "\x73\x3f\x5d\x6f\x07\x4b\x2e\x50"
			  "\xab\x6c\x6b\xff\xea\x00\x67\xaa"
			  "\x0e\x82\x32\xdd\x3d\xb5\xe5\x76"
			  "\x2b\x77\x3f\xbe\x12\x75\xfb\x92"
			  "\xc6\x89\x67\x4d\xca\xf7\xd4\x50"
			  "\xc0\x74\x47\xcc\xd9\x0a\xd4\xc6"
			  "\x3b\x17\x2e\xe3\x35\xbb\x53\xb5"
			  "\x86\xad\x51\xcc\xd5\x96\xb8\xdc"
			  "\x03\x57\xe6\x98\x52\x2f\x61\x62"
			  "\xc4\x5c\x9c\x36\x71\x07\xfb\x94"
			  "\xe3\x02\xc4\x2b\x08\x75\xc7\x35"
			  "\xfb\x2e\x88\x7b\xbb\x67\x00\xe1"
			  "\xc9\xdd\x99\xb2\x13\x53\x1a\x4e"
			  "\x76\x87\x19\x04\x1a\x2f\x38\x3e"
			  "\xef\x91\x64\x1d\x18\x07\x4e\x31"
			  "\x88\x21\x7c\xb0\xa5\x12\x4c\x3c"
			  "\xb0\x20\xbd\xda\xdf\xf9\x7c\xdd",
		.ilen	= 512,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.rlen	= 512,
	}, {
		.key	= "\x27\x18\x28\x18\x28\x45\x90\x45"
			  "\x23\x53\x60\x28\x74\x71\x35\x26"
			  "\x62\x49\x77\x57\x24\x70\x93\x69"
			  "\x99\x59\x57\x49\x66\x96\x76\x27"
			  "\x31\x41\x59\x26\x53\x58\x97\x93"
			  "\x23\x84\x62\x64\x33\x83\x27\x95"
			  "\x02\x88\x41\x97\x16\x93\x99\x37"
			  "\x51\x05\x82\x09\x74\x94\x45\x92",
		.klen	= 64,
		.iv	= "\xff\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x00",
		.input	= "\x2b\xc9\xb4\x6b\x10\x94\xa9\x32"
			  "\xaa\xb0\x20\xc6\x44\x3d\x74\x1f"
			  "\x75\x01\xa7\xf6\xf5\xf7\x62\x1b"
			  "\x80\x1b\x82\xcb\x01\x59\x91\x7f"
			  "\x80\x3a\x98\xf0\xd2\xca\xc4\xc3"
			  "\x34\xfd\xe6\x11\xf9\x33\x45\x12"
			  "\x48\xc5\x8c\x25\xf1\xc5\xc5\x23"
			  "\xd3\x44\xb4\x73\xd5\x04\xc0\xb7"
			  "\xca\x2f\xf5\xcd\xc5\xb4\xdd\xb0"
			  "\xf4\x60\xe8\xfb\xc6\x9c\xc5\x78"
			  "\xcd\xec\x7d\xdc\x19\x9c\x72\x64"
			  "\x63\x0b\x38\x2e\x76\xdd\x2d\x36"
			  "\x49\xb0\x1d\xea\x78\x9e\x00\xca"
			  "\x20\xcc\x1b\x1e\x98\x74\xab\xed"
			  "\x79\xf7\xd0\x6c\xd8\x93\x80\x29"
			  "\xac\xa5\x5e\x34\xa9\xab\xa0\x55"
			  "\x9a\xea\xaa\x95\x4d\x7b\xfe\x46"
			  "\x26\x8a\xfd\x88\xa2\xa8\xa6\xae"
			  "\x25\x42\x17\xbf\x76\x8f\x1c\x3d"
			  "\xec\x9a\xda\x64\x96\xb5\x61\xff"
			  "\x99\xeb\x12\x96\x85\x82\x9d\xd5"
			  "\x81\x85\x14\xa8\x59\xac\x8c\x94"
			  "\xbb\x3b\x85\x2b\xdf\xb3\x0c\xba"
			  "\x82\xc6\x4d\xca\x86\xea\x53\x28"
			  "\x4c\xe0\x4e\x31\xe3\x73\x2f\x79"
			  "\x9d\x42\xe1\x03\xe3\x8b\xc4\xff"
			  "\x05\xca\x81\x7b\xda\xa2\xde\x63"
			  "\x3a\x10\xbe\xc2\xac\x32\xc4\x05"
			  "\x47\x7e\xef\x67\xe2\x5f\x5b\xae"
			  "\xed\xf1\x70\x34\x16\x9a\x07\x7b"
			  "\xf2\x25\x2b\xb0\xf8\x3c\x15\x9a"
			  "\xa6\x59\x55\x5f\xc1\xf4\x1e\xcd"
			  "\x93\x1f\x06\xba\xd4\x9a\x22\x69"
			  "\xfa\x8e\x95\x0d\xf3\x23\x59\x2c"
			  "\xfe\x00\xba\xf0\x0e\xbc\x6d\xd6"
			  "\x62\xf0\x7a\x0e\x83\x3e\xdb\x32"
			  "\xfd\x43\x7d\xda\x42\x51\x87\x43"
			  "\x9d\xf9\xef\xf4\x30\x97\xf8\x09"
			  "\x88\xfc\x3f\x93\x70\xc1\x4a\xec"
			  "\x27\x5f\x11\xac\x71\xc7\x48\x46"
			  "\x2f\xf9\xdf\x8d\x9f\xf7\x2e\x56"
			  "\x0d\x4e\xb0\x32\x76\xce\x86\x81"
			  "\xcd\xdf\xe4\x00\xbf\xfd\x5f\x24"
			  "\xaf\xf7\x9a\xde\xff\x18\xac\x14"
			  "\x90\xc5\x01\x39\x34\x0f\x24\xf3"
			  "\x13\x2f\x5e\x4f\x30\x9a\x36\x40"
			  "\xec\xea\xbc\xcd\x9e\x0e\x5b\x23"
			  "\x50\x88\x97\x40\x69\xb1\x37\xf5"
			  "\xc3\x15\xf9\x3f\xb7\x79\x64\xe8"
			  "\x7b\x10\x20\xb9\x2b\x46\x83\x5b"
			  "\xd8\x39\xfc\xe4\xfa\x88\x52\xf2"
			  "\x72\xb0\x97\x4e\x89\xb3\x48\x00"
			  "\xc1\x16\x73\x50\x77\xba\xa6\x65"
			  "\x20\x2d\xb0\x02\x27\x89\xda\x99"
			  "\x45\xfb\xe9\xd3\x1d\x39\x2f\xd6"
			  "\x2a\xda\x09\x12\x11\xaf\xe6\x57"
			  "\x01\x04\x8a\xff\x86\x8b\xac\xf8"
			  "\xee\xe4\x1c\x98\x5b\xcf\x6b\x76"
			  "\xa3\x0e\x33\x74\x40\x18\x39\x72"
			  "\x66\x50\x31\xfd\x70\xdf\xe8\x51"
			  "\x96\x21\x36\xb2\x9b\xfa\x85\xd1"
			  "\x30\x05\xc8\x92\x98\x80\xff\x7a"
			  "\xaf\x43\x0b\xc5\x20\x41\x92\x20"
			  "\xd4\xa0\x91\x98\x11\x5f\x4d\xb1",
		.ilen	= 512,
		.result	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
			  "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			  "\x20\x21\x22\x23\x24\x25\x26\x27"
			  "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			  "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			  "\x40\x41\x42\x43\x44\x45\x46\x47"
			  "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			  "\x50\x51\x52\x53\x54\x55\x56\x57"
			  "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			  "\x60\x61\x62\x63\x64\x65\x66\x67"
			  "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			  "\x70\x71\x72\x73\x74\x75\x76\x77"
			  "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			  "\x80\x81\x82\x83\x84\x85\x86\x87"
			  "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			  "\x90\x91\x92\x93\x94\x95\x96\x97"
			  "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			  "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
			  "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			  "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
			  "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			  "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
			  "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			  "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
			  "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			  "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
			  "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			  "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
			  "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
		.rlen	= 512,
	},
};

/* Cast6 test vectors from RFC 2612 */
#define CAST6_ENC_TEST_VECTORS	3
#define CAST6_DEC_TEST_VECTORS  3

static struct cipher_testvec cast6_enc_tv_template[] = {
	{
		.key	= "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
			  "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d",
		.klen	= 16,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\xc8\x42\xa0\x89\x72\xb4\x3d\x20"
			  "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b",
		.rlen	= 16,
	}, {
		.key	= "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
			  "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
			  "\xba\xc7\x7a\x77\x17\x94\x28\x63",
		.klen	= 24,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\x1b\x38\x6c\x02\x10\xdc\xad\xcb"
			  "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8",
		.rlen	= 16,
	}, {
		.key	= "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
			  "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
			  "\x8d\x7c\x47\xce\x26\x49\x08\x46"
			  "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04",
		.klen	= 32,
		.input	= zeroed_string,
		.ilen	= 16,
		.result	= "\x4f\x6a\x20\x38\x28\x68\x97\xb9"
			  "\xc9\x87\x01\x36\x55\x33\x17\xfa",
		.rlen	= 16,
	},
};

static struct cipher_testvec cast6_dec_tv_template[] = {
	{
		.key	= "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
			  "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d",
		.klen	= 16,
		.input	= "\xc8\x42\xa0\x89\x72\xb4\x3d\x20"
			  "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
			  "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
			  "\xba\xc7\x7a\x77\x17\x94\x28\x63",
		.klen	= 24,
		.input	= "\x1b\x38\x6c\x02\x10\xdc\xad\xcb"
			  "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	}, {
		.key	= "\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
			  "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
			  "\x8d\x7c\x47\xce\x26\x49\x08\x46"
			  "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04",
		.klen	= 32,
		.input	= "\x4f\x6a\x20\x38\x28\x68\x97\xb9"
			  "\xc9\x87\x01\x36\x55\x33\x17\xfa",
		.ilen	= 16,
		.result	= zeroed_string,
		.rlen	= 16,
	},
};


/*
 * AES test vectors.
 */
#define AES_ENC_TEST_VECTORS 3
#define AES_DEC_TEST_VECTORS 3
#define AES_CBC_ENC_TEST_VECTORS 4
#define AES_CBC_DEC_TEST_VECTORS 4
#define AES_LRW_ENC_TEST_VECTORS 8
#define AES_LRW_DEC_TEST_VECTORS 8
#define AES_XTS_ENC_TEST_VECTORS 5
#define AES_XTS_DEC_TEST_VECTORS 5
#define AES_CTR_ENC_TEST_VECTORS 3
#define AES_CTR_DEC_TEST_VECTORS 3
#define AES_OFB_ENC_TEST_VECTORS 1
#define AES_OFB_DEC_TEST_VECTORS 1
#define AES_CTR_3686_ENC_TEST_VECTORS 7
#define AES_CTR_3686_DEC_TEST_VECTORS 6
#define AES_GCM_ENC_TEST_VECTORS 9
#define AES_GCM_DEC_TEST_VECTORS 8
#define AES_GCM_4106_ENC_TEST_VECTORS 7
#define AES_GCM_4106_DEC_TEST_VECTORS 7
#define AES_CCM_ENC_TEST_VECTORS 7
#define AES_CCM_DEC_TEST_VECTORS 7
#define AES_CCM_4309_ENC_TEST_VECTORS 7
#define AES_CCM_4309_DEC_TEST_VECTORS 10

static struct cipher_testvec aes_enc_tv_template[] = {
	{ /* From FIPS-197 */
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.klen	= 16,
		.input	= "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.ilen	= 16,
		.result	= "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30"
			  "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17",
		.klen	= 24,
		.input	= "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.ilen	= 16,
		.result	= "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0"
			  "\x6e\xaf\x70\xa0\xec\x0d\x71\x91",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.klen	= 32,
		.input	= "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.ilen	= 16,
		.result	= "\x8e\xa2\xb7\xca\x51\x67\x45\xbf"
			  "\xea\xfc\x49\x90\x4b\x49\x60\x89",
		.rlen	= 16,
	},
};

static struct cipher_testvec aes_dec_tv_template[] = {
	{ /* From FIPS-197 */
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.klen	= 16,
		.input	= "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30"
			  "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a",
		.ilen	= 16,
		.result	= "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17",
		.klen	= 24,
		.input	= "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0"
			  "\x6e\xaf\x70\xa0\xec\x0d\x71\x91",
		.ilen	= 16,
		.result	= "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.rlen	= 16,
	}, {
		.key	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.klen	= 32,
		.input	= "\x8e\xa2\xb7\xca\x51\x67\x45\xbf"
			  "\xea\xfc\x49\x90\x4b\x49\x60\x89",
		.ilen	= 16,
		.result	= "\x00\x11\x22\x33\x44\x55\x66\x77"
			  "\x88\x99\xaa\xbb\xcc\xdd\xee\xff",
		.rlen	= 16,
	},
};

static struct cipher_testvec aes_cbc_enc_tv_template[] = {
	{ /* From RFC 3602 */
		.key    = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
			  "\x51\x2e\x03\xd5\x34\x12\x00\x06",
		.klen   = 16,
		.iv	= "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
			  "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
		.input	= "Single block msg",
		.ilen   = 16,
		.result = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
			  "\x27\x08\x94\x2d\xbe\x77\x18\x1a",
		.rlen   = 16,
	}, {
		.key    = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
			  "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
		.klen   = 16,
		.iv     = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
			  "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
		.input  = "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.ilen   = 32,
		.result = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
			  "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
			  "\x75\x86\x60\x2d\x25\x3c\xff\xf9"
			  "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1",
		.rlen   = 32,
	}, { /* From NIST SP800-38A */
		.key	= "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
			  "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
			  "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
		.klen	= 24,
		.iv	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.input	= "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
			  "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
			  "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
			  "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
			  "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
			  "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
			  "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
			  "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
		.ilen	= 64,
		.result	= "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
			  "\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
			  "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
			  "\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
			  "\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
			  "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
			  "\x08\xb0\xe2\x79\x88\x59\x88\x81"
			  "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd",
		.rlen	= 64,
	}, {
		.key	= "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
			  "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
			  "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
			  "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
		.klen	= 32,
		.iv	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.input	= "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
			  "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
			  "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
			  "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
			  "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
			  "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
			  "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
			  "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
		.ilen	= 64,
		.result	= "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
			  "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
			  "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
			  "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
			  "\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
			  "\xa5\x30\xe2\x63\x04\x23\x14\x61"
			  "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
			  "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b",
		.rlen	= 64,
	},
};

static struct cipher_testvec aes_cbc_dec_tv_template[] = {
	{ /* From RFC 3602 */
		.key    = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
			  "\x51\x2e\x03\xd5\x34\x12\x00\x06",
		.klen   = 16,
		.iv     = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
			  "\xb4\x22\xda\x80\x2c\x9f\xac\x41",
		.input  = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
			  "\x27\x08\x94\x2d\xbe\x77\x18\x1a",
		.ilen   = 16,
		.result = "Single block msg",
		.rlen   = 16,
	}, {
		.key    = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
			  "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
		.klen   = 16,
		.iv     = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
			  "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
		.input  = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
			  "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
			  "\x75\x86\x60\x2d\x25\x3c\xff\xf9"
			  "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1",
		.ilen   = 32,
		.result = "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			  "\x10\x11\x12\x13\x14\x15\x16\x17"
			  "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
		.rlen   = 32,
	}, { /* From NIST SP800-38A */
		.key	= "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
			  "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
			  "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
		.klen	= 24,
		.iv	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.input	= "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
			  "\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
			  "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
			  "\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
			  "\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
			  "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
			  "\x08\xb0\xe2\x79\x88\x59\x88\x81"
			  "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd",
		.ilen	= 64,
		.result	= "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
			  "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
			  "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
			  "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
			  "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
			  "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
			  "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
			  "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
		.rlen	= 64,
	}, {
		.key	= "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
			  "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
			  "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
			  "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
		.klen	= 32,
		.iv	= "\x00\x01\x02\x03\x04\x05\x06\x07"
			  "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
		.input	= "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
			  "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
			  "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
			  "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
			  "\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
			  "\xa5\x30\xe2\x63\x04\x23\x14\x61"
			  "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
			  "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b",
		.ilen	= 64,
		.result	= "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
			  "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
			  "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
			  "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
			  "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
			  "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
			  "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
			  "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
		.rlen	= 64,
	},
};

static struct cipher_testvec aes_lrw_enc_tv_template[] = {
	/* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
	{ /* LRW-32-AES 1 */
		.key    = "\x45\x62\xac\x25\xf8\x28\x17\x6d"
			  "\x4c\x26\x84\x14\xb5\x68\x01\x85"
			  "\x25\x8e\x2a\x05\xe7\x3e\x9d\x03"
			  "\xee\x5a\x83\x0c\xcc\x09\x4c\x87",
		.klen   = 32,
		.iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen   = 16,
		.result = "\xf1\xb2\x73\xcd\x65\xa3\xdf\x5f"
			  "\xe9\x5d\x48\x92\x54\x63\x4e\xb8",
		.rlen   = 16,
	}, { /* LRW-32-AES 2 */
		.key    = "\x59\x70\x47\x14\xf5\x57\x47\x8c"
			  "\xd7\x79\xe8\x0f\x54\x88\x79\x44"
			  "\x0d\x48\xf0\xb7\xb1\x5a\x53\xea"
			  "\x1c\xaa\x6b\x29\xc2\xca\xfb\xaf",
		.klen   = 32,
		.iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x02",
		.input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen   = 16,
		.result = "\x00\xc8\x2b\xae\x95\xbb\xcd\xe5"
			  "\x27\x4f\x07\x69\xb2\x60\xe1\x36",
		.rlen   = 16,
	}, { /* LRW-32-AES 3 */
		.key    = "\xd8\x2a\x91\x34\xb2\x6a\x56\x50"
			  "\x30\xfe\x69\xe2\x37\x7f\x98\x47"
			  "\xcd\xf9\x0b\x16\x0c\x64\x8f\xb6"
			  "\xb0\x0d\x0d\x1b\xae\x85\x87\x1f",
		.klen   = 32,
		.iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x02\x00\x00\x00\x00",
		.input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen   = 16,
		.result = "\x76\x32\x21\x83\xed\x8f\xf1\x82"
			  "\xf9\x59\x62\x03\x69\x0e\x5e\x01",
		.rlen   = 16,
	}, { /* LRW-32-AES 4 */
		.key    = "\x0f\x6a\xef\xf8\xd3\xd2\xbb\x15"
			  "\x25\x83\xf7\x3c\x1f\x01\x28\x74"
			  "\xca\xc6\xbc\x35\x4d\x4a\x65\x54"
			  "\x90\xae\x61\xcf\x7b\xae\xbd\xcc"
			  "\xad\xe4\x94\xc5\x4a\x29\xae\x70",
		.klen   = 40,
		.iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
			  "\x00\x00\x00\x00\x00\x00\x00\x01",
		.input  = "\x30\x31\x32\x33\x34\x35\x36\x37"
			  "\x38\x39\x41\x42\x43\x44\x45\x46",
		.ilen   = 16,
		.result = "\x9c\x0f\x15\x2f\x55\xa2\xd8\xf0"
			  "\xd6\x7b\x8f\x9e\x28\x22\xbc\x41",
		.rlen   = 16,