blob: 2d07e8af5c4b856114dfcd88d44546b488fb402a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Quick & dirty crypto testing module.
3 *
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
6 *
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
Herbert Xuef2736f2005-06-22 13:26:03 -070012 * Software Foundation; either version 2 of the License, or (at your option)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * any later version.
14 *
Harald Welteebfd9bc2005-06-22 13:27:23 -070015 * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net>
16 * 2003-09-14 Changes by Kartikey Mahendra Bhatt
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 *
18 */
19#ifndef _CRYPTO_TCRYPT_H
20#define _CRYPTO_TCRYPT_H
21
22#define MAX_DIGEST_SIZE 64
23#define MAX_TAP 8
24
25#define MAX_KEYLEN 56
26#define MAX_IVLEN 32
27
28struct hash_testvec {
Atsushi Nemoto06b42aa2006-03-13 21:39:23 +110029 /* only used with keyed hash algorithms */
30 char key[128] __attribute__ ((__aligned__(4)));
Herbert Xuc907ee72006-08-21 22:04:03 +100031 char plaintext[240];
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 char digest[MAX_DIGEST_SIZE];
Herbert Xuef2736f2005-06-22 13:26:03 -070033 unsigned char tap[MAX_TAP];
Atsushi Nemoto06b42aa2006-03-13 21:39:23 +110034 unsigned char psize;
35 unsigned char np;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 unsigned char ksize;
37};
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039struct cipher_testvec {
Atsushi Nemoto06b42aa2006-03-13 21:39:23 +110040 char key[MAX_KEYLEN] __attribute__ ((__aligned__(4)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 char iv[MAX_IVLEN];
42 char input[48];
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 char result[48];
Herbert Xuef2736f2005-06-22 13:26:03 -070044 unsigned char tap[MAX_TAP];
Atsushi Nemoto06b42aa2006-03-13 21:39:23 +110045 int np;
46 unsigned char fail;
47 unsigned char wk; /* weak key flag */
48 unsigned char klen;
49 unsigned char ilen;
50 unsigned char rlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051};
52
Harald Welteebfd9bc2005-06-22 13:27:23 -070053struct cipher_speed {
54 unsigned char klen;
55 unsigned int blen;
56};
57
Herbert Xue9d41162006-08-19 21:38:49 +100058struct hash_speed {
Michal Ludvige8057922006-05-30 22:04:19 +100059 unsigned int blen; /* buffer length */
60 unsigned int plen; /* per-update length */
61};
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063/*
64 * MD4 test vectors from RFC1320
65 */
66#define MD4_TEST_VECTORS 7
67
68static struct hash_testvec md4_tv_template [] = {
69 {
70 .plaintext = "",
71 .digest = { 0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31,
72 0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0 },
73 }, {
74 .plaintext = "a",
75 .psize = 1,
76 .digest = { 0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46,
77 0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24 },
78 }, {
79 .plaintext = "abc",
80 .psize = 3,
81 .digest = { 0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52,
82 0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d },
83 }, {
84 .plaintext = "message digest",
85 .psize = 14,
86 .digest = { 0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8,
87 0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b },
88 }, {
89 .plaintext = "abcdefghijklmnopqrstuvwxyz",
90 .psize = 26,
91 .digest = { 0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd,
92 0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9 },
93 .np = 2,
94 .tap = { 13, 13 },
95 }, {
96 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
97 .psize = 62,
98 .digest = { 0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35,
99 0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4 },
100 }, {
101 .plaintext = "123456789012345678901234567890123456789012345678901234567890123"
102 "45678901234567890",
103 .psize = 80,
104 .digest = { 0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19,
105 0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36 },
106 },
107};
108
109/*
110 * MD5 test vectors from RFC1321
111 */
112#define MD5_TEST_VECTORS 7
113
114static struct hash_testvec md5_tv_template[] = {
115 {
116 .digest = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
117 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e },
118 }, {
119 .plaintext = "a",
120 .psize = 1,
121 .digest = { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8,
122 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 },
123 }, {
124 .plaintext = "abc",
125 .psize = 3,
126 .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
127 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 },
128 }, {
129 .plaintext = "message digest",
130 .psize = 14,
131 .digest = { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d,
132 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 },
133 }, {
134 .plaintext = "abcdefghijklmnopqrstuvwxyz",
135 .psize = 26,
136 .digest = { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00,
137 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b },
138 .np = 2,
139 .tap = {13, 13}
140 }, {
141 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
142 .psize = 62,
143 .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
144 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f },
145 }, {
146 .plaintext = "12345678901234567890123456789012345678901234567890123456789012"
147 "345678901234567890",
148 .psize = 80,
149 .digest = { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55,
150 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a },
151 }
152};
153
154/*
155 * SHA1 test vectors from from FIPS PUB 180-1
156 */
157#define SHA1_TEST_VECTORS 2
158
159static struct hash_testvec sha1_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700160 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 .plaintext = "abc",
162 .psize = 3,
163 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
164 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d },
165 }, {
166 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
167 .psize = 56,
168 .digest = { 0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae,
169 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1 },
170 .np = 2,
171 .tap = { 28, 28 }
172 }
173};
174
175/*
176 * SHA256 test vectors from from NIST
177 */
178#define SHA256_TEST_VECTORS 2
179
Herbert Xuef2736f2005-06-22 13:26:03 -0700180static struct hash_testvec sha256_tv_template[] = {
181 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 .plaintext = "abc",
183 .psize = 3,
184 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
185 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
186 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
187 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad },
188 }, {
189 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
190 .psize = 56,
191 .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
192 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
193 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
194 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 },
195 .np = 2,
196 .tap = { 28, 28 }
197 },
198};
199
200/*
201 * SHA384 test vectors from from NIST and kerneli
202 */
203#define SHA384_TEST_VECTORS 4
204
205static struct hash_testvec sha384_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700206 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 .plaintext= "abc",
208 .psize = 3,
209 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
210 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
211 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
212 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
213 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
214 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 },
215 }, {
216 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
217 .psize = 56,
218 .digest = { 0x33, 0x91, 0xfd, 0xdd, 0xfc, 0x8d, 0xc7, 0x39,
219 0x37, 0x07, 0xa6, 0x5b, 0x1b, 0x47, 0x09, 0x39,
220 0x7c, 0xf8, 0xb1, 0xd1, 0x62, 0xaf, 0x05, 0xab,
221 0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6,
222 0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f,
223 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b},
224 }, {
225 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
Herbert Xuef2736f2005-06-22 13:26:03 -0700226 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 .psize = 112,
228 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
229 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
230 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
231 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
232 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
233 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 },
234 }, {
235 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
236 "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
237 .psize = 104,
238 .digest = { 0x3d, 0x20, 0x89, 0x73, 0xab, 0x35, 0x08, 0xdb,
239 0xbd, 0x7e, 0x2c, 0x28, 0x62, 0xba, 0x29, 0x0a,
240 0xd3, 0x01, 0x0e, 0x49, 0x78, 0xc1, 0x98, 0xdc,
241 0x4d, 0x8f, 0xd0, 0x14, 0xe5, 0x82, 0x82, 0x3a,
242 0x89, 0xe1, 0x6f, 0x9b, 0x2a, 0x7b, 0xbc, 0x1a,
243 0xc9, 0x38, 0xe2, 0xd1, 0x99, 0xe8, 0xbe, 0xa4 },
244 .np = 4,
245 .tap = { 26, 26, 26, 26 }
246 },
247};
248
249/*
250 * SHA512 test vectors from from NIST and kerneli
251 */
252#define SHA512_TEST_VECTORS 4
253
254static struct hash_testvec sha512_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700255 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .plaintext = "abc",
257 .psize = 3,
258 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
259 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
260 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
261 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
262 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
263 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
264 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
265 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f },
266 }, {
267 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
268 .psize = 56,
269 .digest = { 0x20, 0x4a, 0x8f, 0xc6, 0xdd, 0xa8, 0x2f, 0x0a,
270 0x0c, 0xed, 0x7b, 0xeb, 0x8e, 0x08, 0xa4, 0x16,
271 0x57, 0xc1, 0x6e, 0xf4, 0x68, 0xb2, 0x28, 0xa8,
272 0x27, 0x9b, 0xe3, 0x31, 0xa7, 0x03, 0xc3, 0x35,
273 0x96, 0xfd, 0x15, 0xc1, 0x3b, 0x1b, 0x07, 0xf9,
274 0xaa, 0x1d, 0x3b, 0xea, 0x57, 0x78, 0x9c, 0xa0,
275 0x31, 0xad, 0x85, 0xc7, 0xa7, 0x1d, 0xd7, 0x03,
276 0x54, 0xec, 0x63, 0x12, 0x38, 0xca, 0x34, 0x45 },
277 }, {
278 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
279 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
280 .psize = 112,
281 .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
282 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
283 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
284 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
285 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
286 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
287 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
288 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 },
289 }, {
290 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
291 "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
292 .psize = 104,
293 .digest = { 0x93, 0x0d, 0x0c, 0xef, 0xcb, 0x30, 0xff, 0x11,
294 0x33, 0xb6, 0x89, 0x81, 0x21, 0xf1, 0xcf, 0x3d,
295 0x27, 0x57, 0x8a, 0xfc, 0xaf, 0xe8, 0x67, 0x7c,
296 0x52, 0x57, 0xcf, 0x06, 0x99, 0x11, 0xf7, 0x5d,
297 0x8f, 0x58, 0x31, 0xb5, 0x6e, 0xbf, 0xda, 0x67,
298 0xb2, 0x78, 0xe6, 0x6d, 0xff, 0x8b, 0x84, 0xfe,
299 0x2b, 0x28, 0x70, 0xf7, 0x42, 0xa5, 0x80, 0xd8,
300 0xed, 0xb4, 0x19, 0x87, 0x23, 0x28, 0x50, 0xc9 },
301 .np = 4,
302 .tap = { 26, 26, 26, 26 }
303 },
304};
305
306
307/*
Herbert Xuef2736f2005-06-22 13:26:03 -0700308 * WHIRLPOOL test vectors from Whirlpool package
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
310 * submission
311 */
312#define WP512_TEST_VECTORS 8
313
314static struct hash_testvec wp512_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700315 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 .plaintext = "",
317 .psize = 0,
318 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
319 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
320 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
321 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
322 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
323 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57,
324 0xEA, 0x89, 0x64, 0xE5, 0x9B, 0x63, 0xD9, 0x37,
325 0x08, 0xB1, 0x38, 0xCC, 0x42, 0xA6, 0x6E, 0xB3 },
326
327
328 }, {
329 .plaintext = "a",
330 .psize = 1,
331 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
332 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
333 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
334 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
335 0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
336 0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59,
337 0x1A, 0x92, 0x20, 0x0D, 0x56, 0x01, 0x95, 0xE5,
338 0x3B, 0x47, 0x85, 0x84, 0xFD, 0xAE, 0x23, 0x1A },
339 }, {
340 .plaintext = "abc",
341 .psize = 3,
342 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
343 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
344 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
345 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
346 0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
347 0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6,
348 0xC7, 0x97, 0xFC, 0x9D, 0x95, 0xD8, 0xB5, 0x82,
349 0xD2, 0x25, 0x29, 0x20, 0x76, 0xD4, 0xEE, 0xF5 },
350 }, {
351 .plaintext = "message digest",
352 .psize = 14,
Herbert Xuef2736f2005-06-22 13:26:03 -0700353 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
354 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
355 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
356 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
357 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
358 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6,
359 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E },
361 }, {
362 .plaintext = "abcdefghijklmnopqrstuvwxyz",
363 .psize = 26,
364 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
365 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
366 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
367 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
368 0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
369 0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6,
370 0xF6, 0x8F, 0x67, 0x3E, 0x72, 0x07, 0x86, 0x5D,
371 0x5D, 0x98, 0x19, 0xA3, 0xDB, 0xA4, 0xEB, 0x3B },
372 }, {
373 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
374 "abcdefghijklmnopqrstuvwxyz0123456789",
375 .psize = 62,
376 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
377 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
378 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
379 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
380 0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
381 0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6,
382 0x55, 0x17, 0xCC, 0x87, 0x9D, 0x7B, 0x96, 0x21,
383 0x42, 0xC6, 0x5F, 0x5A, 0x7A, 0xF0, 0x14, 0x67 },
384 }, {
385 .plaintext = "1234567890123456789012345678901234567890"
386 "1234567890123456789012345678901234567890",
387 .psize = 80,
388 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
389 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
390 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
391 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
392 0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
393 0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A,
394 0x2C, 0x60, 0x48, 0x1E, 0x88, 0xC5, 0xA2, 0x0B,
395 0x2C, 0x2A, 0x80, 0xCF, 0x3A, 0x9A, 0x08, 0x3B },
396 }, {
397 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
398 .psize = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -0700399 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
401 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
402 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
403 0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
404 0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56,
405 0x93, 0x9B, 0xAA, 0xA0, 0xAD, 0xFF, 0x9A, 0xE6,
406 0x74, 0x5B, 0x7B, 0x18, 0x1C, 0x3B, 0xE3, 0xFD },
407 },
408};
409
410#define WP384_TEST_VECTORS 8
411
412static struct hash_testvec wp384_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700413 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 .plaintext = "",
415 .psize = 0,
416 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
417 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
418 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
419 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
420 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
421 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57 },
422
423
424 }, {
425 .plaintext = "a",
426 .psize = 1,
427 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
428 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
429 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
430 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
431 0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
432 0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59 },
433 }, {
434 .plaintext = "abc",
435 .psize = 3,
436 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
437 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
438 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
439 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
440 0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
441 0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6 },
442 }, {
443 .plaintext = "message digest",
444 .psize = 14,
Herbert Xuef2736f2005-06-22 13:26:03 -0700445 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
446 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
447 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
448 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
449 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 },
451 }, {
452 .plaintext = "abcdefghijklmnopqrstuvwxyz",
453 .psize = 26,
454 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
455 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
456 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
457 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
458 0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
459 0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6 },
460 }, {
461 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
462 "abcdefghijklmnopqrstuvwxyz0123456789",
463 .psize = 62,
464 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
465 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
466 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
467 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
468 0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
469 0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6 },
470 }, {
471 .plaintext = "1234567890123456789012345678901234567890"
472 "1234567890123456789012345678901234567890",
473 .psize = 80,
474 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
475 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
476 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
477 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
478 0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
479 0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A },
480 }, {
481 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
482 .psize = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -0700483 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
485 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
486 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
487 0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
488 0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56 },
489 },
490};
491
492#define WP256_TEST_VECTORS 8
493
494static struct hash_testvec wp256_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .plaintext = "",
497 .psize = 0,
498 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
499 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
500 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
501 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7 },
502
503
504 }, {
505 .plaintext = "a",
506 .psize = 1,
507 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
508 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
509 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
510 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42 },
511 }, {
512 .plaintext = "abc",
513 .psize = 3,
514 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
515 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
516 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
517 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C },
518 }, {
519 .plaintext = "message digest",
520 .psize = 14,
Herbert Xuef2736f2005-06-22 13:26:03 -0700521 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
522 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
523 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B },
525 }, {
526 .plaintext = "abcdefghijklmnopqrstuvwxyz",
527 .psize = 26,
528 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
529 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
530 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
531 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B },
532 }, {
533 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
534 "abcdefghijklmnopqrstuvwxyz0123456789",
535 .psize = 62,
536 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
537 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
538 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
539 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E },
540 }, {
541 .plaintext = "1234567890123456789012345678901234567890"
542 "1234567890123456789012345678901234567890",
543 .psize = 80,
544 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
545 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
546 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
547 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29 },
548 }, {
549 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
550 .psize = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -0700551 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
553 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
554 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 },
555 },
556};
557
558/*
Herbert Xuef2736f2005-06-22 13:26:03 -0700559 * TIGER test vectors from Tiger website
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 */
561#define TGR192_TEST_VECTORS 6
562
563static struct hash_testvec tgr192_tv_template[] = {
564 {
565 .plaintext = "",
566 .psize = 0,
567 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
568 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
569 0xf3, 0x73, 0xde, 0x2d, 0x49, 0x58, 0x4e, 0x7a },
570 }, {
571 .plaintext = "abc",
572 .psize = 3,
573 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
574 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
575 0x93, 0x5f, 0x7b, 0x95, 0x1c, 0x13, 0x29, 0x51 },
576 }, {
577 .plaintext = "Tiger",
578 .psize = 5,
579 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
580 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
581 0x37, 0x79, 0x0c, 0x11, 0x6f, 0x9d, 0x2b, 0xdf },
582 }, {
583 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
584 .psize = 64,
585 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
586 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
587 0xb5, 0x86, 0x44, 0x50, 0x34, 0xa5, 0xa3, 0x86 },
588 }, {
589 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
590 .psize = 64,
591 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
592 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
593 0x57, 0x89, 0x65, 0x65, 0x97, 0x5f, 0x91, 0x97 },
594 }, {
595 .plaintext = "Tiger - A Fast New Hash Function, "
596 "by Ross Anderson and Eli Biham, "
597 "proceedings of Fast Software Encryption 3, "
598 "Cambridge, 1996.",
599 .psize = 125,
600 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
601 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
602 0xdd, 0x68, 0x15, 0x1d, 0x50, 0x39, 0x74, 0xfc },
603 },
604};
605
606#define TGR160_TEST_VECTORS 6
607
608static struct hash_testvec tgr160_tv_template[] = {
609 {
610 .plaintext = "",
611 .psize = 0,
612 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
613 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
614 0xf3, 0x73, 0xde, 0x2d },
615 }, {
616 .plaintext = "abc",
617 .psize = 3,
618 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
619 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
620 0x93, 0x5f, 0x7b, 0x95 },
621 }, {
622 .plaintext = "Tiger",
623 .psize = 5,
624 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
625 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
626 0x37, 0x79, 0x0c, 0x11 },
627 }, {
628 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
629 .psize = 64,
630 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
631 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
632 0xb5, 0x86, 0x44, 0x50 },
633 }, {
634 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
635 .psize = 64,
636 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
637 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
638 0x57, 0x89, 0x65, 0x65 },
639 }, {
640 .plaintext = "Tiger - A Fast New Hash Function, "
641 "by Ross Anderson and Eli Biham, "
642 "proceedings of Fast Software Encryption 3, "
643 "Cambridge, 1996.",
644 .psize = 125,
645 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
646 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
647 0xdd, 0x68, 0x15, 0x1d },
648 },
649};
650
651#define TGR128_TEST_VECTORS 6
652
653static struct hash_testvec tgr128_tv_template[] = {
654 {
655 .plaintext = "",
656 .psize = 0,
657 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
658 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f },
659 }, {
660 .plaintext = "abc",
661 .psize = 3,
662 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
663 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf },
664 }, {
665 .plaintext = "Tiger",
666 .psize = 5,
667 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
668 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec },
669 }, {
670 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
671 .psize = 64,
672 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
673 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e },
674 }, {
675 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
676 .psize = 64,
677 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
678 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9 },
679 }, {
680 .plaintext = "Tiger - A Fast New Hash Function, "
681 "by Ross Anderson and Eli Biham, "
682 "proceedings of Fast Software Encryption 3, "
683 "Cambridge, 1996.",
684 .psize = 125,
685 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
686 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24 },
687 },
688};
689
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690/*
691 * HMAC-MD5 test vectors from RFC2202
692 * (These need to be fixed to not use strlen).
693 */
694#define HMAC_MD5_TEST_VECTORS 7
695
Herbert Xue9d41162006-08-19 21:38:49 +1000696static struct hash_testvec hmac_md5_tv_template[] =
Herbert Xuef2736f2005-06-22 13:26:03 -0700697{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 {
699 .key = { [0 ... 15] = 0x0b },
700 .ksize = 16,
701 .plaintext = "Hi There",
702 .psize = 8,
703 .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
704 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
705 }, {
706 .key = { 'J', 'e', 'f', 'e' },
707 .ksize = 4,
708 .plaintext = "what do ya want for nothing?",
709 .psize = 28,
710 .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
711 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
712 .np = 2,
713 .tap = {14, 14}
714 }, {
715 .key = { [0 ... 15] = 0xaa },
716 .ksize = 16,
717 .plaintext = { [0 ... 49] = 0xdd },
718 .psize = 50,
719 .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
720 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 },
721 }, {
722 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
723 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
724 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, },
725 .ksize = 25,
726 .plaintext = { [0 ... 49] = 0xcd },
727 .psize = 50,
728 .digest = { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
729 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 },
730 }, {
731 .key = { [0 ... 15] = 0x0c },
732 .ksize = 16,
733 .plaintext = "Test With Truncation",
734 .psize = 20,
735 .digest = { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
736 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c },
737 }, {
738 .key = { [0 ... 79] = 0xaa },
739 .ksize = 80,
740 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
741 .psize = 54,
742 .digest = { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f,
743 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd },
744 }, {
745 .key = { [0 ... 79] = 0xaa },
746 .ksize = 80,
747 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
748 "Block-Size Data",
749 .psize = 73,
750 .digest = { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee,
751 0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e },
752 },
753};
754
755/*
756 * HMAC-SHA1 test vectors from RFC2202
757 */
758#define HMAC_SHA1_TEST_VECTORS 7
759
Herbert Xue9d41162006-08-19 21:38:49 +1000760static struct hash_testvec hmac_sha1_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 {
762 .key = { [0 ... 19] = 0x0b },
763 .ksize = 20,
764 .plaintext = "Hi There",
765 .psize = 8,
766 .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
767 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1,
768 0x46, 0xbe },
769 }, {
Herbert Xuef2736f2005-06-22 13:26:03 -0700770 .key = { 'J', 'e', 'f', 'e' },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 .ksize = 4,
772 .plaintext = "what do ya want for nothing?",
773 .psize = 28,
Herbert Xuef2736f2005-06-22 13:26:03 -0700774 .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 },
776 .np = 2,
777 .tap = { 14, 14 }
778 }, {
779 .key = { [0 ... 19] = 0xaa },
780 .ksize = 20,
781 .plaintext = { [0 ... 49] = 0xdd },
782 .psize = 50,
Herbert Xuef2736f2005-06-22 13:26:03 -0700783 .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 },
785 }, {
786 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
Herbert Xuef2736f2005-06-22 13:26:03 -0700787 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 },
789 .ksize = 25,
790 .plaintext = { [0 ... 49] = 0xcd },
791 .psize = 50,
Herbert Xuef2736f2005-06-22 13:26:03 -0700792 .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda },
794 }, {
795 .key = { [0 ... 19] = 0x0c },
796 .ksize = 20,
797 .plaintext = "Test With Truncation",
798 .psize = 20,
Herbert Xuef2736f2005-06-22 13:26:03 -0700799 .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 },
801 }, {
802 .key = { [0 ... 79] = 0xaa },
803 .ksize = 80,
804 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
805 .psize = 54,
Herbert Xuef2736f2005-06-22 13:26:03 -0700806 .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 },
808 }, {
809 .key = { [0 ... 79] = 0xaa },
810 .ksize = 80,
811 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
812 "Block-Size Data",
813 .psize = 73,
Herbert Xuef2736f2005-06-22 13:26:03 -0700814 .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 },
816 },
817};
818
819/*
820 * HMAC-SHA256 test vectors from
821 * draft-ietf-ipsec-ciph-sha-256-01.txt
822 */
823#define HMAC_SHA256_TEST_VECTORS 10
824
Herbert Xue9d41162006-08-19 21:38:49 +1000825static struct hash_testvec hmac_sha256_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 {
827 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
828 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
829 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
830 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20},
831 .ksize = 32,
832 .plaintext = "abc",
833 .psize = 3,
834 .digest = { 0xa2, 0x1b, 0x1f, 0x5d, 0x4c, 0xf4, 0xf7, 0x3a,
835 0x4d, 0xd9, 0x39, 0x75, 0x0f, 0x7a, 0x06, 0x6a,
836 0x7f, 0x98, 0xcc, 0x13, 0x1c, 0xb1, 0x6a, 0x66,
837 0x92, 0x75, 0x90, 0x21, 0xcf, 0xab, 0x81, 0x81 },
838 }, {
839 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
840 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
841 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
842 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
843 .ksize = 32,
844 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
845 .psize = 56,
846 .digest = { 0x10, 0x4f, 0xdc, 0x12, 0x57, 0x32, 0x8f, 0x08,
847 0x18, 0x4b, 0xa7, 0x31, 0x31, 0xc5, 0x3c, 0xae,
848 0xe6, 0x98, 0xe3, 0x61, 0x19, 0x42, 0x11, 0x49,
849 0xea, 0x8c, 0x71, 0x24, 0x56, 0x69, 0x7d, 0x30 },
850 }, {
851 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
852 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
853 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
854 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
855 .ksize = 32,
856 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
857 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
858 .psize = 112,
859 .digest = { 0x47, 0x03, 0x05, 0xfc, 0x7e, 0x40, 0xfe, 0x34,
860 0xd3, 0xee, 0xb3, 0xe7, 0x73, 0xd9, 0x5a, 0xab,
861 0x73, 0xac, 0xf0, 0xfd, 0x06, 0x04, 0x47, 0xa5,
862 0xeb, 0x45, 0x95, 0xbf, 0x33, 0xa9, 0xd1, 0xa3 },
863 }, {
864 .key = { [0 ... 31] = 0x0b },
865 .ksize = 32,
866 .plaintext = "Hi There",
867 .psize = 8,
868 .digest = { 0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb, 0xc6,
869 0x99, 0x03, 0xa0, 0xf1, 0xcf, 0x2b, 0xbd, 0xc5,
870 0xba, 0x0a, 0xa3, 0xf3, 0xd9, 0xae, 0x3c, 0x1c,
871 0x7a, 0x3b, 0x16, 0x96, 0xa0, 0xb6, 0x8c, 0xf7 },
872 }, {
873 .key = "Jefe",
874 .ksize = 4,
875 .plaintext = "what do ya want for nothing?",
876 .psize = 28,
877 .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
878 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
879 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
880 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 },
881 .np = 2,
882 .tap = { 14, 14 }
883 }, {
884 .key = { [0 ... 31] = 0xaa },
885 .ksize = 32,
886 .plaintext = { [0 ... 49] = 0xdd },
887 .psize = 50,
888 .digest = { 0xcd, 0xcb, 0x12, 0x20, 0xd1, 0xec, 0xcc, 0xea,
889 0x91, 0xe5, 0x3a, 0xba, 0x30, 0x92, 0xf9, 0x62,
890 0xe5, 0x49, 0xfe, 0x6c, 0xe9, 0xed, 0x7f, 0xdc,
891 0x43, 0x19, 0x1f, 0xbd, 0xe4, 0x5c, 0x30, 0xb0 },
892 }, {
893 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
894 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
895 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
896 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
897 0x21, 0x22, 0x23, 0x24, 0x25 },
898 .ksize = 37,
899 .plaintext = { [0 ... 49] = 0xcd },
900 .psize = 50,
901 .digest = { 0xd4, 0x63, 0x3c, 0x17, 0xf6, 0xfb, 0x8d, 0x74,
902 0x4c, 0x66, 0xde, 0xe0, 0xf8, 0xf0, 0x74, 0x55,
903 0x6e, 0xc4, 0xaf, 0x55, 0xef, 0x07, 0x99, 0x85,
904 0x41, 0x46, 0x8e, 0xb4, 0x9b, 0xd2, 0xe9, 0x17 },
905 }, {
906 .key = { [0 ... 31] = 0x0c },
907 .ksize = 32,
908 .plaintext = "Test With Truncation",
909 .psize = 20,
910 .digest = { 0x75, 0x46, 0xaf, 0x01, 0x84, 0x1f, 0xc0, 0x9b,
911 0x1a, 0xb9, 0xc3, 0x74, 0x9a, 0x5f, 0x1c, 0x17,
912 0xd4, 0xf5, 0x89, 0x66, 0x8a, 0x58, 0x7b, 0x27,
913 0x00, 0xa9, 0xc9, 0x7c, 0x11, 0x93, 0xcf, 0x42 },
914 }, {
915 .key = { [0 ... 79] = 0xaa },
916 .ksize = 80,
917 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
918 .psize = 54,
919 .digest = { 0x69, 0x53, 0x02, 0x5e, 0xd9, 0x6f, 0x0c, 0x09,
920 0xf8, 0x0a, 0x96, 0xf7, 0x8e, 0x65, 0x38, 0xdb,
921 0xe2, 0xe7, 0xb8, 0x20, 0xe3, 0xdd, 0x97, 0x0e,
922 0x7d, 0xdd, 0x39, 0x09, 0x1b, 0x32, 0x35, 0x2f },
923 }, {
924 .key = { [0 ... 79] = 0xaa },
925 .ksize = 80,
926 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
927 "One Block-Size Data",
928 .psize = 73,
929 .digest = { 0x63, 0x55, 0xac, 0x22, 0xe8, 0x90, 0xd0, 0xa3,
930 0xc8, 0x48, 0x1a, 0x5c, 0xa4, 0x82, 0x5b, 0xc8,
931 0x84, 0xd3, 0xe7, 0xa1, 0xff, 0x98, 0xa2, 0xfc,
932 0x2a, 0xc7, 0xd8, 0xe0, 0x64, 0xc3, 0xb2, 0xe6 },
933 },
934};
935
Kazunori MIYAZAWA5b2becf2006-10-28 13:18:53 +1000936#define XCBC_AES_TEST_VECTORS 6
937
938static struct hash_testvec aes_xcbc128_tv_template[] = {
939 {
940 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
941 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
942 .plaintext = { [0 ... 15] = 0 },
943 .digest = { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
944 0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29 },
945 .psize = 0,
946 .ksize = 16,
947 }, {
948 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
949 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
950 .plaintext = { 0x00, 0x01, 0x02 },
951 .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
952 0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f },
953 .psize = 3,
954 .ksize = 16,
955 } , {
956 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
957 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
958 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
959 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
960 .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
961 0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 },
962 .psize = 16,
963 .ksize = 16,
964 }, {
965 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
966 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
967 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
968 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
969 0x10, 0x11, 0x12, 0x13 },
970 .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15,
971 0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 },
972 .tap = { 10, 10 },
973 .psize = 20,
974 .np = 2,
975 .ksize = 16,
976 }, {
977 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
978 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
979 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
980 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
981 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
982 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
983 .digest = { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
984 0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4 },
985 .psize = 32,
986 .ksize = 16,
987 }, {
988 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
989 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
990 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
991 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
992 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
993 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
994 0x20, 0x21 },
995 .digest = { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
996 0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8 },
997 .tap = { 17, 17 },
998 .psize = 34,
999 .np = 2,
1000 .ksize = 16,
1001 }
1002};
1003
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004/*
1005 * DES test vectors.
1006 */
1007#define DES_ENC_TEST_VECTORS 10
1008#define DES_DEC_TEST_VECTORS 4
1009#define DES_CBC_ENC_TEST_VECTORS 5
1010#define DES_CBC_DEC_TEST_VECTORS 4
1011#define DES3_EDE_ENC_TEST_VECTORS 3
1012#define DES3_EDE_DEC_TEST_VECTORS 3
1013
1014static struct cipher_testvec des_enc_tv_template[] = {
1015 { /* From Applied Cryptography */
1016 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1017 .klen = 8,
1018 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1019 .ilen = 8,
1020 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1021 .rlen = 8,
1022 }, { /* Same key, different plaintext block */
1023 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1024 .klen = 8,
1025 .input = { 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1026 .ilen = 8,
1027 .result = { 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1028 .rlen = 8,
1029 }, { /* Sbox test from NBS */
1030 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
1031 .klen = 8,
1032 .input = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
1033 .ilen = 8,
1034 .result = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1035 .rlen = 8,
1036 }, { /* Three blocks */
1037 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1038 .klen = 8,
1039 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1040 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1041 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
1042 .ilen = 24,
1043 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1044 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1045 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1046 .rlen = 24,
1047 }, { /* Weak key */
1048 .fail = 1,
1049 .wk = 1,
1050 .key = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
1051 .klen = 8,
1052 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1053 .ilen = 8,
1054 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1055 .rlen = 8,
1056 }, { /* Two blocks -- for testing encryption across pages */
1057 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1058 .klen = 8,
1059 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1060 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1061 .ilen = 16,
1062 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1063 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1064 .rlen = 16,
1065 .np = 2,
1066 .tap = { 8, 8 }
1067 }, { /* Four blocks -- for testing encryption with chunking */
1068 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1069 .klen = 8,
1070 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1071 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1072 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef,
1073 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1074 .ilen = 32,
1075 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1076 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1077 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90,
1078 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1079 .rlen = 32,
1080 .np = 3,
Herbert Xuef2736f2005-06-22 13:26:03 -07001081 .tap = { 14, 10, 8 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 }, {
1083 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1084 .klen = 8,
1085 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1086 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1087 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
1088 .ilen = 24,
1089 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1090 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1091 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1092 .rlen = 24,
1093 .np = 4,
Herbert Xuef2736f2005-06-22 13:26:03 -07001094 .tap = { 2, 1, 3, 18 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 }, {
1096 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1097 .klen = 8,
1098 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1099 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1100 .ilen = 16,
1101 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1102 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1103 .rlen = 16,
1104 .np = 5,
Herbert Xuef2736f2005-06-22 13:26:03 -07001105 .tap = { 2, 2, 2, 2, 8 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 }, {
1107 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1108 .klen = 8,
1109 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1110 .ilen = 8,
1111 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1112 .rlen = 8,
1113 .np = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001114 .tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 },
1116};
1117
1118static struct cipher_testvec des_dec_tv_template[] = {
1119 { /* From Applied Cryptography */
1120 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1121 .klen = 8,
1122 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1123 .ilen = 8,
1124 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1125 .rlen = 8,
1126 }, { /* Sbox test from NBS */
Herbert Xuef2736f2005-06-22 13:26:03 -07001127 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 .klen = 8,
1129 .input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1130 .ilen = 8,
1131 .result = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
1132 .rlen = 8,
1133 }, { /* Two blocks, for chunking test */
1134 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1135 .klen = 8,
1136 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1137 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1138 .ilen = 16,
1139 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1140 0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1141 .rlen = 16,
1142 .np = 2,
1143 .tap = { 8, 8 }
1144 }, {
1145 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1146 .klen = 8,
1147 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1148 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1149 .ilen = 16,
1150 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1151 0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1152 .rlen = 16,
1153 .np = 3,
1154 .tap = { 3, 12, 1 }
1155 },
1156};
1157
1158static struct cipher_testvec des_cbc_enc_tv_template[] = {
1159 { /* From OpenSSL */
1160 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1161 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001162 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1163 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1164 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1165 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 .ilen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001167 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1168 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1169 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 .rlen = 24,
1171 }, { /* FIPS Pub 81 */
1172 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1173 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001174 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 .input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1176 .ilen = 8,
1177 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1178 .rlen = 8,
1179 }, {
1180 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1181 .klen = 8,
1182 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1183 .input = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1184 .ilen = 8,
1185 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1186 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001187 }, {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1189 .klen = 8,
1190 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1191 .input = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1192 .ilen = 8,
1193 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1194 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001195 }, { /* Copy of openssl vector for chunk testing */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 /* From OpenSSL */
1197 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1198 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001199 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1200 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1201 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1202 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .ilen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001204 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1205 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1206 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 .rlen = 24,
1208 .np = 2,
1209 .tap = { 13, 11 }
1210 },
1211};
1212
1213static struct cipher_testvec des_cbc_dec_tv_template[] = {
1214 { /* FIPS Pub 81 */
1215 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1216 .klen = 8,
1217 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1218 .input = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1219 .ilen = 8,
1220 .result = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1221 .rlen = 8,
1222 }, {
1223 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1224 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001225 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 .input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1227 .ilen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001228 .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 .rlen = 8,
1230 }, {
1231 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1232 .klen = 8,
1233 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
Herbert Xuef2736f2005-06-22 13:26:03 -07001234 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 .ilen = 8,
1236 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1237 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001238 }, { /* Copy of above, for chunk testing */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1240 .klen = 8,
1241 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
Herbert Xuef2736f2005-06-22 13:26:03 -07001242 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .ilen = 8,
1244 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1245 .rlen = 8,
1246 .np = 2,
1247 .tap = { 4, 4 }
1248 },
1249};
1250
1251/*
1252 * We really need some more test vectors, especially for DES3 CBC.
1253 */
1254static struct cipher_testvec des3_ede_enc_tv_template[] = {
1255 { /* These are from openssl */
1256 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1257 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1258 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1259 .klen = 24,
1260 .input = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1261 .ilen = 8,
1262 .result = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1263 .rlen = 8,
1264 }, {
1265 .key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1266 0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1267 0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1268 .klen = 24,
1269 .input = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1270 .ilen = 8,
1271 .result = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1272 .rlen = 8,
1273 }, {
1274 .key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1275 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1276 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1277 .klen = 24,
1278 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1279 .ilen = 8,
1280 .result = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1281 .rlen = 8,
1282 },
1283};
1284
1285static struct cipher_testvec des3_ede_dec_tv_template[] = {
1286 { /* These are from openssl */
1287 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1288 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1289 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1290 .klen = 24,
1291 .input = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1292 .ilen = 8,
1293 .result = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1294 .rlen = 8,
1295 }, {
1296 .key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1297 0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1298 0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1299 .klen = 24,
1300 .input = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1301 .ilen = 8,
1302 .result = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1303 .rlen = 8,
1304 }, {
1305 .key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1306 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1307 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1308 .klen = 24,
1309 .input = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1310 .ilen = 8,
1311 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1312 .rlen = 8,
1313 },
1314};
1315
1316/*
1317 * Blowfish test vectors.
1318 */
1319#define BF_ENC_TEST_VECTORS 6
1320#define BF_DEC_TEST_VECTORS 6
1321#define BF_CBC_ENC_TEST_VECTORS 1
1322#define BF_CBC_DEC_TEST_VECTORS 1
1323
1324static struct cipher_testvec bf_enc_tv_template[] = {
1325 { /* DES test vectors from OpenSSL */
1326 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
1327 .klen = 8,
1328 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1329 .ilen = 8,
1330 .result = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1331 .rlen = 8,
1332 }, {
1333 .key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1334 .klen = 8,
1335 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1336 .ilen = 8,
1337 .result = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1338 .rlen = 8,
1339 }, {
1340 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1341 .klen = 8,
1342 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1343 .ilen = 8,
1344 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1345 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001346 }, { /* Vary the keylength... */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1348 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1349 .klen = 16,
1350 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1351 .ilen = 8,
1352 .result = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1353 .rlen = 8,
1354 }, {
1355 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1356 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1357 0x00, 0x11, 0x22, 0x33, 0x44 },
1358 .klen = 21,
1359 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1360 .ilen = 8,
1361 .result = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1362 .rlen = 8,
1363 }, { /* Generated with bf488 */
1364 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1365 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1366 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Herbert Xuef2736f2005-06-22 13:26:03 -07001367 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1368 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1369 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1371 .klen = 56,
1372 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1373 .ilen = 8,
1374 .result = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1375 .rlen = 8,
1376 },
1377};
1378
1379static struct cipher_testvec bf_dec_tv_template[] = {
1380 { /* DES test vectors from OpenSSL */
1381 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1382 .klen = 8,
1383 .input = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1384 .ilen = 8,
1385 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1386 .rlen = 8,
1387 }, {
1388 .key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1389 .klen = 8,
1390 .input = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1391 .ilen = 8,
1392 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1393 .rlen = 8,
1394 }, {
1395 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1396 .klen = 8,
1397 .input = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1398 .ilen = 8,
1399 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1400 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001401 }, { /* Vary the keylength... */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1403 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1404 .klen = 16,
1405 .input = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1406 .ilen = 8,
1407 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1408 .rlen = 8,
1409 }, {
1410 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1411 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1412 0x00, 0x11, 0x22, 0x33, 0x44 },
1413 .klen = 21,
1414 .input = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1415 .ilen = 8,
1416 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1417 .rlen = 8,
1418 }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
1419 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1420 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1421 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Herbert Xuef2736f2005-06-22 13:26:03 -07001422 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1423 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1424 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1426 .klen = 56,
1427 .input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1428 .ilen = 8,
1429 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1430 .rlen = 8,
1431 },
1432};
1433
1434static struct cipher_testvec bf_cbc_enc_tv_template[] = {
1435 { /* From OpenSSL */
1436 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1437 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1438 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001439 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1441 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1442 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1443 0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1444 .ilen = 32,
1445 .result = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1446 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1447 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1448 0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1449 .rlen = 32,
1450 },
1451};
1452
1453static struct cipher_testvec bf_cbc_dec_tv_template[] = {
1454 { /* From OpenSSL */
1455 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1456 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1457 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001458 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1460 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1461 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1462 0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1463 .ilen = 32,
1464 .result = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1465 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1466 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1467 0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1468 .rlen = 32,
1469 },
1470};
1471
1472/*
1473 * Twofish test vectors.
1474 */
1475#define TF_ENC_TEST_VECTORS 3
1476#define TF_DEC_TEST_VECTORS 3
1477#define TF_CBC_ENC_TEST_VECTORS 4
1478#define TF_CBC_DEC_TEST_VECTORS 4
1479
1480static struct cipher_testvec tf_enc_tv_template[] = {
1481 {
1482 .key = { [0 ... 15] = 0x00 },
1483 .klen = 16,
1484 .input = { [0 ... 15] = 0x00 },
1485 .ilen = 16,
1486 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1487 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1488 .rlen = 16,
1489 }, {
1490 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1491 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1492 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1493 .klen = 24,
1494 .input = { [0 ... 15] = 0x00 },
1495 .ilen = 16,
1496 .result = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1497 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1498 .rlen = 16,
1499 }, {
1500 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1501 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1502 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1503 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1504 .klen = 32,
1505 .input = { [0 ... 15] = 0x00 },
1506 .ilen = 16,
1507 .result = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1508 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1509 .rlen = 16,
1510 },
1511};
1512
1513static struct cipher_testvec tf_dec_tv_template[] = {
1514 {
1515 .key = { [0 ... 15] = 0x00 },
1516 .klen = 16,
1517 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1518 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1519 .ilen = 16,
1520 .result = { [0 ... 15] = 0x00 },
1521 .rlen = 16,
1522 }, {
1523 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1524 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1525 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1526 .klen = 24,
1527 .input = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1528 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1529 .ilen = 16,
1530 .result = { [0 ... 15] = 0x00 },
1531 .rlen = 16,
1532 }, {
1533 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1534 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1535 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1536 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1537 .klen = 32,
1538 .input = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1539 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1540 .ilen = 16,
1541 .result = { [0 ... 15] = 0x00 },
1542 .rlen = 16,
1543 },
1544};
1545
1546static struct cipher_testvec tf_cbc_enc_tv_template[] = {
1547 { /* Generated with Nettle */
1548 .key = { [0 ... 15] = 0x00 },
1549 .klen = 16,
1550 .iv = { [0 ... 15] = 0x00 },
1551 .input = { [0 ... 15] = 0x00 },
1552 .ilen = 16,
1553 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1554 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1555 .rlen = 16,
1556 }, {
1557 .key = { [0 ... 15] = 0x00 },
1558 .klen = 16,
1559 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001560 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561 .input = { [0 ... 15] = 0x00 },
1562 .ilen = 16,
1563 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1564 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1565 .rlen = 16,
1566 }, {
1567 .key = { [0 ... 15] = 0x00 },
1568 .klen = 16,
1569 .iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1570 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1571 .input = { [0 ... 15] = 0x00 },
1572 .ilen = 16,
1573 .result = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1574 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1575 .rlen = 16,
1576 }, {
1577 .key = { [0 ... 15] = 0x00 },
1578 .klen = 16,
1579 .iv = { [0 ... 15] = 0x00 },
1580 .input = { [0 ... 47] = 0x00 },
1581 .ilen = 48,
1582 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1583 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1584 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1585 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1586 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1587 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1588 .rlen = 48,
1589 },
1590};
1591
1592static struct cipher_testvec tf_cbc_dec_tv_template[] = {
1593 { /* Reverse of the first four above */
1594 .key = { [0 ... 15] = 0x00 },
1595 .klen = 16,
1596 .iv = { [0 ... 15] = 0x00 },
1597 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001598 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599 .ilen = 16,
1600 .result = { [0 ... 15] = 0x00 },
1601 .rlen = 16,
1602 }, {
1603 .key = { [0 ... 15] = 0x00 },
1604 .klen = 16,
1605 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1606 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1607 .input = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1608 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1609 .ilen = 16,
1610 .result = { [0 ... 15] = 0x00 },
1611 .rlen = 16,
1612 }, {
1613 .key = { [0 ... 15] = 0x00 },
1614 .klen = 16,
1615 .iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1616 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1617 .input = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1618 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1619 .ilen = 16,
1620 .result = { [0 ... 15] = 0x00 },
1621 .rlen = 16,
1622 }, {
1623 .key = { [0 ... 15] = 0x00 },
1624 .klen = 16,
1625 .iv = { [0 ... 15] = 0x00 },
1626 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1627 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1628 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1629 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1630 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1631 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1632 .ilen = 48,
1633 .result = { [0 ... 47] = 0x00 },
1634 .rlen = 48,
1635 },
1636};
1637
1638/*
1639 * Serpent test vectors. These are backwards because Serpent writes
1640 * octet sequences in right-to-left mode.
1641 */
1642#define SERPENT_ENC_TEST_VECTORS 4
1643#define SERPENT_DEC_TEST_VECTORS 4
1644
1645#define TNEPRES_ENC_TEST_VECTORS 4
1646#define TNEPRES_DEC_TEST_VECTORS 4
1647
Herbert Xuef2736f2005-06-22 13:26:03 -07001648static struct cipher_testvec serpent_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649 {
1650 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1651 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1652 .ilen = 16,
1653 .result = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1654 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1655 .rlen = 16,
1656 }, {
1657 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1658 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1659 .klen = 16,
1660 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1661 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1662 .ilen = 16,
1663 .result = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1664 0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1665 .rlen = 16,
1666 }, {
1667 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1668 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1669 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1670 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1671 .klen = 32,
1672 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1673 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1674 .ilen = 16,
1675 .result = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1676 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1677 .rlen = 16,
1678 }, {
1679 .key = { [15] = 0x80 },
1680 .klen = 16,
1681 .input = { [0 ... 15] = 0x00 },
1682 .ilen = 16,
1683 .result = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1684 0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1685 .rlen = 16,
1686 },
1687};
1688
Herbert Xuef2736f2005-06-22 13:26:03 -07001689static struct cipher_testvec tnepres_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690 { /* KeySize=128, PT=0, I=1 */
1691 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1692 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1693 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1694 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1695 .klen = 16,
1696 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001697 .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd },
1699 .rlen = 16,
1700 }, { /* KeySize=192, PT=0, I=1 */
1701 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1702 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1703 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1704 .klen = 24,
1705 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1707 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001708 .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 },
1710 .rlen = 16,
1711 }, { /* KeySize=256, PT=0, I=1 */
1712 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1713 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1715 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1716 .klen = 32,
1717 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1718 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1719 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001720 .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 },
1722 .rlen = 16,
1723 }, { /* KeySize=256, I=257 */
1724 .key = { 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
1725 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
1726 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1727 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1728 .klen = 32,
1729 .input = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1730 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1731 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001732 .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde },
1734 .rlen = 16,
1735 },
1736};
1737
1738
Herbert Xuef2736f2005-06-22 13:26:03 -07001739static struct cipher_testvec serpent_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 {
1741 .input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1742 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1743 .ilen = 16,
1744 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1745 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1746 .rlen = 16,
1747 }, {
1748 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1749 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1750 .klen = 16,
1751 .input = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1752 0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1753 .ilen = 16,
1754 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1755 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1756 .rlen = 16,
1757 }, {
1758 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1759 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1760 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1761 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1762 .klen = 32,
1763 .input = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1764 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1765 .ilen = 16,
1766 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1767 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1768 .rlen = 16,
1769 }, {
1770 .key = { [15] = 0x80 },
1771 .klen = 16,
1772 .input = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1773 0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1774 .ilen = 16,
1775 .result = { [0 ... 15] = 0x00 },
1776 .rlen = 16,
1777 },
1778};
1779
Herbert Xuef2736f2005-06-22 13:26:03 -07001780static struct cipher_testvec tnepres_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781 {
1782 .input = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
1783 0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
1784 .ilen = 16,
1785 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1786 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1787 .rlen = 16,
1788 }, {
1789 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1790 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1791 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001792 .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793 0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e },
1794 .ilen = 16,
1795 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1796 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1797 .rlen = 16,
1798 }, {
1799 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1800 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1801 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1802 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1803 .klen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001804 .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee },
1806 .ilen = 16,
1807 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1808 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1809 .rlen = 16,
1810 }, { /* KeySize=128, I=121 */
1811 .key = { [15] = 0x80 },
1812 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001813 .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 },
1815 .ilen = 16,
1816 .result = { [0 ... 15] = 0x00 },
1817 .rlen = 16,
1818 },
1819};
1820
1821
1822/* Cast6 test vectors from RFC 2612 */
1823#define CAST6_ENC_TEST_VECTORS 3
1824#define CAST6_DEC_TEST_VECTORS 3
1825
Herbert Xuef2736f2005-06-22 13:26:03 -07001826static struct cipher_testvec cast6_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001827 {
Herbert Xuef2736f2005-06-22 13:26:03 -07001828 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1830 .klen = 16,
1831 .input = { [0 ... 15] = 0x00 },
1832 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001833 .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1835 .rlen = 16,
1836 }, {
Herbert Xuef2736f2005-06-22 13:26:03 -07001837 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1838 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1840 .klen = 24,
1841 .input = { [0 ... 15] = 0x00 },
1842 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001843 .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1845 .rlen = 16,
1846 }, {
1847 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1848 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1849 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
Herbert Xuef2736f2005-06-22 13:26:03 -07001850 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001851 .klen = 32,
1852 .input = { [0 ... 15] = 0x00 },
1853 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001854 .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001855 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1856 .rlen = 16,
1857 },
1858};
1859
Herbert Xuef2736f2005-06-22 13:26:03 -07001860static struct cipher_testvec cast6_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001861 {
Herbert Xuef2736f2005-06-22 13:26:03 -07001862 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1864 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001865 .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1867 .ilen = 16,
1868 .result = { [0 ... 15] = 0x00 },
1869 .rlen = 16,
1870 }, {
Herbert Xuef2736f2005-06-22 13:26:03 -07001871 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1872 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1874 .klen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001875 .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1877 .ilen = 16,
1878 .result = { [0 ... 15] = 0x00 },
1879 .rlen = 16,
1880 }, {
1881 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1882 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1883 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
Herbert Xuef2736f2005-06-22 13:26:03 -07001884 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885 .klen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001886 .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1888 .ilen = 16,
1889 .result = { [0 ... 15] = 0x00 },
1890 .rlen = 16,
1891 },
1892};
1893
1894
1895/*
1896 * AES test vectors.
1897 */
1898#define AES_ENC_TEST_VECTORS 3
1899#define AES_DEC_TEST_VECTORS 3
Jan Glauber05f29fc2006-01-06 00:19:19 -08001900#define AES_CBC_ENC_TEST_VECTORS 2
1901#define AES_CBC_DEC_TEST_VECTORS 2
Linus Torvalds1da177e2005-04-16 15:20:36 -07001902
Herbert Xuef2736f2005-06-22 13:26:03 -07001903static struct cipher_testvec aes_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 { /* From FIPS-197 */
Herbert Xuef2736f2005-06-22 13:26:03 -07001905 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1907 .klen = 16,
1908 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1909 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1910 .ilen = 16,
1911 .result = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
1912 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
1913 .rlen = 16,
1914 }, {
1915 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1916 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1917 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1918 .klen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001919 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1921 .ilen = 16,
1922 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1923 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1924 .rlen = 16,
1925 }, {
1926 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1927 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1928 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1929 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1930 .klen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001931 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1933 .ilen = 16,
1934 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1935 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1936 .rlen = 16,
1937 },
1938};
1939
Herbert Xuef2736f2005-06-22 13:26:03 -07001940static struct cipher_testvec aes_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941 { /* From FIPS-197 */
Herbert Xuef2736f2005-06-22 13:26:03 -07001942 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001943 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1944 .klen = 16,
1945 .input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
1946 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
1947 .ilen = 16,
1948 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1949 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1950 .rlen = 16,
1951 }, {
1952 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1953 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1954 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1955 .klen = 24,
1956 .input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1957 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1958 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001959 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1960 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001961 .rlen = 16,
1962 }, {
1963 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1964 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1965 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1966 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1967 .klen = 32,
1968 .input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1969 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1970 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001971 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1973 .rlen = 16,
1974 },
1975};
1976
Jan Glauber05f29fc2006-01-06 00:19:19 -08001977static struct cipher_testvec aes_cbc_enc_tv_template[] = {
1978 { /* From RFC 3602 */
1979 .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
1980 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
1981 .klen = 16,
1982 .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
1983 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
1984 .input = { "Single block msg" },
1985 .ilen = 16,
1986 .result = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
1987 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a },
1988 .rlen = 16,
1989 }, {
1990 .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
1991 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
1992 .klen = 16,
1993 .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
1994 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
1995 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1996 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1997 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1998 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1999 .ilen = 32,
2000 .result = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
2001 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
2002 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
2003 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 },
2004 .rlen = 32,
2005 },
2006};
2007
2008static struct cipher_testvec aes_cbc_dec_tv_template[] = {
2009 { /* From RFC 3602 */
2010 .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
2011 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
2012 .klen = 16,
2013 .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
2014 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
2015 .input = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
2016 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a },
2017 .ilen = 16,
2018 .result = { "Single block msg" },
2019 .rlen = 16,
2020 }, {
2021 .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
2022 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
2023 .klen = 16,
2024 .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
2025 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
2026 .input = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
2027 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
2028 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
2029 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 },
2030 .ilen = 32,
2031 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2032 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2033 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2034 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
2035 .rlen = 32,
2036 },
2037};
2038
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039/* Cast5 test vectors from RFC 2144 */
2040#define CAST5_ENC_TEST_VECTORS 3
2041#define CAST5_DEC_TEST_VECTORS 3
2042
Herbert Xuef2736f2005-06-22 13:26:03 -07002043static struct cipher_testvec cast5_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044 {
2045 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
2046 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
2047 .klen = 16,
2048 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2049 .ilen = 8,
2050 .result = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
2051 .rlen = 8,
2052 }, {
2053 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
2054 0x23, 0x45 },
2055 .klen = 10,
2056 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2057 .ilen = 8,
2058 .result = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
2059 .rlen = 8,
2060 }, {
2061 .key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
2062 .klen = 5,
2063 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2064 .ilen = 8,
2065 .result = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
2066 .rlen = 8,
2067 },
2068};
2069
Herbert Xuef2736f2005-06-22 13:26:03 -07002070static struct cipher_testvec cast5_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071 {
2072 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
2073 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
2074 .klen = 16,
2075 .input = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
2076 .ilen = 8,
2077 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2078 .rlen = 8,
2079 }, {
2080 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
2081 0x23, 0x45 },
2082 .klen = 10,
2083 .input = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
2084 .ilen = 8,
2085 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2086 .rlen = 8,
2087 }, {
2088 .key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
2089 .klen = 5,
2090 .input = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
2091 .ilen = 8,
2092 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2093 .rlen = 8,
2094 },
2095};
2096
Herbert Xuef2736f2005-06-22 13:26:03 -07002097/*
2098 * ARC4 test vectors from OpenSSL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099 */
2100#define ARC4_ENC_TEST_VECTORS 7
2101#define ARC4_DEC_TEST_VECTORS 7
2102
Herbert Xuef2736f2005-06-22 13:26:03 -07002103static struct cipher_testvec arc4_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104 {
2105 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2106 .klen = 8,
2107 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2108 .ilen = 8,
2109 .result = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
2110 .rlen = 8,
2111 }, {
2112 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2113 .klen = 8,
2114 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2115 .ilen = 8,
2116 .result = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
2117 .rlen = 8,
2118 }, {
2119 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2120 .klen = 8,
2121 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2122 .ilen = 8,
2123 .result = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
2124 .rlen = 8,
2125 }, {
2126 .key = { 0xef, 0x01, 0x23, 0x45},
2127 .klen = 4,
2128 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2130 0x00, 0x00, 0x00, 0x00 },
2131 .ilen = 20,
2132 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2133 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
2134 0x36, 0xb6, 0x78, 0x58 },
2135 .rlen = 20,
2136 }, {
2137 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2138 .klen = 8,
2139 .input = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2140 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2141 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2142 0x12, 0x34, 0x56, 0x78 },
2143 .ilen = 28,
2144 .result = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
2145 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
2146 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
2147 0x40, 0x01, 0x1e, 0xcf },
2148 .rlen = 28,
2149 }, {
2150 .key = { 0xef, 0x01, 0x23, 0x45 },
2151 .klen = 4,
2152 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2153 0x00, 0x00 },
2154 .ilen = 10,
2155 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2156 0xbd, 0x61 },
2157 .rlen = 10,
2158 }, {
2159 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
2160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2161 .klen = 16,
2162 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
2163 .ilen = 8,
2164 .result = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
2165 .rlen = 8,
2166 },
2167};
2168
Herbert Xuef2736f2005-06-22 13:26:03 -07002169static struct cipher_testvec arc4_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 {
2171 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2172 .klen = 8,
2173 .input = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
2174 .ilen = 8,
2175 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2176 .rlen = 8,
2177 }, {
2178 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2179 .klen = 8,
2180 .input = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
2181 .ilen = 8,
2182 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2183 .rlen = 8,
2184 }, {
2185 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2186 .klen = 8,
2187 .input = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
2188 .ilen = 8,
2189 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2190 .rlen = 8,
2191 }, {
2192 .key = { 0xef, 0x01, 0x23, 0x45},
2193 .klen = 4,
2194 .input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2195 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
2196 0x36, 0xb6, 0x78, 0x58 },
2197 .ilen = 20,
2198 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2200 0x00, 0x00, 0x00, 0x00 },
2201 .rlen = 20,
2202 }, {
2203 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2204 .klen = 8,
2205 .input = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
2206 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
2207 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
2208 0x40, 0x01, 0x1e, 0xcf },
2209 .ilen = 28,
2210 .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2211 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2212 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2213 0x12, 0x34, 0x56, 0x78 },
2214 .rlen = 28,
2215 }, {
2216 .key = { 0xef, 0x01, 0x23, 0x45 },
2217 .klen = 4,
2218 .input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2219 0xbd, 0x61 },
2220 .ilen = 10,
2221 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2222 0x00, 0x00 },
2223 .rlen = 10,
2224 }, {
2225 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
2226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2227 .klen = 16,
2228 .input = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
2229 .ilen = 8,
2230 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
2231 .rlen = 8,
2232 },
2233};
2234
Herbert Xuef2736f2005-06-22 13:26:03 -07002235/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 * TEA test vectors
2237 */
2238#define TEA_ENC_TEST_VECTORS 4
2239#define TEA_DEC_TEST_VECTORS 4
2240
Herbert Xuef2736f2005-06-22 13:26:03 -07002241static struct cipher_testvec tea_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002242 {
2243 .key = { [0 ... 15] = 0x00 },
2244 .klen = 16,
2245 .input = { [0 ... 8] = 0x00 },
2246 .ilen = 8,
2247 .result = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
2248 .rlen = 8,
2249 }, {
2250 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2251 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2252 .klen = 16,
2253 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2254 .ilen = 8,
2255 .result = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
2256 .rlen = 8,
2257 }, {
2258 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2259 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2260 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002261 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2263 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002264 .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2266 .rlen = 16,
2267 }, {
2268 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2269 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2270 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002271 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2272 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2273 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2275 .ilen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07002276 .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
2277 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2278 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
2280 .rlen = 32,
2281 }
2282};
2283
Herbert Xuef2736f2005-06-22 13:26:03 -07002284static struct cipher_testvec tea_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 {
2286 .key = { [0 ... 15] = 0x00 },
2287 .klen = 16,
2288 .input = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
2289 .ilen = 8,
2290 .result = { [0 ... 8] = 0x00 },
2291 .rlen = 8,
2292 }, {
2293 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2294 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2295 .klen = 16,
2296 .input = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
2297 .ilen = 8,
2298 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2299 .rlen = 8,
2300 }, {
2301 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2302 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2303 .klen = 16,
2304 .input = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
Herbert Xuef2736f2005-06-22 13:26:03 -07002305 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2306 .ilen = 16,
2307 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002308 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2309 .rlen = 16,
2310 }, {
2311 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2312 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2313 .klen = 16,
2314 .input = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
Herbert Xuef2736f2005-06-22 13:26:03 -07002315 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2316 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
2317 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 .ilen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07002319 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2320 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2321 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2323 .rlen = 32,
2324 }
2325};
2326
Herbert Xuef2736f2005-06-22 13:26:03 -07002327/*
2328 * XTEA test vectors
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 */
2330#define XTEA_ENC_TEST_VECTORS 4
2331#define XTEA_DEC_TEST_VECTORS 4
2332
Herbert Xuef2736f2005-06-22 13:26:03 -07002333static struct cipher_testvec xtea_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 {
2335 .key = { [0 ... 15] = 0x00 },
2336 .klen = 16,
2337 .input = { [0 ... 8] = 0x00 },
2338 .ilen = 8,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002339 .result = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 .rlen = 8,
2341 }, {
2342 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2343 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2344 .klen = 16,
2345 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2346 .ilen = 8,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002347 .result = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 .rlen = 8,
2349 }, {
2350 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2351 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2352 .klen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002353 .input = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2355 .ilen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002356 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2358 .rlen = 16,
2359 }, {
2360 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2361 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2362 .klen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002363 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2364 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2365 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2367 .ilen = 32,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002368 .result = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a,
2369 0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07,
2370 0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4,
2371 0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 .rlen = 32,
2373 }
2374};
2375
Herbert Xuef2736f2005-06-22 13:26:03 -07002376static struct cipher_testvec xtea_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 {
2378 .key = { [0 ... 15] = 0x00 },
2379 .klen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002380 .input = { 0xd8, 0xd4, 0xe9, 0xde, 0xd9, 0x1e, 0x13, 0xf7 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 .ilen = 8,
2382 .result = { [0 ... 8] = 0x00 },
2383 .rlen = 8,
2384 }, {
2385 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2386 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2387 .klen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002388 .input = { 0x94, 0xeb, 0xc8, 0x96, 0x84, 0x6a, 0x49, 0xa8 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 .ilen = 8,
2390 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2391 .rlen = 8,
2392 }, {
2393 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2394 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2395 .klen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002396 .input = { 0x3e, 0xce, 0xae, 0x22, 0x60, 0x56, 0xa8, 0x9d,
2397 0x77, 0x4d, 0xd4, 0xb4, 0x87, 0x24, 0xe3, 0x9a },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 .ilen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002399 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2401 .rlen = 16,
2402 }, {
2403 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2404 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2405 .klen = 16,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002406 .input = { 0x99, 0x81, 0x9f, 0x5d, 0x6f, 0x4b, 0x31, 0x3a,
2407 0x86, 0xff, 0x6f, 0xd0, 0xe3, 0x87, 0x70, 0x07,
2408 0x4d, 0xb8, 0xcf, 0xf3, 0x99, 0x50, 0xb3, 0xd4,
2409 0x73, 0xa2, 0xfa, 0xc9, 0x16, 0x59, 0x5d, 0x81 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410 .ilen = 32,
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002411 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2412 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2413 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2415 .rlen = 32,
2416 }
2417};
2418
2419/*
2420 * KHAZAD test vectors.
2421 */
2422#define KHAZAD_ENC_TEST_VECTORS 5
2423#define KHAZAD_DEC_TEST_VECTORS 5
2424
Herbert Xuef2736f2005-06-22 13:26:03 -07002425static struct cipher_testvec khazad_enc_tv_template[] = {
2426 {
2427 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2429 .klen = 16,
2430 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2431 .ilen = 8,
2432 .result = { 0x49, 0xa4, 0xce, 0x32, 0xac, 0x19, 0x0e, 0x3f },
2433 .rlen = 8,
2434 }, {
2435 .key = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
2436 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2437 .klen = 16,
2438 .input = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2439 .ilen = 8,
2440 .result = { 0x7e, 0x82, 0x12, 0xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
2441 .rlen = 8,
2442 }, {
2443 .key = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
2444 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2445 .klen = 16,
2446 .input = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2447 .ilen = 8,
2448 .result = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
2449 .rlen = 8,
2450 }, {
2451 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2452 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2453 .klen = 16,
2454 .input = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2455 .ilen = 8,
2456 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2457 .rlen = 8,
2458 }, {
2459 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2460 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2461 .klen = 16,
2462 .input = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
2463 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2464 .ilen = 16,
2465 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
2466 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2467 .rlen = 16,
2468 },
2469};
2470
Herbert Xuef2736f2005-06-22 13:26:03 -07002471static struct cipher_testvec khazad_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 {
Herbert Xuef2736f2005-06-22 13:26:03 -07002473 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2475 .klen = 16,
2476 .input = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f },
2477 .ilen = 8,
2478 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2479 .rlen = 8,
2480 }, {
2481 .key = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
2482 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2483 .klen = 16,
2484 .input = { 0X7e, 0X82, 0X12, 0Xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
2485 .ilen = 8,
2486 .result = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2487 .rlen = 8,
2488 }, {
2489 .key = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
2490 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2491 .klen = 16,
2492 .input = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
2493 .ilen = 8,
2494 .result = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2495 .rlen = 8,
2496 }, {
2497 .key = { 0x2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2498 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2499 .klen = 16,
2500 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2501 .ilen = 8,
2502 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2503 .rlen = 8,
2504 }, {
2505 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2506 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2507 .klen = 16,
2508 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
2509 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2510 .ilen = 16,
2511 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
2512 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2513 .rlen = 16,
2514 },
2515};
2516
2517/*
2518 * Anubis test vectors.
2519 */
2520
2521#define ANUBIS_ENC_TEST_VECTORS 5
2522#define ANUBIS_DEC_TEST_VECTORS 5
2523#define ANUBIS_CBC_ENC_TEST_VECTORS 2
2524#define ANUBIS_CBC_DEC_TEST_VECTORS 2
2525
2526static struct cipher_testvec anubis_enc_tv_template[] = {
2527 {
2528 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2529 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2530 .klen = 16,
2531 .input = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2532 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2533 .ilen = 16,
2534 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2535 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
2536 .rlen = 16,
2537 }, {
2538
2539 .key = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2540 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2541 0x03, 0x03, 0x03, 0x03 },
2542 .klen = 20,
2543 .input = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2544 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
2545 .ilen = 16,
2546 .result = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
2547 0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
2548 .rlen = 16,
2549 }, {
2550 .key = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2551 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2552 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2553 0x24, 0x24, 0x24, 0x24 },
2554 .klen = 28,
2555 .input = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2556 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
2557 .ilen = 16,
2558 .result = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
2559 0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
2560 .rlen = 16,
2561 }, {
2562 .key = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2563 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2564 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2565 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2566 .klen = 32,
2567 .input = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2568 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2569 .ilen = 16,
2570 .result = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
2571 0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
2572 .rlen = 16,
2573 }, {
2574 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2575 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2576 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2577 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2578 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2579 .klen = 40,
2580 .input = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2581 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2582 .ilen = 16,
2583 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2584 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
2585 .rlen = 16,
2586 },
2587};
2588
2589static struct cipher_testvec anubis_dec_tv_template[] = {
2590 {
2591 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2592 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2593 .klen = 16,
2594 .input = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2595 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
2596 .ilen = 16,
2597 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2598 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2599 .rlen = 16,
2600 }, {
2601
2602 .key = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2603 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2604 0x03, 0x03, 0x03, 0x03 },
2605 .klen = 20,
2606 .input = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
2607 0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
2608 .ilen = 16,
2609 .result = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2610 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
2611 .rlen = 16,
2612 }, {
2613 .key = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2614 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2615 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2616 0x24, 0x24, 0x24, 0x24 },
2617 .klen = 28,
2618 .input = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
2619 0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
2620 .ilen = 16,
2621 .result = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2622 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
2623 .rlen = 16,
2624 }, {
2625 .key = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2626 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2627 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2628 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2629 .klen = 32,
2630 .input = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
2631 0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
2632 .ilen = 16,
2633 .result = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2634 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2635 .rlen = 16,
2636 }, {
2637 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2638 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2639 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2640 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2641 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2642 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2643 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
2644 .klen = 40,
2645 .ilen = 16,
2646 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2647 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2648 .rlen = 16,
2649 },
2650};
2651
2652static struct cipher_testvec anubis_cbc_enc_tv_template[] = {
2653 {
2654 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2655 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2656 .klen = 16,
2657 .input = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2658 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2659 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2660 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2661 .ilen = 32,
2662 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2663 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
2664 0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
2665 0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
2666 .rlen = 32,
2667 }, {
2668 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2669 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2670 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2671 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2672 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2673 .klen = 40,
2674 .input = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2675 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2676 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2677 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2678 .ilen = 32,
2679 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2680 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
2681 0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
2682 0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
2683 .rlen = 32,
2684 },
2685};
2686
2687static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
2688 {
2689 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2690 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2691 .klen = 16,
2692 .input = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2693 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
2694 0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
2695 0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
2696 .ilen = 32,
2697 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2698 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2699 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2700 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2701 .rlen = 32,
2702 }, {
2703 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2704 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2705 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2706 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2707 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2708 .klen = 40,
2709 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2710 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
2711 0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
2712 0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
2713 .ilen = 32,
2714 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2715 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2716 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2717 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2718 .rlen = 32,
2719 },
2720};
2721
Aaron Grothefb4f10e2005-09-01 17:42:46 -07002722/*
2723 * XETA test vectors
2724 */
2725#define XETA_ENC_TEST_VECTORS 4
2726#define XETA_DEC_TEST_VECTORS 4
2727
2728static struct cipher_testvec xeta_enc_tv_template[] = {
2729 {
2730 .key = { [0 ... 15] = 0x00 },
2731 .klen = 16,
2732 .input = { [0 ... 8] = 0x00 },
2733 .ilen = 8,
2734 .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
2735 .rlen = 8,
2736 }, {
2737 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2738 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2739 .klen = 16,
2740 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2741 .ilen = 8,
2742 .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
2743 .rlen = 8,
2744 }, {
2745 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2746 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2747 .klen = 16,
2748 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2749 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2750 .ilen = 16,
2751 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
2752 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2753 .rlen = 16,
2754 }, {
2755 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2756 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2757 .klen = 16,
2758 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2759 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2760 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2761 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2762 .ilen = 32,
2763 .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2764 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2765 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
2766 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2767 .rlen = 32,
2768 }
2769};
2770
2771static struct cipher_testvec xeta_dec_tv_template[] = {
2772 {
2773 .key = { [0 ... 15] = 0x00 },
2774 .klen = 16,
2775 .input = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
2776 .ilen = 8,
2777 .result = { [0 ... 8] = 0x00 },
2778 .rlen = 8,
2779 }, {
2780 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2781 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2782 .klen = 16,
2783 .input = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
2784 .ilen = 8,
2785 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2786 .rlen = 8,
2787 }, {
2788 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2789 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2790 .klen = 16,
2791 .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
2792 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2793 .ilen = 16,
2794 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2795 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2796 .rlen = 16,
2797 }, {
2798 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2799 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2800 .klen = 16,
2801 .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2802 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2803 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
2804 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2805 .ilen = 32,
2806 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2807 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2808 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2809 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2810 .rlen = 32,
2811 }
2812};
2813
Linus Torvalds1da177e2005-04-16 15:20:36 -07002814/*
2815 * Compression stuff.
2816 */
2817#define COMP_BUF_SIZE 512
2818
2819struct comp_testvec {
2820 int inlen, outlen;
2821 char input[COMP_BUF_SIZE];
2822 char output[COMP_BUF_SIZE];
2823};
2824
2825/*
2826 * Deflate test vectors (null-terminated strings).
2827 * Params: winbits=11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
2828 */
2829#define DEFLATE_COMP_TEST_VECTORS 2
2830#define DEFLATE_DECOMP_TEST_VECTORS 2
2831
2832static struct comp_testvec deflate_comp_tv_template[] = {
2833 {
2834 .inlen = 70,
2835 .outlen = 38,
2836 .input = "Join us now and share the software "
2837 "Join us now and share the software ",
2838 .output = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
2839 0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
2840 0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
2841 0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
2842 0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
2843 }, {
2844 .inlen = 191,
2845 .outlen = 122,
2846 .input = "This document describes a compression method based on the DEFLATE"
2847 "compression algorithm. This document defines the application of "
2848 "the DEFLATE algorithm to the IP Payload Compression Protocol.",
2849 .output = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
2850 0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
2851 0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
2852 0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
2853 0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
2854 0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
2855 0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
2856 0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
2857 0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
2858 0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
2859 0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
2860 0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
2861 0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
2862 0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
2863 0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
2864 0xfa, 0x02 },
2865 },
2866};
2867
2868static struct comp_testvec deflate_decomp_tv_template[] = {
2869 {
2870 .inlen = 122,
2871 .outlen = 191,
2872 .input = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
2873 0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
2874 0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
2875 0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
2876 0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
2877 0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
2878 0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
2879 0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
2880 0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
2881 0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
2882 0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
2883 0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
2884 0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
2885 0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
2886 0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
2887 0xfa, 0x02 },
2888 .output = "This document describes a compression method based on the DEFLATE"
2889 "compression algorithm. This document defines the application of "
2890 "the DEFLATE algorithm to the IP Payload Compression Protocol.",
2891 }, {
2892 .inlen = 38,
2893 .outlen = 70,
2894 .input = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
2895 0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
2896 0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
2897 0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
2898 0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
2899 .output = "Join us now and share the software "
2900 "Join us now and share the software ",
2901 },
2902};
2903
2904/*
2905 * Michael MIC test vectors from IEEE 802.11i
2906 */
2907#define MICHAEL_MIC_TEST_VECTORS 6
2908
Herbert Xuef2736f2005-06-22 13:26:03 -07002909static struct hash_testvec michael_mic_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910 {
2911 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2912 .ksize = 8,
2913 .plaintext = { },
2914 .psize = 0,
2915 .digest = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 }
2916 },
2917 {
2918 .key = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 },
2919 .ksize = 8,
2920 .plaintext = { 'M' },
2921 .psize = 1,
2922 .digest = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f }
2923 },
2924 {
2925 .key = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f },
2926 .ksize = 8,
2927 .plaintext = { 'M', 'i' },
2928 .psize = 2,
2929 .digest = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 }
2930 },
2931 {
2932 .key = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 },
2933 .ksize = 8,
2934 .plaintext = { 'M', 'i', 'c' },
2935 .psize = 3,
2936 .digest = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb }
2937 },
2938 {
2939 .key = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb },
2940 .ksize = 8,
2941 .plaintext = { 'M', 'i', 'c', 'h' },
2942 .psize = 4,
2943 .digest = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 }
2944 },
2945 {
2946 .key = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 },
2947 .ksize = 8,
2948 .plaintext = { 'M', 'i', 'c', 'h', 'a', 'e', 'l' },
2949 .psize = 7,
2950 .digest = { 0x0a, 0x94, 0x2b, 0x12, 0x4e, 0xca, 0xa5, 0x46 },
2951 }
2952};
2953
Harald Welteebfd9bc2005-06-22 13:27:23 -07002954/*
Herbert Xuc907ee72006-08-21 22:04:03 +10002955 * CRC32C test vectors
2956 */
2957#define CRC32C_TEST_VECTORS 14
2958
2959static struct hash_testvec crc32c_tv_template[] = {
2960 {
2961 .psize = 0,
2962 .digest = { 0x00, 0x00, 0x00, 0x00 }
2963 },
2964 {
2965 .key = { 0x87, 0xa9, 0xcb, 0xed },
2966 .ksize = 4,
2967 .psize = 0,
2968 .digest = { 0x78, 0x56, 0x34, 0x12 },
2969 },
2970 {
2971 .key = { 0xff, 0xff, 0xff, 0xff },
2972 .ksize = 4,
2973 .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
2974 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
2975 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
2976 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
2977 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28 },
2978 .psize = 40,
2979 .digest = { 0x7f, 0x15, 0x2c, 0x0e }
2980 },
2981 {
2982 .key = { 0xff, 0xff, 0xff, 0xff },
2983 .ksize = 4,
2984 .plaintext = { 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
2985 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
2986 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
2987 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
2988 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50 },
2989 .psize = 40,
2990 .digest = { 0xf6, 0xeb, 0x80, 0xe9 }
2991 },
2992 {
2993 .key = { 0xff, 0xff, 0xff, 0xff },
2994 .ksize = 4,
2995 .plaintext = { 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
2996 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
2997 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
2998 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
2999 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78 },
3000 .psize = 40,
3001 .digest = { 0xed, 0xbd, 0x74, 0xde }
3002 },
3003 {
3004 .key = { 0xff, 0xff, 0xff, 0xff },
3005 .ksize = 4,
3006 .plaintext = { 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
3007 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
3008 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
3009 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
3010 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0 },
3011 .psize = 40,
3012 .digest = { 0x62, 0xc8, 0x79, 0xd5 }
3013 },
3014 {
3015 .key = { 0xff, 0xff, 0xff, 0xff },
3016 .ksize = 4,
3017 .plaintext = { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
3018 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
3019 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
3020 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
3021 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8 },
3022 .psize = 40,
3023 .digest = { 0xd0, 0x9a, 0x97, 0xba }
3024 },
3025 {
3026 .key = { 0xff, 0xff, 0xff, 0xff },
3027 .ksize = 4,
3028 .plaintext = { 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
3029 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
3030 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
3031 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
3032 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0 },
3033 .psize = 40,
3034 .digest = { 0x13, 0xd9, 0x29, 0x2b }
3035 },
3036 {
3037 .key = { 0x80, 0xea, 0xd3, 0xf1 },
3038 .ksize = 4,
3039 .plaintext = { 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
3040 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
3041 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
3042 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
3043 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50 },
3044 .psize = 40,
3045 .digest = { 0x0c, 0xb5, 0xe2, 0xa2 }
3046 },
3047 {
3048 .key = { 0xf3, 0x4a, 0x1d, 0x5d },
3049 .ksize = 4,
3050 .plaintext = { 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
3051 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
3052 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
3053 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
3054 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78 },
3055 .psize = 40,
3056 .digest = { 0xd1, 0x7f, 0xfb, 0xa6 }
3057 },
3058 {
3059 .key = { 0x2e, 0x80, 0x04, 0x59 },
3060 .ksize = 4,
3061 .plaintext = { 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
3062 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
3063 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
3064 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
3065 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0 },
3066 .psize = 40,
3067 .digest = { 0x59, 0x33, 0xe6, 0x7a }
3068 },
3069 {
3070 .key = { 0xa6, 0xcc, 0x19, 0x85 },
3071 .ksize = 4,
3072 .plaintext = { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
3073 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
3074 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
3075 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
3076 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8 },
3077 .psize = 40,
3078 .digest = { 0xbe, 0x03, 0x01, 0xd2 }
3079 },
3080 {
3081 .key = { 0x41, 0xfc, 0xfe, 0x2d },
3082 .ksize = 4,
3083 .plaintext = { 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
3084 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
3085 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
3086 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
3087 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0 },
3088 .psize = 40,
3089 .digest = { 0x75, 0xd3, 0xc5, 0x24 }
3090 },
3091 {
3092 .key = { 0xff, 0xff, 0xff, 0xff },
3093 .ksize = 4,
3094 .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
3095 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
3096 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
3097 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
3098 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
3099 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
3100 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
3101 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
3102 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
3103 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
3104 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
3105 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60,
3106 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
3107 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
3108 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
3109 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80,
3110 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
3111 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90,
3112 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
3113 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0,
3114 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
3115 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0,
3116 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
3117 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
3118 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
3119 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
3120 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
3121 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0,
3122 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
3123 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0 },
3124 .psize = 240,
3125 .digest = { 0x75, 0xd3, 0xc5, 0x24 },
3126 .np = 2,
3127 .tap = { 31, 209 }
3128 },
3129};
3130
3131/*
Harald Welteebfd9bc2005-06-22 13:27:23 -07003132 * Cipher speed tests
3133 */
3134static struct cipher_speed aes_speed_template[] = {
3135 { .klen = 16, .blen = 16, },
3136 { .klen = 16, .blen = 64, },
3137 { .klen = 16, .blen = 256, },
3138 { .klen = 16, .blen = 1024, },
3139 { .klen = 16, .blen = 8192, },
3140 { .klen = 24, .blen = 16, },
3141 { .klen = 24, .blen = 64, },
3142 { .klen = 24, .blen = 256, },
3143 { .klen = 24, .blen = 1024, },
3144 { .klen = 24, .blen = 8192, },
3145 { .klen = 32, .blen = 16, },
3146 { .klen = 32, .blen = 64, },
3147 { .klen = 32, .blen = 256, },
3148 { .klen = 32, .blen = 1024, },
3149 { .klen = 32, .blen = 8192, },
3150
3151 /* End marker */
3152 { .klen = 0, .blen = 0, }
3153};
3154
3155static struct cipher_speed des3_ede_speed_template[] = {
3156 { .klen = 24, .blen = 16, },
3157 { .klen = 24, .blen = 64, },
3158 { .klen = 24, .blen = 256, },
3159 { .klen = 24, .blen = 1024, },
3160 { .klen = 24, .blen = 8192, },
3161
3162 /* End marker */
3163 { .klen = 0, .blen = 0, }
3164};
3165
3166static struct cipher_speed twofish_speed_template[] = {
3167 { .klen = 16, .blen = 16, },
3168 { .klen = 16, .blen = 64, },
3169 { .klen = 16, .blen = 256, },
3170 { .klen = 16, .blen = 1024, },
3171 { .klen = 16, .blen = 8192, },
3172 { .klen = 24, .blen = 16, },
3173 { .klen = 24, .blen = 64, },
3174 { .klen = 24, .blen = 256, },
3175 { .klen = 24, .blen = 1024, },
3176 { .klen = 24, .blen = 8192, },
3177 { .klen = 32, .blen = 16, },
3178 { .klen = 32, .blen = 64, },
3179 { .klen = 32, .blen = 256, },
3180 { .klen = 32, .blen = 1024, },
3181 { .klen = 32, .blen = 8192, },
3182
3183 /* End marker */
3184 { .klen = 0, .blen = 0, }
3185};
3186
3187static struct cipher_speed blowfish_speed_template[] = {
3188 /* Don't support blowfish keys > 256 bit in this test */
3189 { .klen = 8, .blen = 16, },
3190 { .klen = 8, .blen = 64, },
3191 { .klen = 8, .blen = 256, },
3192 { .klen = 8, .blen = 1024, },
3193 { .klen = 8, .blen = 8192, },
3194 { .klen = 32, .blen = 16, },
3195 { .klen = 32, .blen = 64, },
3196 { .klen = 32, .blen = 256, },
3197 { .klen = 32, .blen = 1024, },
3198 { .klen = 32, .blen = 8192, },
3199
3200 /* End marker */
3201 { .klen = 0, .blen = 0, }
3202};
3203
3204static struct cipher_speed des_speed_template[] = {
3205 { .klen = 8, .blen = 16, },
3206 { .klen = 8, .blen = 64, },
3207 { .klen = 8, .blen = 256, },
3208 { .klen = 8, .blen = 1024, },
3209 { .klen = 8, .blen = 8192, },
3210
3211 /* End marker */
3212 { .klen = 0, .blen = 0, }
3213};
3214
Michal Ludvige8057922006-05-30 22:04:19 +10003215/*
3216 * Digest speed tests
3217 */
Herbert Xue9d41162006-08-19 21:38:49 +10003218static struct hash_speed generic_hash_speed_template[] = {
Michal Ludvige8057922006-05-30 22:04:19 +10003219 { .blen = 16, .plen = 16, },
3220 { .blen = 64, .plen = 16, },
3221 { .blen = 64, .plen = 64, },
3222 { .blen = 256, .plen = 16, },
3223 { .blen = 256, .plen = 64, },
3224 { .blen = 256, .plen = 256, },
3225 { .blen = 1024, .plen = 16, },
3226 { .blen = 1024, .plen = 256, },
3227 { .blen = 1024, .plen = 1024, },
3228 { .blen = 2048, .plen = 16, },
3229 { .blen = 2048, .plen = 256, },
3230 { .blen = 2048, .plen = 1024, },
3231 { .blen = 2048, .plen = 2048, },
3232 { .blen = 4096, .plen = 16, },
3233 { .blen = 4096, .plen = 256, },
3234 { .blen = 4096, .plen = 1024, },
3235 { .blen = 4096, .plen = 4096, },
3236 { .blen = 8192, .plen = 16, },
3237 { .blen = 8192, .plen = 256, },
3238 { .blen = 8192, .plen = 1024, },
3239 { .blen = 8192, .plen = 4096, },
3240 { .blen = 8192, .plen = 8192, },
3241
3242 /* End marker */
3243 { .blen = 0, .plen = 0, }
3244};
3245
Linus Torvalds1da177e2005-04-16 15:20:36 -07003246#endif /* _CRYPTO_TCRYPT_H */