]> git.ipfire.org Git - thirdparty/openssl.git/blob - apps/openssl.c
Fix pointer size issues with argv on VMS
[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 setup_ui_method();
180
181 return 1;
182 }
183
184 static void apps_shutdown()
185 {
186 destroy_ui_method();
187 }
188
189 static char *make_config_name()
190 {
191 const char *t;
192 size_t len;
193 char *p;
194
195 if ((t = getenv("OPENSSL_CONF")) != NULL)
196 return OPENSSL_strdup(t);
197
198 t = X509_get_default_cert_area();
199 len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
200 p = app_malloc(len, "config filename buffer");
201 strcpy(p, t);
202 #ifndef OPENSSL_SYS_VMS
203 strcat(p, "/");
204 #endif
205 strcat(p, OPENSSL_CONF);
206
207 return p;
208 }
209
210 int main(int argc, char *argv[])
211 {
212 FUNCTION f, *fp;
213 LHASH_OF(FUNCTION) *prog = NULL;
214 char **copied_argv = NULL;
215 char **argv_alias = NULL;
216 char *p, *pname;
217 char buf[1024];
218 const char *prompt;
219 ARGS arg;
220 int first, n, i, ret = 0;
221
222 arg.argv = NULL;
223 arg.size = 0;
224
225 /* Set up some of the environment. */
226 default_config_file = make_config_name();
227 bio_in = dup_bio_in(FORMAT_TEXT);
228 bio_out = dup_bio_out(FORMAT_TEXT);
229 bio_err = dup_bio_err(FORMAT_TEXT);
230
231 #if defined( OPENSSL_SYS_VMS) && defined(__DECC)
232 copied_argv = argv_alias = copy_argv(&argc, argv);
233 #else
234 argv_alias = argv;
235 #endif
236
237 p = getenv("OPENSSL_DEBUG_MEMORY");
238 if (p != NULL && strcmp(p, "on") == 0)
239 CRYPTO_set_mem_debug(1);
240 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
241
242 if (getenv("OPENSSL_FIPS")) {
243 #ifdef OPENSSL_FIPS
244 if (!FIPS_mode_set(1)) {
245 ERR_print_errors(bio_err);
246 return 1;
247 }
248 #else
249 BIO_printf(bio_err, "FIPS mode not supported.\n");
250 return 1;
251 #endif
252 }
253
254 if (!apps_startup())
255 goto end;
256
257 prog = prog_init();
258 pname = opt_progname(argv_alias[0]);
259
260 /* first check the program name */
261 f.name = pname;
262 fp = lh_FUNCTION_retrieve(prog, &f);
263 if (fp != NULL) {
264 argv_alias[0] = pname;
265 ret = fp->func(argc, argv_alias);
266 goto end;
267 }
268
269 /* If there is stuff on the command line, run with that. */
270 if (argc != 1) {
271 argc--;
272 argv_alias++;
273 ret = do_cmd(prog, argc, argv_alias);
274 if (ret < 0)
275 ret = 0;
276 goto end;
277 }
278
279 /* ok, lets enter interactive mode */
280 for (;;) {
281 ret = 0;
282 /* Read a line, continue reading if line ends with \ */
283 for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) {
284 prompt = first ? "OpenSSL> " : "> ";
285 p[0] = '\0';
286 #ifndef READLINE
287 fputs(prompt, stdout);
288 fflush(stdout);
289 if (!fgets(p, n, stdin))
290 goto end;
291 if (p[0] == '\0')
292 goto end;
293 i = strlen(p);
294 if (i <= 1)
295 break;
296 if (p[i - 2] != '\\')
297 break;
298 i -= 2;
299 p += i;
300 n -= i;
301 #else
302 {
303 extern char *readline(const char *);
304 extern void add_history(const char *cp);
305 char *text;
306
307 char *text = readline(prompt);
308 if (text == NULL)
309 goto end;
310 i = strlen(text);
311 if (i == 0 || i > n)
312 break;
313 if (text[i - 1] != '\\') {
314 p += strlen(strcpy(p, text));
315 free(text);
316 add_history(buf);
317 break;
318 }
319
320 text[i - 1] = '\0';
321 p += strlen(strcpy(p, text));
322 free(text);
323 n -= i;
324 }
325 #endif
326 }
327
328 if (!chopup_args(&arg, buf)) {
329 BIO_printf(bio_err, "Can't parse (no memory?)\n");
330 break;
331 }
332
333 ret = do_cmd(prog, arg.argc, arg.argv);
334 if (ret == EXIT_THE_PROGRAM) {
335 ret = 0;
336 goto end;
337 }
338 if (ret != 0)
339 BIO_printf(bio_err, "error in %s\n", arg.argv[0]);
340 (void)BIO_flush(bio_out);
341 (void)BIO_flush(bio_err);
342 }
343 ret = 1;
344 end:
345 OPENSSL_free(copied_argv);
346 OPENSSL_free(default_config_file);
347 NCONF_free(config);
348 config = NULL;
349 lh_FUNCTION_free(prog);
350 OPENSSL_free(arg.argv);
351
352 BIO_free(bio_in);
353 BIO_free_all(bio_out);
354 apps_shutdown();
355 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
356 if (CRYPTO_mem_leaks(bio_err) <= 0)
357 ret = 1;
358 #endif
359 BIO_free(bio_err);
360 EXIT(ret);
361 }
362
363 OPTIONS exit_options[] = {
364 {NULL}
365 };
366
367 static void list_cipher_fn(const EVP_CIPHER *c,
368 const char *from, const char *to, void *arg)
369 {
370 if (c)
371 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
372 else {
373 if (!from)
374 from = "<undefined>";
375 if (!to)
376 to = "<undefined>";
377 BIO_printf(arg, "%s => %s\n", from, to);
378 }
379 }
380
381 static void list_md_fn(const EVP_MD *m,
382 const char *from, const char *to, void *arg)
383 {
384 if (m)
385 BIO_printf(arg, "%s\n", EVP_MD_name(m));
386 else {
387 if (!from)
388 from = "<undefined>";
389 if (!to)
390 to = "<undefined>";
391 BIO_printf((BIO *)arg, "%s => %s\n", from, to);
392 }
393 }
394
395 /* Unified enum for help and list commands. */
396 typedef enum HELPLIST_CHOICE {
397 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
398 OPT_COMMANDS, OPT_DIGEST_COMMANDS,
399 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
400 OPT_PK_ALGORITHMS, OPT_DISABLED
401 } HELPLIST_CHOICE;
402
403 OPTIONS list_options[] = {
404 {"help", OPT_HELP, '-', "Display this summary"},
405 {"commands", OPT_COMMANDS, '-', "List of standard commands"},
406 {"digest-commands", OPT_DIGEST_COMMANDS, '-',
407 "List of message digest commands"},
408 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
409 "List of message digest algorithms"},
410 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
411 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
412 "List of cipher algorithms"},
413 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
414 "List of public key algorithms"},
415 {"disabled", OPT_DISABLED, '-',
416 "List of disabled features"},
417 {NULL}
418 };
419
420 int list_main(int argc, char **argv)
421 {
422 char *prog;
423 HELPLIST_CHOICE o;
424 int done = 0;
425
426 prog = opt_init(argc, argv, list_options);
427 while ((o = opt_next()) != OPT_EOF) {
428 switch (o) {
429 case OPT_EOF: /* Never hit, but suppresses warning */
430 case OPT_ERR:
431 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
432 return 1;
433 case OPT_HELP:
434 opt_help(list_options);
435 break;
436 case OPT_COMMANDS:
437 list_type(FT_general);
438 break;
439 case OPT_DIGEST_COMMANDS:
440 list_type(FT_md);
441 break;
442 case OPT_DIGEST_ALGORITHMS:
443 EVP_MD_do_all_sorted(list_md_fn, bio_out);
444 break;
445 case OPT_CIPHER_COMMANDS:
446 list_type(FT_cipher);
447 break;
448 case OPT_CIPHER_ALGORITHMS:
449 EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
450 break;
451 case OPT_PK_ALGORITHMS:
452 list_pkey();
453 break;
454 case OPT_DISABLED:
455 list_disabled();
456 break;
457 }
458 done = 1;
459 }
460
461 if (!done) {
462 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
463 return 1;
464 }
465
466 return 0;
467 }
468
469 OPTIONS help_options[] = {
470 {"help", OPT_HELP, '-', "Display this summary"},
471 {NULL}
472 };
473
474 int help_main(int argc, char **argv)
475 {
476 FUNCTION *fp;
477 int i, nl;
478 FUNC_TYPE tp;
479 char *prog;
480 HELPLIST_CHOICE o;
481
482 prog = opt_init(argc, argv, help_options);
483 while ((o = opt_next()) != OPT_EOF) {
484 switch (o) {
485 default:
486 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
487 return 1;
488 case OPT_HELP:
489 opt_help(help_options);
490 return 0;
491 }
492 }
493 argc = opt_num_rest();
494 argv = opt_rest();
495
496 if (argc != 0) {
497 BIO_printf(bio_err, "Usage: %s\n", prog);
498 return 1;
499 }
500
501 BIO_printf(bio_err, "\nStandard commands");
502 i = 0;
503 tp = FT_none;
504 for (fp = functions; fp->name != NULL; fp++) {
505 nl = 0;
506 if (((i++) % COLUMNS) == 0) {
507 BIO_printf(bio_err, "\n");
508 nl = 1;
509 }
510 if (fp->type != tp) {
511 tp = fp->type;
512 if (!nl)
513 BIO_printf(bio_err, "\n");
514 if (tp == FT_md) {
515 i = 1;
516 BIO_printf(bio_err,
517 "\nMessage Digest commands (see the `dgst' command for more details)\n");
518 } else if (tp == FT_cipher) {
519 i = 1;
520 BIO_printf(bio_err,
521 "\nCipher commands (see the `enc' command for more details)\n");
522 }
523 }
524 BIO_printf(bio_err, FORMAT, fp->name);
525 }
526 BIO_printf(bio_err, "\n\n");
527 return 0;
528 }
529
530 int exit_main(int argc, char **argv)
531 {
532 return EXIT_THE_PROGRAM;
533 }
534
535 static void list_type(FUNC_TYPE ft)
536 {
537 FUNCTION *fp;
538 int i = 0;
539
540 for (fp = functions; fp->name != NULL; fp++)
541 if (fp->type == ft) {
542 if ((i++ % COLUMNS) == 0)
543 BIO_printf(bio_out, "\n");
544 BIO_printf(bio_out, FORMAT, fp->name);
545 }
546 BIO_printf(bio_out, "\n");
547 }
548
549 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
550 {
551 FUNCTION f, *fp;
552
553 if (argc <= 0 || argv[0] == NULL)
554 return (0);
555 f.name = argv[0];
556 fp = lh_FUNCTION_retrieve(prog, &f);
557 if (fp == NULL) {
558 if (EVP_get_digestbyname(argv[0])) {
559 f.type = FT_md;
560 f.func = dgst_main;
561 fp = &f;
562 } else if (EVP_get_cipherbyname(argv[0])) {
563 f.type = FT_cipher;
564 f.func = enc_main;
565 fp = &f;
566 }
567 }
568 if (fp != NULL) {
569 return (fp->func(argc, argv));
570 }
571 if ((strncmp(argv[0], "no-", 3)) == 0) {
572 /*
573 * User is asking if foo is unsupported, by trying to "run" the
574 * no-foo command. Strange.
575 */
576 f.name = argv[0] + 3;
577 if (lh_FUNCTION_retrieve(prog, &f) == NULL) {
578 BIO_printf(bio_out, "%s\n", argv[0]);
579 return (0);
580 }
581 BIO_printf(bio_out, "%s\n", argv[0] + 3);
582 return 1;
583 }
584 if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||
585 strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)
586 /* Special value to mean "exit the program. */
587 return EXIT_THE_PROGRAM;
588
589 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
590 argv[0]);
591 return (1);
592 }
593
594 static void list_pkey(void)
595 {
596 int i;
597
598 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
599 const EVP_PKEY_ASN1_METHOD *ameth;
600 int pkey_id, pkey_base_id, pkey_flags;
601 const char *pinfo, *pem_str;
602 ameth = EVP_PKEY_asn1_get0(i);
603 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
604 &pinfo, &pem_str, ameth);
605 if (pkey_flags & ASN1_PKEY_ALIAS) {
606 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
607 BIO_printf(bio_out, "\tAlias for: %s\n",
608 OBJ_nid2ln(pkey_base_id));
609 } else {
610 BIO_printf(bio_out, "Name: %s\n", pinfo);
611 BIO_printf(bio_out, "\tType: %s Algorithm\n",
612 pkey_flags & ASN1_PKEY_DYNAMIC ?
613 "External" : "Builtin");
614 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
615 if (pem_str == NULL)
616 pem_str = "(none)";
617 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
618 }
619
620 }
621 }
622
623 static int function_cmp(const FUNCTION * a, const FUNCTION * b)
624 {
625 return strncmp(a->name, b->name, 8);
626 }
627
628 static unsigned long function_hash(const FUNCTION * a)
629 {
630 return lh_strhash(a->name);
631 }
632
633 static int SortFnByName(const void *_f1, const void *_f2)
634 {
635 const FUNCTION *f1 = _f1;
636 const FUNCTION *f2 = _f2;
637
638 if (f1->type != f2->type)
639 return f1->type - f2->type;
640 return strcmp(f1->name, f2->name);
641 }
642
643 static void list_disabled(void)
644 {
645 BIO_puts(bio_out, "Disabled algorithms:\n");
646 #ifdef OPENSSL_NO_AES
647 BIO_puts(bio_out, "AES\n");
648 #endif
649 #ifdef OPENSSL_NO_BF
650 BIO_puts(bio_out, "BF\n");
651 #endif
652 #ifndef OPENSSL_NO_BLAKE2
653 BIO_puts(bio_out, "BLAKE2\n");
654 #endif
655 #ifdef OPENSSL_NO_CAMELLIA
656 BIO_puts(bio_out, "CAMELLIA\n");
657 #endif
658 #ifdef OPENSSL_NO_CAST
659 BIO_puts(bio_out, "CAST\n");
660 #endif
661 #ifdef OPENSSL_NO_CMAC
662 BIO_puts(bio_out, "CMAC\n");
663 #endif
664 #ifdef OPENSSL_NO_CMS
665 BIO_puts(bio_out, "CMS\n");
666 #endif
667 #ifdef OPENSSL_NO_COMP
668 BIO_puts(bio_out, "COMP\n");
669 #endif
670 #ifdef OPENSSL_NO_DES
671 BIO_puts(bio_out, "DES\n");
672 #endif
673 #ifdef OPENSSL_NO_DGRAM
674 BIO_puts(bio_out, "DGRAM\n");
675 #endif
676 #ifdef OPENSSL_NO_DH
677 BIO_puts(bio_out, "DH\n");
678 #endif
679 #ifdef OPENSSL_NO_DSA
680 BIO_puts(bio_out, "DSA\n");
681 #endif
682 #if defined(OPENSSL_NO_DTLS)
683 BIO_puts(bio_out, "DTLS\n");
684 #endif
685 #if defined(OPENSSL_NO_DTLS1)
686 BIO_puts(bio_out, "DTLS1\n");
687 #endif
688 #if defined(OPENSSL_NO_DTLS1_2)
689 BIO_puts(bio_out, "DTLS1_2\n");
690 #endif
691 #ifdef OPENSSL_NO_EC
692 BIO_puts(bio_out, "EC\n");
693 #endif
694 #ifdef OPENSSL_NO_EC2M
695 BIO_puts(bio_out, "EC2M\n");
696 #endif
697 #ifdef OPENSSL_NO_ENGINE
698 BIO_puts(bio_out, "ENGINE\n");
699 #endif
700 #ifdef OPENSSL_NO_GOST
701 BIO_puts(bio_out, "GOST\n");
702 #endif
703 #ifdef OPENSSL_NO_HEARTBEATS
704 BIO_puts(bio_out, "HEARTBEATS\n");
705 #endif
706 #ifdef OPENSSL_NO_HMAC
707 BIO_puts(bio_out, "HMAC\n");
708 #endif
709 #ifdef OPENSSL_NO_IDEA
710 BIO_puts(bio_out, "IDEA\n");
711 #endif
712 #ifdef OPENSSL_NO_MD2
713 BIO_puts(bio_out, "MD2\n");
714 #endif
715 #ifdef OPENSSL_NO_MD4
716 BIO_puts(bio_out, "MD4\n");
717 #endif
718 #ifdef OPENSSL_NO_MD5
719 BIO_puts(bio_out, "MD5\n");
720 #endif
721 #ifdef OPENSSL_NO_MDC2
722 BIO_puts(bio_out, "MDC2\n");
723 #endif
724 #ifdef OPENSSL_NO_OCB
725 BIO_puts(bio_out, "OCB\n");
726 #endif
727 #ifdef OPENSSL_NO_OCSP
728 BIO_puts(bio_out, "OCSP\n");
729 #endif
730 #ifdef OPENSSL_NO_PSK
731 BIO_puts(bio_out, "PSK\n");
732 #endif
733 #ifdef OPENSSL_NO_RC2
734 BIO_puts(bio_out, "RC2\n");
735 #endif
736 #ifdef OPENSSL_NO_RC4
737 BIO_puts(bio_out, "RC4\n");
738 #endif
739 #ifdef OPENSSL_NO_RC5
740 BIO_puts(bio_out, "RC5\n");
741 #endif
742 #ifdef OPENSSL_NO_RMD160
743 BIO_puts(bio_out, "RMD160\n");
744 #endif
745 #ifdef OPENSSL_NO_RSA
746 BIO_puts(bio_out, "RSA\n");
747 #endif
748 #ifdef OPENSSL_NO_SCRYPT
749 BIO_puts(bio_out, "SCRYPT\n");
750 #endif
751 #ifdef OPENSSL_NO_SCT
752 BIO_puts(bio_out, "SCT\n");
753 #endif
754 #ifdef OPENSSL_NO_SCTP
755 BIO_puts(bio_out, "SCTP\n");
756 #endif
757 #ifdef OPENSSL_NO_SEED
758 BIO_puts(bio_out, "SEED\n");
759 #endif
760 #ifdef OPENSSL_NO_SHA
761 BIO_puts(bio_out, "SHA\n");
762 #endif
763 #ifdef OPENSSL_NO_SOCK
764 BIO_puts(bio_out, "SOCK\n");
765 #endif
766 #ifdef OPENSSL_NO_SRP
767 BIO_puts(bio_out, "SRP\n");
768 #endif
769 #ifdef OPENSSL_NO_SRTP
770 BIO_puts(bio_out, "SRTP\n");
771 #endif
772 #ifdef OPENSSL_NO_SSL
773 BIO_puts(bio_out, "SSL\n");
774 #endif
775 #ifdef OPENSSL_NO_SSL3
776 BIO_puts(bio_out, "SSL3\n");
777 #endif
778 #if defined(OPENSSL_NO_TLS)
779 BIO_puts(bio_out, "TLS\n");
780 #endif
781 #ifdef OPENSSL_NO_TLS1
782 BIO_puts(bio_out, "TLS1\n");
783 #endif
784 #ifdef OPENSSL_NO_TLS1_1
785 BIO_puts(bio_out, "TLS1_1\n");
786 #endif
787 #ifdef OPENSSL_NO_TLS1_2
788 BIO_puts(bio_out, "TLS1_2\n");
789 #endif
790 #ifdef OPENSSL_NO_WHIRLPOOL
791 BIO_puts(bio_out, "WHIRLPOOL\n");
792 #endif
793 #ifndef ZLIB
794 BIO_puts(bio_out, "ZLIB\n");
795 #endif
796 }
797
798 static LHASH_OF(FUNCTION) *prog_init(void)
799 {
800 LHASH_OF(FUNCTION) *ret;
801 FUNCTION *f;
802 size_t i;
803
804 /* Sort alphabetically within category. For nicer help displays. */
805 for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
806 qsort(functions, i, sizeof(*functions), SortFnByName);
807
808 if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)
809 return (NULL);
810
811 for (f = functions; f->name != NULL; f++)
812 (void)lh_FUNCTION_insert(ret, f);
813 return (ret);
814 }