blob: 72d40704042f5097460afdecd9807fd75de88041 [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 *
15 * 14 - 09 - 2003 Changes by Kartikey Mahendra Bhatt
16 *
17 */
18#ifndef _CRYPTO_TCRYPT_H
19#define _CRYPTO_TCRYPT_H
20
21#define MAX_DIGEST_SIZE 64
22#define MAX_TAP 8
23
24#define MAX_KEYLEN 56
25#define MAX_IVLEN 32
26
27struct hash_testvec {
28 char plaintext[128];
29 unsigned char psize;
30 char digest[MAX_DIGEST_SIZE];
31 unsigned char np;
Herbert Xuef2736f2005-06-22 13:26:03 -070032 unsigned char tap[MAX_TAP];
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 char key[128]; /* only used with keyed hash algorithms */
34 unsigned char ksize;
35};
36
Herbert Xuef2736f2005-06-22 13:26:03 -070037struct hmac_testvec {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 char key[128];
39 unsigned char ksize;
40 char plaintext[128];
41 unsigned char psize;
42 char digest[MAX_DIGEST_SIZE];
43 unsigned char np;
Herbert Xuef2736f2005-06-22 13:26:03 -070044 unsigned char tap[MAX_TAP];
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
47struct cipher_testvec {
48 unsigned char fail;
49 unsigned char wk; /* weak key flag */
50 char key[MAX_KEYLEN];
51 unsigned char klen;
52 char iv[MAX_IVLEN];
53 char input[48];
54 unsigned char ilen;
55 char result[48];
56 unsigned char rlen;
57 int np;
Herbert Xuef2736f2005-06-22 13:26:03 -070058 unsigned char tap[MAX_TAP];
Linus Torvalds1da177e2005-04-16 15:20:36 -070059};
60
61/*
62 * MD4 test vectors from RFC1320
63 */
64#define MD4_TEST_VECTORS 7
65
66static struct hash_testvec md4_tv_template [] = {
67 {
68 .plaintext = "",
69 .digest = { 0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31,
70 0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0 },
71 }, {
72 .plaintext = "a",
73 .psize = 1,
74 .digest = { 0xbd, 0xe5, 0x2c, 0xb3, 0x1d, 0xe3, 0x3e, 0x46,
75 0x24, 0x5e, 0x05, 0xfb, 0xdb, 0xd6, 0xfb, 0x24 },
76 }, {
77 .plaintext = "abc",
78 .psize = 3,
79 .digest = { 0xa4, 0x48, 0x01, 0x7a, 0xaf, 0x21, 0xd8, 0x52,
80 0x5f, 0xc1, 0x0a, 0xe8, 0x7a, 0xa6, 0x72, 0x9d },
81 }, {
82 .plaintext = "message digest",
83 .psize = 14,
84 .digest = { 0xd9, 0x13, 0x0a, 0x81, 0x64, 0x54, 0x9f, 0xe8,
85 0x18, 0x87, 0x48, 0x06, 0xe1, 0xc7, 0x01, 0x4b },
86 }, {
87 .plaintext = "abcdefghijklmnopqrstuvwxyz",
88 .psize = 26,
89 .digest = { 0xd7, 0x9e, 0x1c, 0x30, 0x8a, 0xa5, 0xbb, 0xcd,
90 0xee, 0xa8, 0xed, 0x63, 0xdf, 0x41, 0x2d, 0xa9 },
91 .np = 2,
92 .tap = { 13, 13 },
93 }, {
94 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
95 .psize = 62,
96 .digest = { 0x04, 0x3f, 0x85, 0x82, 0xf2, 0x41, 0xdb, 0x35,
97 0x1c, 0xe6, 0x27, 0xe1, 0x53, 0xe7, 0xf0, 0xe4 },
98 }, {
99 .plaintext = "123456789012345678901234567890123456789012345678901234567890123"
100 "45678901234567890",
101 .psize = 80,
102 .digest = { 0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19,
103 0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36 },
104 },
105};
106
107/*
108 * MD5 test vectors from RFC1321
109 */
110#define MD5_TEST_VECTORS 7
111
112static struct hash_testvec md5_tv_template[] = {
113 {
114 .digest = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
115 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e },
116 }, {
117 .plaintext = "a",
118 .psize = 1,
119 .digest = { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8,
120 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 },
121 }, {
122 .plaintext = "abc",
123 .psize = 3,
124 .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
125 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 },
126 }, {
127 .plaintext = "message digest",
128 .psize = 14,
129 .digest = { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d,
130 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 },
131 }, {
132 .plaintext = "abcdefghijklmnopqrstuvwxyz",
133 .psize = 26,
134 .digest = { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00,
135 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b },
136 .np = 2,
137 .tap = {13, 13}
138 }, {
139 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
140 .psize = 62,
141 .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
142 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f },
143 }, {
144 .plaintext = "12345678901234567890123456789012345678901234567890123456789012"
145 "345678901234567890",
146 .psize = 80,
147 .digest = { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55,
148 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a },
149 }
150};
151
152/*
153 * SHA1 test vectors from from FIPS PUB 180-1
154 */
155#define SHA1_TEST_VECTORS 2
156
157static struct hash_testvec sha1_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700158 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 .plaintext = "abc",
160 .psize = 3,
161 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
162 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d },
163 }, {
164 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
165 .psize = 56,
166 .digest = { 0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae,
167 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1 },
168 .np = 2,
169 .tap = { 28, 28 }
170 }
171};
172
173/*
174 * SHA256 test vectors from from NIST
175 */
176#define SHA256_TEST_VECTORS 2
177
Herbert Xuef2736f2005-06-22 13:26:03 -0700178static struct hash_testvec sha256_tv_template[] = {
179 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 .plaintext = "abc",
181 .psize = 3,
182 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
183 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
184 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
185 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad },
186 }, {
187 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
188 .psize = 56,
189 .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
190 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
191 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
192 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1 },
193 .np = 2,
194 .tap = { 28, 28 }
195 },
196};
197
198/*
199 * SHA384 test vectors from from NIST and kerneli
200 */
201#define SHA384_TEST_VECTORS 4
202
203static struct hash_testvec sha384_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700204 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 .plaintext= "abc",
206 .psize = 3,
207 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
208 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
209 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
210 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
211 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
212 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 },
213 }, {
214 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
215 .psize = 56,
216 .digest = { 0x33, 0x91, 0xfd, 0xdd, 0xfc, 0x8d, 0xc7, 0x39,
217 0x37, 0x07, 0xa6, 0x5b, 0x1b, 0x47, 0x09, 0x39,
218 0x7c, 0xf8, 0xb1, 0xd1, 0x62, 0xaf, 0x05, 0xab,
219 0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6,
220 0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f,
221 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b},
222 }, {
223 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
Herbert Xuef2736f2005-06-22 13:26:03 -0700224 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 .psize = 112,
226 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
227 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
228 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
229 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
230 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
231 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 },
232 }, {
233 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
234 "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
235 .psize = 104,
236 .digest = { 0x3d, 0x20, 0x89, 0x73, 0xab, 0x35, 0x08, 0xdb,
237 0xbd, 0x7e, 0x2c, 0x28, 0x62, 0xba, 0x29, 0x0a,
238 0xd3, 0x01, 0x0e, 0x49, 0x78, 0xc1, 0x98, 0xdc,
239 0x4d, 0x8f, 0xd0, 0x14, 0xe5, 0x82, 0x82, 0x3a,
240 0x89, 0xe1, 0x6f, 0x9b, 0x2a, 0x7b, 0xbc, 0x1a,
241 0xc9, 0x38, 0xe2, 0xd1, 0x99, 0xe8, 0xbe, 0xa4 },
242 .np = 4,
243 .tap = { 26, 26, 26, 26 }
244 },
245};
246
247/*
248 * SHA512 test vectors from from NIST and kerneli
249 */
250#define SHA512_TEST_VECTORS 4
251
252static struct hash_testvec sha512_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 .plaintext = "abc",
255 .psize = 3,
256 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
257 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
258 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
259 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
260 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
261 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
262 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
263 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f },
264 }, {
265 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
266 .psize = 56,
267 .digest = { 0x20, 0x4a, 0x8f, 0xc6, 0xdd, 0xa8, 0x2f, 0x0a,
268 0x0c, 0xed, 0x7b, 0xeb, 0x8e, 0x08, 0xa4, 0x16,
269 0x57, 0xc1, 0x6e, 0xf4, 0x68, 0xb2, 0x28, 0xa8,
270 0x27, 0x9b, 0xe3, 0x31, 0xa7, 0x03, 0xc3, 0x35,
271 0x96, 0xfd, 0x15, 0xc1, 0x3b, 0x1b, 0x07, 0xf9,
272 0xaa, 0x1d, 0x3b, 0xea, 0x57, 0x78, 0x9c, 0xa0,
273 0x31, 0xad, 0x85, 0xc7, 0xa7, 0x1d, 0xd7, 0x03,
274 0x54, 0xec, 0x63, 0x12, 0x38, 0xca, 0x34, 0x45 },
275 }, {
276 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
277 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
278 .psize = 112,
279 .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
280 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
281 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
282 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
283 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
284 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
285 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
286 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 },
287 }, {
288 .plaintext = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
289 "efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
290 .psize = 104,
291 .digest = { 0x93, 0x0d, 0x0c, 0xef, 0xcb, 0x30, 0xff, 0x11,
292 0x33, 0xb6, 0x89, 0x81, 0x21, 0xf1, 0xcf, 0x3d,
293 0x27, 0x57, 0x8a, 0xfc, 0xaf, 0xe8, 0x67, 0x7c,
294 0x52, 0x57, 0xcf, 0x06, 0x99, 0x11, 0xf7, 0x5d,
295 0x8f, 0x58, 0x31, 0xb5, 0x6e, 0xbf, 0xda, 0x67,
296 0xb2, 0x78, 0xe6, 0x6d, 0xff, 0x8b, 0x84, 0xfe,
297 0x2b, 0x28, 0x70, 0xf7, 0x42, 0xa5, 0x80, 0xd8,
298 0xed, 0xb4, 0x19, 0x87, 0x23, 0x28, 0x50, 0xc9 },
299 .np = 4,
300 .tap = { 26, 26, 26, 26 }
301 },
302};
303
304
305/*
Herbert Xuef2736f2005-06-22 13:26:03 -0700306 * WHIRLPOOL test vectors from Whirlpool package
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
308 * submission
309 */
310#define WP512_TEST_VECTORS 8
311
312static struct hash_testvec wp512_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700313 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 .plaintext = "",
315 .psize = 0,
316 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
317 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
318 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
319 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
320 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
321 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57,
322 0xEA, 0x89, 0x64, 0xE5, 0x9B, 0x63, 0xD9, 0x37,
323 0x08, 0xB1, 0x38, 0xCC, 0x42, 0xA6, 0x6E, 0xB3 },
324
325
326 }, {
327 .plaintext = "a",
328 .psize = 1,
329 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
330 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
331 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
332 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
333 0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
334 0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59,
335 0x1A, 0x92, 0x20, 0x0D, 0x56, 0x01, 0x95, 0xE5,
336 0x3B, 0x47, 0x85, 0x84, 0xFD, 0xAE, 0x23, 0x1A },
337 }, {
338 .plaintext = "abc",
339 .psize = 3,
340 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
341 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
342 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
343 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
344 0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
345 0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6,
346 0xC7, 0x97, 0xFC, 0x9D, 0x95, 0xD8, 0xB5, 0x82,
347 0xD2, 0x25, 0x29, 0x20, 0x76, 0xD4, 0xEE, 0xF5 },
348 }, {
349 .plaintext = "message digest",
350 .psize = 14,
Herbert Xuef2736f2005-06-22 13:26:03 -0700351 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
352 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
353 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
354 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
355 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
356 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6,
357 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E },
359 }, {
360 .plaintext = "abcdefghijklmnopqrstuvwxyz",
361 .psize = 26,
362 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
363 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
364 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
365 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
366 0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
367 0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6,
368 0xF6, 0x8F, 0x67, 0x3E, 0x72, 0x07, 0x86, 0x5D,
369 0x5D, 0x98, 0x19, 0xA3, 0xDB, 0xA4, 0xEB, 0x3B },
370 }, {
371 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
372 "abcdefghijklmnopqrstuvwxyz0123456789",
373 .psize = 62,
374 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
375 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
376 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
377 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
378 0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
379 0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6,
380 0x55, 0x17, 0xCC, 0x87, 0x9D, 0x7B, 0x96, 0x21,
381 0x42, 0xC6, 0x5F, 0x5A, 0x7A, 0xF0, 0x14, 0x67 },
382 }, {
383 .plaintext = "1234567890123456789012345678901234567890"
384 "1234567890123456789012345678901234567890",
385 .psize = 80,
386 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
387 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
388 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
389 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
390 0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
391 0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A,
392 0x2C, 0x60, 0x48, 0x1E, 0x88, 0xC5, 0xA2, 0x0B,
393 0x2C, 0x2A, 0x80, 0xCF, 0x3A, 0x9A, 0x08, 0x3B },
394 }, {
395 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
396 .psize = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -0700397 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
399 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
400 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
401 0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
402 0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56,
403 0x93, 0x9B, 0xAA, 0xA0, 0xAD, 0xFF, 0x9A, 0xE6,
404 0x74, 0x5B, 0x7B, 0x18, 0x1C, 0x3B, 0xE3, 0xFD },
405 },
406};
407
408#define WP384_TEST_VECTORS 8
409
410static struct hash_testvec wp384_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700411 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 .plaintext = "",
413 .psize = 0,
414 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
415 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
416 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
417 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7,
418 0x3E, 0x83, 0xBE, 0x69, 0x8B, 0x28, 0x8F, 0xEB,
419 0xCF, 0x88, 0xE3, 0xE0, 0x3C, 0x4F, 0x07, 0x57 },
420
421
422 }, {
423 .plaintext = "a",
424 .psize = 1,
425 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
426 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
427 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
428 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42,
429 0xD1, 0x1B, 0xC6, 0x45, 0x41, 0x3A, 0xEF, 0xF6,
430 0x3A, 0x42, 0x39, 0x1A, 0x39, 0x14, 0x5A, 0x59 },
431 }, {
432 .plaintext = "abc",
433 .psize = 3,
434 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
435 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
436 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
437 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C,
438 0x71, 0x81, 0xEE, 0xBD, 0xB6, 0xC5, 0x7E, 0x27,
439 0x7D, 0x0E, 0x34, 0x95, 0x71, 0x14, 0xCB, 0xD6 },
440 }, {
441 .plaintext = "message digest",
442 .psize = 14,
Herbert Xuef2736f2005-06-22 13:26:03 -0700443 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
444 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
445 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
446 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
447 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 },
449 }, {
450 .plaintext = "abcdefghijklmnopqrstuvwxyz",
451 .psize = 26,
452 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
453 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
454 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
455 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B,
456 0x08, 0xBF, 0x2A, 0x92, 0x51, 0xC3, 0x0B, 0x6A,
457 0x0B, 0x8A, 0xAE, 0x86, 0x17, 0x7A, 0xB4, 0xA6 },
458 }, {
459 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
460 "abcdefghijklmnopqrstuvwxyz0123456789",
461 .psize = 62,
462 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
463 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
464 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
465 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E,
466 0x08, 0xEB, 0xA2, 0x66, 0x29, 0x12, 0x9D, 0x8F,
467 0xB7, 0xCB, 0x57, 0x21, 0x1B, 0x92, 0x81, 0xA6 },
468 }, {
469 .plaintext = "1234567890123456789012345678901234567890"
470 "1234567890123456789012345678901234567890",
471 .psize = 80,
472 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
473 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
474 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
475 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29,
476 0x4D, 0x5B, 0xD8, 0xDF, 0x2A, 0x6C, 0x44, 0xE5,
477 0x38, 0xCD, 0x04, 0x7B, 0x26, 0x81, 0xA5, 0x1A },
478 }, {
479 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
480 .psize = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -0700481 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
483 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
484 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
485 0x16, 0xBD, 0xC8, 0x03, 0x1B, 0xC5, 0xBE, 0x1B,
486 0x7B, 0x94, 0x76, 0x39, 0xFE, 0x05, 0x0B, 0x56 },
487 },
488};
489
490#define WP256_TEST_VECTORS 8
491
492static struct hash_testvec wp256_tv_template[] = {
Herbert Xuef2736f2005-06-22 13:26:03 -0700493 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 .plaintext = "",
495 .psize = 0,
496 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
497 0x9B, 0x44, 0xE3, 0x9C, 0x1D, 0x2E, 0x17, 0x26,
498 0xC5, 0x30, 0x23, 0x21, 0x30, 0xD4, 0x07, 0xF8,
499 0x9A, 0xFE, 0xE0, 0x96, 0x49, 0x97, 0xF7, 0xA7 },
500
501
502 }, {
503 .plaintext = "a",
504 .psize = 1,
505 .digest = { 0x8A, 0xCA, 0x26, 0x02, 0x79, 0x2A, 0xEC, 0x6F,
506 0x11, 0xA6, 0x72, 0x06, 0x53, 0x1F, 0xB7, 0xD7,
507 0xF0, 0xDF, 0xF5, 0x94, 0x13, 0x14, 0x5E, 0x69,
508 0x73, 0xC4, 0x50, 0x01, 0xD0, 0x08, 0x7B, 0x42 },
509 }, {
510 .plaintext = "abc",
511 .psize = 3,
512 .digest = { 0x4E, 0x24, 0x48, 0xA4, 0xC6, 0xF4, 0x86, 0xBB,
513 0x16, 0xB6, 0x56, 0x2C, 0x73, 0xB4, 0x02, 0x0B,
514 0xF3, 0x04, 0x3E, 0x3A, 0x73, 0x1B, 0xCE, 0x72,
515 0x1A, 0xE1, 0xB3, 0x03, 0xD9, 0x7E, 0x6D, 0x4C },
516 }, {
517 .plaintext = "message digest",
518 .psize = 14,
Herbert Xuef2736f2005-06-22 13:26:03 -0700519 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
520 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
521 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B },
523 }, {
524 .plaintext = "abcdefghijklmnopqrstuvwxyz",
525 .psize = 26,
526 .digest = { 0xF1, 0xD7, 0x54, 0x66, 0x26, 0x36, 0xFF, 0xE9,
527 0x2C, 0x82, 0xEB, 0xB9, 0x21, 0x2A, 0x48, 0x4A,
528 0x8D, 0x38, 0x63, 0x1E, 0xAD, 0x42, 0x38, 0xF5,
529 0x44, 0x2E, 0xE1, 0x3B, 0x80, 0x54, 0xE4, 0x1B },
530 }, {
531 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
532 "abcdefghijklmnopqrstuvwxyz0123456789",
533 .psize = 62,
534 .digest = { 0xDC, 0x37, 0xE0, 0x08, 0xCF, 0x9E, 0xE6, 0x9B,
535 0xF1, 0x1F, 0x00, 0xED, 0x9A, 0xBA, 0x26, 0x90,
536 0x1D, 0xD7, 0xC2, 0x8C, 0xDE, 0xC0, 0x66, 0xCC,
537 0x6A, 0xF4, 0x2E, 0x40, 0xF8, 0x2F, 0x3A, 0x1E },
538 }, {
539 .plaintext = "1234567890123456789012345678901234567890"
540 "1234567890123456789012345678901234567890",
541 .psize = 80,
542 .digest = { 0x46, 0x6E, 0xF1, 0x8B, 0xAB, 0xB0, 0x15, 0x4D,
543 0x25, 0xB9, 0xD3, 0x8A, 0x64, 0x14, 0xF5, 0xC0,
544 0x87, 0x84, 0x37, 0x2B, 0xCC, 0xB2, 0x04, 0xD6,
545 0x54, 0x9C, 0x4A, 0xFA, 0xDB, 0x60, 0x14, 0x29 },
546 }, {
547 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
548 .psize = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -0700549 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
551 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
552 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 },
553 },
554};
555
556/*
Herbert Xuef2736f2005-06-22 13:26:03 -0700557 * TIGER test vectors from Tiger website
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 */
559#define TGR192_TEST_VECTORS 6
560
561static struct hash_testvec tgr192_tv_template[] = {
562 {
563 .plaintext = "",
564 .psize = 0,
565 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
566 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
567 0xf3, 0x73, 0xde, 0x2d, 0x49, 0x58, 0x4e, 0x7a },
568 }, {
569 .plaintext = "abc",
570 .psize = 3,
571 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
572 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
573 0x93, 0x5f, 0x7b, 0x95, 0x1c, 0x13, 0x29, 0x51 },
574 }, {
575 .plaintext = "Tiger",
576 .psize = 5,
577 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
578 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
579 0x37, 0x79, 0x0c, 0x11, 0x6f, 0x9d, 0x2b, 0xdf },
580 }, {
581 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
582 .psize = 64,
583 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
584 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
585 0xb5, 0x86, 0x44, 0x50, 0x34, 0xa5, 0xa3, 0x86 },
586 }, {
587 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
588 .psize = 64,
589 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
590 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
591 0x57, 0x89, 0x65, 0x65, 0x97, 0x5f, 0x91, 0x97 },
592 }, {
593 .plaintext = "Tiger - A Fast New Hash Function, "
594 "by Ross Anderson and Eli Biham, "
595 "proceedings of Fast Software Encryption 3, "
596 "Cambridge, 1996.",
597 .psize = 125,
598 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
599 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
600 0xdd, 0x68, 0x15, 0x1d, 0x50, 0x39, 0x74, 0xfc },
601 },
602};
603
604#define TGR160_TEST_VECTORS 6
605
606static struct hash_testvec tgr160_tv_template[] = {
607 {
608 .plaintext = "",
609 .psize = 0,
610 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
611 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f,
612 0xf3, 0x73, 0xde, 0x2d },
613 }, {
614 .plaintext = "abc",
615 .psize = 3,
616 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
617 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf,
618 0x93, 0x5f, 0x7b, 0x95 },
619 }, {
620 .plaintext = "Tiger",
621 .psize = 5,
622 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
623 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec,
624 0x37, 0x79, 0x0c, 0x11 },
625 }, {
626 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
627 .psize = 64,
628 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
629 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e,
630 0xb5, 0x86, 0x44, 0x50 },
631 }, {
632 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
633 .psize = 64,
634 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
635 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9,
636 0x57, 0x89, 0x65, 0x65 },
637 }, {
638 .plaintext = "Tiger - A Fast New Hash Function, "
639 "by Ross Anderson and Eli Biham, "
640 "proceedings of Fast Software Encryption 3, "
641 "Cambridge, 1996.",
642 .psize = 125,
643 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
644 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24,
645 0xdd, 0x68, 0x15, 0x1d },
646 },
647};
648
649#define TGR128_TEST_VECTORS 6
650
651static struct hash_testvec tgr128_tv_template[] = {
652 {
653 .plaintext = "",
654 .psize = 0,
655 .digest = { 0x24, 0xf0, 0x13, 0x0c, 0x63, 0xac, 0x93, 0x32,
656 0x16, 0x16, 0x6e, 0x76, 0xb1, 0xbb, 0x92, 0x5f },
657 }, {
658 .plaintext = "abc",
659 .psize = 3,
660 .digest = { 0xf2, 0x58, 0xc1, 0xe8, 0x84, 0x14, 0xab, 0x2a,
661 0x52, 0x7a, 0xb5, 0x41, 0xff, 0xc5, 0xb8, 0xbf },
662 }, {
663 .plaintext = "Tiger",
664 .psize = 5,
665 .digest = { 0x9f, 0x00, 0xf5, 0x99, 0x07, 0x23, 0x00, 0xdd,
666 0x27, 0x6a, 0xbb, 0x38, 0xc8, 0xeb, 0x6d, 0xec },
667 }, {
668 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
669 .psize = 64,
670 .digest = { 0x87, 0xfb, 0x2a, 0x90, 0x83, 0x85, 0x1c, 0xf7,
671 0x47, 0x0d, 0x2c, 0xf8, 0x10, 0xe6, 0xdf, 0x9e },
672 }, {
673 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789",
674 .psize = 64,
675 .digest = { 0x46, 0x7d, 0xb8, 0x08, 0x63, 0xeb, 0xce, 0x48,
676 0x8d, 0xf1, 0xcd, 0x12, 0x61, 0x65, 0x5d, 0xe9 },
677 }, {
678 .plaintext = "Tiger - A Fast New Hash Function, "
679 "by Ross Anderson and Eli Biham, "
680 "proceedings of Fast Software Encryption 3, "
681 "Cambridge, 1996.",
682 .psize = 125,
683 .digest = { 0x3d, 0x9a, 0xeb, 0x03, 0xd1, 0xbd, 0x1a, 0x63,
684 0x57, 0xb2, 0x77, 0x4d, 0xfd, 0x6d, 0x5b, 0x24 },
685 },
686};
687
688#ifdef CONFIG_CRYPTO_HMAC
689/*
690 * HMAC-MD5 test vectors from RFC2202
691 * (These need to be fixed to not use strlen).
692 */
693#define HMAC_MD5_TEST_VECTORS 7
694
695static struct hmac_testvec hmac_md5_tv_template[] =
Herbert Xuef2736f2005-06-22 13:26:03 -0700696{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 {
698 .key = { [0 ... 15] = 0x0b },
699 .ksize = 16,
700 .plaintext = "Hi There",
701 .psize = 8,
702 .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
703 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d },
704 }, {
705 .key = { 'J', 'e', 'f', 'e' },
706 .ksize = 4,
707 .plaintext = "what do ya want for nothing?",
708 .psize = 28,
709 .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
710 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 },
711 .np = 2,
712 .tap = {14, 14}
713 }, {
714 .key = { [0 ... 15] = 0xaa },
715 .ksize = 16,
716 .plaintext = { [0 ... 49] = 0xdd },
717 .psize = 50,
718 .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
719 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 },
720 }, {
721 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
722 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
723 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, },
724 .ksize = 25,
725 .plaintext = { [0 ... 49] = 0xcd },
726 .psize = 50,
727 .digest = { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
728 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 },
729 }, {
730 .key = { [0 ... 15] = 0x0c },
731 .ksize = 16,
732 .plaintext = "Test With Truncation",
733 .psize = 20,
734 .digest = { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
735 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c },
736 }, {
737 .key = { [0 ... 79] = 0xaa },
738 .ksize = 80,
739 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
740 .psize = 54,
741 .digest = { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f,
742 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd },
743 }, {
744 .key = { [0 ... 79] = 0xaa },
745 .ksize = 80,
746 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
747 "Block-Size Data",
748 .psize = 73,
749 .digest = { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee,
750 0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e },
751 },
752};
753
754/*
755 * HMAC-SHA1 test vectors from RFC2202
756 */
757#define HMAC_SHA1_TEST_VECTORS 7
758
Herbert Xuef2736f2005-06-22 13:26:03 -0700759static struct hmac_testvec hmac_sha1_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 {
761 .key = { [0 ... 19] = 0x0b },
762 .ksize = 20,
763 .plaintext = "Hi There",
764 .psize = 8,
765 .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
766 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1,
767 0x46, 0xbe },
768 }, {
Herbert Xuef2736f2005-06-22 13:26:03 -0700769 .key = { 'J', 'e', 'f', 'e' },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 .ksize = 4,
771 .plaintext = "what do ya want for nothing?",
772 .psize = 28,
Herbert Xuef2736f2005-06-22 13:26:03 -0700773 .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 },
775 .np = 2,
776 .tap = { 14, 14 }
777 }, {
778 .key = { [0 ... 19] = 0xaa },
779 .ksize = 20,
780 .plaintext = { [0 ... 49] = 0xdd },
781 .psize = 50,
Herbert Xuef2736f2005-06-22 13:26:03 -0700782 .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 },
784 }, {
785 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
Herbert Xuef2736f2005-06-22 13:26:03 -0700786 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 },
788 .ksize = 25,
789 .plaintext = { [0 ... 49] = 0xcd },
790 .psize = 50,
Herbert Xuef2736f2005-06-22 13:26:03 -0700791 .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda },
793 }, {
794 .key = { [0 ... 19] = 0x0c },
795 .ksize = 20,
796 .plaintext = "Test With Truncation",
797 .psize = 20,
Herbert Xuef2736f2005-06-22 13:26:03 -0700798 .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 },
800 }, {
801 .key = { [0 ... 79] = 0xaa },
802 .ksize = 80,
803 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
804 .psize = 54,
Herbert Xuef2736f2005-06-22 13:26:03 -0700805 .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 },
807 }, {
808 .key = { [0 ... 79] = 0xaa },
809 .ksize = 80,
810 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
811 "Block-Size Data",
812 .psize = 73,
Herbert Xuef2736f2005-06-22 13:26:03 -0700813 .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 },
815 },
816};
817
818/*
819 * HMAC-SHA256 test vectors from
820 * draft-ietf-ipsec-ciph-sha-256-01.txt
821 */
822#define HMAC_SHA256_TEST_VECTORS 10
823
824static struct hmac_testvec hmac_sha256_tv_template[] = {
825 {
826 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
827 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
828 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
829 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20},
830 .ksize = 32,
831 .plaintext = "abc",
832 .psize = 3,
833 .digest = { 0xa2, 0x1b, 0x1f, 0x5d, 0x4c, 0xf4, 0xf7, 0x3a,
834 0x4d, 0xd9, 0x39, 0x75, 0x0f, 0x7a, 0x06, 0x6a,
835 0x7f, 0x98, 0xcc, 0x13, 0x1c, 0xb1, 0x6a, 0x66,
836 0x92, 0x75, 0x90, 0x21, 0xcf, 0xab, 0x81, 0x81 },
837 }, {
838 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
839 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
840 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
841 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
842 .ksize = 32,
843 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
844 .psize = 56,
845 .digest = { 0x10, 0x4f, 0xdc, 0x12, 0x57, 0x32, 0x8f, 0x08,
846 0x18, 0x4b, 0xa7, 0x31, 0x31, 0xc5, 0x3c, 0xae,
847 0xe6, 0x98, 0xe3, 0x61, 0x19, 0x42, 0x11, 0x49,
848 0xea, 0x8c, 0x71, 0x24, 0x56, 0x69, 0x7d, 0x30 },
849 }, {
850 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
851 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
852 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
853 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 },
854 .ksize = 32,
855 .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
856 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
857 .psize = 112,
858 .digest = { 0x47, 0x03, 0x05, 0xfc, 0x7e, 0x40, 0xfe, 0x34,
859 0xd3, 0xee, 0xb3, 0xe7, 0x73, 0xd9, 0x5a, 0xab,
860 0x73, 0xac, 0xf0, 0xfd, 0x06, 0x04, 0x47, 0xa5,
861 0xeb, 0x45, 0x95, 0xbf, 0x33, 0xa9, 0xd1, 0xa3 },
862 }, {
863 .key = { [0 ... 31] = 0x0b },
864 .ksize = 32,
865 .plaintext = "Hi There",
866 .psize = 8,
867 .digest = { 0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb, 0xc6,
868 0x99, 0x03, 0xa0, 0xf1, 0xcf, 0x2b, 0xbd, 0xc5,
869 0xba, 0x0a, 0xa3, 0xf3, 0xd9, 0xae, 0x3c, 0x1c,
870 0x7a, 0x3b, 0x16, 0x96, 0xa0, 0xb6, 0x8c, 0xf7 },
871 }, {
872 .key = "Jefe",
873 .ksize = 4,
874 .plaintext = "what do ya want for nothing?",
875 .psize = 28,
876 .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
877 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
878 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
879 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 },
880 .np = 2,
881 .tap = { 14, 14 }
882 }, {
883 .key = { [0 ... 31] = 0xaa },
884 .ksize = 32,
885 .plaintext = { [0 ... 49] = 0xdd },
886 .psize = 50,
887 .digest = { 0xcd, 0xcb, 0x12, 0x20, 0xd1, 0xec, 0xcc, 0xea,
888 0x91, 0xe5, 0x3a, 0xba, 0x30, 0x92, 0xf9, 0x62,
889 0xe5, 0x49, 0xfe, 0x6c, 0xe9, 0xed, 0x7f, 0xdc,
890 0x43, 0x19, 0x1f, 0xbd, 0xe4, 0x5c, 0x30, 0xb0 },
891 }, {
892 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
893 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
894 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
895 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
896 0x21, 0x22, 0x23, 0x24, 0x25 },
897 .ksize = 37,
898 .plaintext = { [0 ... 49] = 0xcd },
899 .psize = 50,
900 .digest = { 0xd4, 0x63, 0x3c, 0x17, 0xf6, 0xfb, 0x8d, 0x74,
901 0x4c, 0x66, 0xde, 0xe0, 0xf8, 0xf0, 0x74, 0x55,
902 0x6e, 0xc4, 0xaf, 0x55, 0xef, 0x07, 0x99, 0x85,
903 0x41, 0x46, 0x8e, 0xb4, 0x9b, 0xd2, 0xe9, 0x17 },
904 }, {
905 .key = { [0 ... 31] = 0x0c },
906 .ksize = 32,
907 .plaintext = "Test With Truncation",
908 .psize = 20,
909 .digest = { 0x75, 0x46, 0xaf, 0x01, 0x84, 0x1f, 0xc0, 0x9b,
910 0x1a, 0xb9, 0xc3, 0x74, 0x9a, 0x5f, 0x1c, 0x17,
911 0xd4, 0xf5, 0x89, 0x66, 0x8a, 0x58, 0x7b, 0x27,
912 0x00, 0xa9, 0xc9, 0x7c, 0x11, 0x93, 0xcf, 0x42 },
913 }, {
914 .key = { [0 ... 79] = 0xaa },
915 .ksize = 80,
916 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
917 .psize = 54,
918 .digest = { 0x69, 0x53, 0x02, 0x5e, 0xd9, 0x6f, 0x0c, 0x09,
919 0xf8, 0x0a, 0x96, 0xf7, 0x8e, 0x65, 0x38, 0xdb,
920 0xe2, 0xe7, 0xb8, 0x20, 0xe3, 0xdd, 0x97, 0x0e,
921 0x7d, 0xdd, 0x39, 0x09, 0x1b, 0x32, 0x35, 0x2f },
922 }, {
923 .key = { [0 ... 79] = 0xaa },
924 .ksize = 80,
925 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than "
926 "One Block-Size Data",
927 .psize = 73,
928 .digest = { 0x63, 0x55, 0xac, 0x22, 0xe8, 0x90, 0xd0, 0xa3,
929 0xc8, 0x48, 0x1a, 0x5c, 0xa4, 0x82, 0x5b, 0xc8,
930 0x84, 0xd3, 0xe7, 0xa1, 0xff, 0x98, 0xa2, 0xfc,
931 0x2a, 0xc7, 0xd8, 0xe0, 0x64, 0xc3, 0xb2, 0xe6 },
932 },
933};
934
935#endif /* CONFIG_CRYPTO_HMAC */
936
937/*
938 * DES test vectors.
939 */
940#define DES_ENC_TEST_VECTORS 10
941#define DES_DEC_TEST_VECTORS 4
942#define DES_CBC_ENC_TEST_VECTORS 5
943#define DES_CBC_DEC_TEST_VECTORS 4
944#define DES3_EDE_ENC_TEST_VECTORS 3
945#define DES3_EDE_DEC_TEST_VECTORS 3
946
947static struct cipher_testvec des_enc_tv_template[] = {
948 { /* From Applied Cryptography */
949 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
950 .klen = 8,
951 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
952 .ilen = 8,
953 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
954 .rlen = 8,
955 }, { /* Same key, different plaintext block */
956 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
957 .klen = 8,
958 .input = { 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
959 .ilen = 8,
960 .result = { 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
961 .rlen = 8,
962 }, { /* Sbox test from NBS */
963 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
964 .klen = 8,
965 .input = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
966 .ilen = 8,
967 .result = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
968 .rlen = 8,
969 }, { /* Three blocks */
970 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
971 .klen = 8,
972 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
973 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
974 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
975 .ilen = 24,
976 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
977 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
978 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
979 .rlen = 24,
980 }, { /* Weak key */
981 .fail = 1,
982 .wk = 1,
983 .key = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
984 .klen = 8,
985 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
986 .ilen = 8,
987 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
988 .rlen = 8,
989 }, { /* Two blocks -- for testing encryption across pages */
990 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
991 .klen = 8,
992 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
993 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
994 .ilen = 16,
995 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
996 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
997 .rlen = 16,
998 .np = 2,
999 .tap = { 8, 8 }
1000 }, { /* Four blocks -- for testing encryption with chunking */
1001 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1002 .klen = 8,
1003 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1004 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1005 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef,
1006 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1007 .ilen = 32,
1008 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1009 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1010 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90,
1011 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1012 .rlen = 32,
1013 .np = 3,
Herbert Xuef2736f2005-06-22 13:26:03 -07001014 .tap = { 14, 10, 8 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 }, {
1016 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1017 .klen = 8,
1018 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1019 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
1020 0xca, 0xfe, 0xba, 0xbe, 0xfe, 0xed, 0xbe, 0xef },
1021 .ilen = 24,
1022 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1023 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b,
1024 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1025 .rlen = 24,
1026 .np = 4,
Herbert Xuef2736f2005-06-22 13:26:03 -07001027 .tap = { 2, 1, 3, 18 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 }, {
1029 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1030 .klen = 8,
1031 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1032 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 },
1033 .ilen = 16,
1034 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1035 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1036 .rlen = 16,
1037 .np = 5,
Herbert Xuef2736f2005-06-22 13:26:03 -07001038 .tap = { 2, 2, 2, 2, 8 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 }, {
1040 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1041 .klen = 8,
1042 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1043 .ilen = 8,
1044 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1045 .rlen = 8,
1046 .np = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001047 .tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 },
1049};
1050
1051static struct cipher_testvec des_dec_tv_template[] = {
1052 { /* From Applied Cryptography */
1053 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1054 .klen = 8,
1055 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1056 .ilen = 8,
1057 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1058 .rlen = 8,
1059 }, { /* Sbox test from NBS */
Herbert Xuef2736f2005-06-22 13:26:03 -07001060 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 .klen = 8,
1062 .input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1063 .ilen = 8,
1064 .result = { 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42 },
1065 .rlen = 8,
1066 }, { /* Two blocks, for chunking test */
1067 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1068 .klen = 8,
1069 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1070 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1071 .ilen = 16,
1072 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1073 0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1074 .rlen = 16,
1075 .np = 2,
1076 .tap = { 8, 8 }
1077 }, {
1078 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1079 .klen = 8,
1080 .input = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d,
1081 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1082 .ilen = 16,
1083 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7,
1084 0xa3, 0x99, 0x7b, 0xca, 0xaf, 0x69, 0xa0, 0xf5 },
1085 .rlen = 16,
1086 .np = 3,
1087 .tap = { 3, 12, 1 }
1088 },
1089};
1090
1091static struct cipher_testvec des_cbc_enc_tv_template[] = {
1092 { /* From OpenSSL */
1093 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1094 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001095 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1096 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1097 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1098 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 .ilen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001100 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1101 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1102 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 .rlen = 24,
1104 }, { /* FIPS Pub 81 */
1105 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1106 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001107 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 .input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1109 .ilen = 8,
1110 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1111 .rlen = 8,
1112 }, {
1113 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1114 .klen = 8,
1115 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1116 .input = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1117 .ilen = 8,
1118 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1119 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001120 }, {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1122 .klen = 8,
1123 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1124 .input = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1125 .ilen = 8,
1126 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1127 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001128 }, { /* Copy of openssl vector for chunk testing */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 /* From OpenSSL */
1130 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1131 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001132 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1133 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1134 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1135 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 .ilen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001137 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1138 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1139 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .rlen = 24,
1141 .np = 2,
1142 .tap = { 13, 11 }
1143 },
1144};
1145
1146static struct cipher_testvec des_cbc_dec_tv_template[] = {
1147 { /* FIPS Pub 81 */
1148 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1149 .klen = 8,
1150 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1151 .input = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1152 .ilen = 8,
1153 .result = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1154 .rlen = 8,
1155 }, {
1156 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1157 .klen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001158 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 .input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1160 .ilen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001161 .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 .rlen = 8,
1163 }, {
1164 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1165 .klen = 8,
1166 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
Herbert Xuef2736f2005-06-22 13:26:03 -07001167 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 .ilen = 8,
1169 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1170 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001171 }, { /* Copy of above, for chunk testing */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1173 .klen = 8,
1174 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
Herbert Xuef2736f2005-06-22 13:26:03 -07001175 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 .ilen = 8,
1177 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1178 .rlen = 8,
1179 .np = 2,
1180 .tap = { 4, 4 }
1181 },
1182};
1183
1184/*
1185 * We really need some more test vectors, especially for DES3 CBC.
1186 */
1187static struct cipher_testvec des3_ede_enc_tv_template[] = {
1188 { /* These are from openssl */
1189 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1190 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1191 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1192 .klen = 24,
1193 .input = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1194 .ilen = 8,
1195 .result = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1196 .rlen = 8,
1197 }, {
1198 .key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1199 0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1200 0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1201 .klen = 24,
1202 .input = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1203 .ilen = 8,
1204 .result = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1205 .rlen = 8,
1206 }, {
1207 .key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1208 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1209 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1210 .klen = 24,
1211 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1212 .ilen = 8,
1213 .result = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1214 .rlen = 8,
1215 },
1216};
1217
1218static struct cipher_testvec des3_ede_dec_tv_template[] = {
1219 { /* These are from openssl */
1220 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1221 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
1222 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1223 .klen = 24,
1224 .input = { 0x18, 0xd7, 0x48, 0xe5, 0x63, 0x62, 0x05, 0x72 },
1225 .ilen = 8,
1226 .result = { 0x73, 0x6f, 0x6d, 0x65, 0x64, 0x61, 0x74, 0x61 },
1227 .rlen = 8,
1228 }, {
1229 .key = { 0x03, 0x52, 0x02, 0x07, 0x67, 0x20, 0x82, 0x17,
1230 0x86, 0x02, 0x87, 0x66, 0x59, 0x08, 0x21, 0x98,
1231 0x64, 0x05, 0x6a, 0xbd, 0xfe, 0xa9, 0x34, 0x57 },
1232 .klen = 24,
1233 .input = { 0xc0, 0x7d, 0x2a, 0x0f, 0xa5, 0x66, 0xfa, 0x30 },
1234 .ilen = 8,
1235 .result = { 0x73, 0x71, 0x75, 0x69, 0x67, 0x67, 0x6c, 0x65 },
1236 .rlen = 8,
1237 }, {
1238 .key = { 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20,
1239 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01,
1240 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01 },
1241 .klen = 24,
1242 .input = { 0xe1, 0xef, 0x62, 0xc3, 0x32, 0xfe, 0x82, 0x5b },
1243 .ilen = 8,
1244 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1245 .rlen = 8,
1246 },
1247};
1248
1249/*
1250 * Blowfish test vectors.
1251 */
1252#define BF_ENC_TEST_VECTORS 6
1253#define BF_DEC_TEST_VECTORS 6
1254#define BF_CBC_ENC_TEST_VECTORS 1
1255#define BF_CBC_DEC_TEST_VECTORS 1
1256
1257static struct cipher_testvec bf_enc_tv_template[] = {
1258 { /* DES test vectors from OpenSSL */
1259 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
1260 .klen = 8,
1261 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1262 .ilen = 8,
1263 .result = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1264 .rlen = 8,
1265 }, {
1266 .key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1267 .klen = 8,
1268 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1269 .ilen = 8,
1270 .result = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1271 .rlen = 8,
1272 }, {
1273 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1274 .klen = 8,
1275 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1276 .ilen = 8,
1277 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1278 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001279 }, { /* Vary the keylength... */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1281 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1282 .klen = 16,
1283 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1284 .ilen = 8,
1285 .result = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1286 .rlen = 8,
1287 }, {
1288 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1289 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1290 0x00, 0x11, 0x22, 0x33, 0x44 },
1291 .klen = 21,
1292 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1293 .ilen = 8,
1294 .result = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1295 .rlen = 8,
1296 }, { /* Generated with bf488 */
1297 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1298 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1299 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Herbert Xuef2736f2005-06-22 13:26:03 -07001300 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1301 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1302 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1304 .klen = 56,
1305 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1306 .ilen = 8,
1307 .result = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1308 .rlen = 8,
1309 },
1310};
1311
1312static struct cipher_testvec bf_dec_tv_template[] = {
1313 { /* DES test vectors from OpenSSL */
1314 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1315 .klen = 8,
1316 .input = { 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78 },
1317 .ilen = 8,
1318 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1319 .rlen = 8,
1320 }, {
1321 .key = { 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e },
1322 .klen = 8,
1323 .input = { 0xa7, 0x90, 0x79, 0x51, 0x08, 0xea, 0x3c, 0xae },
1324 .ilen = 8,
1325 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1326 .rlen = 8,
1327 }, {
1328 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1329 .klen = 8,
1330 .input = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1331 .ilen = 8,
1332 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1333 .rlen = 8,
Herbert Xuef2736f2005-06-22 13:26:03 -07001334 }, { /* Vary the keylength... */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1336 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1337 .klen = 16,
1338 .input = { 0x93, 0x14, 0x28, 0x87, 0xee, 0x3b, 0xe1, 0x5c },
1339 .ilen = 8,
1340 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1341 .rlen = 8,
1342 }, {
1343 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1344 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1345 0x00, 0x11, 0x22, 0x33, 0x44 },
1346 .klen = 21,
1347 .input = { 0xe6, 0xf5, 0x1e, 0xd7, 0x9b, 0x9d, 0xb2, 0x1f },
1348 .ilen = 8,
1349 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1350 .rlen = 8,
1351 }, { /* Generated with bf488, using OpenSSL, Libgcrypt and Nettle */
1352 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1353 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1354 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Herbert Xuef2736f2005-06-22 13:26:03 -07001355 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1356 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1357 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1359 .klen = 56,
1360 .input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
1361 .ilen = 8,
1362 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1363 .rlen = 8,
1364 },
1365};
1366
1367static struct cipher_testvec bf_cbc_enc_tv_template[] = {
1368 { /* From OpenSSL */
1369 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1370 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1371 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001372 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1374 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1375 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1376 0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1377 .ilen = 32,
1378 .result = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1379 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1380 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1381 0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1382 .rlen = 32,
1383 },
1384};
1385
1386static struct cipher_testvec bf_cbc_dec_tv_template[] = {
1387 { /* From OpenSSL */
1388 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1389 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1390 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001391 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 .input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1393 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1394 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
1395 0x59, 0xf1, 0x65, 0x2b, 0xd5, 0xff, 0x92, 0xcc },
1396 .ilen = 32,
1397 .result = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1398 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1399 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
1400 0x66, 0x6f, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 },
1401 .rlen = 32,
1402 },
1403};
1404
1405/*
1406 * Twofish test vectors.
1407 */
1408#define TF_ENC_TEST_VECTORS 3
1409#define TF_DEC_TEST_VECTORS 3
1410#define TF_CBC_ENC_TEST_VECTORS 4
1411#define TF_CBC_DEC_TEST_VECTORS 4
1412
1413static struct cipher_testvec tf_enc_tv_template[] = {
1414 {
1415 .key = { [0 ... 15] = 0x00 },
1416 .klen = 16,
1417 .input = { [0 ... 15] = 0x00 },
1418 .ilen = 16,
1419 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1420 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1421 .rlen = 16,
1422 }, {
1423 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1424 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1425 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1426 .klen = 24,
1427 .input = { [0 ... 15] = 0x00 },
1428 .ilen = 16,
1429 .result = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1430 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1431 .rlen = 16,
1432 }, {
1433 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1434 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1435 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1436 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1437 .klen = 32,
1438 .input = { [0 ... 15] = 0x00 },
1439 .ilen = 16,
1440 .result = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1441 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1442 .rlen = 16,
1443 },
1444};
1445
1446static struct cipher_testvec tf_dec_tv_template[] = {
1447 {
1448 .key = { [0 ... 15] = 0x00 },
1449 .klen = 16,
1450 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1451 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1452 .ilen = 16,
1453 .result = { [0 ... 15] = 0x00 },
1454 .rlen = 16,
1455 }, {
1456 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1457 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1458 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
1459 .klen = 24,
1460 .input = { 0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf,
1461 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48 },
1462 .ilen = 16,
1463 .result = { [0 ... 15] = 0x00 },
1464 .rlen = 16,
1465 }, {
1466 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1467 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
1468 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1469 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1470 .klen = 32,
1471 .input = { 0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8,
1472 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20 },
1473 .ilen = 16,
1474 .result = { [0 ... 15] = 0x00 },
1475 .rlen = 16,
1476 },
1477};
1478
1479static struct cipher_testvec tf_cbc_enc_tv_template[] = {
1480 { /* Generated with Nettle */
1481 .key = { [0 ... 15] = 0x00 },
1482 .klen = 16,
1483 .iv = { [0 ... 15] = 0x00 },
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 = { [0 ... 15] = 0x00 },
1491 .klen = 16,
1492 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001493 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .input = { [0 ... 15] = 0x00 },
1495 .ilen = 16,
1496 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1497 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1498 .rlen = 16,
1499 }, {
1500 .key = { [0 ... 15] = 0x00 },
1501 .klen = 16,
1502 .iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1503 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1504 .input = { [0 ... 15] = 0x00 },
1505 .ilen = 16,
1506 .result = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1507 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1508 .rlen = 16,
1509 }, {
1510 .key = { [0 ... 15] = 0x00 },
1511 .klen = 16,
1512 .iv = { [0 ... 15] = 0x00 },
1513 .input = { [0 ... 47] = 0x00 },
1514 .ilen = 48,
1515 .result = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1516 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1517 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1518 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1519 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1520 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1521 .rlen = 48,
1522 },
1523};
1524
1525static struct cipher_testvec tf_cbc_dec_tv_template[] = {
1526 { /* Reverse of the first four above */
1527 .key = { [0 ... 15] = 0x00 },
1528 .klen = 16,
1529 .iv = { [0 ... 15] = 0x00 },
1530 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001531 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 .ilen = 16,
1533 .result = { [0 ... 15] = 0x00 },
1534 .rlen = 16,
1535 }, {
1536 .key = { [0 ... 15] = 0x00 },
1537 .klen = 16,
1538 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1539 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1540 .input = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1541 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1542 .ilen = 16,
1543 .result = { [0 ... 15] = 0x00 },
1544 .rlen = 16,
1545 }, {
1546 .key = { [0 ... 15] = 0x00 },
1547 .klen = 16,
1548 .iv = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1549 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19 },
1550 .input = { 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1551 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1552 .ilen = 16,
1553 .result = { [0 ... 15] = 0x00 },
1554 .rlen = 16,
1555 }, {
1556 .key = { [0 ... 15] = 0x00 },
1557 .klen = 16,
1558 .iv = { [0 ... 15] = 0x00 },
1559 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1560 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a,
1561 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
1562 0x86, 0xcb, 0x08, 0x6b, 0x78, 0x9f, 0x54, 0x19,
1563 0x05, 0xef, 0x8c, 0x61, 0xa8, 0x11, 0x58, 0x26,
1564 0x34, 0xba, 0x5c, 0xb7, 0x10, 0x6a, 0xa6, 0x41 },
1565 .ilen = 48,
1566 .result = { [0 ... 47] = 0x00 },
1567 .rlen = 48,
1568 },
1569};
1570
1571/*
1572 * Serpent test vectors. These are backwards because Serpent writes
1573 * octet sequences in right-to-left mode.
1574 */
1575#define SERPENT_ENC_TEST_VECTORS 4
1576#define SERPENT_DEC_TEST_VECTORS 4
1577
1578#define TNEPRES_ENC_TEST_VECTORS 4
1579#define TNEPRES_DEC_TEST_VECTORS 4
1580
Herbert Xuef2736f2005-06-22 13:26:03 -07001581static struct cipher_testvec serpent_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582 {
1583 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1584 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1585 .ilen = 16,
1586 .result = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1587 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1588 .rlen = 16,
1589 }, {
1590 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1591 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1592 .klen = 16,
1593 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1594 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1595 .ilen = 16,
1596 .result = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1597 0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1598 .rlen = 16,
1599 }, {
1600 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1601 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1602 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1603 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1604 .klen = 32,
1605 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1606 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1607 .ilen = 16,
1608 .result = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1609 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1610 .rlen = 16,
1611 }, {
1612 .key = { [15] = 0x80 },
1613 .klen = 16,
1614 .input = { [0 ... 15] = 0x00 },
1615 .ilen = 16,
1616 .result = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1617 0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1618 .rlen = 16,
1619 },
1620};
1621
Herbert Xuef2736f2005-06-22 13:26:03 -07001622static struct cipher_testvec tnepres_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 { /* KeySize=128, PT=0, I=1 */
1624 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1625 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1626 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1627 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1628 .klen = 16,
1629 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001630 .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631 0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd },
1632 .rlen = 16,
1633 }, { /* KeySize=192, PT=0, I=1 */
1634 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1635 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1636 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1637 .klen = 24,
1638 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1639 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1640 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001641 .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642 0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 },
1643 .rlen = 16,
1644 }, { /* KeySize=256, PT=0, I=1 */
1645 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1646 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1647 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1648 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1649 .klen = 32,
1650 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1651 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1652 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001653 .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654 0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 },
1655 .rlen = 16,
1656 }, { /* KeySize=256, I=257 */
1657 .key = { 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
1658 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
1659 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1660 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1661 .klen = 32,
1662 .input = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1663 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1664 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001665 .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde },
1667 .rlen = 16,
1668 },
1669};
1670
1671
Herbert Xuef2736f2005-06-22 13:26:03 -07001672static struct cipher_testvec serpent_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 {
1674 .input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1675 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
1676 .ilen = 16,
1677 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1678 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1679 .rlen = 16,
1680 }, {
1681 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1682 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1683 .klen = 16,
1684 .input = { 0x4c, 0x7d, 0x8a, 0x32, 0x80, 0x72, 0xa2, 0x2c,
1685 0x82, 0x3e, 0x4a, 0x1f, 0x3a, 0xcd, 0xa1, 0x6d },
1686 .ilen = 16,
1687 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1688 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1689 .rlen = 16,
1690 }, {
1691 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1692 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1693 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1694 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1695 .klen = 32,
1696 .input = { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8,
1697 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c },
1698 .ilen = 16,
1699 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1700 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1701 .rlen = 16,
1702 }, {
1703 .key = { [15] = 0x80 },
1704 .klen = 16,
1705 .input = { 0xdd, 0xd2, 0x6b, 0x98, 0xa5, 0xff, 0xd8, 0x2c,
1706 0x05, 0x34, 0x5a, 0x9d, 0xad, 0xbf, 0xaf, 0x49},
1707 .ilen = 16,
1708 .result = { [0 ... 15] = 0x00 },
1709 .rlen = 16,
1710 },
1711};
1712
Herbert Xuef2736f2005-06-22 13:26:03 -07001713static struct cipher_testvec tnepres_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714 {
1715 .input = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
1716 0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
1717 .ilen = 16,
1718 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1719 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1720 .rlen = 16,
1721 }, {
1722 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1723 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1724 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001725 .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e },
1727 .ilen = 16,
1728 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1729 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1730 .rlen = 16,
1731 }, {
1732 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1733 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1734 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1735 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1736 .klen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001737 .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee },
1739 .ilen = 16,
1740 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1741 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1742 .rlen = 16,
1743 }, { /* KeySize=128, I=121 */
1744 .key = { [15] = 0x80 },
1745 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001746 .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747 0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 },
1748 .ilen = 16,
1749 .result = { [0 ... 15] = 0x00 },
1750 .rlen = 16,
1751 },
1752};
1753
1754
1755/* Cast6 test vectors from RFC 2612 */
1756#define CAST6_ENC_TEST_VECTORS 3
1757#define CAST6_DEC_TEST_VECTORS 3
1758
Herbert Xuef2736f2005-06-22 13:26:03 -07001759static struct cipher_testvec cast6_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 {
Herbert Xuef2736f2005-06-22 13:26:03 -07001761 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1763 .klen = 16,
1764 .input = { [0 ... 15] = 0x00 },
1765 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001766 .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1768 .rlen = 16,
1769 }, {
Herbert Xuef2736f2005-06-22 13:26:03 -07001770 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1771 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001772 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1773 .klen = 24,
1774 .input = { [0 ... 15] = 0x00 },
1775 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001776 .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001777 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1778 .rlen = 16,
1779 }, {
1780 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1781 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1782 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
Herbert Xuef2736f2005-06-22 13:26:03 -07001783 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 .klen = 32,
1785 .input = { [0 ... 15] = 0x00 },
1786 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001787 .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1789 .rlen = 16,
1790 },
1791};
1792
Herbert Xuef2736f2005-06-22 13:26:03 -07001793static struct cipher_testvec cast6_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794 {
Herbert Xuef2736f2005-06-22 13:26:03 -07001795 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1797 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001798 .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1800 .ilen = 16,
1801 .result = { [0 ... 15] = 0x00 },
1802 .rlen = 16,
1803 }, {
Herbert Xuef2736f2005-06-22 13:26:03 -07001804 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1805 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001806 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1807 .klen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001808 .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001809 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1810 .ilen = 16,
1811 .result = { [0 ... 15] = 0x00 },
1812 .rlen = 16,
1813 }, {
1814 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1815 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1816 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
Herbert Xuef2736f2005-06-22 13:26:03 -07001817 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818 .klen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001819 .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1821 .ilen = 16,
1822 .result = { [0 ... 15] = 0x00 },
1823 .rlen = 16,
1824 },
1825};
1826
1827
1828/*
1829 * AES test vectors.
1830 */
1831#define AES_ENC_TEST_VECTORS 3
1832#define AES_DEC_TEST_VECTORS 3
1833
Herbert Xuef2736f2005-06-22 13:26:03 -07001834static struct cipher_testvec aes_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 { /* From FIPS-197 */
Herbert Xuef2736f2005-06-22 13:26:03 -07001836 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1838 .klen = 16,
1839 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1840 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1841 .ilen = 16,
1842 .result = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
1843 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
1844 .rlen = 16,
1845 }, {
1846 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1847 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1848 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1849 .klen = 24,
Herbert Xuef2736f2005-06-22 13:26:03 -07001850 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001851 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1852 .ilen = 16,
1853 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1854 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1855 .rlen = 16,
1856 }, {
1857 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1858 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1859 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1860 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1861 .klen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07001862 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1864 .ilen = 16,
1865 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1866 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1867 .rlen = 16,
1868 },
1869};
1870
Herbert Xuef2736f2005-06-22 13:26:03 -07001871static struct cipher_testvec aes_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872 { /* From FIPS-197 */
Herbert Xuef2736f2005-06-22 13:26:03 -07001873 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1875 .klen = 16,
1876 .input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
1877 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a },
1878 .ilen = 16,
1879 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1880 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1881 .rlen = 16,
1882 }, {
1883 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1884 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1885 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1886 .klen = 24,
1887 .input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1888 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1889 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001890 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1891 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 .rlen = 16,
1893 }, {
1894 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1895 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1896 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1897 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1898 .klen = 32,
1899 .input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1900 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1901 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07001902 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1904 .rlen = 16,
1905 },
1906};
1907
1908/* Cast5 test vectors from RFC 2144 */
1909#define CAST5_ENC_TEST_VECTORS 3
1910#define CAST5_DEC_TEST_VECTORS 3
1911
Herbert Xuef2736f2005-06-22 13:26:03 -07001912static struct cipher_testvec cast5_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913 {
1914 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1915 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
1916 .klen = 16,
1917 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1918 .ilen = 8,
1919 .result = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
1920 .rlen = 8,
1921 }, {
1922 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1923 0x23, 0x45 },
1924 .klen = 10,
1925 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1926 .ilen = 8,
1927 .result = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
1928 .rlen = 8,
1929 }, {
1930 .key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
1931 .klen = 5,
1932 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1933 .ilen = 8,
1934 .result = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
1935 .rlen = 8,
1936 },
1937};
1938
Herbert Xuef2736f2005-06-22 13:26:03 -07001939static struct cipher_testvec cast5_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001940 {
1941 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1942 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
1943 .klen = 16,
1944 .input = { 0x23, 0x8b, 0x4f, 0xe5, 0x84, 0x7e, 0x44, 0xb2 },
1945 .ilen = 8,
1946 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1947 .rlen = 8,
1948 }, {
1949 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1950 0x23, 0x45 },
1951 .klen = 10,
1952 .input = { 0xeb, 0x6a, 0x71, 0x1a, 0x2c, 0x02, 0x27, 0x1b },
1953 .ilen = 8,
1954 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1955 .rlen = 8,
1956 }, {
1957 .key = { 0x01, 0x23, 0x45, 0x67, 0x12 },
1958 .klen = 5,
1959 .input = { 0x7a, 0xc8, 0x16, 0xd1, 0x6e, 0x9b, 0x30, 0x2e },
1960 .ilen = 8,
1961 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1962 .rlen = 8,
1963 },
1964};
1965
Herbert Xuef2736f2005-06-22 13:26:03 -07001966/*
1967 * ARC4 test vectors from OpenSSL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 */
1969#define ARC4_ENC_TEST_VECTORS 7
1970#define ARC4_DEC_TEST_VECTORS 7
1971
Herbert Xuef2736f2005-06-22 13:26:03 -07001972static struct cipher_testvec arc4_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973 {
1974 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1975 .klen = 8,
1976 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1977 .ilen = 8,
1978 .result = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
1979 .rlen = 8,
1980 }, {
1981 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1982 .klen = 8,
1983 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1984 .ilen = 8,
1985 .result = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
1986 .rlen = 8,
1987 }, {
1988 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1989 .klen = 8,
1990 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1991 .ilen = 8,
1992 .result = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
1993 .rlen = 8,
1994 }, {
1995 .key = { 0xef, 0x01, 0x23, 0x45},
1996 .klen = 4,
1997 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1998 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1999 0x00, 0x00, 0x00, 0x00 },
2000 .ilen = 20,
2001 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2002 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
2003 0x36, 0xb6, 0x78, 0x58 },
2004 .rlen = 20,
2005 }, {
2006 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2007 .klen = 8,
2008 .input = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2009 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2010 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2011 0x12, 0x34, 0x56, 0x78 },
2012 .ilen = 28,
2013 .result = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
2014 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
2015 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
2016 0x40, 0x01, 0x1e, 0xcf },
2017 .rlen = 28,
2018 }, {
2019 .key = { 0xef, 0x01, 0x23, 0x45 },
2020 .klen = 4,
2021 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2022 0x00, 0x00 },
2023 .ilen = 10,
2024 .result = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2025 0xbd, 0x61 },
2026 .rlen = 10,
2027 }, {
2028 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
2029 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2030 .klen = 16,
2031 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
2032 .ilen = 8,
2033 .result = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
2034 .rlen = 8,
2035 },
2036};
2037
Herbert Xuef2736f2005-06-22 13:26:03 -07002038static struct cipher_testvec arc4_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 {
2040 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2041 .klen = 8,
2042 .input = { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96 },
2043 .ilen = 8,
2044 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2045 .rlen = 8,
2046 }, {
2047 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2048 .klen = 8,
2049 .input = { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79 },
2050 .ilen = 8,
2051 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2052 .rlen = 8,
2053 }, {
2054 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2055 .klen = 8,
2056 .input = { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a },
2057 .ilen = 8,
2058 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2059 .rlen = 8,
2060 }, {
2061 .key = { 0xef, 0x01, 0x23, 0x45},
2062 .klen = 4,
2063 .input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2064 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
2065 0x36, 0xb6, 0x78, 0x58 },
2066 .ilen = 20,
2067 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2068 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2069 0x00, 0x00, 0x00, 0x00 },
2070 .rlen = 20,
2071 }, {
2072 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2073 .klen = 8,
2074 .input = { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
2075 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
2076 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
2077 0x40, 0x01, 0x1e, 0xcf },
2078 .ilen = 28,
2079 .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2080 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2081 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
2082 0x12, 0x34, 0x56, 0x78 },
2083 .rlen = 28,
2084 }, {
2085 .key = { 0xef, 0x01, 0x23, 0x45 },
2086 .klen = 4,
2087 .input = { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
2088 0xbd, 0x61 },
2089 .ilen = 10,
2090 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2091 0x00, 0x00 },
2092 .rlen = 10,
2093 }, {
2094 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
2095 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2096 .klen = 16,
2097 .input = { 0x69, 0x72, 0x36, 0x59, 0x1B, 0x52, 0x42, 0xB1 },
2098 .ilen = 8,
2099 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
2100 .rlen = 8,
2101 },
2102};
2103
Herbert Xuef2736f2005-06-22 13:26:03 -07002104/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 * TEA test vectors
2106 */
2107#define TEA_ENC_TEST_VECTORS 4
2108#define TEA_DEC_TEST_VECTORS 4
2109
Herbert Xuef2736f2005-06-22 13:26:03 -07002110static struct cipher_testvec tea_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111 {
2112 .key = { [0 ... 15] = 0x00 },
2113 .klen = 16,
2114 .input = { [0 ... 8] = 0x00 },
2115 .ilen = 8,
2116 .result = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
2117 .rlen = 8,
2118 }, {
2119 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2120 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2121 .klen = 16,
2122 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2123 .ilen = 8,
2124 .result = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
2125 .rlen = 8,
2126 }, {
2127 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2128 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2129 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002130 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2132 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002133 .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2135 .rlen = 16,
2136 }, {
2137 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2138 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2139 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002140 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2141 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2142 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002143 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2144 .ilen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07002145 .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
2146 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2147 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
2149 .rlen = 32,
2150 }
2151};
2152
Herbert Xuef2736f2005-06-22 13:26:03 -07002153static struct cipher_testvec tea_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 {
2155 .key = { [0 ... 15] = 0x00 },
2156 .klen = 16,
2157 .input = { 0x0a, 0x3a, 0xea, 0x41, 0x40, 0xa9, 0xba, 0x94 },
2158 .ilen = 8,
2159 .result = { [0 ... 8] = 0x00 },
2160 .rlen = 8,
2161 }, {
2162 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2163 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2164 .klen = 16,
2165 .input = { 0x77, 0x5d, 0x2a, 0x6a, 0xf6, 0xce, 0x92, 0x09 },
2166 .ilen = 8,
2167 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2168 .rlen = 8,
2169 }, {
2170 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2171 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2172 .klen = 16,
2173 .input = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
Herbert Xuef2736f2005-06-22 13:26:03 -07002174 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2175 .ilen = 16,
2176 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2178 .rlen = 16,
2179 }, {
2180 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2181 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2182 .klen = 16,
2183 .input = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
Herbert Xuef2736f2005-06-22 13:26:03 -07002184 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2185 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
2186 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 .ilen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07002188 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2189 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2190 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2192 .rlen = 32,
2193 }
2194};
2195
Herbert Xuef2736f2005-06-22 13:26:03 -07002196/*
2197 * XTEA test vectors
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 */
2199#define XTEA_ENC_TEST_VECTORS 4
2200#define XTEA_DEC_TEST_VECTORS 4
2201
Herbert Xuef2736f2005-06-22 13:26:03 -07002202static struct cipher_testvec xtea_enc_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 {
2204 .key = { [0 ... 15] = 0x00 },
2205 .klen = 16,
2206 .input = { [0 ... 8] = 0x00 },
2207 .ilen = 8,
2208 .result = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
2209 .rlen = 8,
2210 }, {
2211 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2212 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2213 .klen = 16,
2214 .input = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2215 .ilen = 8,
2216 .result = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
2217 .rlen = 8,
2218 }, {
2219 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2220 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2221 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002222 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2224 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002225 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002226 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2227 .rlen = 16,
2228 }, {
2229 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2230 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2231 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002232 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2233 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2234 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2236 .ilen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07002237 .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2238 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2239 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2241 .rlen = 32,
2242 }
2243};
2244
Herbert Xuef2736f2005-06-22 13:26:03 -07002245static struct cipher_testvec xtea_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246 {
2247 .key = { [0 ... 15] = 0x00 },
2248 .klen = 16,
2249 .input = { 0xaa, 0x22, 0x96, 0xe5, 0x6c, 0x61, 0xf3, 0x45 },
2250 .ilen = 8,
2251 .result = { [0 ... 8] = 0x00 },
2252 .rlen = 8,
2253 }, {
2254 .key = { 0x2b, 0x02, 0x05, 0x68, 0x06, 0x14, 0x49, 0x76,
2255 0x77, 0x5d, 0x0e, 0x26, 0x6c, 0x28, 0x78, 0x43 },
2256 .klen = 16,
2257 .input = { 0x82, 0x3e, 0xeb, 0x35, 0xdc, 0xdd, 0xd9, 0xc3 },
2258 .ilen = 8,
2259 .result = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x2e },
2260 .rlen = 8,
2261 }, {
2262 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2263 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2264 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002265 .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2267 .ilen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002268 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002269 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2270 .rlen = 16,
2271 }, {
2272 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2273 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2274 .klen = 16,
Herbert Xuef2736f2005-06-22 13:26:03 -07002275 .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2276 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2277 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2279 .ilen = 32,
Herbert Xuef2736f2005-06-22 13:26:03 -07002280 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2281 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2282 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2284 .rlen = 32,
2285 }
2286};
2287
2288/*
2289 * KHAZAD test vectors.
2290 */
2291#define KHAZAD_ENC_TEST_VECTORS 5
2292#define KHAZAD_DEC_TEST_VECTORS 5
2293
Herbert Xuef2736f2005-06-22 13:26:03 -07002294static struct cipher_testvec khazad_enc_tv_template[] = {
2295 {
2296 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2298 .klen = 16,
2299 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2300 .ilen = 8,
2301 .result = { 0x49, 0xa4, 0xce, 0x32, 0xac, 0x19, 0x0e, 0x3f },
2302 .rlen = 8,
2303 }, {
2304 .key = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
2305 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2306 .klen = 16,
2307 .input = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2308 .ilen = 8,
2309 .result = { 0x7e, 0x82, 0x12, 0xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
2310 .rlen = 8,
2311 }, {
2312 .key = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
2313 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2314 .klen = 16,
2315 .input = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2316 .ilen = 8,
2317 .result = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
2318 .rlen = 8,
2319 }, {
2320 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2321 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2322 .klen = 16,
2323 .input = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2324 .ilen = 8,
2325 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2326 .rlen = 8,
2327 }, {
2328 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2329 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2330 .klen = 16,
2331 .input = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
2332 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2333 .ilen = 16,
2334 .result = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
2335 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2336 .rlen = 16,
2337 },
2338};
2339
Herbert Xuef2736f2005-06-22 13:26:03 -07002340static struct cipher_testvec khazad_dec_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 {
Herbert Xuef2736f2005-06-22 13:26:03 -07002342 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2344 .klen = 16,
2345 .input = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f },
2346 .ilen = 8,
2347 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2348 .rlen = 8,
2349 }, {
2350 .key = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
2351 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2352 .klen = 16,
2353 .input = { 0X7e, 0X82, 0X12, 0Xa1, 0Xd9, 0X5b, 0Xe4, 0Xf9 },
2354 .ilen = 8,
2355 .result = { 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38 },
2356 .rlen = 8,
2357 }, {
2358 .key = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2,
2359 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2360 .klen = 16,
2361 .input = { 0Xaa, 0Xbe, 0Xc1, 0X95, 0Xc5, 0X94, 0X1a, 0X9c },
2362 .ilen = 8,
2363 .result = { 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2, 0Xa2 },
2364 .rlen = 8,
2365 }, {
2366 .key = { 0x2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2367 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2368 .klen = 16,
2369 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2370 .ilen = 8,
2371 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2372 .rlen = 8,
2373 }, {
2374 .key = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f,
2375 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2376 .klen = 16,
2377 .input = { 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 ,
2378 0X04, 0X74, 0Xf5, 0X70, 0X50, 0X16, 0Xd3, 0Xb8 },
2379 .ilen = 16,
2380 .result = { 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f ,
2381 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f, 0X2f },
2382 .rlen = 16,
2383 },
2384};
2385
2386/*
2387 * Anubis test vectors.
2388 */
2389
2390#define ANUBIS_ENC_TEST_VECTORS 5
2391#define ANUBIS_DEC_TEST_VECTORS 5
2392#define ANUBIS_CBC_ENC_TEST_VECTORS 2
2393#define ANUBIS_CBC_DEC_TEST_VECTORS 2
2394
2395static struct cipher_testvec anubis_enc_tv_template[] = {
2396 {
2397 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2398 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2399 .klen = 16,
2400 .input = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2401 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2402 .ilen = 16,
2403 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2404 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
2405 .rlen = 16,
2406 }, {
2407
2408 .key = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2409 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2410 0x03, 0x03, 0x03, 0x03 },
2411 .klen = 20,
2412 .input = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2413 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
2414 .ilen = 16,
2415 .result = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
2416 0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
2417 .rlen = 16,
2418 }, {
2419 .key = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2420 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2421 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2422 0x24, 0x24, 0x24, 0x24 },
2423 .klen = 28,
2424 .input = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2425 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
2426 .ilen = 16,
2427 .result = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
2428 0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
2429 .rlen = 16,
2430 }, {
2431 .key = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2432 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2433 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2434 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2435 .klen = 32,
2436 .input = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2437 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2438 .ilen = 16,
2439 .result = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
2440 0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
2441 .rlen = 16,
2442 }, {
2443 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2444 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2445 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2446 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2447 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2448 .klen = 40,
2449 .input = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2450 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2451 .ilen = 16,
2452 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2453 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
2454 .rlen = 16,
2455 },
2456};
2457
2458static struct cipher_testvec anubis_dec_tv_template[] = {
2459 {
2460 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2461 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2462 .klen = 16,
2463 .input = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2464 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90 },
2465 .ilen = 16,
2466 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2467 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2468 .rlen = 16,
2469 }, {
2470
2471 .key = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2472 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2473 0x03, 0x03, 0x03, 0x03 },
2474 .klen = 20,
2475 .input = { 0xdb, 0xf1, 0x42, 0xf4, 0xd1, 0x8a, 0xc7, 0x49,
2476 0x87, 0x41, 0x6f, 0x82, 0x0a, 0x98, 0x64, 0xae },
2477 .ilen = 16,
2478 .result = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
2479 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 },
2480 .rlen = 16,
2481 }, {
2482 .key = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2483 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2484 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2485 0x24, 0x24, 0x24, 0x24 },
2486 .klen = 28,
2487 .input = { 0xfd, 0x1b, 0x4a, 0xe3, 0xbf, 0xf0, 0xad, 0x3d,
2488 0x06, 0xd3, 0x61, 0x27, 0xfd, 0x13, 0x9e, 0xde },
2489 .ilen = 16,
2490 .result = { 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24,
2491 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24 },
2492 .rlen = 16,
2493 }, {
2494 .key = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2495 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2496 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2497 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2498 .klen = 32,
2499 .input = { 0x1a, 0x91, 0xfb, 0x2b, 0xb7, 0x78, 0x6b, 0xc4,
2500 0x17, 0xd9, 0xff, 0x40, 0x3b, 0x0e, 0xe5, 0xfe },
2501 .ilen = 16,
2502 .result = { 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25,
2503 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25 },
2504 .rlen = 16,
2505 }, {
2506 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2507 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2508 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2509 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2510 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2511 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2512 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee },
2513 .klen = 40,
2514 .ilen = 16,
2515 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2516 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2517 .rlen = 16,
2518 },
2519};
2520
2521static struct cipher_testvec anubis_cbc_enc_tv_template[] = {
2522 {
2523 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2524 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2525 .klen = 16,
2526 .input = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2527 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2528 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2529 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2530 .ilen = 32,
2531 .result = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2532 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
2533 0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
2534 0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
2535 .rlen = 32,
2536 }, {
2537 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2538 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2539 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2540 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2541 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2542 .klen = 40,
2543 .input = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2544 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2545 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2546 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2547 .ilen = 32,
2548 .result = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2549 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
2550 0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
2551 0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
2552 .rlen = 32,
2553 },
2554};
2555
2556static struct cipher_testvec anubis_cbc_dec_tv_template[] = {
2557 {
2558 .key = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2559 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2560 .klen = 16,
2561 .input = { 0x6d, 0xc5, 0xda, 0xa2, 0x26, 0x7d, 0x62, 0x6f,
2562 0x08, 0xb7, 0x52, 0x8e, 0x6e, 0x6e, 0x86, 0x90,
2563 0x86, 0xd8, 0xb5, 0x6f, 0x98, 0x5e, 0x8a, 0x66,
2564 0x4f, 0x1f, 0x78, 0xa1, 0xbb, 0x37, 0xf1, 0xbe },
2565 .ilen = 32,
2566 .result = { 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2567 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2568 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
2569 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe },
2570 .rlen = 32,
2571 }, {
2572 .key = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2573 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2574 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 .klen = 40,
2578 .input = { 0xa5, 0x2c, 0x85, 0x6f, 0x9c, 0xba, 0xa0, 0x97,
2579 0x9e, 0xc6, 0x84, 0x0f, 0x17, 0x21, 0x07, 0xee,
2580 0xa2, 0xbc, 0x06, 0x98, 0xc6, 0x4b, 0xda, 0x75,
2581 0x2e, 0xaa, 0xbe, 0x58, 0xce, 0x01, 0x5b, 0xc7 },
2582 .ilen = 32,
2583 .result = { 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2584 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2585 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
2586 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35 },
2587 .rlen = 32,
2588 },
2589};
2590
2591/*
2592 * Compression stuff.
2593 */
2594#define COMP_BUF_SIZE 512
2595
2596struct comp_testvec {
2597 int inlen, outlen;
2598 char input[COMP_BUF_SIZE];
2599 char output[COMP_BUF_SIZE];
2600};
2601
2602/*
2603 * Deflate test vectors (null-terminated strings).
2604 * Params: winbits=11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
2605 */
2606#define DEFLATE_COMP_TEST_VECTORS 2
2607#define DEFLATE_DECOMP_TEST_VECTORS 2
2608
2609static struct comp_testvec deflate_comp_tv_template[] = {
2610 {
2611 .inlen = 70,
2612 .outlen = 38,
2613 .input = "Join us now and share the software "
2614 "Join us now and share the software ",
2615 .output = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
2616 0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
2617 0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
2618 0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
2619 0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
2620 }, {
2621 .inlen = 191,
2622 .outlen = 122,
2623 .input = "This document describes a compression method based on the DEFLATE"
2624 "compression algorithm. This document defines the application of "
2625 "the DEFLATE algorithm to the IP Payload Compression Protocol.",
2626 .output = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
2627 0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
2628 0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
2629 0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
2630 0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
2631 0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
2632 0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
2633 0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
2634 0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
2635 0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
2636 0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
2637 0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
2638 0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
2639 0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
2640 0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
2641 0xfa, 0x02 },
2642 },
2643};
2644
2645static struct comp_testvec deflate_decomp_tv_template[] = {
2646 {
2647 .inlen = 122,
2648 .outlen = 191,
2649 .input = { 0x5d, 0x8d, 0x31, 0x0e, 0xc2, 0x30, 0x10, 0x04,
2650 0xbf, 0xb2, 0x2f, 0xc8, 0x1f, 0x10, 0x04, 0x09,
2651 0x89, 0xc2, 0x85, 0x3f, 0x70, 0xb1, 0x2f, 0xf8,
2652 0x24, 0xdb, 0x67, 0xd9, 0x47, 0xc1, 0xef, 0x49,
2653 0x68, 0x12, 0x51, 0xae, 0x76, 0x67, 0xd6, 0x27,
2654 0x19, 0x88, 0x1a, 0xde, 0x85, 0xab, 0x21, 0xf2,
2655 0x08, 0x5d, 0x16, 0x1e, 0x20, 0x04, 0x2d, 0xad,
2656 0xf3, 0x18, 0xa2, 0x15, 0x85, 0x2d, 0x69, 0xc4,
2657 0x42, 0x83, 0x23, 0xb6, 0x6c, 0x89, 0x71, 0x9b,
2658 0xef, 0xcf, 0x8b, 0x9f, 0xcf, 0x33, 0xca, 0x2f,
2659 0xed, 0x62, 0xa9, 0x4c, 0x80, 0xff, 0x13, 0xaf,
2660 0x52, 0x37, 0xed, 0x0e, 0x52, 0x6b, 0x59, 0x02,
2661 0xd9, 0x4e, 0xe8, 0x7a, 0x76, 0x1d, 0x02, 0x98,
2662 0xfe, 0x8a, 0x87, 0x83, 0xa3, 0x4f, 0x56, 0x8a,
2663 0xb8, 0x9e, 0x8e, 0x5c, 0x57, 0xd3, 0xa0, 0x79,
2664 0xfa, 0x02 },
2665 .output = "This document describes a compression method based on the DEFLATE"
2666 "compression algorithm. This document defines the application of "
2667 "the DEFLATE algorithm to the IP Payload Compression Protocol.",
2668 }, {
2669 .inlen = 38,
2670 .outlen = 70,
2671 .input = { 0xf3, 0xca, 0xcf, 0xcc, 0x53, 0x28, 0x2d, 0x56,
2672 0xc8, 0xcb, 0x2f, 0x57, 0x48, 0xcc, 0x4b, 0x51,
2673 0x28, 0xce, 0x48, 0x2c, 0x4a, 0x55, 0x28, 0xc9,
2674 0x48, 0x55, 0x28, 0xce, 0x4f, 0x2b, 0x29, 0x07,
2675 0x71, 0xbc, 0x08, 0x2b, 0x01, 0x00 },
2676 .output = "Join us now and share the software "
2677 "Join us now and share the software ",
2678 },
2679};
2680
2681/*
2682 * Michael MIC test vectors from IEEE 802.11i
2683 */
2684#define MICHAEL_MIC_TEST_VECTORS 6
2685
Herbert Xuef2736f2005-06-22 13:26:03 -07002686static struct hash_testvec michael_mic_tv_template[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002687 {
2688 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2689 .ksize = 8,
2690 .plaintext = { },
2691 .psize = 0,
2692 .digest = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 }
2693 },
2694 {
2695 .key = { 0x82, 0x92, 0x5c, 0x1c, 0xa1, 0xd1, 0x30, 0xb8 },
2696 .ksize = 8,
2697 .plaintext = { 'M' },
2698 .psize = 1,
2699 .digest = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f }
2700 },
2701 {
2702 .key = { 0x43, 0x47, 0x21, 0xca, 0x40, 0x63, 0x9b, 0x3f },
2703 .ksize = 8,
2704 .plaintext = { 'M', 'i' },
2705 .psize = 2,
2706 .digest = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 }
2707 },
2708 {
2709 .key = { 0xe8, 0xf9, 0xbe, 0xca, 0xe9, 0x7e, 0x5d, 0x29 },
2710 .ksize = 8,
2711 .plaintext = { 'M', 'i', 'c' },
2712 .psize = 3,
2713 .digest = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb }
2714 },
2715 {
2716 .key = { 0x90, 0x03, 0x8f, 0xc6, 0xcf, 0x13, 0xc1, 0xdb },
2717 .ksize = 8,
2718 .plaintext = { 'M', 'i', 'c', 'h' },
2719 .psize = 4,
2720 .digest = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 }
2721 },
2722 {
2723 .key = { 0xd5, 0x5e, 0x10, 0x05, 0x10, 0x12, 0x89, 0x86 },
2724 .ksize = 8,
2725 .plaintext = { 'M', 'i', 'c', 'h', 'a', 'e', 'l' },
2726 .psize = 7,
2727 .digest = { 0x0a, 0x94, 0x2b, 0x12, 0x4e, 0xca, 0xa5, 0x46 },
2728 }
2729};
2730
2731#endif /* _CRYPTO_TCRYPT_H */