2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
10 #include <internal/cryptlib.h>
14 #include <openssl/bio.h>
15 #include <openssl/crypto.h>
16 #include <openssl/trace.h>
17 #include <openssl/lhash.h>
18 #include <openssl/conf.h>
19 #include <openssl/x509.h>
20 #include <openssl/pem.h>
21 #include <openssl/ssl.h>
22 #ifndef OPENSSL_NO_ENGINE
23 # include <openssl/engine.h>
25 #include <openssl/err.h>
27 /* Needed to get the other O_xxx flags. */
28 #ifdef OPENSSL_SYS_VMS
32 #define INCLUDE_FUNCTION_TABLE
35 /* Structure to hold the number of columns to be displayed and the
36 * field width used to display them.
43 /* Special sentinel to exit the program. */
44 #define EXIT_THE_PROGRAM (-1)
47 * The LHASH callbacks ("hash" & "cmp") have been replaced by functions with
48 * the base prototypes (we cast each variable inside the function to the
49 * required type of "FUNCTION*"). This removes the necessity for
50 * macro-generated wrapper functions.
52 static LHASH_OF(FUNCTION) *prog_init(void);
53 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
54 static void list_pkey(void);
55 static void list_pkey_meth(void);
56 static void list_type(FUNC_TYPE ft, int one);
57 static void list_engines(void);
58 static void list_disabled(void);
59 char *default_config_file = NULL;
65 static void calculate_columns(DISPLAY_COLUMNS *dc)
70 for (f = functions; f->name != NULL; ++f)
71 if (f->type == FT_general || f->type == FT_md || f->type == FT_cipher)
72 if ((len = strlen(f->name)) > maxlen)
75 dc->width = maxlen + 2;
76 dc->columns = (80 - 1) / dc->width;
79 static int apps_startup(void)
82 signal(SIGPIPE, SIG_IGN);
85 /* Set non-default library initialisation settings */
86 if (!OPENSSL_init_ssl(OPENSSL_INIT_ENGINE_ALL_BUILTIN
87 | OPENSSL_INIT_LOAD_CONFIG, NULL))
95 static void apps_shutdown(void)
100 static char *make_config_name(void)
106 if ((t = getenv("OPENSSL_CONF")) != NULL)
107 return OPENSSL_strdup(t);
109 t = X509_get_default_cert_area();
110 len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
111 p = app_malloc(len, "config filename buffer");
113 #ifndef OPENSSL_SYS_VMS
116 strcat(p, OPENSSL_CONF);
122 #ifndef OPENSSL_NO_TRACE
123 typedef struct tracedata_st {
125 unsigned int ingroup:1;
128 static size_t internal_trace_cb(const char *buf, size_t cnt,
129 int category, int cmd, void *vdata)
132 tracedata *trace_data = vdata;
134 CRYPTO_THREAD_ID tid;
140 case OSSL_TRACE_CTRL_BEGIN:
141 if (!ossl_assert(!trace_data->ingroup))
143 trace_data->ingroup = 1;
146 tid.tid = CRYPTO_THREAD_get_current_id();
148 BIO_snprintf(buffer, sizeof(buffer), "TRACE[%lx]:%s: ", tid.ltid,
149 OSSL_trace_get_category_name(category));
150 BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
151 strlen(buffer), buffer);
153 case OSSL_TRACE_CTRL_WRITE:
154 if (!ossl_assert(trace_data->ingroup))
157 ret = BIO_write(trace_data->bio, buf, cnt);
159 case OSSL_TRACE_CTRL_END:
160 if (!ossl_assert(trace_data->ingroup))
162 trace_data->ingroup = 0;
164 BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL);
169 return ret < 0 ? 0 : ret;
172 DEFINE_STACK_OF(tracedata)
173 static STACK_OF(tracedata) *trace_data_stack;
175 static void tracedata_free(tracedata *data)
177 BIO_free_all(data->bio);
181 static STACK_OF(tracedata) *trace_data_stack;
183 static void cleanup_trace(void)
185 sk_tracedata_pop_free(trace_data_stack, tracedata_free);
188 static void setup_trace_category(int category)
191 tracedata *trace_data;
193 if (OSSL_trace_enabled(category))
196 channel = BIO_push(BIO_new(apps_bf_prefix()),
197 dup_bio_err(FORMAT_TEXT));
198 trace_data = OPENSSL_zalloc(sizeof(*trace_data));
200 if (trace_data == NULL
201 || (trace_data->bio = channel) == NULL
202 || OSSL_trace_set_callback(category, internal_trace_cb,
204 || sk_tracedata_push(trace_data_stack, trace_data) == 0) {
207 "warning: unable to setup trace callback for category '%s'.\n",
208 OSSL_trace_get_category_name(category));
210 OSSL_trace_set_callback(category, NULL, NULL);
211 BIO_free_all(channel);
215 static void setup_trace(const char *str)
219 trace_data_stack = sk_tracedata_new_null();
220 val = OPENSSL_strdup(str);
226 for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) {
227 int category = OSSL_trace_get_category_num(item);
229 if (category == OSSL_TRACE_CATEGORY_ALL) {
230 while (++category < OSSL_TRACE_CATEGORY_NUM)
231 setup_trace_category(category);
233 } else if (category > 0) {
234 setup_trace_category(category);
237 "warning: unknown trace category: '%s'.\n", item);
243 atexit(cleanup_trace);
245 #endif /* OPENSSL_NO_TRACE */
247 int main(int argc, char *argv[])
250 LHASH_OF(FUNCTION) *prog = NULL;
255 int first, n, i, ret = 0;
260 /* Set up some of the environment. */
261 default_config_file = make_config_name();
262 bio_in = dup_bio_in(FORMAT_TEXT);
263 bio_out = dup_bio_out(FORMAT_TEXT);
264 bio_err = dup_bio_err(FORMAT_TEXT);
266 #if defined(OPENSSL_SYS_VMS) && defined(__DECC)
267 argv = copy_argv(&argc, argv);
268 #elif defined(_WIN32)
270 * Replace argv[] with UTF-8 encoded strings.
272 win32_utf8argv(&argc, &argv);
276 * We use the prefix method to get the trace output we want. Since some
277 * trace outputs happen with OPENSSL_cleanup(), which is run automatically
278 * after exit(), we need to destroy the prefix method as late as possible.
280 atexit(destroy_prefix_method);
282 #ifndef OPENSSL_NO_TRACE
283 setup_trace(getenv("OPENSSL_TRACE"));
286 p = getenv("OPENSSL_DEBUG_MEMORY");
287 if (p != NULL && strcmp(p, "on") == 0)
288 CRYPTO_set_mem_debug(1);
289 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
291 if (getenv("OPENSSL_FIPS")) {
292 BIO_printf(bio_err, "FIPS mode not supported.\n");
296 if (!apps_startup()) {
298 "FATAL: Startup failure (dev note: apps_startup() failed)\n");
299 ERR_print_errors(bio_err);
305 pname = opt_progname(argv[0]);
307 /* first check the program name */
309 fp = lh_FUNCTION_retrieve(prog, &f);
312 ret = fp->func(argc, argv);
316 /* If there is stuff on the command line, run with that. */
320 ret = do_cmd(prog, argc, argv);
326 /* ok, lets enter interactive mode */
329 /* Read a line, continue reading if line ends with \ */
330 for (p = buf, n = sizeof(buf), i = 0, first = 1; n > 0; first = 0) {
331 prompt = first ? "OpenSSL> " : "> ";
334 fputs(prompt, stdout);
336 if (!fgets(p, n, stdin))
343 if (p[i - 2] != '\\')
350 extern char *readline(const char *);
351 extern void add_history(const char *cp);
354 text = readline(prompt);
360 if (text[i - 1] != '\\') {
361 p += strlen(strcpy(p, text));
368 p += strlen(strcpy(p, text));
375 if (!chopup_args(&arg, buf)) {
376 BIO_printf(bio_err, "Can't parse (no memory?)\n");
380 ret = do_cmd(prog, arg.argc, arg.argv);
381 if (ret == EXIT_THE_PROGRAM) {
386 BIO_printf(bio_err, "error in %s\n", arg.argv[0]);
387 (void)BIO_flush(bio_out);
388 (void)BIO_flush(bio_err);
392 OPENSSL_free(default_config_file);
393 lh_FUNCTION_free(prog);
394 OPENSSL_free(arg.argv);
398 BIO_free_all(bio_out);
400 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
401 if (CRYPTO_mem_leaks(bio_err) <= 0)
408 static void list_cipher_fn(const EVP_CIPHER *c,
409 const char *from, const char *to, void *arg)
412 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
415 from = "<undefined>";
418 BIO_printf(arg, "%s => %s\n", from, to);
422 static void list_md_fn(const EVP_MD *m,
423 const char *from, const char *to, void *arg)
426 BIO_printf(arg, "%s\n", EVP_MD_name(m));
429 from = "<undefined>";
432 BIO_printf((BIO *)arg, "%s => %s\n", from, to);
436 static void list_mac_fn(const EVP_MAC *m,
437 const char *from, const char *to, void *arg)
440 BIO_printf(arg, "%s\n", EVP_MAC_name(m));
443 from = "<undefined>";
446 BIO_printf(arg, "%s => %s\n", from, to);
450 static void list_missing_help(void)
455 for (fp = functions; fp->name != NULL; fp++) {
456 if ((o = fp->help) != NULL) {
457 /* If there is help, list what flags are not documented. */
458 for ( ; o->name != NULL; o++) {
459 if (o->helpstr == NULL)
460 BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
462 } else if (fp->func != dgst_main) {
463 /* If not aliased to the dgst command, */
464 BIO_printf(bio_out, "%s *\n", fp->name);
469 static void list_objects(void)
471 int max_nid = OBJ_new_nid(0);
473 char *oid_buf = NULL;
476 /* Skip 0, since that's NID_undef */
477 for (i = 1; i < max_nid; i++) {
478 const ASN1_OBJECT *obj = OBJ_nid2obj(i);
479 const char *sn = OBJ_nid2sn(i);
480 const char *ln = OBJ_nid2ln(i);
484 * If one of the retrieved objects somehow generated an error,
485 * we ignore it. The check for NID_undef below will detect the
486 * error and simply skip to the next NID.
490 if (OBJ_obj2nid(obj) == NID_undef)
493 if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
494 BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
501 oid_buf = OPENSSL_realloc(oid_buf, n + 1);
502 if (oid_buf == NULL) {
503 BIO_printf(bio_err, "ERROR: Memory allocation\n");
508 if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
510 if (ln == NULL || strcmp(sn, ln) == 0)
511 BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
513 BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
516 OPENSSL_free(oid_buf);
519 static void list_options_for_command(const char *command)
524 for (fp = functions; fp->name != NULL; fp++)
525 if (strcmp(fp->name, command) == 0)
527 if (fp->name == NULL) {
528 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
533 if ((o = fp->help) == NULL)
536 for ( ; o->name != NULL; o++) {
537 if (o->name == OPT_HELP_STR
538 || o->name == OPT_MORE_STR
539 || o->name[0] == '\0')
541 BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);
546 /* Unified enum for help and list commands. */
547 typedef enum HELPLIST_CHOICE {
548 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,
549 OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
550 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
551 OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
552 OPT_MISSING_HELP, OPT_OBJECTS
555 const OPTIONS list_options[] = {
556 {"help", OPT_HELP, '-', "Display this summary"},
557 {"1", OPT_ONE, '-', "List in one column"},
558 {"commands", OPT_COMMANDS, '-', "List of standard commands"},
559 {"digest-commands", OPT_DIGEST_COMMANDS, '-',
560 "List of message digest commands"},
561 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
562 "List of message digest algorithms"},
563 {"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
564 "List of message authentication code algorithms"},
565 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
566 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
567 "List of cipher algorithms"},
568 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
569 "List of public key algorithms"},
570 {"public-key-methods", OPT_PK_METHOD, '-',
571 "List of public key methods"},
572 {"engines", OPT_ENGINES, '-',
573 "List of loaded engines"},
574 {"disabled", OPT_DISABLED, '-',
575 "List of disabled features"},
576 {"missing-help", OPT_MISSING_HELP, '-',
577 "List missing detailed help strings"},
578 {"options", OPT_OPTIONS, 's',
579 "List options for specified command"},
580 {"objects", OPT_OBJECTS, '-',
581 "List built in objects (OID<->name mappings)"},
585 int list_main(int argc, char **argv)
589 int one = 0, done = 0;
591 prog = opt_init(argc, argv, list_options);
592 while ((o = opt_next()) != OPT_EOF) {
594 case OPT_EOF: /* Never hit, but suppresses warning */
597 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
600 opt_help(list_options);
606 list_type(FT_general, one);
608 case OPT_DIGEST_COMMANDS:
609 list_type(FT_md, one);
611 case OPT_DIGEST_ALGORITHMS:
612 EVP_MD_do_all_sorted(list_md_fn, bio_out);
614 case OPT_MAC_ALGORITHMS:
615 EVP_MAC_do_all_sorted(list_mac_fn, bio_out);
617 case OPT_CIPHER_COMMANDS:
618 list_type(FT_cipher, one);
620 case OPT_CIPHER_ALGORITHMS:
621 EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
623 case OPT_PK_ALGORITHMS:
635 case OPT_MISSING_HELP:
642 list_options_for_command(opt_arg());
647 if (opt_num_rest() != 0) {
648 BIO_printf(bio_err, "Extra arguments given.\n");
658 typedef enum HELP_CHOICE {
659 OPT_hERR = -1, OPT_hEOF = 0, OPT_hHELP
662 const OPTIONS help_options[] = {
663 {OPT_HELP_STR, 1, '-', "Usage: help [options]\n"},
664 {OPT_HELP_STR, 1, '-', " help [command]\n"},
665 {"help", OPT_hHELP, '-', "Display this summary"},
670 int help_main(int argc, char **argv)
679 prog = opt_init(argc, argv, help_options);
680 while ((o = opt_next()) != OPT_hEOF) {
684 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
687 opt_help(help_options);
692 if (opt_num_rest() == 1) {
695 new_argv[0] = opt_rest()[0];
696 new_argv[1] = "--help";
698 return do_cmd(prog_init(), 2, new_argv);
700 if (opt_num_rest() != 0) {
701 BIO_printf(bio_err, "Usage: %s\n", prog);
705 calculate_columns(&dc);
706 BIO_printf(bio_err, "Standard commands");
709 for (fp = functions; fp->name != NULL; fp++) {
711 if (i++ % dc.columns == 0) {
712 BIO_printf(bio_err, "\n");
715 if (fp->type != tp) {
718 BIO_printf(bio_err, "\n");
722 "\nMessage Digest commands (see the `dgst' command for more details)\n");
723 } else if (tp == FT_cipher) {
726 "\nCipher commands (see the `enc' command for more details)\n");
729 BIO_printf(bio_err, "%-*s", dc.width, fp->name);
731 BIO_printf(bio_err, "\n\n");
735 static void list_type(FUNC_TYPE ft, int one)
741 memset(&dc, 0, sizeof(dc));
743 calculate_columns(&dc);
745 for (fp = functions; fp->name != NULL; fp++) {
749 BIO_printf(bio_out, "%s\n", fp->name);
751 if (i % dc.columns == 0 && i > 0)
752 BIO_printf(bio_out, "\n");
753 BIO_printf(bio_out, "%-*s", dc.width, fp->name);
758 BIO_printf(bio_out, "\n\n");
761 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
765 if (argc <= 0 || argv[0] == NULL)
768 fp = lh_FUNCTION_retrieve(prog, &f);
770 if (EVP_get_digestbyname(argv[0])) {
774 } else if (EVP_get_cipherbyname(argv[0])) {
781 return fp->func(argc, argv);
783 if ((strncmp(argv[0], "no-", 3)) == 0) {
785 * User is asking if foo is unsupported, by trying to "run" the
786 * no-foo command. Strange.
788 f.name = argv[0] + 3;
789 if (lh_FUNCTION_retrieve(prog, &f) == NULL) {
790 BIO_printf(bio_out, "%s\n", argv[0]);
793 BIO_printf(bio_out, "%s\n", argv[0] + 3);
796 if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||
797 strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)
798 /* Special value to mean "exit the program. */
799 return EXIT_THE_PROGRAM;
801 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
806 static void list_pkey(void)
810 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
811 const EVP_PKEY_ASN1_METHOD *ameth;
812 int pkey_id, pkey_base_id, pkey_flags;
813 const char *pinfo, *pem_str;
814 ameth = EVP_PKEY_asn1_get0(i);
815 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
816 &pinfo, &pem_str, ameth);
817 if (pkey_flags & ASN1_PKEY_ALIAS) {
818 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
819 BIO_printf(bio_out, "\tAlias for: %s\n",
820 OBJ_nid2ln(pkey_base_id));
822 BIO_printf(bio_out, "Name: %s\n", pinfo);
823 BIO_printf(bio_out, "\tType: %s Algorithm\n",
824 pkey_flags & ASN1_PKEY_DYNAMIC ?
825 "External" : "Builtin");
826 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
829 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
835 static void list_pkey_meth(void)
838 size_t meth_count = EVP_PKEY_meth_get_count();
840 for (i = 0; i < meth_count; i++) {
841 const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
842 int pkey_id, pkey_flags;
844 EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
845 BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
846 BIO_printf(bio_out, "\tType: %s Algorithm\n",
847 pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
851 static int function_cmp(const FUNCTION * a, const FUNCTION * b)
853 return strncmp(a->name, b->name, 8);
856 static unsigned long function_hash(const FUNCTION * a)
858 return OPENSSL_LH_strhash(a->name);
861 static int SortFnByName(const void *_f1, const void *_f2)
863 const FUNCTION *f1 = _f1;
864 const FUNCTION *f2 = _f2;
866 if (f1->type != f2->type)
867 return f1->type - f2->type;
868 return strcmp(f1->name, f2->name);
871 static void list_engines(void)
873 #ifndef OPENSSL_NO_ENGINE
876 BIO_puts(bio_out, "Engines:\n");
877 e = ENGINE_get_first();
879 BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
880 e = ENGINE_get_next(e);
883 BIO_puts(bio_out, "Engine support is disabled.\n");
887 static void list_disabled(void)
889 BIO_puts(bio_out, "Disabled algorithms:\n");
890 #ifdef OPENSSL_NO_ARIA
891 BIO_puts(bio_out, "ARIA\n");
894 BIO_puts(bio_out, "BF\n");
896 #ifdef OPENSSL_NO_BLAKE2
897 BIO_puts(bio_out, "BLAKE2\n");
899 #ifdef OPENSSL_NO_CAMELLIA
900 BIO_puts(bio_out, "CAMELLIA\n");
902 #ifdef OPENSSL_NO_CAST
903 BIO_puts(bio_out, "CAST\n");
905 #ifdef OPENSSL_NO_CMAC
906 BIO_puts(bio_out, "CMAC\n");
908 #ifdef OPENSSL_NO_CMS
909 BIO_puts(bio_out, "CMS\n");
911 #ifdef OPENSSL_NO_COMP
912 BIO_puts(bio_out, "COMP\n");
914 #ifdef OPENSSL_NO_DES
915 BIO_puts(bio_out, "DES\n");
917 #ifdef OPENSSL_NO_DGRAM
918 BIO_puts(bio_out, "DGRAM\n");
921 BIO_puts(bio_out, "DH\n");
923 #ifdef OPENSSL_NO_DSA
924 BIO_puts(bio_out, "DSA\n");
926 #if defined(OPENSSL_NO_DTLS)
927 BIO_puts(bio_out, "DTLS\n");
929 #if defined(OPENSSL_NO_DTLS1)
930 BIO_puts(bio_out, "DTLS1\n");
932 #if defined(OPENSSL_NO_DTLS1_2)
933 BIO_puts(bio_out, "DTLS1_2\n");
936 BIO_puts(bio_out, "EC\n");
938 #ifdef OPENSSL_NO_EC2M
939 BIO_puts(bio_out, "EC2M\n");
941 #ifdef OPENSSL_NO_ENGINE
942 BIO_puts(bio_out, "ENGINE\n");
944 #ifdef OPENSSL_NO_GOST
945 BIO_puts(bio_out, "GOST\n");
947 #ifdef OPENSSL_NO_IDEA
948 BIO_puts(bio_out, "IDEA\n");
950 #ifdef OPENSSL_NO_MD2
951 BIO_puts(bio_out, "MD2\n");
953 #ifdef OPENSSL_NO_MD4
954 BIO_puts(bio_out, "MD4\n");
956 #ifdef OPENSSL_NO_MD5
957 BIO_puts(bio_out, "MD5\n");
959 #ifdef OPENSSL_NO_MDC2
960 BIO_puts(bio_out, "MDC2\n");
962 #ifdef OPENSSL_NO_OCB
963 BIO_puts(bio_out, "OCB\n");
965 #ifdef OPENSSL_NO_OCSP
966 BIO_puts(bio_out, "OCSP\n");
968 #ifdef OPENSSL_NO_PSK
969 BIO_puts(bio_out, "PSK\n");
971 #ifdef OPENSSL_NO_RC2
972 BIO_puts(bio_out, "RC2\n");
974 #ifdef OPENSSL_NO_RC4
975 BIO_puts(bio_out, "RC4\n");
977 #ifdef OPENSSL_NO_RC5
978 BIO_puts(bio_out, "RC5\n");
980 #ifdef OPENSSL_NO_RMD160
981 BIO_puts(bio_out, "RMD160\n");
983 #ifdef OPENSSL_NO_RSA
984 BIO_puts(bio_out, "RSA\n");
986 #ifdef OPENSSL_NO_SCRYPT
987 BIO_puts(bio_out, "SCRYPT\n");
989 #ifdef OPENSSL_NO_SCTP
990 BIO_puts(bio_out, "SCTP\n");
992 #ifdef OPENSSL_NO_SEED
993 BIO_puts(bio_out, "SEED\n");
995 #ifdef OPENSSL_NO_SM2
996 BIO_puts(bio_out, "SM2\n");
998 #ifdef OPENSSL_NO_SM3
999 BIO_puts(bio_out, "SM3\n");
1001 #ifdef OPENSSL_NO_SM4
1002 BIO_puts(bio_out, "SM4\n");
1004 #ifdef OPENSSL_NO_SOCK
1005 BIO_puts(bio_out, "SOCK\n");
1007 #ifdef OPENSSL_NO_SRP
1008 BIO_puts(bio_out, "SRP\n");
1010 #ifdef OPENSSL_NO_SRTP
1011 BIO_puts(bio_out, "SRTP\n");
1013 #ifdef OPENSSL_NO_SSL3
1014 BIO_puts(bio_out, "SSL3\n");
1016 #ifdef OPENSSL_NO_TLS1
1017 BIO_puts(bio_out, "TLS1\n");
1019 #ifdef OPENSSL_NO_TLS1_1
1020 BIO_puts(bio_out, "TLS1_1\n");
1022 #ifdef OPENSSL_NO_TLS1_2
1023 BIO_puts(bio_out, "TLS1_2\n");
1025 #ifdef OPENSSL_NO_WHIRLPOOL
1026 BIO_puts(bio_out, "WHIRLPOOL\n");
1029 BIO_puts(bio_out, "ZLIB\n");
1033 static LHASH_OF(FUNCTION) *prog_init(void)
1035 static LHASH_OF(FUNCTION) *ret = NULL;
1036 static int prog_inited = 0;
1045 /* Sort alphabetically within category. For nicer help displays. */
1046 for (i = 0, f = functions; f->name != NULL; ++f, ++i)
1048 qsort(functions, i, sizeof(*functions), SortFnByName);
1050 if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)
1053 for (f = functions; f->name != NULL; f++)
1054 (void)lh_FUNCTION_insert(ret, f);