]> git.ipfire.org Git - thirdparty/openssl.git/blob - apps/openssl.c
Remove the never-functional no-sct
[thirdparty/openssl.git] / apps / openssl.c
1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2 * All rights reserved.
3 *
4 * This package is an SSL implementation written
5 * by Eric Young (eay@cryptsoft.com).
6 * The implementation was written so as to conform with Netscapes SSL.
7 *
8 * This library is free for commercial and non-commercial use as long as
9 * the following conditions are aheared to. The following conditions
10 * apply to all code found in this distribution, be it the RC4, RSA,
11 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12 * included with this distribution is covered by the same copyright terms
13 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14 *
15 * Copyright remains Eric Young's, and as such any Copyright notices in
16 * the code are not to be removed.
17 * If this package is used in a product, Eric Young should be given attribution
18 * as the author of the parts of the library used.
19 * This can be in the form of a textual message at program startup or
20 * in documentation (online or textual) provided with the package.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 3. All advertising materials mentioning features or use of this software
31 * must display the following acknowledgement:
32 * "This product includes cryptographic software written by
33 * Eric Young (eay@cryptsoft.com)"
34 * The word 'cryptographic' can be left out if the rouines from the library
35 * being used are not cryptographic related :-).
36 * 4. If you include any Windows specific code (or a derivative thereof) from
37 * the apps directory (application code) you must include an acknowledgement:
38 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 *
52 * The licence and distribution terms for any publically available version or
53 * derivative of this code cannot be changed. i.e. this code cannot simply be
54 * copied and put under another distribution licence
55 * [including the GNU Public Licence.]
56 */
57 /* ====================================================================
58 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
59 *
60 * Redistribution and use in source and binary forms, with or without
61 * modification, are permitted provided that the following conditions
62 * are met:
63 *
64 * 1. Redistributions of source code must retain the above copyright
65 * notice, this list of conditions and the following disclaimer.
66 *
67 * 2. Redistributions in binary form must reproduce the above copyright
68 * notice, this list of conditions and the following disclaimer in
69 * the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3. All advertising materials mentioning features or use of this
73 * software must display the following acknowledgment:
74 * "This product includes software developed by the OpenSSL Project
75 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
76 *
77 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
78 * endorse or promote products derived from this software without
79 * prior written permission. For written permission, please contact
80 * openssl-core@openssl.org.
81 *
82 * 5. Products derived from this software may not be called "OpenSSL"
83 * nor may "OpenSSL" appear in their names without prior written
84 * permission of the OpenSSL Project.
85 *
86 * 6. Redistributions of any form whatsoever must retain the following
87 * acknowledgment:
88 * "This product includes software developed by the OpenSSL Project
89 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
90 *
91 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
92 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
94 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
95 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
96 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
97 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
98 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
99 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
100 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
101 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
102 * OF THE POSSIBILITY OF SUCH DAMAGE.
103 * ====================================================================
104 *
105 * This product includes cryptographic software written by Eric Young
106 * (eay@cryptsoft.com). This product includes software written by Tim
107 * Hudson (tjh@cryptsoft.com).
108 *
109 */
110
111 #include <stdio.h>
112 #include <string.h>
113 #include <stdlib.h>
114 #include <openssl/bio.h>
115 #include <openssl/crypto.h>
116 #include <openssl/rand.h>
117 #include <openssl/lhash.h>
118 #include <openssl/conf.h>
119 #include <openssl/x509.h>
120 #include <openssl/pem.h>
121 #include <openssl/ssl.h>
122 #ifndef OPENSSL_NO_ENGINE
123 # include <openssl/engine.h>
124 #endif
125 #include <openssl/err.h>
126 #ifdef OPENSSL_FIPS
127 # include <openssl/fips.h>
128 #endif
129 #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
130 #include "s_apps.h"
131 /* Needed to get the other O_xxx flags. */
132 #ifdef OPENSSL_SYS_VMS
133 # include <unixio.h>
134 #endif
135 #define INCLUDE_FUNCTION_TABLE
136 #include "apps.h"
137
138
139 #ifdef OPENSSL_NO_CAMELLIA
140 # define FORMAT "%-15s"
141 # define COLUMNS 5
142 #else
143 # define FORMAT "%-18s"
144 # define COLUMNS 4
145 #endif
146
147 /* Special sentinel to exit the program. */
148 #define EXIT_THE_PROGRAM (-1)
149
150 /*
151 * The LHASH callbacks ("hash" & "cmp") have been replaced by functions with
152 * the base prototypes (we cast each variable inside the function to the
153 * required type of "FUNCTION*"). This removes the necessity for
154 * macro-generated wrapper functions.
155 */
156 static LHASH_OF(FUNCTION) *prog_init(void);
157 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
158 static void list_pkey(void);
159 static void list_type(FUNC_TYPE ft);
160 static void list_disabled(void);
161 char *default_config_file = NULL;
162
163 static CONF *config = NULL;
164 BIO *bio_in = NULL;
165 BIO *bio_out = NULL;
166 BIO *bio_err = NULL;
167
168 static int apps_startup()
169 {
170 #ifdef SIGPIPE
171 signal(SIGPIPE, SIG_IGN);
172 #endif
173
174 /* Set non-default library initialisation settings */
175 if (!OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN
176 | OPENSSL_INIT_LOAD_CONFIG, NULL))
177 return 0;
178
179 #ifndef OPENSSL_NO_UI
180 setup_ui_method();
181 #endif
182
183 return 1;
184 }
185
186 static void apps_shutdown()
187 {
188 #ifndef OPENSSL_NO_UI
189 destroy_ui_method();
190 #endif
191 }
192
193 static char *make_config_name()
194 {
195 const char *t;
196 size_t len;
197 char *p;
198
199 if ((t = getenv("OPENSSL_CONF")) != NULL)
200 return OPENSSL_strdup(t);
201
202 t = X509_get_default_cert_area();
203 len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
204 p = app_malloc(len, "config filename buffer");
205 strcpy(p, t);
206 #ifndef OPENSSL_SYS_VMS
207 strcat(p, "/");
208 #endif
209 strcat(p, OPENSSL_CONF);
210
211 return p;
212 }
213
214 int main(int argc, char *argv[])
215 {
216 FUNCTION f, *fp;
217 LHASH_OF(FUNCTION) *prog = NULL;
218 char **copied_argv = NULL;
219 char *p, *pname;
220 char buf[1024];
221 const char *prompt;
222 ARGS arg;
223 int first, n, i, ret = 0;
224
225 arg.argv = NULL;
226 arg.size = 0;
227
228 /* Set up some of the environment. */
229 default_config_file = make_config_name();
230 bio_in = dup_bio_in(FORMAT_TEXT);
231 bio_out = dup_bio_out(FORMAT_TEXT);
232 bio_err = dup_bio_err(FORMAT_TEXT);
233
234 #if defined(OPENSSL_SYS_VMS) && defined(__DECC)
235 copied_argv = argv = copy_argv(&argc, argv);
236 #endif
237
238 p = getenv("OPENSSL_DEBUG_MEMORY");
239 if (p != NULL && strcmp(p, "on") == 0)
240 CRYPTO_set_mem_debug(1);
241 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
242
243 if (getenv("OPENSSL_FIPS")) {
244 #ifdef OPENSSL_FIPS
245 if (!FIPS_mode_set(1)) {
246 ERR_print_errors(bio_err);
247 return 1;
248 }
249 #else
250 BIO_printf(bio_err, "FIPS mode not supported.\n");
251 return 1;
252 #endif
253 }
254
255 if (!apps_startup())
256 goto end;
257
258 prog = prog_init();
259 pname = opt_progname(argv[0]);
260
261 /* first check the program name */
262 f.name = pname;
263 fp = lh_FUNCTION_retrieve(prog, &f);
264 if (fp != NULL) {
265 argv[0] = pname;
266 ret = fp->func(argc, argv);
267 goto end;
268 }
269
270 /* If there is stuff on the command line, run with that. */
271 if (argc != 1) {
272 argc--;
273 argv++;
274 ret = do_cmd(prog, argc, argv);
275 if (ret < 0)
276 ret = 0;
277 goto end;
278 }
279
280 /* ok, lets enter interactive mode */
281 for (;;) {
282 ret = 0;
283 /* Read a line, continue reading if line ends with \ */
284 for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) {
285 prompt = first ? "OpenSSL> " : "> ";
286 p[0] = '\0';
287 #ifndef READLINE
288 fputs(prompt, stdout);
289 fflush(stdout);
290 if (!fgets(p, n, stdin))
291 goto end;
292 if (p[0] == '\0')
293 goto end;
294 i = strlen(p);
295 if (i <= 1)
296 break;
297 if (p[i - 2] != '\\')
298 break;
299 i -= 2;
300 p += i;
301 n -= i;
302 #else
303 {
304 extern char *readline(const char *);
305 extern void add_history(const char *cp);
306 char *text;
307
308 char *text = readline(prompt);
309 if (text == NULL)
310 goto end;
311 i = strlen(text);
312 if (i == 0 || i > n)
313 break;
314 if (text[i - 1] != '\\') {
315 p += strlen(strcpy(p, text));
316 free(text);
317 add_history(buf);
318 break;
319 }
320
321 text[i - 1] = '\0';
322 p += strlen(strcpy(p, text));
323 free(text);
324 n -= i;
325 }
326 #endif
327 }
328
329 if (!chopup_args(&arg, buf)) {
330 BIO_printf(bio_err, "Can't parse (no memory?)\n");
331 break;
332 }
333
334 ret = do_cmd(prog, arg.argc, arg.argv);
335 if (ret == EXIT_THE_PROGRAM) {
336 ret = 0;
337 goto end;
338 }
339 if (ret != 0)
340 BIO_printf(bio_err, "error in %s\n", arg.argv[0]);
341 (void)BIO_flush(bio_out);
342 (void)BIO_flush(bio_err);
343 }
344 ret = 1;
345 end:
346 OPENSSL_free(copied_argv);
347 OPENSSL_free(default_config_file);
348 NCONF_free(config);
349 config = NULL;
350 lh_FUNCTION_free(prog);
351 OPENSSL_free(arg.argv);
352
353 BIO_free(bio_in);
354 BIO_free_all(bio_out);
355 apps_shutdown();
356 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
357 if (CRYPTO_mem_leaks(bio_err) <= 0)
358 ret = 1;
359 #endif
360 BIO_free(bio_err);
361 EXIT(ret);
362 }
363
364 OPTIONS exit_options[] = {
365 {NULL}
366 };
367
368 static void list_cipher_fn(const EVP_CIPHER *c,
369 const char *from, const char *to, void *arg)
370 {
371 if (c)
372 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
373 else {
374 if (!from)
375 from = "<undefined>";
376 if (!to)
377 to = "<undefined>";
378 BIO_printf(arg, "%s => %s\n", from, to);
379 }
380 }
381
382 static void list_md_fn(const EVP_MD *m,
383 const char *from, const char *to, void *arg)
384 {
385 if (m)
386 BIO_printf(arg, "%s\n", EVP_MD_name(m));
387 else {
388 if (!from)
389 from = "<undefined>";
390 if (!to)
391 to = "<undefined>";
392 BIO_printf((BIO *)arg, "%s => %s\n", from, to);
393 }
394 }
395
396 /* Unified enum for help and list commands. */
397 typedef enum HELPLIST_CHOICE {
398 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
399 OPT_COMMANDS, OPT_DIGEST_COMMANDS,
400 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
401 OPT_PK_ALGORITHMS, OPT_DISABLED
402 } HELPLIST_CHOICE;
403
404 OPTIONS list_options[] = {
405 {"help", OPT_HELP, '-', "Display this summary"},
406 {"commands", OPT_COMMANDS, '-', "List of standard commands"},
407 {"digest-commands", OPT_DIGEST_COMMANDS, '-',
408 "List of message digest commands"},
409 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
410 "List of message digest algorithms"},
411 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
412 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
413 "List of cipher algorithms"},
414 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
415 "List of public key algorithms"},
416 {"disabled", OPT_DISABLED, '-',
417 "List of disabled features"},
418 {NULL}
419 };
420
421 int list_main(int argc, char **argv)
422 {
423 char *prog;
424 HELPLIST_CHOICE o;
425 int done = 0;
426
427 prog = opt_init(argc, argv, list_options);
428 while ((o = opt_next()) != OPT_EOF) {
429 switch (o) {
430 case OPT_EOF: /* Never hit, but suppresses warning */
431 case OPT_ERR:
432 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
433 return 1;
434 case OPT_HELP:
435 opt_help(list_options);
436 break;
437 case OPT_COMMANDS:
438 list_type(FT_general);
439 break;
440 case OPT_DIGEST_COMMANDS:
441 list_type(FT_md);
442 break;
443 case OPT_DIGEST_ALGORITHMS:
444 EVP_MD_do_all_sorted(list_md_fn, bio_out);
445 break;
446 case OPT_CIPHER_COMMANDS:
447 list_type(FT_cipher);
448 break;
449 case OPT_CIPHER_ALGORITHMS:
450 EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
451 break;
452 case OPT_PK_ALGORITHMS:
453 list_pkey();
454 break;
455 case OPT_DISABLED:
456 list_disabled();
457 break;
458 }
459 done = 1;
460 }
461
462 if (!done) {
463 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
464 return 1;
465 }
466
467 return 0;
468 }
469
470 OPTIONS help_options[] = {
471 {"help", OPT_HELP, '-', "Display this summary"},
472 {NULL}
473 };
474
475 int help_main(int argc, char **argv)
476 {
477 FUNCTION *fp;
478 int i, nl;
479 FUNC_TYPE tp;
480 char *prog;
481 HELPLIST_CHOICE o;
482
483 prog = opt_init(argc, argv, help_options);
484 while ((o = opt_next()) != OPT_EOF) {
485 switch (o) {
486 default:
487 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
488 return 1;
489 case OPT_HELP:
490 opt_help(help_options);
491 return 0;
492 }
493 }
494
495 if (opt_num_rest() != 0) {
496 BIO_printf(bio_err, "Usage: %s\n", prog);
497 return 1;
498 }
499
500 BIO_printf(bio_err, "\nStandard commands");
501 i = 0;
502 tp = FT_none;
503 for (fp = functions; fp->name != NULL; fp++) {
504 nl = 0;
505 if (((i++) % COLUMNS) == 0) {
506 BIO_printf(bio_err, "\n");
507 nl = 1;
508 }
509 if (fp->type != tp) {
510 tp = fp->type;
511 if (!nl)
512 BIO_printf(bio_err, "\n");
513 if (tp == FT_md) {
514 i = 1;
515 BIO_printf(bio_err,
516 "\nMessage Digest commands (see the `dgst' command for more details)\n");
517 } else if (tp == FT_cipher) {
518 i = 1;
519 BIO_printf(bio_err,
520 "\nCipher commands (see the `enc' command for more details)\n");
521 }
522 }
523 BIO_printf(bio_err, FORMAT, fp->name);
524 }
525 BIO_printf(bio_err, "\n\n");
526 return 0;
527 }
528
529 int exit_main(int argc, char **argv)
530 {
531 return EXIT_THE_PROGRAM;
532 }
533
534 static void list_type(FUNC_TYPE ft)
535 {
536 FUNCTION *fp;
537 int i = 0;
538
539 for (fp = functions; fp->name != NULL; fp++)
540 if (fp->type == ft) {
541 if ((i++ % COLUMNS) == 0)
542 BIO_printf(bio_out, "\n");
543 BIO_printf(bio_out, FORMAT, fp->name);
544 }
545 BIO_printf(bio_out, "\n");
546 }
547
548 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
549 {
550 FUNCTION f, *fp;
551
552 if (argc <= 0 || argv[0] == NULL)
553 return (0);
554 f.name = argv[0];
555 fp = lh_FUNCTION_retrieve(prog, &f);
556 if (fp == NULL) {
557 if (EVP_get_digestbyname(argv[0])) {
558 f.type = FT_md;
559 f.func = dgst_main;
560 fp = &f;
561 } else if (EVP_get_cipherbyname(argv[0])) {
562 f.type = FT_cipher;
563 f.func = enc_main;
564 fp = &f;
565 }
566 }
567 if (fp != NULL) {
568 return (fp->func(argc, argv));
569 }
570 if ((strncmp(argv[0], "no-", 3)) == 0) {
571 /*
572 * User is asking if foo is unsupported, by trying to "run" the
573 * no-foo command. Strange.
574 */
575 f.name = argv[0] + 3;
576 if (lh_FUNCTION_retrieve(prog, &f) == NULL) {
577 BIO_printf(bio_out, "%s\n", argv[0]);
578 return (0);
579 }
580 BIO_printf(bio_out, "%s\n", argv[0] + 3);
581 return 1;
582 }
583 if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||
584 strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)
585 /* Special value to mean "exit the program. */
586 return EXIT_THE_PROGRAM;
587
588 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
589 argv[0]);
590 return (1);
591 }
592
593 static void list_pkey(void)
594 {
595 int i;
596
597 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
598 const EVP_PKEY_ASN1_METHOD *ameth;
599 int pkey_id, pkey_base_id, pkey_flags;
600 const char *pinfo, *pem_str;
601 ameth = EVP_PKEY_asn1_get0(i);
602 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
603 &pinfo, &pem_str, ameth);
604 if (pkey_flags & ASN1_PKEY_ALIAS) {
605 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
606 BIO_printf(bio_out, "\tAlias for: %s\n",
607 OBJ_nid2ln(pkey_base_id));
608 } else {
609 BIO_printf(bio_out, "Name: %s\n", pinfo);
610 BIO_printf(bio_out, "\tType: %s Algorithm\n",
611 pkey_flags & ASN1_PKEY_DYNAMIC ?
612 "External" : "Builtin");
613 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
614 if (pem_str == NULL)
615 pem_str = "(none)";
616 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
617 }
618
619 }
620 }
621
622 static int function_cmp(const FUNCTION * a, const FUNCTION * b)
623 {
624 return strncmp(a->name, b->name, 8);
625 }
626
627 static unsigned long function_hash(const FUNCTION * a)
628 {
629 return lh_strhash(a->name);
630 }
631
632 static int SortFnByName(const void *_f1, const void *_f2)
633 {
634 const FUNCTION *f1 = _f1;
635 const FUNCTION *f2 = _f2;
636
637 if (f1->type != f2->type)
638 return f1->type - f2->type;
639 return strcmp(f1->name, f2->name);
640 }
641
642 static void list_disabled(void)
643 {
644 BIO_puts(bio_out, "Disabled algorithms:\n");
645 #ifdef OPENSSL_NO_BF
646 BIO_puts(bio_out, "BF\n");
647 #endif
648 #ifndef OPENSSL_NO_BLAKE2
649 BIO_puts(bio_out, "BLAKE2\n");
650 #endif
651 #ifdef OPENSSL_NO_CAMELLIA
652 BIO_puts(bio_out, "CAMELLIA\n");
653 #endif
654 #ifdef OPENSSL_NO_CAST
655 BIO_puts(bio_out, "CAST\n");
656 #endif
657 #ifdef OPENSSL_NO_CMAC
658 BIO_puts(bio_out, "CMAC\n");
659 #endif
660 #ifdef OPENSSL_NO_CMS
661 BIO_puts(bio_out, "CMS\n");
662 #endif
663 #ifdef OPENSSL_NO_COMP
664 BIO_puts(bio_out, "COMP\n");
665 #endif
666 #ifdef OPENSSL_NO_DES
667 BIO_puts(bio_out, "DES\n");
668 #endif
669 #ifdef OPENSSL_NO_DGRAM
670 BIO_puts(bio_out, "DGRAM\n");
671 #endif
672 #ifdef OPENSSL_NO_DH
673 BIO_puts(bio_out, "DH\n");
674 #endif
675 #ifdef OPENSSL_NO_DSA
676 BIO_puts(bio_out, "DSA\n");
677 #endif
678 #if defined(OPENSSL_NO_DTLS)
679 BIO_puts(bio_out, "DTLS\n");
680 #endif
681 #if defined(OPENSSL_NO_DTLS1)
682 BIO_puts(bio_out, "DTLS1\n");
683 #endif
684 #if defined(OPENSSL_NO_DTLS1_2)
685 BIO_puts(bio_out, "DTLS1_2\n");
686 #endif
687 #ifdef OPENSSL_NO_EC
688 BIO_puts(bio_out, "EC\n");
689 #endif
690 #ifdef OPENSSL_NO_EC2M
691 BIO_puts(bio_out, "EC2M\n");
692 #endif
693 #ifdef OPENSSL_NO_ENGINE
694 BIO_puts(bio_out, "ENGINE\n");
695 #endif
696 #ifdef OPENSSL_NO_GOST
697 BIO_puts(bio_out, "GOST\n");
698 #endif
699 #ifdef OPENSSL_NO_HEARTBEATS
700 BIO_puts(bio_out, "HEARTBEATS\n");
701 #endif
702 #ifdef OPENSSL_NO_IDEA
703 BIO_puts(bio_out, "IDEA\n");
704 #endif
705 #ifdef OPENSSL_NO_MD2
706 BIO_puts(bio_out, "MD2\n");
707 #endif
708 #ifdef OPENSSL_NO_MD4
709 BIO_puts(bio_out, "MD4\n");
710 #endif
711 #ifdef OPENSSL_NO_MD5
712 BIO_puts(bio_out, "MD5\n");
713 #endif
714 #ifdef OPENSSL_NO_MDC2
715 BIO_puts(bio_out, "MDC2\n");
716 #endif
717 #ifdef OPENSSL_NO_OCB
718 BIO_puts(bio_out, "OCB\n");
719 #endif
720 #ifdef OPENSSL_NO_OCSP
721 BIO_puts(bio_out, "OCSP\n");
722 #endif
723 #ifdef OPENSSL_NO_PSK
724 BIO_puts(bio_out, "PSK\n");
725 #endif
726 #ifdef OPENSSL_NO_RC2
727 BIO_puts(bio_out, "RC2\n");
728 #endif
729 #ifdef OPENSSL_NO_RC4
730 BIO_puts(bio_out, "RC4\n");
731 #endif
732 #ifdef OPENSSL_NO_RC5
733 BIO_puts(bio_out, "RC5\n");
734 #endif
735 #ifdef OPENSSL_NO_RMD160
736 BIO_puts(bio_out, "RMD160\n");
737 #endif
738 #ifdef OPENSSL_NO_RSA
739 BIO_puts(bio_out, "RSA\n");
740 #endif
741 #ifdef OPENSSL_NO_SCRYPT
742 BIO_puts(bio_out, "SCRYPT\n");
743 #endif
744 #ifdef OPENSSL_NO_SCTP
745 BIO_puts(bio_out, "SCTP\n");
746 #endif
747 #ifdef OPENSSL_NO_SEED
748 BIO_puts(bio_out, "SEED\n");
749 #endif
750 #ifdef OPENSSL_NO_SOCK
751 BIO_puts(bio_out, "SOCK\n");
752 #endif
753 #ifdef OPENSSL_NO_SRP
754 BIO_puts(bio_out, "SRP\n");
755 #endif
756 #ifdef OPENSSL_NO_SRTP
757 BIO_puts(bio_out, "SRTP\n");
758 #endif
759 #ifdef OPENSSL_NO_SSL
760 BIO_puts(bio_out, "SSL\n");
761 #endif
762 #ifdef OPENSSL_NO_SSL3
763 BIO_puts(bio_out, "SSL3\n");
764 #endif
765 #if defined(OPENSSL_NO_TLS)
766 BIO_puts(bio_out, "TLS\n");
767 #endif
768 #ifdef OPENSSL_NO_TLS1
769 BIO_puts(bio_out, "TLS1\n");
770 #endif
771 #ifdef OPENSSL_NO_TLS1_1
772 BIO_puts(bio_out, "TLS1_1\n");
773 #endif
774 #ifdef OPENSSL_NO_TLS1_2
775 BIO_puts(bio_out, "TLS1_2\n");
776 #endif
777 #ifdef OPENSSL_NO_WHIRLPOOL
778 BIO_puts(bio_out, "WHIRLPOOL\n");
779 #endif
780 #ifndef ZLIB
781 BIO_puts(bio_out, "ZLIB\n");
782 #endif
783 }
784
785 static LHASH_OF(FUNCTION) *prog_init(void)
786 {
787 LHASH_OF(FUNCTION) *ret;
788 FUNCTION *f;
789 size_t i;
790
791 /* Sort alphabetically within category. For nicer help displays. */
792 for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
793 qsort(functions, i, sizeof(*functions), SortFnByName);
794
795 if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)
796 return (NULL);
797
798 for (f = functions; f->name != NULL; f++)
799 (void)lh_FUNCTION_insert(ret, f);
800 return (ret);
801 }