2 * Copyright 1995-2019 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;
133 char buffer[256], *hex;
134 CRYPTO_THREAD_ID tid;
137 case OSSL_TRACE_CTRL_BEGIN:
138 if (!ossl_assert(!trace_data->ingroup))
140 trace_data->ingroup = 1;
142 tid = CRYPTO_THREAD_get_current_id();
143 hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
144 BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ",
145 hex, OSSL_trace_get_category_name(category));
147 BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
148 strlen(buffer), buffer);
150 case OSSL_TRACE_CTRL_WRITE:
151 if (!ossl_assert(trace_data->ingroup))
154 ret = BIO_write(trace_data->bio, buf, cnt);
156 case OSSL_TRACE_CTRL_END:
157 if (!ossl_assert(trace_data->ingroup))
159 trace_data->ingroup = 0;
161 BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL);
166 return ret < 0 ? 0 : ret;
169 DEFINE_STACK_OF(tracedata)
170 static STACK_OF(tracedata) *trace_data_stack;
172 static void tracedata_free(tracedata *data)
174 BIO_free_all(data->bio);
178 static STACK_OF(tracedata) *trace_data_stack;
180 static void cleanup_trace(void)
182 sk_tracedata_pop_free(trace_data_stack, tracedata_free);
185 static void setup_trace_category(int category)
188 tracedata *trace_data;
190 if (OSSL_trace_enabled(category))
193 channel = BIO_push(BIO_new(apps_bf_prefix()),
194 dup_bio_err(FORMAT_TEXT));
195 trace_data = OPENSSL_zalloc(sizeof(*trace_data));
197 if (trace_data == NULL
198 || (trace_data->bio = channel) == NULL
199 || OSSL_trace_set_callback(category, internal_trace_cb,
201 || sk_tracedata_push(trace_data_stack, trace_data) == 0) {
204 "warning: unable to setup trace callback for category '%s'.\n",
205 OSSL_trace_get_category_name(category));
207 OSSL_trace_set_callback(category, NULL, NULL);
208 BIO_free_all(channel);
212 static void setup_trace(const char *str)
217 * We add this handler as early as possible to ensure it's executed
218 * as late as possible, i.e. after the TRACE code has done its cleanup
219 * (which happens last in OPENSSL_cleanup).
221 atexit(cleanup_trace);
223 trace_data_stack = sk_tracedata_new_null();
224 val = OPENSSL_strdup(str);
230 for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) {
231 int category = OSSL_trace_get_category_num(item);
233 if (category == OSSL_TRACE_CATEGORY_ALL) {
234 while (++category < OSSL_TRACE_CATEGORY_NUM)
235 setup_trace_category(category);
237 } else if (category > 0) {
238 setup_trace_category(category);
241 "warning: unknown trace category: '%s'.\n", item);
248 #endif /* OPENSSL_NO_TRACE */
250 int main(int argc, char *argv[])
253 LHASH_OF(FUNCTION) *prog = NULL;
258 int first, n, i, ret = 0;
263 /* Set up some of the environment. */
264 default_config_file = make_config_name();
265 bio_in = dup_bio_in(FORMAT_TEXT);
266 bio_out = dup_bio_out(FORMAT_TEXT);
267 bio_err = dup_bio_err(FORMAT_TEXT);
269 #if defined(OPENSSL_SYS_VMS) && defined(__DECC)
270 argv = copy_argv(&argc, argv);
271 #elif defined(_WIN32)
273 * Replace argv[] with UTF-8 encoded strings.
275 win32_utf8argv(&argc, &argv);
279 * We use the prefix method to get the trace output we want. Since some
280 * trace outputs happen with OPENSSL_cleanup(), which is run automatically
281 * after exit(), we need to destroy the prefix method as late as possible.
283 atexit(destroy_prefix_method);
285 #ifndef OPENSSL_NO_TRACE
286 setup_trace(getenv("OPENSSL_TRACE"));
289 p = getenv("OPENSSL_DEBUG_MEMORY");
290 if (p != NULL && strcmp(p, "on") == 0)
291 CRYPTO_set_mem_debug(1);
292 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
294 if (getenv("OPENSSL_FIPS")) {
295 BIO_printf(bio_err, "FIPS mode not supported.\n");
299 if (!apps_startup()) {
301 "FATAL: Startup failure (dev note: apps_startup() failed)\n");
302 ERR_print_errors(bio_err);
308 pname = opt_progname(argv[0]);
310 /* first check the program name */
312 fp = lh_FUNCTION_retrieve(prog, &f);
315 ret = fp->func(argc, argv);
319 /* If there is stuff on the command line, run with that. */
323 ret = do_cmd(prog, argc, argv);
329 /* ok, lets enter interactive mode */
332 /* Read a line, continue reading if line ends with \ */
333 for (p = buf, n = sizeof(buf), i = 0, first = 1; n > 0; first = 0) {
334 prompt = first ? "OpenSSL> " : "> ";
337 fputs(prompt, stdout);
339 if (!fgets(p, n, stdin))
346 if (p[i - 2] != '\\')
353 extern char *readline(const char *);
354 extern void add_history(const char *cp);
357 text = readline(prompt);
363 if (text[i - 1] != '\\') {
364 p += strlen(strcpy(p, text));
371 p += strlen(strcpy(p, text));
378 if (!chopup_args(&arg, buf)) {
379 BIO_printf(bio_err, "Can't parse (no memory?)\n");
383 ret = do_cmd(prog, arg.argc, arg.argv);
384 if (ret == EXIT_THE_PROGRAM) {
389 BIO_printf(bio_err, "error in %s\n", arg.argv[0]);
390 (void)BIO_flush(bio_out);
391 (void)BIO_flush(bio_err);
395 OPENSSL_free(default_config_file);
396 lh_FUNCTION_free(prog);
397 OPENSSL_free(arg.argv);
401 BIO_free_all(bio_out);
403 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
404 if (CRYPTO_mem_leaks(bio_err) <= 0)
411 static void list_cipher_fn(const EVP_CIPHER *c,
412 const char *from, const char *to, void *arg)
415 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
418 from = "<undefined>";
421 BIO_printf(arg, "%s => %s\n", from, to);
425 static void list_md_fn(const EVP_MD *m,
426 const char *from, const char *to, void *arg)
429 BIO_printf(arg, "%s\n", EVP_MD_name(m));
432 from = "<undefined>";
435 BIO_printf((BIO *)arg, "%s => %s\n", from, to);
439 static void list_mac_fn(const EVP_MAC *m,
440 const char *from, const char *to, void *arg)
443 BIO_printf(arg, "%s\n", EVP_MAC_name(m));
446 from = "<undefined>";
449 BIO_printf(arg, "%s => %s\n", from, to);
453 static void list_missing_help(void)
458 for (fp = functions; fp->name != NULL; fp++) {
459 if ((o = fp->help) != NULL) {
460 /* If there is help, list what flags are not documented. */
461 for ( ; o->name != NULL; o++) {
462 if (o->helpstr == NULL)
463 BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
465 } else if (fp->func != dgst_main) {
466 /* If not aliased to the dgst command, */
467 BIO_printf(bio_out, "%s *\n", fp->name);
472 static void list_objects(void)
474 int max_nid = OBJ_new_nid(0);
476 char *oid_buf = NULL;
479 /* Skip 0, since that's NID_undef */
480 for (i = 1; i < max_nid; i++) {
481 const ASN1_OBJECT *obj = OBJ_nid2obj(i);
482 const char *sn = OBJ_nid2sn(i);
483 const char *ln = OBJ_nid2ln(i);
487 * If one of the retrieved objects somehow generated an error,
488 * we ignore it. The check for NID_undef below will detect the
489 * error and simply skip to the next NID.
493 if (OBJ_obj2nid(obj) == NID_undef)
496 if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
497 BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
504 oid_buf = OPENSSL_realloc(oid_buf, n + 1);
505 if (oid_buf == NULL) {
506 BIO_printf(bio_err, "ERROR: Memory allocation\n");
511 if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
513 if (ln == NULL || strcmp(sn, ln) == 0)
514 BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
516 BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
519 OPENSSL_free(oid_buf);
522 static void list_options_for_command(const char *command)
527 for (fp = functions; fp->name != NULL; fp++)
528 if (strcmp(fp->name, command) == 0)
530 if (fp->name == NULL) {
531 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
536 if ((o = fp->help) == NULL)
539 for ( ; o->name != NULL; o++) {
540 if (o->name == OPT_HELP_STR
541 || o->name == OPT_MORE_STR
542 || o->name[0] == '\0')
544 BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);
549 /* Unified enum for help and list commands. */
550 typedef enum HELPLIST_CHOICE {
551 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,
552 OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
553 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
554 OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
555 OPT_MISSING_HELP, OPT_OBJECTS
558 const OPTIONS list_options[] = {
559 {"help", OPT_HELP, '-', "Display this summary"},
560 {"1", OPT_ONE, '-', "List in one column"},
561 {"commands", OPT_COMMANDS, '-', "List of standard commands"},
562 {"digest-commands", OPT_DIGEST_COMMANDS, '-',
563 "List of message digest commands"},
564 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
565 "List of message digest algorithms"},
566 {"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
567 "List of message authentication code algorithms"},
568 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
569 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
570 "List of cipher algorithms"},
571 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
572 "List of public key algorithms"},
573 {"public-key-methods", OPT_PK_METHOD, '-',
574 "List of public key methods"},
575 {"engines", OPT_ENGINES, '-',
576 "List of loaded engines"},
577 {"disabled", OPT_DISABLED, '-',
578 "List of disabled features"},
579 {"missing-help", OPT_MISSING_HELP, '-',
580 "List missing detailed help strings"},
581 {"options", OPT_OPTIONS, 's',
582 "List options for specified command"},
583 {"objects", OPT_OBJECTS, '-',
584 "List built in objects (OID<->name mappings)"},
588 int list_main(int argc, char **argv)
592 int one = 0, done = 0;
594 prog = opt_init(argc, argv, list_options);
595 while ((o = opt_next()) != OPT_EOF) {
597 case OPT_EOF: /* Never hit, but suppresses warning */
600 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
603 opt_help(list_options);
609 list_type(FT_general, one);
611 case OPT_DIGEST_COMMANDS:
612 list_type(FT_md, one);
614 case OPT_DIGEST_ALGORITHMS:
615 EVP_MD_do_all_sorted(list_md_fn, bio_out);
617 case OPT_MAC_ALGORITHMS:
618 EVP_MAC_do_all_sorted(list_mac_fn, bio_out);
620 case OPT_CIPHER_COMMANDS:
621 list_type(FT_cipher, one);
623 case OPT_CIPHER_ALGORITHMS:
624 EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
626 case OPT_PK_ALGORITHMS:
638 case OPT_MISSING_HELP:
645 list_options_for_command(opt_arg());
650 if (opt_num_rest() != 0) {
651 BIO_printf(bio_err, "Extra arguments given.\n");
661 typedef enum HELP_CHOICE {
662 OPT_hERR = -1, OPT_hEOF = 0, OPT_hHELP
665 const OPTIONS help_options[] = {
666 {OPT_HELP_STR, 1, '-', "Usage: help [options]\n"},
667 {OPT_HELP_STR, 1, '-', " help [command]\n"},
668 {"help", OPT_hHELP, '-', "Display this summary"},
673 int help_main(int argc, char **argv)
682 prog = opt_init(argc, argv, help_options);
683 while ((o = opt_next()) != OPT_hEOF) {
687 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
690 opt_help(help_options);
695 if (opt_num_rest() == 1) {
698 new_argv[0] = opt_rest()[0];
699 new_argv[1] = "--help";
701 return do_cmd(prog_init(), 2, new_argv);
703 if (opt_num_rest() != 0) {
704 BIO_printf(bio_err, "Usage: %s\n", prog);
708 calculate_columns(&dc);
709 BIO_printf(bio_err, "Standard commands");
712 for (fp = functions; fp->name != NULL; fp++) {
714 if (i++ % dc.columns == 0) {
715 BIO_printf(bio_err, "\n");
718 if (fp->type != tp) {
721 BIO_printf(bio_err, "\n");
725 "\nMessage Digest commands (see the `dgst' command for more details)\n");
726 } else if (tp == FT_cipher) {
729 "\nCipher commands (see the `enc' command for more details)\n");
732 BIO_printf(bio_err, "%-*s", dc.width, fp->name);
734 BIO_printf(bio_err, "\n\n");
738 static void list_type(FUNC_TYPE ft, int one)
744 memset(&dc, 0, sizeof(dc));
746 calculate_columns(&dc);
748 for (fp = functions; fp->name != NULL; fp++) {
752 BIO_printf(bio_out, "%s\n", fp->name);
754 if (i % dc.columns == 0 && i > 0)
755 BIO_printf(bio_out, "\n");
756 BIO_printf(bio_out, "%-*s", dc.width, fp->name);
761 BIO_printf(bio_out, "\n\n");
764 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
768 if (argc <= 0 || argv[0] == NULL)
771 fp = lh_FUNCTION_retrieve(prog, &f);
773 if (EVP_get_digestbyname(argv[0])) {
777 } else if (EVP_get_cipherbyname(argv[0])) {
784 return fp->func(argc, argv);
786 if ((strncmp(argv[0], "no-", 3)) == 0) {
788 * User is asking if foo is unsupported, by trying to "run" the
789 * no-foo command. Strange.
791 f.name = argv[0] + 3;
792 if (lh_FUNCTION_retrieve(prog, &f) == NULL) {
793 BIO_printf(bio_out, "%s\n", argv[0]);
796 BIO_printf(bio_out, "%s\n", argv[0] + 3);
799 if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||
800 strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)
801 /* Special value to mean "exit the program. */
802 return EXIT_THE_PROGRAM;
804 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
809 static void list_pkey(void)
813 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
814 const EVP_PKEY_ASN1_METHOD *ameth;
815 int pkey_id, pkey_base_id, pkey_flags;
816 const char *pinfo, *pem_str;
817 ameth = EVP_PKEY_asn1_get0(i);
818 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
819 &pinfo, &pem_str, ameth);
820 if (pkey_flags & ASN1_PKEY_ALIAS) {
821 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
822 BIO_printf(bio_out, "\tAlias for: %s\n",
823 OBJ_nid2ln(pkey_base_id));
825 BIO_printf(bio_out, "Name: %s\n", pinfo);
826 BIO_printf(bio_out, "\tType: %s Algorithm\n",
827 pkey_flags & ASN1_PKEY_DYNAMIC ?
828 "External" : "Builtin");
829 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
832 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
838 static void list_pkey_meth(void)
841 size_t meth_count = EVP_PKEY_meth_get_count();
843 for (i = 0; i < meth_count; i++) {
844 const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
845 int pkey_id, pkey_flags;
847 EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
848 BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
849 BIO_printf(bio_out, "\tType: %s Algorithm\n",
850 pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
854 static int function_cmp(const FUNCTION * a, const FUNCTION * b)
856 return strncmp(a->name, b->name, 8);
859 static unsigned long function_hash(const FUNCTION * a)
861 return OPENSSL_LH_strhash(a->name);
864 static int SortFnByName(const void *_f1, const void *_f2)
866 const FUNCTION *f1 = _f1;
867 const FUNCTION *f2 = _f2;
869 if (f1->type != f2->type)
870 return f1->type - f2->type;
871 return strcmp(f1->name, f2->name);
874 static void list_engines(void)
876 #ifndef OPENSSL_NO_ENGINE
879 BIO_puts(bio_out, "Engines:\n");
880 e = ENGINE_get_first();
882 BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
883 e = ENGINE_get_next(e);
886 BIO_puts(bio_out, "Engine support is disabled.\n");
890 static void list_disabled(void)
892 BIO_puts(bio_out, "Disabled algorithms:\n");
893 #ifdef OPENSSL_NO_ARIA
894 BIO_puts(bio_out, "ARIA\n");
897 BIO_puts(bio_out, "BF\n");
899 #ifdef OPENSSL_NO_BLAKE2
900 BIO_puts(bio_out, "BLAKE2\n");
902 #ifdef OPENSSL_NO_CAMELLIA
903 BIO_puts(bio_out, "CAMELLIA\n");
905 #ifdef OPENSSL_NO_CAST
906 BIO_puts(bio_out, "CAST\n");
908 #ifdef OPENSSL_NO_CMAC
909 BIO_puts(bio_out, "CMAC\n");
911 #ifdef OPENSSL_NO_CMS
912 BIO_puts(bio_out, "CMS\n");
914 #ifdef OPENSSL_NO_COMP
915 BIO_puts(bio_out, "COMP\n");
917 #ifdef OPENSSL_NO_DES
918 BIO_puts(bio_out, "DES\n");
920 #ifdef OPENSSL_NO_DGRAM
921 BIO_puts(bio_out, "DGRAM\n");
924 BIO_puts(bio_out, "DH\n");
926 #ifdef OPENSSL_NO_DSA
927 BIO_puts(bio_out, "DSA\n");
929 #if defined(OPENSSL_NO_DTLS)
930 BIO_puts(bio_out, "DTLS\n");
932 #if defined(OPENSSL_NO_DTLS1)
933 BIO_puts(bio_out, "DTLS1\n");
935 #if defined(OPENSSL_NO_DTLS1_2)
936 BIO_puts(bio_out, "DTLS1_2\n");
939 BIO_puts(bio_out, "EC\n");
941 #ifdef OPENSSL_NO_EC2M
942 BIO_puts(bio_out, "EC2M\n");
944 #ifdef OPENSSL_NO_ENGINE
945 BIO_puts(bio_out, "ENGINE\n");
947 #ifdef OPENSSL_NO_GOST
948 BIO_puts(bio_out, "GOST\n");
950 #ifdef OPENSSL_NO_IDEA
951 BIO_puts(bio_out, "IDEA\n");
953 #ifdef OPENSSL_NO_MD2
954 BIO_puts(bio_out, "MD2\n");
956 #ifdef OPENSSL_NO_MD4
957 BIO_puts(bio_out, "MD4\n");
959 #ifdef OPENSSL_NO_MD5
960 BIO_puts(bio_out, "MD5\n");
962 #ifdef OPENSSL_NO_MDC2
963 BIO_puts(bio_out, "MDC2\n");
965 #ifdef OPENSSL_NO_OCB
966 BIO_puts(bio_out, "OCB\n");
968 #ifdef OPENSSL_NO_OCSP
969 BIO_puts(bio_out, "OCSP\n");
971 #ifdef OPENSSL_NO_PSK
972 BIO_puts(bio_out, "PSK\n");
974 #ifdef OPENSSL_NO_RC2
975 BIO_puts(bio_out, "RC2\n");
977 #ifdef OPENSSL_NO_RC4
978 BIO_puts(bio_out, "RC4\n");
980 #ifdef OPENSSL_NO_RC5
981 BIO_puts(bio_out, "RC5\n");
983 #ifdef OPENSSL_NO_RMD160
984 BIO_puts(bio_out, "RMD160\n");
986 #ifdef OPENSSL_NO_RSA
987 BIO_puts(bio_out, "RSA\n");
989 #ifdef OPENSSL_NO_SCRYPT
990 BIO_puts(bio_out, "SCRYPT\n");
992 #ifdef OPENSSL_NO_SCTP
993 BIO_puts(bio_out, "SCTP\n");
995 #ifdef OPENSSL_NO_SEED
996 BIO_puts(bio_out, "SEED\n");
998 #ifdef OPENSSL_NO_SM2
999 BIO_puts(bio_out, "SM2\n");
1001 #ifdef OPENSSL_NO_SM3
1002 BIO_puts(bio_out, "SM3\n");
1004 #ifdef OPENSSL_NO_SM4
1005 BIO_puts(bio_out, "SM4\n");
1007 #ifdef OPENSSL_NO_SOCK
1008 BIO_puts(bio_out, "SOCK\n");
1010 #ifdef OPENSSL_NO_SRP
1011 BIO_puts(bio_out, "SRP\n");
1013 #ifdef OPENSSL_NO_SRTP
1014 BIO_puts(bio_out, "SRTP\n");
1016 #ifdef OPENSSL_NO_SSL3
1017 BIO_puts(bio_out, "SSL3\n");
1019 #ifdef OPENSSL_NO_TLS1
1020 BIO_puts(bio_out, "TLS1\n");
1022 #ifdef OPENSSL_NO_TLS1_1
1023 BIO_puts(bio_out, "TLS1_1\n");
1025 #ifdef OPENSSL_NO_TLS1_2
1026 BIO_puts(bio_out, "TLS1_2\n");
1028 #ifdef OPENSSL_NO_WHIRLPOOL
1029 BIO_puts(bio_out, "WHIRLPOOL\n");
1032 BIO_puts(bio_out, "ZLIB\n");
1036 static LHASH_OF(FUNCTION) *prog_init(void)
1038 static LHASH_OF(FUNCTION) *ret = NULL;
1039 static int prog_inited = 0;
1048 /* Sort alphabetically within category. For nicer help displays. */
1049 for (i = 0, f = functions; f->name != NULL; ++f, ++i)
1051 qsort(functions, i, sizeof(*functions), SortFnByName);
1053 if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)
1056 for (f = functions; f->name != NULL; f++)
1057 (void)lh_FUNCTION_insert(ret, f);