openssl.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <openssl/bio.h>
  13. #include <openssl/crypto.h>
  14. #include <openssl/lhash.h>
  15. #include <openssl/conf.h>
  16. #include <openssl/x509.h>
  17. #include <openssl/pem.h>
  18. #include <openssl/ssl.h>
  19. #ifndef OPENSSL_NO_ENGINE
  20. # include <openssl/engine.h>
  21. #endif
  22. #include <openssl/err.h>
  23. #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
  24. #include "s_apps.h"
  25. /* Needed to get the other O_xxx flags. */
  26. #ifdef OPENSSL_SYS_VMS
  27. # include <unixio.h>
  28. #endif
  29. #define INCLUDE_FUNCTION_TABLE
  30. #include "apps.h"
  31. #ifdef OPENSSL_NO_CAMELLIA
  32. # define FORMAT "%-15s"
  33. # define COLUMNS 5
  34. #else
  35. # define FORMAT "%-18s"
  36. # define COLUMNS 4
  37. #endif
  38. /* Special sentinel to exit the program. */
  39. #define EXIT_THE_PROGRAM (-1)
  40. /*
  41. * The LHASH callbacks ("hash" & "cmp") have been replaced by functions with
  42. * the base prototypes (we cast each variable inside the function to the
  43. * required type of "FUNCTION*"). This removes the necessity for
  44. * macro-generated wrapper functions.
  45. */
  46. static LHASH_OF(FUNCTION) *prog_init(void);
  47. static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
  48. static void list_pkey(void);
  49. static void list_type(FUNC_TYPE ft);
  50. static void list_disabled(void);
  51. char *default_config_file = NULL;
  52. BIO *bio_in = NULL;
  53. BIO *bio_out = NULL;
  54. BIO *bio_err = NULL;
  55. static int apps_startup()
  56. {
  57. #ifdef SIGPIPE
  58. signal(SIGPIPE, SIG_IGN);
  59. #endif
  60. /* Set non-default library initialisation settings */
  61. if (!OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN
  62. | OPENSSL_INIT_LOAD_CONFIG, NULL))
  63. return 0;
  64. #ifndef OPENSSL_NO_UI
  65. setup_ui_method();
  66. #endif
  67. return 1;
  68. }
  69. static void apps_shutdown()
  70. {
  71. #ifndef OPENSSL_NO_UI
  72. destroy_ui_method();
  73. #endif
  74. }
  75. static char *make_config_name()
  76. {
  77. const char *t;
  78. size_t len;
  79. char *p;
  80. if ((t = getenv("OPENSSL_CONF")) != NULL)
  81. return OPENSSL_strdup(t);
  82. t = X509_get_default_cert_area();
  83. len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
  84. p = app_malloc(len, "config filename buffer");
  85. strcpy(p, t);
  86. #ifndef OPENSSL_SYS_VMS
  87. strcat(p, "/");
  88. #endif
  89. strcat(p, OPENSSL_CONF);
  90. return p;
  91. }
  92. int main(int argc, char *argv[])
  93. {
  94. FUNCTION f, *fp;
  95. LHASH_OF(FUNCTION) *prog = NULL;
  96. char **copied_argv = NULL;
  97. char *p, *pname;
  98. char buf[1024];
  99. const char *prompt;
  100. ARGS arg;
  101. int first, n, i, ret = 0;
  102. arg.argv = NULL;
  103. arg.size = 0;
  104. /* Set up some of the environment. */
  105. default_config_file = make_config_name();
  106. bio_in = dup_bio_in(FORMAT_TEXT);
  107. bio_out = dup_bio_out(FORMAT_TEXT);
  108. bio_err = dup_bio_err(FORMAT_TEXT);
  109. #if defined(OPENSSL_SYS_VMS) && defined(__DECC)
  110. copied_argv = argv = copy_argv(&argc, argv);
  111. #elif defined(_WIN32)
  112. /*
  113. * Replace argv[] with UTF-8 encoded strings.
  114. */
  115. win32_utf8argv(&argc, &argv);
  116. #endif
  117. p = getenv("OPENSSL_DEBUG_MEMORY");
  118. if (p != NULL && strcmp(p, "on") == 0)
  119. CRYPTO_set_mem_debug(1);
  120. CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
  121. if (getenv("OPENSSL_FIPS")) {
  122. BIO_printf(bio_err, "FIPS mode not supported.\n");
  123. return 1;
  124. }
  125. if (!apps_startup())
  126. goto end;
  127. prog = prog_init();
  128. pname = opt_progname(argv[0]);
  129. /* first check the program name */
  130. f.name = pname;
  131. fp = lh_FUNCTION_retrieve(prog, &f);
  132. if (fp != NULL) {
  133. argv[0] = pname;
  134. ret = fp->func(argc, argv);
  135. goto end;
  136. }
  137. /* If there is stuff on the command line, run with that. */
  138. if (argc != 1) {
  139. argc--;
  140. argv++;
  141. ret = do_cmd(prog, argc, argv);
  142. if (ret < 0)
  143. ret = 0;
  144. goto end;
  145. }
  146. /* ok, lets enter interactive mode */
  147. for (;;) {
  148. ret = 0;
  149. /* Read a line, continue reading if line ends with \ */
  150. for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) {
  151. prompt = first ? "OpenSSL> " : "> ";
  152. p[0] = '\0';
  153. #ifndef READLINE
  154. fputs(prompt, stdout);
  155. fflush(stdout);
  156. if (!fgets(p, n, stdin))
  157. goto end;
  158. if (p[0] == '\0')
  159. goto end;
  160. i = strlen(p);
  161. if (i <= 1)
  162. break;
  163. if (p[i - 2] != '\\')
  164. break;
  165. i -= 2;
  166. p += i;
  167. n -= i;
  168. #else
  169. {
  170. extern char *readline(const char *);
  171. extern void add_history(const char *cp);
  172. char *text;
  173. text = readline(prompt);
  174. if (text == NULL)
  175. goto end;
  176. i = strlen(text);
  177. if (i == 0 || i > n)
  178. break;
  179. if (text[i - 1] != '\\') {
  180. p += strlen(strcpy(p, text));
  181. free(text);
  182. add_history(buf);
  183. break;
  184. }
  185. text[i - 1] = '\0';
  186. p += strlen(strcpy(p, text));
  187. free(text);
  188. n -= i;
  189. }
  190. #endif
  191. }
  192. if (!chopup_args(&arg, buf)) {
  193. BIO_printf(bio_err, "Can't parse (no memory?)\n");
  194. break;
  195. }
  196. ret = do_cmd(prog, arg.argc, arg.argv);
  197. if (ret == EXIT_THE_PROGRAM) {
  198. ret = 0;
  199. goto end;
  200. }
  201. if (ret != 0)
  202. BIO_printf(bio_err, "error in %s\n", arg.argv[0]);
  203. (void)BIO_flush(bio_out);
  204. (void)BIO_flush(bio_err);
  205. }
  206. ret = 1;
  207. end:
  208. OPENSSL_free(copied_argv);
  209. OPENSSL_free(default_config_file);
  210. lh_FUNCTION_free(prog);
  211. OPENSSL_free(arg.argv);
  212. BIO_free(bio_in);
  213. BIO_free_all(bio_out);
  214. apps_shutdown();
  215. #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  216. if (CRYPTO_mem_leaks(bio_err) <= 0)
  217. ret = 1;
  218. #endif
  219. BIO_free(bio_err);
  220. EXIT(ret);
  221. }
  222. const OPTIONS exit_options[] = {
  223. {NULL}
  224. };
  225. static void list_cipher_fn(const EVP_CIPHER *c,
  226. const char *from, const char *to, void *arg)
  227. {
  228. if (c)
  229. BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
  230. else {
  231. if (!from)
  232. from = "<undefined>";
  233. if (!to)
  234. to = "<undefined>";
  235. BIO_printf(arg, "%s => %s\n", from, to);
  236. }
  237. }
  238. static void list_md_fn(const EVP_MD *m,
  239. const char *from, const char *to, void *arg)
  240. {
  241. if (m)
  242. BIO_printf(arg, "%s\n", EVP_MD_name(m));
  243. else {
  244. if (!from)
  245. from = "<undefined>";
  246. if (!to)
  247. to = "<undefined>";
  248. BIO_printf((BIO *)arg, "%s => %s\n", from, to);
  249. }
  250. }
  251. static void list_missing_help(void)
  252. {
  253. const FUNCTION *fp;
  254. const OPTIONS *o;
  255. for (fp = functions; fp->name != NULL; fp++) {
  256. if ((o = fp->help) == NULL) {
  257. BIO_printf(bio_out, "%s *\n", fp->name);
  258. continue;
  259. }
  260. for ( ; o->name != NULL; o++) {
  261. if (o->helpstr == NULL)
  262. BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
  263. }
  264. }
  265. }
  266. /* Unified enum for help and list commands. */
  267. typedef enum HELPLIST_CHOICE {
  268. OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
  269. OPT_COMMANDS, OPT_DIGEST_COMMANDS,
  270. OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
  271. OPT_PK_ALGORITHMS, OPT_DISABLED, OPT_MISSING_HELP
  272. } HELPLIST_CHOICE;
  273. const OPTIONS list_options[] = {
  274. {"help", OPT_HELP, '-', "Display this summary"},
  275. {"commands", OPT_COMMANDS, '-', "List of standard commands"},
  276. {"digest-commands", OPT_DIGEST_COMMANDS, '-',
  277. "List of message digest commands"},
  278. {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
  279. "List of message digest algorithms"},
  280. {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
  281. {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
  282. "List of cipher algorithms"},
  283. {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
  284. "List of public key algorithms"},
  285. {"disabled", OPT_DISABLED, '-',
  286. "List of disabled features"},
  287. {"missing-help", OPT_MISSING_HELP, '-',
  288. "List missing detailed help strings"},
  289. {NULL}
  290. };
  291. int list_main(int argc, char **argv)
  292. {
  293. char *prog;
  294. HELPLIST_CHOICE o;
  295. int done = 0;
  296. prog = opt_init(argc, argv, list_options);
  297. while ((o = opt_next()) != OPT_EOF) {
  298. switch (o) {
  299. case OPT_EOF: /* Never hit, but suppresses warning */
  300. case OPT_ERR:
  301. BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
  302. return 1;
  303. case OPT_HELP:
  304. opt_help(list_options);
  305. break;
  306. case OPT_COMMANDS:
  307. list_type(FT_general);
  308. break;
  309. case OPT_DIGEST_COMMANDS:
  310. list_type(FT_md);
  311. break;
  312. case OPT_DIGEST_ALGORITHMS:
  313. EVP_MD_do_all_sorted(list_md_fn, bio_out);
  314. break;
  315. case OPT_CIPHER_COMMANDS:
  316. list_type(FT_cipher);
  317. break;
  318. case OPT_CIPHER_ALGORITHMS:
  319. EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
  320. break;
  321. case OPT_PK_ALGORITHMS:
  322. list_pkey();
  323. break;
  324. case OPT_DISABLED:
  325. list_disabled();
  326. break;
  327. case OPT_MISSING_HELP:
  328. list_missing_help();
  329. break;
  330. }
  331. done = 1;
  332. }
  333. if (!done) {
  334. BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
  335. return 1;
  336. }
  337. return 0;
  338. }
  339. typedef enum HELP_CHOICE {
  340. OPT_hERR = -1, OPT_hEOF = 0, OPT_hHELP
  341. } HELP_CHOICE;
  342. const OPTIONS help_options[] = {
  343. {"help", OPT_hHELP, '-', "Display this summary"},
  344. {NULL}
  345. };
  346. int help_main(int argc, char **argv)
  347. {
  348. FUNCTION *fp;
  349. int i, nl;
  350. FUNC_TYPE tp;
  351. char *prog;
  352. HELP_CHOICE o;
  353. prog = opt_init(argc, argv, help_options);
  354. while ((o = opt_next()) != OPT_hEOF) {
  355. switch (o) {
  356. case OPT_hERR:
  357. case OPT_hEOF:
  358. BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
  359. return 1;
  360. case OPT_hHELP:
  361. opt_help(help_options);
  362. return 0;
  363. }
  364. }
  365. if (opt_num_rest() != 0) {
  366. BIO_printf(bio_err, "Usage: %s\n", prog);
  367. return 1;
  368. }
  369. BIO_printf(bio_err, "\nStandard commands");
  370. i = 0;
  371. tp = FT_none;
  372. for (fp = functions; fp->name != NULL; fp++) {
  373. nl = 0;
  374. if (((i++) % COLUMNS) == 0) {
  375. BIO_printf(bio_err, "\n");
  376. nl = 1;
  377. }
  378. if (fp->type != tp) {
  379. tp = fp->type;
  380. if (!nl)
  381. BIO_printf(bio_err, "\n");
  382. if (tp == FT_md) {
  383. i = 1;
  384. BIO_printf(bio_err,
  385. "\nMessage Digest commands (see the `dgst' command for more details)\n");
  386. } else if (tp == FT_cipher) {
  387. i = 1;
  388. BIO_printf(bio_err,
  389. "\nCipher commands (see the `enc' command for more details)\n");
  390. }
  391. }
  392. BIO_printf(bio_err, FORMAT, fp->name);
  393. }
  394. BIO_printf(bio_err, "\n\n");
  395. return 0;
  396. }
  397. int exit_main(int argc, char **argv)
  398. {
  399. return EXIT_THE_PROGRAM;
  400. }
  401. static void list_type(FUNC_TYPE ft)
  402. {
  403. FUNCTION *fp;
  404. int i = 0;
  405. for (fp = functions; fp->name != NULL; fp++)
  406. if (fp->type == ft) {
  407. if ((i++ % COLUMNS) == 0)
  408. BIO_printf(bio_out, "\n");
  409. BIO_printf(bio_out, FORMAT, fp->name);
  410. }
  411. BIO_printf(bio_out, "\n");
  412. }
  413. static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
  414. {
  415. FUNCTION f, *fp;
  416. if (argc <= 0 || argv[0] == NULL)
  417. return (0);
  418. f.name = argv[0];
  419. fp = lh_FUNCTION_retrieve(prog, &f);
  420. if (fp == NULL) {
  421. if (EVP_get_digestbyname(argv[0])) {
  422. f.type = FT_md;
  423. f.func = dgst_main;
  424. fp = &f;
  425. } else if (EVP_get_cipherbyname(argv[0])) {
  426. f.type = FT_cipher;
  427. f.func = enc_main;
  428. fp = &f;
  429. }
  430. }
  431. if (fp != NULL) {
  432. return (fp->func(argc, argv));
  433. }
  434. if ((strncmp(argv[0], "no-", 3)) == 0) {
  435. /*
  436. * User is asking if foo is unsupported, by trying to "run" the
  437. * no-foo command. Strange.
  438. */
  439. f.name = argv[0] + 3;
  440. if (lh_FUNCTION_retrieve(prog, &f) == NULL) {
  441. BIO_printf(bio_out, "%s\n", argv[0]);
  442. return (0);
  443. }
  444. BIO_printf(bio_out, "%s\n", argv[0] + 3);
  445. return 1;
  446. }
  447. if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||
  448. strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)
  449. /* Special value to mean "exit the program. */
  450. return EXIT_THE_PROGRAM;
  451. BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
  452. argv[0]);
  453. return (1);
  454. }
  455. static void list_pkey(void)
  456. {
  457. int i;
  458. for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
  459. const EVP_PKEY_ASN1_METHOD *ameth;
  460. int pkey_id, pkey_base_id, pkey_flags;
  461. const char *pinfo, *pem_str;
  462. ameth = EVP_PKEY_asn1_get0(i);
  463. EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
  464. &pinfo, &pem_str, ameth);
  465. if (pkey_flags & ASN1_PKEY_ALIAS) {
  466. BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
  467. BIO_printf(bio_out, "\tAlias for: %s\n",
  468. OBJ_nid2ln(pkey_base_id));
  469. } else {
  470. BIO_printf(bio_out, "Name: %s\n", pinfo);
  471. BIO_printf(bio_out, "\tType: %s Algorithm\n",
  472. pkey_flags & ASN1_PKEY_DYNAMIC ?
  473. "External" : "Builtin");
  474. BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
  475. if (pem_str == NULL)
  476. pem_str = "(none)";
  477. BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
  478. }
  479. }
  480. }
  481. static int function_cmp(const FUNCTION * a, const FUNCTION * b)
  482. {
  483. return strncmp(a->name, b->name, 8);
  484. }
  485. static unsigned long function_hash(const FUNCTION * a)
  486. {
  487. return OPENSSL_LH_strhash(a->name);
  488. }
  489. static int SortFnByName(const void *_f1, const void *_f2)
  490. {
  491. const FUNCTION *f1 = _f1;
  492. const FUNCTION *f2 = _f2;
  493. if (f1->type != f2->type)
  494. return f1->type - f2->type;
  495. return strcmp(f1->name, f2->name);
  496. }
  497. static void list_disabled(void)
  498. {
  499. BIO_puts(bio_out, "Disabled algorithms:\n");
  500. #ifdef OPENSSL_NO_ARIA
  501. BIO_puts(bio_out, "ARIA\n");
  502. #endif
  503. #ifdef OPENSSL_NO_BF
  504. BIO_puts(bio_out, "BF\n");
  505. #endif
  506. #ifdef OPENSSL_NO_BLAKE2
  507. BIO_puts(bio_out, "BLAKE2\n");
  508. #endif
  509. #ifdef OPENSSL_NO_CAMELLIA
  510. BIO_puts(bio_out, "CAMELLIA\n");
  511. #endif
  512. #ifdef OPENSSL_NO_CAST
  513. BIO_puts(bio_out, "CAST\n");
  514. #endif
  515. #ifdef OPENSSL_NO_CMAC
  516. BIO_puts(bio_out, "CMAC\n");
  517. #endif
  518. #ifdef OPENSSL_NO_CMS
  519. BIO_puts(bio_out, "CMS\n");
  520. #endif
  521. #ifdef OPENSSL_NO_COMP
  522. BIO_puts(bio_out, "COMP\n");
  523. #endif
  524. #ifdef OPENSSL_NO_DES
  525. BIO_puts(bio_out, "DES\n");
  526. #endif
  527. #ifdef OPENSSL_NO_DGRAM
  528. BIO_puts(bio_out, "DGRAM\n");
  529. #endif
  530. #ifdef OPENSSL_NO_DH
  531. BIO_puts(bio_out, "DH\n");
  532. #endif
  533. #ifdef OPENSSL_NO_DSA
  534. BIO_puts(bio_out, "DSA\n");
  535. #endif
  536. #if defined(OPENSSL_NO_DTLS)
  537. BIO_puts(bio_out, "DTLS\n");
  538. #endif
  539. #if defined(OPENSSL_NO_DTLS1)
  540. BIO_puts(bio_out, "DTLS1\n");
  541. #endif
  542. #if defined(OPENSSL_NO_DTLS1_2)
  543. BIO_puts(bio_out, "DTLS1_2\n");
  544. #endif
  545. #ifdef OPENSSL_NO_EC
  546. BIO_puts(bio_out, "EC\n");
  547. #endif
  548. #ifdef OPENSSL_NO_EC2M
  549. BIO_puts(bio_out, "EC2M\n");
  550. #endif
  551. #ifdef OPENSSL_NO_ENGINE
  552. BIO_puts(bio_out, "ENGINE\n");
  553. #endif
  554. #ifdef OPENSSL_NO_GOST
  555. BIO_puts(bio_out, "GOST\n");
  556. #endif
  557. #ifdef OPENSSL_NO_HEARTBEATS
  558. BIO_puts(bio_out, "HEARTBEATS\n");
  559. #endif
  560. #ifdef OPENSSL_NO_IDEA
  561. BIO_puts(bio_out, "IDEA\n");
  562. #endif
  563. #ifdef OPENSSL_NO_MD2
  564. BIO_puts(bio_out, "MD2\n");
  565. #endif
  566. #ifdef OPENSSL_NO_MD4
  567. BIO_puts(bio_out, "MD4\n");
  568. #endif
  569. #ifdef OPENSSL_NO_MD5
  570. BIO_puts(bio_out, "MD5\n");
  571. #endif
  572. #ifdef OPENSSL_NO_MDC2
  573. BIO_puts(bio_out, "MDC2\n");
  574. #endif
  575. #ifdef OPENSSL_NO_OCB
  576. BIO_puts(bio_out, "OCB\n");
  577. #endif
  578. #ifdef OPENSSL_NO_OCSP
  579. BIO_puts(bio_out, "OCSP\n");
  580. #endif
  581. #ifdef OPENSSL_NO_PSK
  582. BIO_puts(bio_out, "PSK\n");
  583. #endif
  584. #ifdef OPENSSL_NO_RC2
  585. BIO_puts(bio_out, "RC2\n");
  586. #endif
  587. #ifdef OPENSSL_NO_RC4
  588. BIO_puts(bio_out, "RC4\n");
  589. #endif
  590. #ifdef OPENSSL_NO_RC5
  591. BIO_puts(bio_out, "RC5\n");
  592. #endif
  593. #ifdef OPENSSL_NO_RMD160
  594. BIO_puts(bio_out, "RMD160\n");
  595. #endif
  596. #ifdef OPENSSL_NO_RSA
  597. BIO_puts(bio_out, "RSA\n");
  598. #endif
  599. #ifdef OPENSSL_NO_SCRYPT
  600. BIO_puts(bio_out, "SCRYPT\n");
  601. #endif
  602. #ifdef OPENSSL_NO_SCTP
  603. BIO_puts(bio_out, "SCTP\n");
  604. #endif
  605. #ifdef OPENSSL_NO_SEED
  606. BIO_puts(bio_out, "SEED\n");
  607. #endif
  608. #ifdef OPENSSL_NO_SOCK
  609. BIO_puts(bio_out, "SOCK\n");
  610. #endif
  611. #ifdef OPENSSL_NO_SRP
  612. BIO_puts(bio_out, "SRP\n");
  613. #endif
  614. #ifdef OPENSSL_NO_SRTP
  615. BIO_puts(bio_out, "SRTP\n");
  616. #endif
  617. #ifdef OPENSSL_NO_SSL3
  618. BIO_puts(bio_out, "SSL3\n");
  619. #endif
  620. #ifdef OPENSSL_NO_TLS1
  621. BIO_puts(bio_out, "TLS1\n");
  622. #endif
  623. #ifdef OPENSSL_NO_TLS1_1
  624. BIO_puts(bio_out, "TLS1_1\n");
  625. #endif
  626. #ifdef OPENSSL_NO_TLS1_2
  627. BIO_puts(bio_out, "TLS1_2\n");
  628. #endif
  629. #ifdef OPENSSL_NO_WHIRLPOOL
  630. BIO_puts(bio_out, "WHIRLPOOL\n");
  631. #endif
  632. #ifndef ZLIB
  633. BIO_puts(bio_out, "ZLIB\n");
  634. #endif
  635. }
  636. static LHASH_OF(FUNCTION) *prog_init(void)
  637. {
  638. LHASH_OF(FUNCTION) *ret;
  639. FUNCTION *f;
  640. size_t i;
  641. /* Sort alphabetically within category. For nicer help displays. */
  642. for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
  643. qsort(functions, i, sizeof(*functions), SortFnByName);
  644. if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)
  645. return (NULL);
  646. for (f = functions; f->name != NULL; f++)
  647. (void)lh_FUNCTION_insert(ret, f);
  648. return (ret);
  649. }