evp_test.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /* Written by Ben Laurie, 2001 */
  2. /*
  3. * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. *
  17. * 3. All advertising materials mentioning features or use of this
  18. * software must display the following acknowledgment:
  19. * "This product includes software developed by the OpenSSL Project
  20. * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
  21. *
  22. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  23. * endorse or promote products derived from this software without
  24. * prior written permission. For written permission, please contact
  25. * openssl-core@openssl.org.
  26. *
  27. * 5. Products derived from this software may not be called "OpenSSL"
  28. * nor may "OpenSSL" appear in their names without prior written
  29. * permission of the OpenSSL Project.
  30. *
  31. * 6. Redistributions of any form whatsoever must retain the following
  32. * acknowledgment:
  33. * "This product includes software developed by the OpenSSL Project
  34. * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  37. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  39. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  42. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  43. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  44. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  45. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  46. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  47. * OF THE POSSIBILITY OF SUCH DAMAGE.
  48. */
  49. #include <stdio.h>
  50. #include <string.h>
  51. #include "../e_os.h"
  52. #include <openssl/opensslconf.h>
  53. #include <openssl/evp.h>
  54. #ifndef OPENSSL_NO_ENGINE
  55. # include <openssl/engine.h>
  56. #endif
  57. #include <openssl/err.h>
  58. #include <openssl/conf.h>
  59. static void hexdump(FILE *f, const char *title, const unsigned char *s, int l)
  60. {
  61. int n = 0;
  62. fprintf(f, "%s", title);
  63. for (; n < l; ++n) {
  64. if ((n % 16) == 0)
  65. fprintf(f, "\n%04x", n);
  66. fprintf(f, " %02x", s[n]);
  67. }
  68. fprintf(f, "\n");
  69. }
  70. static int convert(unsigned char *s)
  71. {
  72. unsigned char *d;
  73. for (d = s; *s; s += 2, ++d) {
  74. unsigned int n;
  75. if (!s[1]) {
  76. fprintf(stderr, "Odd number of hex digits!");
  77. EXIT(4);
  78. }
  79. sscanf((char *)s, "%2x", &n);
  80. *d = (unsigned char)n;
  81. }
  82. return s - d;
  83. }
  84. static char *sstrsep(char **string, const char *delim)
  85. {
  86. char isdelim[256];
  87. char *token = *string;
  88. if (**string == 0)
  89. return NULL;
  90. memset(isdelim, 0, 256);
  91. isdelim[0] = 1;
  92. while (*delim) {
  93. isdelim[(unsigned char)(*delim)] = 1;
  94. delim++;
  95. }
  96. while (!isdelim[(unsigned char)(**string)]) {
  97. (*string)++;
  98. }
  99. if (**string) {
  100. **string = 0;
  101. (*string)++;
  102. }
  103. return token;
  104. }
  105. static unsigned char *ustrsep(char **p, const char *sep)
  106. {
  107. return (unsigned char *)sstrsep(p, sep);
  108. }
  109. static int test1_exit(int ec)
  110. {
  111. EXIT(ec);
  112. return (0); /* To keep some compilers quiet */
  113. }
  114. static void test1(const EVP_CIPHER *c, const unsigned char *key, int kn,
  115. const unsigned char *iv, int in,
  116. const unsigned char *plaintext, int pn,
  117. const unsigned char *ciphertext, int cn,
  118. const unsigned char *aad, int an,
  119. const unsigned char *tag, int tn, int encdec)
  120. {
  121. EVP_CIPHER_CTX ctx;
  122. unsigned char out[4096];
  123. int outl, outl2, mode;
  124. printf("Testing cipher %s%s\n", EVP_CIPHER_name(c),
  125. (encdec ==
  126. 1 ? "(encrypt)" : (encdec ==
  127. 0 ? "(decrypt)" : "(encrypt/decrypt)")));
  128. hexdump(stdout, "Key", key, kn);
  129. if (in)
  130. hexdump(stdout, "IV", iv, in);
  131. hexdump(stdout, "Plaintext", plaintext, pn);
  132. hexdump(stdout, "Ciphertext", ciphertext, cn);
  133. if (an)
  134. hexdump(stdout, "AAD", aad, an);
  135. if (tn)
  136. hexdump(stdout, "Tag", tag, tn);
  137. mode = EVP_CIPHER_mode(c);
  138. if (kn != EVP_CIPHER_key_length(c)) {
  139. fprintf(stderr, "Key length doesn't match, got %d expected %lu\n", kn,
  140. (unsigned long)EVP_CIPHER_key_length(c));
  141. test1_exit(5);
  142. }
  143. EVP_CIPHER_CTX_init(&ctx);
  144. EVP_CIPHER_CTX_set_flags(&ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
  145. if (encdec != 0) {
  146. if (mode == EVP_CIPH_GCM_MODE) {
  147. if (!EVP_EncryptInit_ex(&ctx, c, NULL, NULL, NULL)) {
  148. fprintf(stderr, "EncryptInit failed\n");
  149. ERR_print_errors_fp(stderr);
  150. test1_exit(10);
  151. }
  152. if (!EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, in, NULL)) {
  153. fprintf(stderr, "IV length set failed\n");
  154. ERR_print_errors_fp(stderr);
  155. test1_exit(11);
  156. }
  157. if (!EVP_EncryptInit_ex(&ctx, NULL, NULL, key, iv)) {
  158. fprintf(stderr, "Key/IV set failed\n");
  159. ERR_print_errors_fp(stderr);
  160. test1_exit(12);
  161. }
  162. if (an && !EVP_EncryptUpdate(&ctx, NULL, &outl, aad, an)) {
  163. fprintf(stderr, "AAD set failed\n");
  164. ERR_print_errors_fp(stderr);
  165. test1_exit(13);
  166. }
  167. } else if (mode == EVP_CIPH_CCM_MODE) {
  168. if (!EVP_EncryptInit_ex(&ctx, c, NULL, NULL, NULL)) {
  169. fprintf(stderr, "EncryptInit failed\n");
  170. ERR_print_errors_fp(stderr);
  171. test1_exit(10);
  172. }
  173. if (!EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_CCM_SET_IVLEN, in, NULL)) {
  174. fprintf(stderr, "IV length set failed\n");
  175. ERR_print_errors_fp(stderr);
  176. test1_exit(11);
  177. }
  178. if (!EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_CCM_SET_TAG, tn, NULL)) {
  179. fprintf(stderr, "Tag length set failed\n");
  180. ERR_print_errors_fp(stderr);
  181. test1_exit(11);
  182. }
  183. if (!EVP_EncryptInit_ex(&ctx, NULL, NULL, key, iv)) {
  184. fprintf(stderr, "Key/IV set failed\n");
  185. ERR_print_errors_fp(stderr);
  186. test1_exit(12);
  187. }
  188. if (!EVP_EncryptUpdate(&ctx, NULL, &outl, NULL, pn)) {
  189. fprintf(stderr, "Plaintext length set failed\n");
  190. ERR_print_errors_fp(stderr);
  191. test1_exit(12);
  192. }
  193. if (an && !EVP_EncryptUpdate(&ctx, NULL, &outl, aad, an)) {
  194. fprintf(stderr, "AAD set failed\n");
  195. ERR_print_errors_fp(stderr);
  196. test1_exit(13);
  197. }
  198. } else if (mode == EVP_CIPH_WRAP_MODE) {
  199. if (!EVP_EncryptInit_ex(&ctx, c, NULL, key, in ? iv : NULL)) {
  200. fprintf(stderr, "EncryptInit failed\n");
  201. ERR_print_errors_fp(stderr);
  202. test1_exit(10);
  203. }
  204. } else if (!EVP_EncryptInit_ex(&ctx, c, NULL, key, iv)) {
  205. fprintf(stderr, "EncryptInit failed\n");
  206. ERR_print_errors_fp(stderr);
  207. test1_exit(10);
  208. }
  209. EVP_CIPHER_CTX_set_padding(&ctx, 0);
  210. if (!EVP_EncryptUpdate(&ctx, out, &outl, plaintext, pn)) {
  211. fprintf(stderr, "Encrypt failed\n");
  212. ERR_print_errors_fp(stderr);
  213. test1_exit(6);
  214. }
  215. if (!EVP_EncryptFinal_ex(&ctx, out + outl, &outl2)) {
  216. fprintf(stderr, "EncryptFinal failed\n");
  217. ERR_print_errors_fp(stderr);
  218. test1_exit(7);
  219. }
  220. if (outl + outl2 != cn) {
  221. fprintf(stderr, "Ciphertext length mismatch got %d expected %d\n",
  222. outl + outl2, cn);
  223. test1_exit(8);
  224. }
  225. if (memcmp(out, ciphertext, cn)) {
  226. fprintf(stderr, "Ciphertext mismatch\n");
  227. hexdump(stderr, "Got", out, cn);
  228. hexdump(stderr, "Expected", ciphertext, cn);
  229. test1_exit(9);
  230. }
  231. if (mode == EVP_CIPH_GCM_MODE || mode == EVP_CIPH_CCM_MODE) {
  232. unsigned char rtag[16];
  233. /*
  234. * Note: EVP_CTRL_CCM_GET_TAG has same value as
  235. * EVP_CTRL_GCM_GET_TAG
  236. */
  237. if (!EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG, tn, rtag)) {
  238. fprintf(stderr, "Get tag failed\n");
  239. ERR_print_errors_fp(stderr);
  240. test1_exit(14);
  241. }
  242. if (memcmp(rtag, tag, tn)) {
  243. fprintf(stderr, "Tag mismatch\n");
  244. hexdump(stderr, "Got", rtag, tn);
  245. hexdump(stderr, "Expected", tag, tn);
  246. test1_exit(9);
  247. }
  248. }
  249. }
  250. if (encdec <= 0) {
  251. if (mode == EVP_CIPH_GCM_MODE) {
  252. if (!EVP_DecryptInit_ex(&ctx, c, NULL, NULL, NULL)) {
  253. fprintf(stderr, "EncryptInit failed\n");
  254. ERR_print_errors_fp(stderr);
  255. test1_exit(10);
  256. }
  257. if (!EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_SET_IVLEN, in, NULL)) {
  258. fprintf(stderr, "IV length set failed\n");
  259. ERR_print_errors_fp(stderr);
  260. test1_exit(11);
  261. }
  262. if (!EVP_DecryptInit_ex(&ctx, NULL, NULL, key, iv)) {
  263. fprintf(stderr, "Key/IV set failed\n");
  264. ERR_print_errors_fp(stderr);
  265. test1_exit(12);
  266. }
  267. if (!EVP_CIPHER_CTX_ctrl
  268. (&ctx, EVP_CTRL_GCM_SET_TAG, tn, (void *)tag)) {
  269. fprintf(stderr, "Set tag failed\n");
  270. ERR_print_errors_fp(stderr);
  271. test1_exit(14);
  272. }
  273. if (an && !EVP_DecryptUpdate(&ctx, NULL, &outl, aad, an)) {
  274. fprintf(stderr, "AAD set failed\n");
  275. ERR_print_errors_fp(stderr);
  276. test1_exit(13);
  277. }
  278. } else if (mode == EVP_CIPH_CCM_MODE) {
  279. if (!EVP_DecryptInit_ex(&ctx, c, NULL, NULL, NULL)) {
  280. fprintf(stderr, "DecryptInit failed\n");
  281. ERR_print_errors_fp(stderr);
  282. test1_exit(10);
  283. }
  284. if (!EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_CCM_SET_IVLEN, in, NULL)) {
  285. fprintf(stderr, "IV length set failed\n");
  286. ERR_print_errors_fp(stderr);
  287. test1_exit(11);
  288. }
  289. if (!EVP_CIPHER_CTX_ctrl
  290. (&ctx, EVP_CTRL_CCM_SET_TAG, tn, (void *)tag)) {
  291. fprintf(stderr, "Tag length set failed\n");
  292. ERR_print_errors_fp(stderr);
  293. test1_exit(11);
  294. }
  295. if (!EVP_DecryptInit_ex(&ctx, NULL, NULL, key, iv)) {
  296. fprintf(stderr, "Key/Nonce set failed\n");
  297. ERR_print_errors_fp(stderr);
  298. test1_exit(12);
  299. }
  300. if (!EVP_DecryptUpdate(&ctx, NULL, &outl, NULL, pn)) {
  301. fprintf(stderr, "Plaintext length set failed\n");
  302. ERR_print_errors_fp(stderr);
  303. test1_exit(12);
  304. }
  305. if (an && !EVP_EncryptUpdate(&ctx, NULL, &outl, aad, an)) {
  306. fprintf(stderr, "AAD set failed\n");
  307. ERR_print_errors_fp(stderr);
  308. test1_exit(13);
  309. }
  310. } else if (mode == EVP_CIPH_WRAP_MODE) {
  311. if (!EVP_DecryptInit_ex(&ctx, c, NULL, key, in ? iv : NULL)) {
  312. fprintf(stderr, "EncryptInit failed\n");
  313. ERR_print_errors_fp(stderr);
  314. test1_exit(10);
  315. }
  316. } else if (!EVP_DecryptInit_ex(&ctx, c, NULL, key, iv)) {
  317. fprintf(stderr, "DecryptInit failed\n");
  318. ERR_print_errors_fp(stderr);
  319. test1_exit(11);
  320. }
  321. EVP_CIPHER_CTX_set_padding(&ctx, 0);
  322. if (!EVP_DecryptUpdate(&ctx, out, &outl, ciphertext, cn)) {
  323. fprintf(stderr, "Decrypt failed\n");
  324. ERR_print_errors_fp(stderr);
  325. test1_exit(6);
  326. }
  327. if (mode != EVP_CIPH_CCM_MODE
  328. && !EVP_DecryptFinal_ex(&ctx, out + outl, &outl2)) {
  329. fprintf(stderr, "DecryptFinal failed\n");
  330. ERR_print_errors_fp(stderr);
  331. test1_exit(7);
  332. }
  333. if (outl + outl2 != pn) {
  334. fprintf(stderr, "Plaintext length mismatch got %d expected %d\n",
  335. outl + outl2, pn);
  336. test1_exit(8);
  337. }
  338. if (memcmp(out, plaintext, pn)) {
  339. fprintf(stderr, "Plaintext mismatch\n");
  340. hexdump(stderr, "Got", out, pn);
  341. hexdump(stderr, "Expected", plaintext, pn);
  342. test1_exit(9);
  343. }
  344. }
  345. EVP_CIPHER_CTX_cleanup(&ctx);
  346. printf("\n");
  347. }
  348. static int test_cipher(const char *cipher, const unsigned char *key, int kn,
  349. const unsigned char *iv, int in,
  350. const unsigned char *plaintext, int pn,
  351. const unsigned char *ciphertext, int cn,
  352. const unsigned char *aad, int an,
  353. const unsigned char *tag, int tn, int encdec)
  354. {
  355. const EVP_CIPHER *c;
  356. c = EVP_get_cipherbyname(cipher);
  357. if (!c)
  358. return 0;
  359. test1(c, key, kn, iv, in, plaintext, pn, ciphertext, cn, aad, an, tag, tn,
  360. encdec);
  361. return 1;
  362. }
  363. static int test_digest(const char *digest,
  364. const unsigned char *plaintext, int pn,
  365. const unsigned char *ciphertext, unsigned int cn)
  366. {
  367. const EVP_MD *d;
  368. EVP_MD_CTX ctx;
  369. unsigned char md[EVP_MAX_MD_SIZE];
  370. unsigned int mdn;
  371. d = EVP_get_digestbyname(digest);
  372. if (!d)
  373. return 0;
  374. printf("Testing digest %s\n", EVP_MD_name(d));
  375. hexdump(stdout, "Plaintext", plaintext, pn);
  376. hexdump(stdout, "Digest", ciphertext, cn);
  377. EVP_MD_CTX_init(&ctx);
  378. if (!EVP_DigestInit_ex(&ctx, d, NULL)) {
  379. fprintf(stderr, "DigestInit failed\n");
  380. ERR_print_errors_fp(stderr);
  381. EXIT(100);
  382. }
  383. if (!EVP_DigestUpdate(&ctx, plaintext, pn)) {
  384. fprintf(stderr, "DigestUpdate failed\n");
  385. ERR_print_errors_fp(stderr);
  386. EXIT(101);
  387. }
  388. if (!EVP_DigestFinal_ex(&ctx, md, &mdn)) {
  389. fprintf(stderr, "DigestFinal failed\n");
  390. ERR_print_errors_fp(stderr);
  391. EXIT(101);
  392. }
  393. EVP_MD_CTX_cleanup(&ctx);
  394. if (mdn != cn) {
  395. fprintf(stderr, "Digest length mismatch, got %d expected %d\n", mdn,
  396. cn);
  397. EXIT(102);
  398. }
  399. if (memcmp(md, ciphertext, cn)) {
  400. fprintf(stderr, "Digest mismatch\n");
  401. hexdump(stderr, "Got", md, cn);
  402. hexdump(stderr, "Expected", ciphertext, cn);
  403. EXIT(103);
  404. }
  405. printf("\n");
  406. EVP_MD_CTX_cleanup(&ctx);
  407. return 1;
  408. }
  409. int main(int argc, char **argv)
  410. {
  411. const char *szTestFile;
  412. FILE *f;
  413. if (argc != 2) {
  414. fprintf(stderr, "%s <test file>\n", argv[0]);
  415. EXIT(1);
  416. }
  417. CRYPTO_malloc_debug_init();
  418. CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
  419. CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
  420. szTestFile = argv[1];
  421. f = fopen(szTestFile, "r");
  422. if (!f) {
  423. perror(szTestFile);
  424. EXIT(2);
  425. }
  426. ERR_load_crypto_strings();
  427. /* Load up the software EVP_CIPHER and EVP_MD definitions */
  428. OpenSSL_add_all_ciphers();
  429. OpenSSL_add_all_digests();
  430. #ifndef OPENSSL_NO_ENGINE
  431. /* Load all compiled-in ENGINEs */
  432. ENGINE_load_builtin_engines();
  433. #endif
  434. #if 0
  435. OPENSSL_config();
  436. #endif
  437. #ifndef OPENSSL_NO_ENGINE
  438. /*
  439. * Register all available ENGINE implementations of ciphers and digests.
  440. * This could perhaps be changed to "ENGINE_register_all_complete()"?
  441. */
  442. ENGINE_register_all_ciphers();
  443. ENGINE_register_all_digests();
  444. /*
  445. * If we add command-line options, this statement should be switchable.
  446. * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use
  447. * if they weren't already initialised.
  448. */
  449. /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
  450. #endif
  451. for (;;) {
  452. char line[4096];
  453. char *p;
  454. char *cipher;
  455. unsigned char *iv, *key, *plaintext, *ciphertext, *aad, *tag;
  456. int encdec;
  457. int kn, in, pn, cn;
  458. int an = 0;
  459. int tn = 0;
  460. if (!fgets((char *)line, sizeof line, f))
  461. break;
  462. if (line[0] == '#' || line[0] == '\n')
  463. continue;
  464. p = line;
  465. cipher = sstrsep(&p, ":");
  466. key = ustrsep(&p, ":");
  467. iv = ustrsep(&p, ":");
  468. plaintext = ustrsep(&p, ":");
  469. ciphertext = ustrsep(&p, ":");
  470. if (p[-1] == '\n') {
  471. encdec = -1;
  472. p[-1] = '\0';
  473. tag = aad = NULL;
  474. an = tn = 0;
  475. } else {
  476. aad = ustrsep(&p, ":");
  477. tag = ustrsep(&p, ":");
  478. if (tag == NULL) {
  479. p = (char *)aad;
  480. tag = aad = NULL;
  481. an = tn = 0;
  482. }
  483. if (p[-1] == '\n') {
  484. encdec = -1;
  485. p[-1] = '\0';
  486. } else
  487. encdec = atoi(sstrsep(&p, "\n"));
  488. }
  489. kn = convert(key);
  490. in = convert(iv);
  491. pn = convert(plaintext);
  492. cn = convert(ciphertext);
  493. if (aad) {
  494. an = convert(aad);
  495. tn = convert(tag);
  496. }
  497. if (!test_cipher
  498. (cipher, key, kn, iv, in, plaintext, pn, ciphertext, cn, aad, an,
  499. tag, tn, encdec)
  500. && !test_digest(cipher, plaintext, pn, ciphertext, cn)) {
  501. #ifdef OPENSSL_NO_AES
  502. if (strstr(cipher, "AES") == cipher) {
  503. fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
  504. continue;
  505. }
  506. #endif
  507. #ifdef OPENSSL_NO_DES
  508. if (strstr(cipher, "DES") == cipher) {
  509. fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
  510. continue;
  511. }
  512. #endif
  513. #ifdef OPENSSL_NO_RC4
  514. if (strstr(cipher, "RC4") == cipher) {
  515. fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
  516. continue;
  517. }
  518. #endif
  519. #ifdef OPENSSL_NO_CAMELLIA
  520. if (strstr(cipher, "CAMELLIA") == cipher) {
  521. fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
  522. continue;
  523. }
  524. #endif
  525. #ifdef OPENSSL_NO_SEED
  526. if (strstr(cipher, "SEED") == cipher) {
  527. fprintf(stdout, "Cipher disabled, skipping %s\n", cipher);
  528. continue;
  529. }
  530. #endif
  531. fprintf(stderr, "Can't find %s\n", cipher);
  532. EXIT(3);
  533. }
  534. }
  535. fclose(f);
  536. #ifndef OPENSSL_NO_ENGINE
  537. ENGINE_cleanup();
  538. #endif
  539. EVP_cleanup();
  540. CRYPTO_cleanup_all_ex_data();
  541. ERR_remove_thread_state(NULL);
  542. ERR_free_strings();
  543. CRYPTO_mem_leaks_fp(stderr);
  544. return 0;
  545. }