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
34 /* Structure to hold the number of columns to be displayed and the
35 * field width used to display them.
42 /* Special sentinel to exit the program. */
43 #define EXIT_THE_PROGRAM (-1)
46 * The LHASH callbacks ("hash" & "cmp") have been replaced by functions with
47 * the base prototypes (we cast each variable inside the function to the
48 * required type of "FUNCTION*"). This removes the necessity for
49 * macro-generated wrapper functions.
51 static LHASH_OF(FUNCTION
) *prog_init(void);
52 static int do_cmd(LHASH_OF(FUNCTION
) *prog
, int argc
, char *argv
[]);
53 static void list_pkey(void);
54 static void list_pkey_meth(void);
55 static void list_type(FUNC_TYPE ft
, int one
);
56 static void list_engines(void);
57 static void list_disabled(void);
58 char *default_config_file
= NULL
;
64 static void calculate_columns(DISPLAY_COLUMNS
*dc
)
69 for (f
= functions
; f
->name
!= NULL
; ++f
)
70 if (f
->type
== FT_general
|| f
->type
== FT_md
|| f
->type
== FT_cipher
)
71 if ((len
= strlen(f
->name
)) > maxlen
)
74 dc
->width
= maxlen
+ 2;
75 dc
->columns
= (80 - 1) / dc
->width
;
78 static int apps_startup(void)
81 signal(SIGPIPE
, SIG_IGN
);
84 /* Set non-default library initialisation settings */
85 if (!OPENSSL_init_ssl(OPENSSL_INIT_ENGINE_ALL_BUILTIN
86 | OPENSSL_INIT_LOAD_CONFIG
, NULL
))
94 static void apps_shutdown(void)
99 static char *make_config_name(void)
105 if ((t
= getenv("OPENSSL_CONF")) != NULL
)
106 return OPENSSL_strdup(t
);
108 t
= X509_get_default_cert_area();
109 len
= strlen(t
) + 1 + strlen(OPENSSL_CONF
) + 1;
110 p
= app_malloc(len
, "config filename buffer");
112 #ifndef OPENSSL_SYS_VMS
115 strcat(p
, OPENSSL_CONF
);
121 #ifndef OPENSSL_NO_TRACE
122 typedef struct tracedata_st
{
124 unsigned int ingroup
:1;
127 static size_t internal_trace_cb(const char *buf
, size_t cnt
,
128 int category
, int cmd
, void *vdata
)
131 tracedata
*trace_data
= vdata
;
132 char buffer
[256], *hex
;
133 CRYPTO_THREAD_ID tid
;
136 case OSSL_TRACE_CTRL_BEGIN
:
137 if (!ossl_assert(!trace_data
->ingroup
))
139 trace_data
->ingroup
= 1;
141 tid
= CRYPTO_THREAD_get_current_id();
142 hex
= OPENSSL_buf2hexstr((const unsigned char *)&tid
, sizeof(tid
));
143 BIO_snprintf(buffer
, sizeof(buffer
), "TRACE[%s]:%s: ",
144 hex
, OSSL_trace_get_category_name(category
));
146 BIO_ctrl(trace_data
->bio
, PREFIX_CTRL_SET_PREFIX
,
147 strlen(buffer
), buffer
);
149 case OSSL_TRACE_CTRL_WRITE
:
150 if (!ossl_assert(trace_data
->ingroup
))
153 ret
= BIO_write(trace_data
->bio
, buf
, cnt
);
155 case OSSL_TRACE_CTRL_END
:
156 if (!ossl_assert(trace_data
->ingroup
))
158 trace_data
->ingroup
= 0;
160 BIO_ctrl(trace_data
->bio
, PREFIX_CTRL_SET_PREFIX
, 0, NULL
);
165 return ret
< 0 ? 0 : ret
;
168 DEFINE_STACK_OF(tracedata
)
169 static STACK_OF(tracedata
) *trace_data_stack
;
171 static void tracedata_free(tracedata
*data
)
173 BIO_free_all(data
->bio
);
177 static STACK_OF(tracedata
) *trace_data_stack
;
179 static void cleanup_trace(void)
181 sk_tracedata_pop_free(trace_data_stack
, tracedata_free
);
184 static void setup_trace_category(int category
)
187 tracedata
*trace_data
;
189 if (OSSL_trace_enabled(category
))
192 channel
= BIO_push(BIO_new(apps_bf_prefix()),
193 dup_bio_err(FORMAT_TEXT
));
194 trace_data
= OPENSSL_zalloc(sizeof(*trace_data
));
196 if (trace_data
== NULL
197 || (trace_data
->bio
= channel
) == NULL
198 || OSSL_trace_set_callback(category
, internal_trace_cb
,
200 || sk_tracedata_push(trace_data_stack
, trace_data
) == 0) {
203 "warning: unable to setup trace callback for category '%s'.\n",
204 OSSL_trace_get_category_name(category
));
206 OSSL_trace_set_callback(category
, NULL
, NULL
);
207 BIO_free_all(channel
);
211 static void setup_trace(const char *str
)
216 * We add this handler as early as possible to ensure it's executed
217 * as late as possible, i.e. after the TRACE code has done its cleanup
218 * (which happens last in OPENSSL_cleanup).
220 atexit(cleanup_trace
);
222 trace_data_stack
= sk_tracedata_new_null();
223 val
= OPENSSL_strdup(str
);
229 for (valp
= val
; (item
= strtok(valp
, ",")) != NULL
; valp
= NULL
) {
230 int category
= OSSL_trace_get_category_num(item
);
232 if (category
== OSSL_TRACE_CATEGORY_ALL
) {
233 while (++category
< OSSL_TRACE_CATEGORY_NUM
)
234 setup_trace_category(category
);
236 } else if (category
> 0) {
237 setup_trace_category(category
);
240 "warning: unknown trace category: '%s'.\n", item
);
247 #endif /* OPENSSL_NO_TRACE */
249 int main(int argc
, char *argv
[])
252 LHASH_OF(FUNCTION
) *prog
= NULL
;
257 int first
, n
, i
, ret
= 0;
262 /* Set up some of the environment. */
263 default_config_file
= make_config_name();
264 bio_in
= dup_bio_in(FORMAT_TEXT
);
265 bio_out
= dup_bio_out(FORMAT_TEXT
);
266 bio_err
= dup_bio_err(FORMAT_TEXT
);
268 #if defined(OPENSSL_SYS_VMS) && defined(__DECC)
269 argv
= copy_argv(&argc
, argv
);
270 #elif defined(_WIN32)
272 * Replace argv[] with UTF-8 encoded strings.
274 win32_utf8argv(&argc
, &argv
);
278 * We use the prefix method to get the trace output we want. Since some
279 * trace outputs happen with OPENSSL_cleanup(), which is run automatically
280 * after exit(), we need to destroy the prefix method as late as possible.
282 atexit(destroy_prefix_method
);
284 #ifndef OPENSSL_NO_TRACE
285 setup_trace(getenv("OPENSSL_TRACE"));
288 p
= getenv("OPENSSL_DEBUG_MEMORY");
289 if (p
!= NULL
&& strcmp(p
, "on") == 0)
290 CRYPTO_set_mem_debug(1);
291 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON
);
293 if (getenv("OPENSSL_FIPS")) {
294 BIO_printf(bio_err
, "FIPS mode not supported.\n");
298 if (!apps_startup()) {
300 "FATAL: Startup failure (dev note: apps_startup() failed)\n");
301 ERR_print_errors(bio_err
);
307 pname
= opt_progname(argv
[0]);
309 /* first check the program name */
311 fp
= lh_FUNCTION_retrieve(prog
, &f
);
314 ret
= fp
->func(argc
, argv
);
318 /* If there is stuff on the command line, run with that. */
322 ret
= do_cmd(prog
, argc
, argv
);
328 /* ok, lets enter interactive mode */
331 /* Read a line, continue reading if line ends with \ */
332 for (p
= buf
, n
= sizeof(buf
), i
= 0, first
= 1; n
> 0; first
= 0) {
333 prompt
= first
? "OpenSSL> " : "> ";
336 fputs(prompt
, stdout
);
338 if (!fgets(p
, n
, stdin
))
345 if (p
[i
- 2] != '\\')
352 extern char *readline(const char *);
353 extern void add_history(const char *cp
);
356 text
= readline(prompt
);
362 if (text
[i
- 1] != '\\') {
363 p
+= strlen(strcpy(p
, text
));
370 p
+= strlen(strcpy(p
, text
));
377 if (!chopup_args(&arg
, buf
)) {
378 BIO_printf(bio_err
, "Can't parse (no memory?)\n");
382 ret
= do_cmd(prog
, arg
.argc
, arg
.argv
);
383 if (ret
== EXIT_THE_PROGRAM
) {
388 BIO_printf(bio_err
, "error in %s\n", arg
.argv
[0]);
389 (void)BIO_flush(bio_out
);
390 (void)BIO_flush(bio_err
);
394 OPENSSL_free(default_config_file
);
395 lh_FUNCTION_free(prog
);
396 OPENSSL_free(arg
.argv
);
400 BIO_free_all(bio_out
);
402 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
403 if (CRYPTO_mem_leaks(bio_err
) <= 0)
410 static void list_cipher_fn(const EVP_CIPHER
*c
,
411 const char *from
, const char *to
, void *arg
)
414 BIO_printf(arg
, "%s\n", EVP_CIPHER_name(c
));
417 from
= "<undefined>";
420 BIO_printf(arg
, "%s => %s\n", from
, to
);
424 static void list_md_fn(const EVP_MD
*m
,
425 const char *from
, const char *to
, void *arg
)
428 BIO_printf(arg
, "%s\n", EVP_MD_name(m
));
431 from
= "<undefined>";
434 BIO_printf((BIO
*)arg
, "%s => %s\n", from
, to
);
438 static void list_mac_fn(const EVP_MAC
*m
,
439 const char *from
, const char *to
, void *arg
)
442 BIO_printf(arg
, "%s\n", EVP_MAC_name(m
));
445 from
= "<undefined>";
448 BIO_printf(arg
, "%s => %s\n", from
, to
);
452 static void list_missing_help(void)
457 for (fp
= functions
; fp
->name
!= NULL
; fp
++) {
458 if ((o
= fp
->help
) != NULL
) {
459 /* If there is help, list what flags are not documented. */
460 for ( ; o
->name
!= NULL
; o
++) {
461 if (o
->helpstr
== NULL
)
462 BIO_printf(bio_out
, "%s %s\n", fp
->name
, o
->name
);
464 } else if (fp
->func
!= dgst_main
) {
465 /* If not aliased to the dgst command, */
466 BIO_printf(bio_out
, "%s *\n", fp
->name
);
471 static void list_objects(void)
473 int max_nid
= OBJ_new_nid(0);
475 char *oid_buf
= NULL
;
478 /* Skip 0, since that's NID_undef */
479 for (i
= 1; i
< max_nid
; i
++) {
480 const ASN1_OBJECT
*obj
= OBJ_nid2obj(i
);
481 const char *sn
= OBJ_nid2sn(i
);
482 const char *ln
= OBJ_nid2ln(i
);
486 * If one of the retrieved objects somehow generated an error,
487 * we ignore it. The check for NID_undef below will detect the
488 * error and simply skip to the next NID.
492 if (OBJ_obj2nid(obj
) == NID_undef
)
495 if ((n
= OBJ_obj2txt(NULL
, 0, obj
, 1)) == 0) {
496 BIO_printf(bio_out
, "# None-OID object: %s, %s\n", sn
, ln
);
503 oid_buf
= OPENSSL_realloc(oid_buf
, n
+ 1);
504 if (oid_buf
== NULL
) {
505 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
510 if (OBJ_obj2txt(oid_buf
, oid_size
, obj
, 1) < 0)
512 if (ln
== NULL
|| strcmp(sn
, ln
) == 0)
513 BIO_printf(bio_out
, "%s = %s\n", sn
, oid_buf
);
515 BIO_printf(bio_out
, "%s = %s, %s\n", sn
, ln
, oid_buf
);
518 OPENSSL_free(oid_buf
);
521 static void list_options_for_command(const char *command
)
526 for (fp
= functions
; fp
->name
!= NULL
; fp
++)
527 if (strcmp(fp
->name
, command
) == 0)
529 if (fp
->name
== NULL
) {
530 BIO_printf(bio_err
, "Invalid command '%s'; type \"help\" for a list.\n",
535 if ((o
= fp
->help
) == NULL
)
538 for ( ; o
->name
!= NULL
; o
++) {
539 if (o
->name
== OPT_HELP_STR
540 || o
->name
== OPT_MORE_STR
541 || o
->name
[0] == '\0')
543 BIO_printf(bio_out
, "%s %c\n", o
->name
, o
->valtype
);
548 /* Unified enum for help and list commands. */
549 typedef enum HELPLIST_CHOICE
{
550 OPT_ERR
= -1, OPT_EOF
= 0, OPT_HELP
, OPT_ONE
,
551 OPT_COMMANDS
, OPT_DIGEST_COMMANDS
, OPT_MAC_ALGORITHMS
, OPT_OPTIONS
,
552 OPT_DIGEST_ALGORITHMS
, OPT_CIPHER_COMMANDS
, OPT_CIPHER_ALGORITHMS
,
553 OPT_PK_ALGORITHMS
, OPT_PK_METHOD
, OPT_ENGINES
, OPT_DISABLED
,
554 OPT_MISSING_HELP
, OPT_OBJECTS
557 const OPTIONS list_options
[] = {
558 {"help", OPT_HELP
, '-', "Display this summary"},
559 {"1", OPT_ONE
, '-', "List in one column"},
560 {"commands", OPT_COMMANDS
, '-', "List of standard commands"},
561 {"digest-commands", OPT_DIGEST_COMMANDS
, '-',
562 "List of message digest commands"},
563 {"digest-algorithms", OPT_DIGEST_ALGORITHMS
, '-',
564 "List of message digest algorithms"},
565 {"mac-algorithms", OPT_MAC_ALGORITHMS
, '-',
566 "List of message authentication code algorithms"},
567 {"cipher-commands", OPT_CIPHER_COMMANDS
, '-', "List of cipher commands"},
568 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS
, '-',
569 "List of cipher algorithms"},
570 {"public-key-algorithms", OPT_PK_ALGORITHMS
, '-',
571 "List of public key algorithms"},
572 {"public-key-methods", OPT_PK_METHOD
, '-',
573 "List of public key methods"},
574 {"engines", OPT_ENGINES
, '-',
575 "List of loaded engines"},
576 {"disabled", OPT_DISABLED
, '-',
577 "List of disabled features"},
578 {"missing-help", OPT_MISSING_HELP
, '-',
579 "List missing detailed help strings"},
580 {"options", OPT_OPTIONS
, 's',
581 "List options for specified command"},
582 {"objects", OPT_OBJECTS
, '-',
583 "List built in objects (OID<->name mappings)"},
587 int list_main(int argc
, char **argv
)
591 int one
= 0, done
= 0;
593 prog
= opt_init(argc
, argv
, list_options
);
594 while ((o
= opt_next()) != OPT_EOF
) {
596 case OPT_EOF
: /* Never hit, but suppresses warning */
599 BIO_printf(bio_err
, "%s: Use -help for summary.\n", prog
);
602 opt_help(list_options
);
608 list_type(FT_general
, one
);
610 case OPT_DIGEST_COMMANDS
:
611 list_type(FT_md
, one
);
613 case OPT_DIGEST_ALGORITHMS
:
614 EVP_MD_do_all_sorted(list_md_fn
, bio_out
);
616 case OPT_MAC_ALGORITHMS
:
617 EVP_MAC_do_all_sorted(list_mac_fn
, bio_out
);
619 case OPT_CIPHER_COMMANDS
:
620 list_type(FT_cipher
, one
);
622 case OPT_CIPHER_ALGORITHMS
:
623 EVP_CIPHER_do_all_sorted(list_cipher_fn
, bio_out
);
625 case OPT_PK_ALGORITHMS
:
637 case OPT_MISSING_HELP
:
644 list_options_for_command(opt_arg());
649 if (opt_num_rest() != 0) {
650 BIO_printf(bio_err
, "Extra arguments given.\n");
660 typedef enum HELP_CHOICE
{
661 OPT_hERR
= -1, OPT_hEOF
= 0, OPT_hHELP
664 const OPTIONS help_options
[] = {
665 {OPT_HELP_STR
, 1, '-', "Usage: help [options]\n"},
666 {OPT_HELP_STR
, 1, '-', " help [command]\n"},
667 {"help", OPT_hHELP
, '-', "Display this summary"},
672 int help_main(int argc
, char **argv
)
681 prog
= opt_init(argc
, argv
, help_options
);
682 while ((o
= opt_next()) != OPT_hEOF
) {
686 BIO_printf(bio_err
, "%s: Use -help for summary.\n", prog
);
689 opt_help(help_options
);
694 if (opt_num_rest() == 1) {
697 new_argv
[0] = opt_rest()[0];
698 new_argv
[1] = "--help";
700 return do_cmd(prog_init(), 2, new_argv
);
702 if (opt_num_rest() != 0) {
703 BIO_printf(bio_err
, "Usage: %s\n", prog
);
707 calculate_columns(&dc
);
708 BIO_printf(bio_err
, "Standard commands");
711 for (fp
= functions
; fp
->name
!= NULL
; fp
++) {
713 if (i
++ % dc
.columns
== 0) {
714 BIO_printf(bio_err
, "\n");
717 if (fp
->type
!= tp
) {
720 BIO_printf(bio_err
, "\n");
724 "\nMessage Digest commands (see the `dgst' command for more details)\n");
725 } else if (tp
== FT_cipher
) {
728 "\nCipher commands (see the `enc' command for more details)\n");
731 BIO_printf(bio_err
, "%-*s", dc
.width
, fp
->name
);
733 BIO_printf(bio_err
, "\n\n");
737 static void list_type(FUNC_TYPE ft
, int one
)
743 memset(&dc
, 0, sizeof(dc
));
745 calculate_columns(&dc
);
747 for (fp
= functions
; fp
->name
!= NULL
; fp
++) {
751 BIO_printf(bio_out
, "%s\n", fp
->name
);
753 if (i
% dc
.columns
== 0 && i
> 0)
754 BIO_printf(bio_out
, "\n");
755 BIO_printf(bio_out
, "%-*s", dc
.width
, fp
->name
);
760 BIO_printf(bio_out
, "\n\n");
763 static int do_cmd(LHASH_OF(FUNCTION
) *prog
, int argc
, char *argv
[])
767 if (argc
<= 0 || argv
[0] == NULL
)
770 fp
= lh_FUNCTION_retrieve(prog
, &f
);
772 if (EVP_get_digestbyname(argv
[0])) {
776 } else if (EVP_get_cipherbyname(argv
[0])) {
783 return fp
->func(argc
, argv
);
785 if ((strncmp(argv
[0], "no-", 3)) == 0) {
787 * User is asking if foo is unsupported, by trying to "run" the
788 * no-foo command. Strange.
790 f
.name
= argv
[0] + 3;
791 if (lh_FUNCTION_retrieve(prog
, &f
) == NULL
) {
792 BIO_printf(bio_out
, "%s\n", argv
[0]);
795 BIO_printf(bio_out
, "%s\n", argv
[0] + 3);
798 if (strcmp(argv
[0], "quit") == 0 || strcmp(argv
[0], "q") == 0 ||
799 strcmp(argv
[0], "exit") == 0 || strcmp(argv
[0], "bye") == 0)
800 /* Special value to mean "exit the program. */
801 return EXIT_THE_PROGRAM
;
803 BIO_printf(bio_err
, "Invalid command '%s'; type \"help\" for a list.\n",
808 static void list_pkey(void)
812 for (i
= 0; i
< EVP_PKEY_asn1_get_count(); i
++) {
813 const EVP_PKEY_ASN1_METHOD
*ameth
;
814 int pkey_id
, pkey_base_id
, pkey_flags
;
815 const char *pinfo
, *pem_str
;
816 ameth
= EVP_PKEY_asn1_get0(i
);
817 EVP_PKEY_asn1_get0_info(&pkey_id
, &pkey_base_id
, &pkey_flags
,
818 &pinfo
, &pem_str
, ameth
);
819 if (pkey_flags
& ASN1_PKEY_ALIAS
) {
820 BIO_printf(bio_out
, "Name: %s\n", OBJ_nid2ln(pkey_id
));
821 BIO_printf(bio_out
, "\tAlias for: %s\n",
822 OBJ_nid2ln(pkey_base_id
));
824 BIO_printf(bio_out
, "Name: %s\n", pinfo
);
825 BIO_printf(bio_out
, "\tType: %s Algorithm\n",
826 pkey_flags
& ASN1_PKEY_DYNAMIC
?
827 "External" : "Builtin");
828 BIO_printf(bio_out
, "\tOID: %s\n", OBJ_nid2ln(pkey_id
));
831 BIO_printf(bio_out
, "\tPEM string: %s\n", pem_str
);
837 static void list_pkey_meth(void)
840 size_t meth_count
= EVP_PKEY_meth_get_count();
842 for (i
= 0; i
< meth_count
; i
++) {
843 const EVP_PKEY_METHOD
*pmeth
= EVP_PKEY_meth_get0(i
);
844 int pkey_id
, pkey_flags
;
846 EVP_PKEY_meth_get0_info(&pkey_id
, &pkey_flags
, pmeth
);
847 BIO_printf(bio_out
, "%s\n", OBJ_nid2ln(pkey_id
));
848 BIO_printf(bio_out
, "\tType: %s Algorithm\n",
849 pkey_flags
& ASN1_PKEY_DYNAMIC
? "External" : "Builtin");
853 static int function_cmp(const FUNCTION
* a
, const FUNCTION
* b
)
855 return strncmp(a
->name
, b
->name
, 8);
858 static unsigned long function_hash(const FUNCTION
* a
)
860 return OPENSSL_LH_strhash(a
->name
);
863 static int SortFnByName(const void *_f1
, const void *_f2
)
865 const FUNCTION
*f1
= _f1
;
866 const FUNCTION
*f2
= _f2
;
868 if (f1
->type
!= f2
->type
)
869 return f1
->type
- f2
->type
;
870 return strcmp(f1
->name
, f2
->name
);
873 static void list_engines(void)
875 #ifndef OPENSSL_NO_ENGINE
878 BIO_puts(bio_out
, "Engines:\n");
879 e
= ENGINE_get_first();
881 BIO_printf(bio_out
, "%s\n", ENGINE_get_id(e
));
882 e
= ENGINE_get_next(e
);
885 BIO_puts(bio_out
, "Engine support is disabled.\n");
889 static void list_disabled(void)
891 BIO_puts(bio_out
, "Disabled algorithms:\n");
892 #ifdef OPENSSL_NO_ARIA
893 BIO_puts(bio_out
, "ARIA\n");
896 BIO_puts(bio_out
, "BF\n");
898 #ifdef OPENSSL_NO_BLAKE2
899 BIO_puts(bio_out
, "BLAKE2\n");
901 #ifdef OPENSSL_NO_CAMELLIA
902 BIO_puts(bio_out
, "CAMELLIA\n");
904 #ifdef OPENSSL_NO_CAST
905 BIO_puts(bio_out
, "CAST\n");
907 #ifdef OPENSSL_NO_CMAC
908 BIO_puts(bio_out
, "CMAC\n");
910 #ifdef OPENSSL_NO_CMS
911 BIO_puts(bio_out
, "CMS\n");
913 #ifdef OPENSSL_NO_COMP
914 BIO_puts(bio_out
, "COMP\n");
916 #ifdef OPENSSL_NO_DES
917 BIO_puts(bio_out
, "DES\n");
919 #ifdef OPENSSL_NO_DGRAM
920 BIO_puts(bio_out
, "DGRAM\n");
923 BIO_puts(bio_out
, "DH\n");
925 #ifdef OPENSSL_NO_DSA
926 BIO_puts(bio_out
, "DSA\n");
928 #if defined(OPENSSL_NO_DTLS)
929 BIO_puts(bio_out
, "DTLS\n");
931 #if defined(OPENSSL_NO_DTLS1)
932 BIO_puts(bio_out
, "DTLS1\n");
934 #if defined(OPENSSL_NO_DTLS1_2)
935 BIO_puts(bio_out
, "DTLS1_2\n");
938 BIO_puts(bio_out
, "EC\n");
940 #ifdef OPENSSL_NO_EC2M
941 BIO_puts(bio_out
, "EC2M\n");
943 #ifdef OPENSSL_NO_ENGINE
944 BIO_puts(bio_out
, "ENGINE\n");
946 #ifdef OPENSSL_NO_GOST
947 BIO_puts(bio_out
, "GOST\n");
949 #ifdef OPENSSL_NO_IDEA
950 BIO_puts(bio_out
, "IDEA\n");
952 #ifdef OPENSSL_NO_MD2
953 BIO_puts(bio_out
, "MD2\n");
955 #ifdef OPENSSL_NO_MD4
956 BIO_puts(bio_out
, "MD4\n");
958 #ifdef OPENSSL_NO_MD5
959 BIO_puts(bio_out
, "MD5\n");
961 #ifdef OPENSSL_NO_MDC2
962 BIO_puts(bio_out
, "MDC2\n");
964 #ifdef OPENSSL_NO_OCB
965 BIO_puts(bio_out
, "OCB\n");
967 #ifdef OPENSSL_NO_OCSP
968 BIO_puts(bio_out
, "OCSP\n");
970 #ifdef OPENSSL_NO_PSK
971 BIO_puts(bio_out
, "PSK\n");
973 #ifdef OPENSSL_NO_RC2
974 BIO_puts(bio_out
, "RC2\n");
976 #ifdef OPENSSL_NO_RC4
977 BIO_puts(bio_out
, "RC4\n");
979 #ifdef OPENSSL_NO_RC5
980 BIO_puts(bio_out
, "RC5\n");
982 #ifdef OPENSSL_NO_RMD160
983 BIO_puts(bio_out
, "RMD160\n");
985 #ifdef OPENSSL_NO_RSA
986 BIO_puts(bio_out
, "RSA\n");
988 #ifdef OPENSSL_NO_SCRYPT
989 BIO_puts(bio_out
, "SCRYPT\n");
991 #ifdef OPENSSL_NO_SCTP
992 BIO_puts(bio_out
, "SCTP\n");
994 #ifdef OPENSSL_NO_SEED
995 BIO_puts(bio_out
, "SEED\n");
997 #ifdef OPENSSL_NO_SM2
998 BIO_puts(bio_out
, "SM2\n");
1000 #ifdef OPENSSL_NO_SM3
1001 BIO_puts(bio_out
, "SM3\n");
1003 #ifdef OPENSSL_NO_SM4
1004 BIO_puts(bio_out
, "SM4\n");
1006 #ifdef OPENSSL_NO_SOCK
1007 BIO_puts(bio_out
, "SOCK\n");
1009 #ifdef OPENSSL_NO_SRP
1010 BIO_puts(bio_out
, "SRP\n");
1012 #ifdef OPENSSL_NO_SRTP
1013 BIO_puts(bio_out
, "SRTP\n");
1015 #ifdef OPENSSL_NO_SSL3
1016 BIO_puts(bio_out
, "SSL3\n");
1018 #ifdef OPENSSL_NO_TLS1
1019 BIO_puts(bio_out
, "TLS1\n");
1021 #ifdef OPENSSL_NO_TLS1_1
1022 BIO_puts(bio_out
, "TLS1_1\n");
1024 #ifdef OPENSSL_NO_TLS1_2
1025 BIO_puts(bio_out
, "TLS1_2\n");
1027 #ifdef OPENSSL_NO_WHIRLPOOL
1028 BIO_puts(bio_out
, "WHIRLPOOL\n");
1031 BIO_puts(bio_out
, "ZLIB\n");
1035 static LHASH_OF(FUNCTION
) *prog_init(void)
1037 static LHASH_OF(FUNCTION
) *ret
= NULL
;
1038 static int prog_inited
= 0;
1047 /* Sort alphabetically within category. For nicer help displays. */
1048 for (i
= 0, f
= functions
; f
->name
!= NULL
; ++f
, ++i
)
1050 qsort(functions
, i
, sizeof(*functions
), SortFnByName
);
1052 if ((ret
= lh_FUNCTION_new(function_hash
, function_cmp
)) == NULL
)
1055 for (f
= functions
; f
->name
!= NULL
; f
++)
1056 (void)lh_FUNCTION_insert(ret
, f
);