xref: /netbsd-src/crypto/external/bsd/heimdal/dist/lib/hcrypto/test_cipher.c (revision afab4e300d3a9fb07dd8c80daf53d0feb3345706)
1 /*	$NetBSD: test_cipher.c,v 1.3 2023/06/19 21:41:43 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 2006-2016 Kungliga Tekniska Högskolan
5  * (Royal Institute of Technology, Stockholm, Sweden).
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the Institute nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 #include <config.h>
37 #include <krb5/roken.h>
38 
39 #define HC_DEPRECATED_CRYPTO
40 
41 #include <krb5/getarg.h>
42 
43 #include <evp.h>
44 #include <evp-hcrypto.h>
45 #include <evp-cc.h>
46 #if defined(_WIN32)
47 #include <evp-w32.h>
48 #endif
49 #include <evp-pkcs11.h>
50 #include <evp-openssl.h>
51 #include <krb5/hex.h>
52 #include <err.h>
53 
54 struct tests {
55     const char *name;
56     void *key;
57     size_t keysize;
58     void *iv;
59     size_t datasize;
60     void *indata;
61     void *outdata;
62     void *outiv;
63 };
64 
65 struct tests aes_tests[] = {
66     { "aes-256",
67       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
68       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
69       32,
70       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
71       16,
72       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
73       "\xdc\x95\xc0\x78\xa2\x40\x89\x89\xad\x48\xa2\x14\x92\x84\x20\x87",
74       NULL
75     }
76 };
77 
78 struct tests aes_cfb_tests[] = {
79     { "aes-cfb8-128",
80       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
81       16,
82       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
83       16,
84       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
85       "\x66\x16\xf9\x2e\x42\xa8\xf1\x1a\x91\x16\x68\x57\x8e\xc3\xaa\x0f",
86       NULL
87     }
88 };
89 
90 
91 struct tests rc2_tests[] = {
92     { "rc2",
93       "\x88\xbc\xa9\x0e\x90\x87\x5a\x7f\x0f\x79\xc3\x84\x62\x7b\xaf\xb2",
94       16,
95       "\x00\x00\x00\x00\x00\x00\x00\x00",
96       8,
97       "\x00\x00\x00\x00\x00\x00\x00\x00",
98       "\x22\x69\x55\x2a\xb0\xf8\x5c\xa6",
99       NULL
100     }
101 };
102 
103 
104 struct tests rc2_40_tests[] = {
105     { "rc2-40",
106       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
107       16,
108       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
109       16,
110       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
111       "\xc0\xb8\xff\xa5\xd6\xeb\xc9\x62\xcc\x52\x5f\xfe\x9a\x3c\x97\xe6",
112       NULL
113     }
114 };
115 
116 struct tests des_ede3_tests[] = {
117     { "des-ede3",
118       "\x19\x17\xff\xe6\xbb\x77\x2e\xfc"
119       "\x29\x76\x43\xbc\x63\x56\x7e\x9a"
120       "\x00\x2e\x4d\x43\x1d\x5f\xfd\x58",
121       24,
122       "\xbf\x9a\x12\xb7\x26\x69\xfd\x05",
123       16,
124       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
125       "\x55\x95\x97\x76\xa9\x6c\x66\x40\x64\xc7\xf4\x1c\x21\xb7\x14\x1b",
126       NULL
127     }
128 };
129 
130 struct tests camellia128_tests[] = {
131     { "camellia128",
132       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
133       16,
134       "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
135       16,
136       "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
137       "\x07\x92\x3A\x39\xEB\x0A\x81\x7D\x1C\x4D\x87\xBD\xB8\x2D\x1F\x1C",
138       NULL
139     }
140 };
141 
142 struct tests rc4_tests[] = {
143     {
144 	"rc4 8",
145 	"\x01\x23\x45\x67\x89\xAB\xCD\xEF",
146 	8,
147 	NULL,
148 	8,
149 	"\x00\x00\x00\x00\x00\x00\x00\x00",
150 	"\x74\x94\xC2\xE7\x10\x4B\x08\x79",
151 	NULL
152     },
153     {
154 	"rc4 5",
155 	"\x61\x8a\x63\xd2\xfb",
156 	5,
157 	NULL,
158 	5,
159 	"\xdc\xee\x4c\xf9\x2c",
160 	"\xf1\x38\x29\xc9\xde",
161 	NULL
162     },
163     {
164 	"rc4 309",
165 	"\x29\x04\x19\x72\xfb\x42\xba\x5f\xc7\x12\x77\x12\xf1\x38\x29\xc9",
166 	16,
167 	NULL,
168 	309,
169 	"\x52\x75\x69\x73\x6c\x69\x6e\x6e"
170 	"\x75\x6e\x20\x6c\x61\x75\x6c\x75"
171 	"\x20\x6b\x6f\x72\x76\x69\x73\x73"
172 	"\x73\x61\x6e\x69\x2c\x20\x74\xe4"
173 	"\x68\x6b\xe4\x70\xe4\x69\x64\x65"
174 	"\x6e\x20\x70\xe4\xe4\x6c\x6c\xe4"
175 	"\x20\x74\xe4\x79\x73\x69\x6b\x75"
176 	"\x75\x2e\x20\x4b\x65\x73\xe4\x79"
177 	"\xf6\x6e\x20\x6f\x6e\x20\x6f\x6e"
178 	"\x6e\x69\x20\x6f\x6d\x61\x6e\x61"
179 	"\x6e\x69\x2c\x20\x6b\x61\x73\x6b"
180 	"\x69\x73\x61\x76\x75\x75\x6e\x20"
181 	"\x6c\x61\x61\x6b\x73\x6f\x74\x20"
182 	"\x76\x65\x72\x68\x6f\x75\x75\x2e"
183 	"\x20\x45\x6e\x20\x6d\x61\x20\x69"
184 	"\x6c\x6f\x69\x74\x73\x65\x2c\x20"
185 	"\x73\x75\x72\x65\x20\x68\x75\x6f"
186 	"\x6b\x61\x61\x2c\x20\x6d\x75\x74"
187 	"\x74\x61\x20\x6d\x65\x74\x73\xe4"
188 	"\x6e\x20\x74\x75\x6d\x6d\x75\x75"
189 	"\x73\x20\x6d\x75\x6c\x6c\x65\x20"
190 	"\x74\x75\x6f\x6b\x61\x61\x2e\x20"
191 	"\x50\x75\x75\x6e\x74\x6f\x20\x70"
192 	"\x69\x6c\x76\x65\x6e\x2c\x20\x6d"
193 	"\x69\x20\x68\x75\x6b\x6b\x75\x75"
194 	"\x2c\x20\x73\x69\x69\x6e\x74\x6f"
195 	"\x20\x76\x61\x72\x61\x6e\x20\x74"
196 	"\x75\x75\x6c\x69\x73\x65\x6e\x2c"
197 	"\x20\x6d\x69\x20\x6e\x75\x6b\x6b"
198 	"\x75\x75\x2e\x20\x54\x75\x6f\x6b"
199 	"\x73\x75\x74\x20\x76\x61\x6e\x61"
200 	"\x6d\x6f\x6e\x20\x6a\x61\x20\x76"
201 	"\x61\x72\x6a\x6f\x74\x20\x76\x65"
202 	"\x65\x6e\x2c\x20\x6e\x69\x69\x73"
203 	"\x74\xe4\x20\x73\x79\x64\xe4\x6d"
204 	"\x65\x6e\x69\x20\x6c\x61\x75\x6c"
205 	"\x75\x6e\x20\x74\x65\x65\x6e\x2e"
206 	"\x20\x2d\x20\x45\x69\x6e\x6f\x20"
207 	"\x4c\x65\x69\x6e\x6f",
208 	"\x35\x81\x86\x99\x90\x01\xe6\xb5"
209 	"\xda\xf0\x5e\xce\xeb\x7e\xee\x21"
210 	"\xe0\x68\x9c\x1f\x00\xee\xa8\x1f"
211 	"\x7d\xd2\xca\xae\xe1\xd2\x76\x3e"
212 	"\x68\xaf\x0e\xad\x33\xd6\x6c\x26"
213 	"\x8b\xc9\x46\xc4\x84\xfb\xe9\x4c"
214 	"\x5f\x5e\x0b\x86\xa5\x92\x79\xe4"
215 	"\xf8\x24\xe7\xa6\x40\xbd\x22\x32"
216 	"\x10\xb0\xa6\x11\x60\xb7\xbc\xe9"
217 	"\x86\xea\x65\x68\x80\x03\x59\x6b"
218 	"\x63\x0a\x6b\x90\xf8\xe0\xca\xf6"
219 	"\x91\x2a\x98\xeb\x87\x21\x76\xe8"
220 	"\x3c\x20\x2c\xaa\x64\x16\x6d\x2c"
221 	"\xce\x57\xff\x1b\xca\x57\xb2\x13"
222 	"\xf0\xed\x1a\xa7\x2f\xb8\xea\x52"
223 	"\xb0\xbe\x01\xcd\x1e\x41\x28\x67"
224 	"\x72\x0b\x32\x6e\xb3\x89\xd0\x11"
225 	"\xbd\x70\xd8\xaf\x03\x5f\xb0\xd8"
226 	"\x58\x9d\xbc\xe3\xc6\x66\xf5\xea"
227 	"\x8d\x4c\x79\x54\xc5\x0c\x3f\x34"
228 	"\x0b\x04\x67\xf8\x1b\x42\x59\x61"
229 	"\xc1\x18\x43\x07\x4d\xf6\x20\xf2"
230 	"\x08\x40\x4b\x39\x4c\xf9\xd3\x7f"
231 	"\xf5\x4b\x5f\x1a\xd8\xf6\xea\x7d"
232 	"\xa3\xc5\x61\xdf\xa7\x28\x1f\x96"
233 	"\x44\x63\xd2\xcc\x35\xa4\xd1\xb0"
234 	"\x34\x90\xde\xc5\x1b\x07\x11\xfb"
235 	"\xd6\xf5\x5f\x79\x23\x4d\x5b\x7c"
236 	"\x76\x66\x22\xa6\x6d\xe9\x2b\xe9"
237 	"\x96\x46\x1d\x5e\x4d\xc8\x78\xef"
238 	"\x9b\xca\x03\x05\x21\xe8\x35\x1e"
239 	"\x4b\xae\xd2\xfd\x04\xf9\x46\x73"
240 	"\x68\xc4\xad\x6a\xc1\x86\xd0\x82"
241 	"\x45\xb2\x63\xa2\x66\x6d\x1f\x6c"
242 	"\x54\x20\xf1\x59\x9d\xfd\x9f\x43"
243 	"\x89\x21\xc2\xf5\xa4\x63\x93\x8c"
244 	"\xe0\x98\x22\x65\xee\xf7\x01\x79"
245 	"\xbc\x55\x3f\x33\x9e\xb1\xa4\xc1"
246 	"\xaf\x5f\x6a\x54\x7f",
247 	NULL
248     }
249 };
250 
251 
252 static int
test_cipher(int i,const EVP_CIPHER * c,struct tests * t)253 test_cipher(int i, const EVP_CIPHER *c, struct tests *t)
254 {
255     EVP_CIPHER_CTX ectx;
256     EVP_CIPHER_CTX dctx;
257     void *d;
258 
259     if (c == NULL) {
260 	printf("%s not supported\n", t->name);
261 	return 0;
262     }
263 
264     EVP_CIPHER_CTX_init(&ectx);
265     EVP_CIPHER_CTX_init(&dctx);
266 
267     if (EVP_CipherInit_ex(&ectx, c, NULL, NULL, NULL, 1) != 1)
268 	errx(1, "%s: %d EVP_CipherInit_ex einit", t->name, i);
269     if (EVP_CipherInit_ex(&dctx, c, NULL, NULL, NULL, 0) != 1)
270 	errx(1, "%s: %d EVP_CipherInit_ex dinit", t->name, i);
271 
272     EVP_CIPHER_CTX_set_key_length(&ectx, t->keysize);
273     EVP_CIPHER_CTX_set_key_length(&dctx, t->keysize);
274 
275     if (EVP_CipherInit_ex(&ectx, NULL, NULL, t->key, t->iv, 1) != 1)
276 	errx(1, "%s: %d EVP_CipherInit_ex encrypt", t->name, i);
277     if (EVP_CipherInit_ex(&dctx, NULL, NULL, t->key, t->iv, 0) != 1)
278 	errx(1, "%s: %d EVP_CipherInit_ex decrypt", t->name, i);
279 
280     d = emalloc(t->datasize);
281 
282     if (!EVP_Cipher(&ectx, d, t->indata, t->datasize))
283 	errx(1, "%s: %d EVP_Cipher encrypt failed", t->name, i);
284 
285     if (memcmp(d, t->outdata, t->datasize) != 0) {
286 	char *s, *s2;
287 	hex_encode(d, t->datasize, &s);
288 	hex_encode(t->outdata, t->datasize, &s2);
289 	errx(1, "%s: %d encrypt not the same: %s != %s", t->name, i, s, s2);
290     }
291 
292     if (!EVP_Cipher(&dctx, d, d, t->datasize))
293 	errx(1, "%s: %d EVP_Cipher decrypt failed", t->name, i);
294 
295     if (memcmp(d, t->indata, t->datasize) != 0) {
296 	char *s;
297 	hex_encode(d, t->datasize, &s);
298 	errx(1, "%s: %d decrypt not the same: %s", t->name, i, s);
299     }
300     if (t->outiv) {
301 	/* XXXX check  */
302         ;
303     }
304 
305     EVP_CIPHER_CTX_cleanup(&ectx);
306     EVP_CIPHER_CTX_cleanup(&dctx);
307     free(d);
308 
309     return 0;
310 }
311 
312 static int version_flag;
313 static int help_flag;
314 
315 static struct getargs args[] = {
316     { "version",	0,	arg_flag,	&version_flag,
317       "print version", NULL },
318     { "help",		0,	arg_flag,	&help_flag,
319       NULL, 	NULL }
320 };
321 
322 static void
usage(int ret)323 usage (int ret)
324 {
325     arg_printusage (args,
326 		    sizeof(args)/sizeof(*args),
327 		    NULL,
328 		    "");
329     exit (ret);
330 }
331 
332 int
main(int argc,char ** argv)333 main(int argc, char **argv)
334 {
335     int ret = 0;
336     int i, idx = 0;
337 
338     setprogname(argv[0]);
339 
340     if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &idx))
341 	usage(1);
342 
343     if (help_flag)
344 	usage(0);
345 
346     if(version_flag){
347 	print_version(NULL);
348 	exit(0);
349     }
350 
351     argc -= idx;
352     argv += idx;
353 
354     /* hcrypto */
355     for (i = 0; i < sizeof(aes_tests)/sizeof(aes_tests[0]); i++)
356 	ret += test_cipher(i, EVP_hcrypto_aes_256_cbc(), &aes_tests[i]);
357     for (i = 0; i < sizeof(aes_cfb_tests)/sizeof(aes_cfb_tests[0]); i++)
358 	ret += test_cipher(i, EVP_hcrypto_aes_128_cfb8(), &aes_cfb_tests[i]);
359     for (i = 0; i < sizeof(rc2_tests)/sizeof(rc2_tests[0]); i++)
360 	ret += test_cipher(i, EVP_hcrypto_rc2_cbc(), &rc2_tests[i]);
361     for (i = 0; i < sizeof(rc2_40_tests)/sizeof(rc2_40_tests[0]); i++)
362 	ret += test_cipher(i, EVP_hcrypto_rc2_40_cbc(), &rc2_40_tests[i]);
363     for (i = 0; i < sizeof(des_ede3_tests)/sizeof(des_ede3_tests[0]); i++)
364 	ret += test_cipher(i, EVP_hcrypto_des_ede3_cbc(), &des_ede3_tests[i]);
365     for (i = 0; i < sizeof(camellia128_tests)/sizeof(camellia128_tests[0]); i++)
366 	ret += test_cipher(i, EVP_hcrypto_camellia_128_cbc(),
367 			   &camellia128_tests[i]);
368     for (i = 0; i < sizeof(rc4_tests)/sizeof(rc4_tests[0]); i++)
369 	ret += test_cipher(i, EVP_hcrypto_rc4(), &rc4_tests[i]);
370 
371     /* Common Crypto */
372 #ifdef __APPLE__
373     for (i = 0; i < sizeof(aes_tests)/sizeof(aes_tests[0]); i++)
374 	ret += test_cipher(i, EVP_cc_aes_256_cbc(), &aes_tests[i]);
375     for (i = 0; i < sizeof(aes_cfb_tests)/sizeof(aes_cfb_tests[0]); i++)
376 	ret += test_cipher(i, EVP_cc_aes_128_cfb8(), &aes_cfb_tests[i]);
377     for (i = 0; i < sizeof(rc2_40_tests)/sizeof(rc2_40_tests[0]); i++)
378 	ret += test_cipher(i, EVP_cc_rc2_40_cbc(), &rc2_40_tests[i]);
379     for (i = 0; i < sizeof(des_ede3_tests)/sizeof(des_ede3_tests[0]); i++)
380 	ret += test_cipher(i, EVP_cc_des_ede3_cbc(), &des_ede3_tests[i]);
381     for (i = 0; i < sizeof(camellia128_tests)/sizeof(camellia128_tests[0]); i++)
382 	ret += test_cipher(i, EVP_cc_camellia_128_cbc(),
383 			   &camellia128_tests[i]);
384     for (i = 0; i < sizeof(rc4_tests)/sizeof(rc4_tests[0]); i++)
385 	ret += test_cipher(i, EVP_cc_rc4(), &rc4_tests[i]);
386 #endif /* __APPLE__ */
387 
388     /* Windows CNG (if available) */
389 #ifdef WIN32
390     for (i = 0; i < sizeof(aes_tests)/sizeof(aes_tests[0]); i++)
391 	ret += test_cipher(i, EVP_w32crypto_aes_256_cbc(), &aes_tests[i]);
392     for (i = 0; i < sizeof(aes_cfb_tests)/sizeof(aes_cfb_tests[0]); i++)
393 	ret += test_cipher(i, EVP_w32crypto_aes_128_cfb8(), &aes_cfb_tests[i]);
394     for (i = 0; i < sizeof(rc2_tests)/sizeof(rc2_tests[0]); i++)
395 	ret += test_cipher(i, EVP_w32crypto_rc2_cbc(), &rc2_tests[i]);
396     for (i = 0; i < sizeof(rc2_40_tests)/sizeof(rc2_40_tests[0]); i++)
397 	ret += test_cipher(i, EVP_w32crypto_rc2_40_cbc(), &rc2_40_tests[i]);
398     for (i = 0; i < sizeof(des_ede3_tests)/sizeof(des_ede3_tests[0]); i++)
399 	ret += test_cipher(i, EVP_w32crypto_des_ede3_cbc(), &des_ede3_tests[i]);
400     for (i = 0; i < sizeof(rc4_tests)/sizeof(rc4_tests[0]); i++)
401 	ret += test_cipher(i, EVP_w32crypto_rc4(), &rc4_tests[i]);
402 #endif /* WIN32 */
403 
404     /* PKCS#11 */
405 #if __sun || defined(PKCS11_MODULE_PATH)
406     for (i = 0; i < sizeof(aes_tests)/sizeof(aes_tests[0]); i++)
407 	ret += test_cipher(i, EVP_pkcs11_aes_256_cbc(), &aes_tests[i]);
408     for (i = 0; i < sizeof(aes_cfb_tests)/sizeof(aes_cfb_tests[0]); i++)
409 	ret += test_cipher(i, EVP_pkcs11_aes_128_cfb8(), &aes_cfb_tests[i]);
410     for (i = 0; i < sizeof(rc2_tests)/sizeof(rc2_tests[0]); i++)
411 	ret += test_cipher(i, EVP_pkcs11_rc2_cbc(), &rc2_tests[i]);
412     for (i = 0; i < sizeof(rc2_40_tests)/sizeof(rc2_40_tests[0]); i++)
413 	ret += test_cipher(i, EVP_pkcs11_rc2_40_cbc(), &rc2_40_tests[i]);
414     for (i = 0; i < sizeof(des_ede3_tests)/sizeof(des_ede3_tests[0]); i++)
415 	ret += test_cipher(i, EVP_pkcs11_des_ede3_cbc(), &des_ede3_tests[i]);
416     for (i = 0; i < sizeof(rc4_tests)/sizeof(rc4_tests[0]); i++)
417 	ret += test_cipher(i, EVP_pkcs11_rc4(), &rc4_tests[i]);
418 #endif /* PKCS11_MODULE_PATH */
419 
420     /* OpenSSL */
421 #ifdef HAVE_HCRYPTO_W_OPENSSL
422     for (i = 0; i < sizeof(aes_tests)/sizeof(aes_tests[0]); i++)
423 	ret += test_cipher(i, EVP_ossl_aes_256_cbc(), &aes_tests[i]);
424     for (i = 0; i < sizeof(aes_cfb_tests)/sizeof(aes_cfb_tests[0]); i++)
425 	ret += test_cipher(i, EVP_ossl_aes_128_cfb8(), &aes_cfb_tests[i]);
426     for (i = 0; i < sizeof(rc2_tests)/sizeof(rc2_tests[0]); i++)
427 	ret += test_cipher(i, EVP_ossl_rc2_cbc(), &rc2_tests[i]);
428     for (i = 0; i < sizeof(rc2_40_tests)/sizeof(rc2_40_tests[0]); i++)
429 	ret += test_cipher(i, EVP_ossl_rc2_40_cbc(), &rc2_40_tests[i]);
430     for (i = 0; i < sizeof(des_ede3_tests)/sizeof(des_ede3_tests[0]); i++)
431 	ret += test_cipher(i, EVP_ossl_des_ede3_cbc(), &des_ede3_tests[i]);
432     for (i = 0; i < sizeof(rc4_tests)/sizeof(rc4_tests[0]); i++)
433 	ret += test_cipher(i, EVP_ossl_rc4(), &rc4_tests[i]);
434 #endif /* PKCS11_MODULE_PATH */
435 
436     return ret;
437 }
438