Modify 'openssl list' to give more verbose descriptions
[openssl.git] / apps / list.c
1 /*
2  * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
3  *
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
8  */
9
10 #include <string.h>
11 #include <openssl/evp.h>
12 #include <openssl/err.h>
13 #include <openssl/provider.h>
14 #include <openssl/safestack.h>
15 #include "apps.h"
16 #include "progs.h"
17 #include "opt.h"
18
19 static int verbose = 0;
20
21 static int describe_param_type(char *buf, size_t bufsz, const OSSL_PARAM *param)
22 {
23     const char *type_mod = "";
24     const char *type = NULL;
25     int show_type_number = 0;
26     int printed_len;
27
28     switch (param->data_type) {
29     case OSSL_PARAM_UNSIGNED_INTEGER:
30         type_mod = "unsigned ";
31         /* FALLTHRU */
32     case OSSL_PARAM_INTEGER:
33         type = "integer";
34         break;
35     case OSSL_PARAM_UTF8_PTR:
36         type_mod = "pointer to a ";
37         /* FALLTHRU */
38     case OSSL_PARAM_UTF8_STRING:
39         type = "UTF8 encoded string";
40         break;
41     case OSSL_PARAM_OCTET_PTR:
42         type_mod = "pointer to an ";
43         /* FALLTHRU */
44     case OSSL_PARAM_OCTET_STRING:
45         type = "octet string";
46         break;
47     default:
48         type = "unknown type";
49         show_type_number = 1;
50         break;
51     }
52
53     printed_len = BIO_snprintf(buf, bufsz, "%s: ", param->key);
54     if (printed_len > 0) {
55         buf += printed_len;
56         bufsz -= printed_len;
57     }
58     printed_len = BIO_snprintf(buf, bufsz, "%s%s", type_mod, type);
59     if (printed_len > 0) {
60         buf += printed_len;
61         bufsz -= printed_len;
62     }
63     if (show_type_number) {
64         printed_len = BIO_snprintf(buf, bufsz, " [%d]", param->data_type);
65         if (printed_len > 0) {
66             buf += printed_len;
67             bufsz -= printed_len;
68         }
69     }
70     if (param->data_size == 0)
71         printed_len = BIO_snprintf(buf, bufsz, " (arbitrary size)");
72     else
73         printed_len = BIO_snprintf(buf, bufsz, " (max %zu bytes large)",
74                                    param->data_size);
75     if (printed_len > 0) {
76         buf += printed_len;
77         bufsz -= printed_len;
78     }
79     *buf = '\0';
80     return 1;
81 }
82
83 static int print_param_types(const char *thing, const OSSL_PARAM *pdefs)
84 {
85     if (pdefs == NULL) {
86         BIO_printf(bio_out, "    No declared %s\n", thing);
87     } else if (pdefs->key == NULL) {
88         /*
89          * An empty list?  This shouldn't happen, but let's just make sure to
90          * say something if there's a badly written provider...
91          */
92         BIO_printf(bio_out, "    Empty list of %s (!!!)\n", thing);
93     } else {
94         BIO_printf(bio_out, "    %s:\n", thing);
95         for (; pdefs->key != NULL; pdefs++) {
96             char buf[200];       /* This should be ample space */
97
98             describe_param_type(buf, sizeof(buf), pdefs);
99             BIO_printf(bio_out, "      %s\n", buf);
100         }
101     }
102     return 1;
103 }
104
105 static void legacy_cipher_fn(const EVP_CIPHER *c,
106                              const char *from, const char *to, void *arg)
107 {
108     if (c != NULL) {
109         BIO_printf(arg, "  %s\n", EVP_CIPHER_name(c));
110     } else {
111         if (from == NULL)
112             from = "<undefined>";
113         if (to == NULL)
114             to = "<undefined>";
115         BIO_printf(arg, "  %s => %s\n", from, to);
116     }
117 }
118
119 DEFINE_STACK_OF(EVP_CIPHER)
120 static int cipher_cmp(const EVP_CIPHER * const *a,
121                       const EVP_CIPHER * const *b)
122 {
123     int ret = strcasecmp(EVP_CIPHER_name(*a), EVP_CIPHER_name(*b));
124
125     if (ret == 0)
126         ret = strcmp(OSSL_PROVIDER_name(EVP_CIPHER_provider(*a)),
127                      OSSL_PROVIDER_name(EVP_CIPHER_provider(*b)));
128
129     return ret;
130 }
131
132 static void collect_ciphers(EVP_CIPHER *cipher, void *stack)
133 {
134     STACK_OF(EVP_CIPHER) *cipher_stack = stack;
135
136     sk_EVP_CIPHER_push(cipher_stack, cipher);
137     EVP_CIPHER_up_ref(cipher);
138 }
139
140 static void list_ciphers(void)
141 {
142     STACK_OF(EVP_CIPHER) *ciphers = sk_EVP_CIPHER_new(cipher_cmp);
143     int i;
144
145     BIO_printf(bio_out, "Legacy:\n");
146     EVP_CIPHER_do_all_sorted(legacy_cipher_fn, bio_out);
147
148     BIO_printf(bio_out, "Provided:\n");
149     EVP_CIPHER_do_all_ex(NULL, collect_ciphers, ciphers);
150     sk_EVP_CIPHER_sort(ciphers);
151     for (i = 0; i < sk_EVP_CIPHER_num(ciphers); i++) {
152         const EVP_CIPHER *c = sk_EVP_CIPHER_value(ciphers, i);
153
154         BIO_printf(bio_out, "  %s", EVP_CIPHER_name(c));
155         BIO_printf(bio_out, " @ %s\n",
156                    OSSL_PROVIDER_name(EVP_CIPHER_provider(c)));
157         if (verbose) {
158             print_param_types("retrievable algorithm parameters",
159                               EVP_CIPHER_gettable_params(c));
160             print_param_types("retrievable operation parameters",
161                               EVP_CIPHER_CTX_gettable_params(c));
162             print_param_types("settable operation parameters",
163                               EVP_CIPHER_CTX_settable_params(c));
164         }
165     }
166     sk_EVP_CIPHER_pop_free(ciphers, EVP_CIPHER_meth_free);
167 }
168
169 static void list_md_fn(const EVP_MD *m,
170                        const char *from, const char *to, void *arg)
171 {
172     if (m != NULL) {
173         BIO_printf(arg, "  %s\n", EVP_MD_name(m));
174     } else {
175         if (from == NULL)
176             from = "<undefined>";
177         if (to == NULL)
178             to = "<undefined>";
179         BIO_printf((BIO *)arg, "  %s => %s\n", from, to);
180     }
181 }
182
183 DEFINE_STACK_OF(EVP_MD)
184 static int md_cmp(const EVP_MD * const *a, const EVP_MD * const *b)
185 {
186     int ret = strcasecmp(EVP_MD_name(*a), EVP_MD_name(*b));
187
188     if (ret == 0)
189         ret = strcmp(OSSL_PROVIDER_name(EVP_MD_provider(*a)),
190                      OSSL_PROVIDER_name(EVP_MD_provider(*b)));
191
192     return ret;
193 }
194
195 static void collect_digests(EVP_MD *md, void *stack)
196 {
197     STACK_OF(EVP_MD) *digest_stack = stack;
198
199     sk_EVP_MD_push(digest_stack, md);
200     EVP_MD_up_ref(md);
201 }
202
203 static void list_digests(void)
204 {
205     STACK_OF(EVP_MD) *digests = sk_EVP_MD_new(md_cmp);
206     int i;
207
208     BIO_printf(bio_out, "Legacy:\n");
209     EVP_MD_do_all_sorted(list_md_fn, bio_out);
210
211     BIO_printf(bio_out, "Provided:\n");
212     EVP_MD_do_all_ex(NULL, collect_digests, digests);
213     sk_EVP_MD_sort(digests);
214     for (i = 0; i < sk_EVP_MD_num(digests); i++) {
215         const EVP_MD *m = sk_EVP_MD_value(digests, i);
216
217         BIO_printf(bio_out, "  %s", EVP_MD_name(m));
218         BIO_printf(bio_out, " @ %s\n",
219                    OSSL_PROVIDER_name(EVP_MD_provider(m)));
220         if (verbose) {
221             print_param_types("retrievable algorithm parameters",
222                               EVP_MD_gettable_params(m));
223             print_param_types("retrievable operation parameters",
224                               EVP_MD_CTX_gettable_params(m));
225             print_param_types("settable operation parameters",
226                               EVP_MD_CTX_settable_params(m));
227         }
228     }
229     sk_EVP_MD_pop_free(digests, EVP_MD_meth_free);
230 }
231
232 static void list_mac_fn(const EVP_MAC *m,
233                         const char *from, const char *to, void *arg)
234 {
235     if (m != NULL) {
236         BIO_printf(arg, "%s\n", EVP_MAC_name(m));
237     } else {
238         if (from == NULL)
239             from = "<undefined>";
240         if (to == NULL)
241             to = "<undefined>";
242         BIO_printf(arg, "%s => %s\n", from, to);
243     }
244 }
245
246 static void list_missing_help(void)
247 {
248     const FUNCTION *fp;
249     const OPTIONS *o;
250
251     for (fp = functions; fp->name != NULL; fp++) {
252         if ((o = fp->help) != NULL) {
253             /* If there is help, list what flags are not documented. */
254             for ( ; o->name != NULL; o++) {
255                 if (o->helpstr == NULL)
256                     BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
257             }
258         } else if (fp->func != dgst_main) {
259             /* If not aliased to the dgst command, */
260             BIO_printf(bio_out, "%s *\n", fp->name);
261         }
262     }
263 }
264
265 static void list_objects(void)
266 {
267     int max_nid = OBJ_new_nid(0);
268     int i;
269     char *oid_buf = NULL;
270     int oid_size = 0;
271
272     /* Skip 0, since that's NID_undef */
273     for (i = 1; i < max_nid; i++) {
274         const ASN1_OBJECT *obj = OBJ_nid2obj(i);
275         const char *sn = OBJ_nid2sn(i);
276         const char *ln = OBJ_nid2ln(i);
277         int n = 0;
278
279         /*
280          * If one of the retrieved objects somehow generated an error,
281          * we ignore it.  The check for NID_undef below will detect the
282          * error and simply skip to the next NID.
283          */
284         ERR_clear_error();
285
286         if (OBJ_obj2nid(obj) == NID_undef)
287             continue;
288
289         if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
290             BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
291             continue;
292         }
293         if (n < 0)
294             break;               /* Error */
295
296         if (n > oid_size) {
297             oid_buf = OPENSSL_realloc(oid_buf, n + 1);
298             if (oid_buf == NULL) {
299                 BIO_printf(bio_err, "ERROR: Memory allocation\n");
300                 break;           /* Error */
301             }
302             oid_size = n + 1;
303         }
304         if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
305             break;               /* Error */
306         if (ln == NULL || strcmp(sn, ln) == 0)
307             BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
308         else
309             BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
310     }
311
312     OPENSSL_free(oid_buf);
313 }
314
315 static void list_options_for_command(const char *command)
316 {
317     const FUNCTION *fp;
318     const OPTIONS *o;
319
320     for (fp = functions; fp->name != NULL; fp++)
321         if (strcmp(fp->name, command) == 0)
322             break;
323     if (fp->name == NULL) {
324         BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
325                 command);
326         return;
327     }
328
329     if ((o = fp->help) == NULL)
330         return;
331
332     for ( ; o->name != NULL; o++) {
333         if (o->name == OPT_HELP_STR
334                 || o->name == OPT_MORE_STR
335                 || o->name[0] == '\0')
336             continue;
337         BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);
338     }
339 }
340
341 static void list_type(FUNC_TYPE ft, int one)
342 {
343     FUNCTION *fp;
344     int i = 0;
345     DISPLAY_COLUMNS dc;
346
347     memset(&dc, 0, sizeof(dc));
348     if (!one)
349         calculate_columns(functions, &dc);
350
351     for (fp = functions; fp->name != NULL; fp++) {
352         if (fp->type != ft)
353             continue;
354         if (one) {
355             BIO_printf(bio_out, "%s\n", fp->name);
356         } else {
357             if (i % dc.columns == 0 && i > 0)
358                 BIO_printf(bio_out, "\n");
359             BIO_printf(bio_out, "%-*s", dc.width, fp->name);
360             i++;
361         }
362     }
363     if (!one)
364         BIO_printf(bio_out, "\n\n");
365 }
366
367 static void list_pkey(void)
368 {
369     int i;
370
371     for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
372         const EVP_PKEY_ASN1_METHOD *ameth;
373         int pkey_id, pkey_base_id, pkey_flags;
374         const char *pinfo, *pem_str;
375         ameth = EVP_PKEY_asn1_get0(i);
376         EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
377                                 &pinfo, &pem_str, ameth);
378         if (pkey_flags & ASN1_PKEY_ALIAS) {
379             BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
380             BIO_printf(bio_out, "\tAlias for: %s\n",
381                        OBJ_nid2ln(pkey_base_id));
382         } else {
383             BIO_printf(bio_out, "Name: %s\n", pinfo);
384             BIO_printf(bio_out, "\tType: %s Algorithm\n",
385                        pkey_flags & ASN1_PKEY_DYNAMIC ?
386                        "External" : "Builtin");
387             BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
388             if (pem_str == NULL)
389                 pem_str = "(none)";
390             BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
391         }
392
393     }
394 }
395
396 static void list_pkey_meth(void)
397 {
398     size_t i;
399     size_t meth_count = EVP_PKEY_meth_get_count();
400
401     for (i = 0; i < meth_count; i++) {
402         const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
403         int pkey_id, pkey_flags;
404
405         EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
406         BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
407         BIO_printf(bio_out, "\tType: %s Algorithm\n",
408                    pkey_flags & ASN1_PKEY_DYNAMIC ?  "External" : "Builtin");
409     }
410 }
411
412 static void list_engines(void)
413 {
414 #ifndef OPENSSL_NO_ENGINE
415     ENGINE *e;
416
417     BIO_puts(bio_out, "Engines:\n");
418     e = ENGINE_get_first();
419     while (e) {
420         BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
421         e = ENGINE_get_next(e);
422     }
423 #else
424     BIO_puts(bio_out, "Engine support is disabled.\n");
425 #endif
426 }
427
428 static void list_disabled(void)
429 {
430     BIO_puts(bio_out, "Disabled algorithms:\n");
431 #ifdef OPENSSL_NO_ARIA
432     BIO_puts(bio_out, "ARIA\n");
433 #endif
434 #ifdef OPENSSL_NO_BF
435     BIO_puts(bio_out, "BF\n");
436 #endif
437 #ifdef OPENSSL_NO_BLAKE2
438     BIO_puts(bio_out, "BLAKE2\n");
439 #endif
440 #ifdef OPENSSL_NO_CAMELLIA
441     BIO_puts(bio_out, "CAMELLIA\n");
442 #endif
443 #ifdef OPENSSL_NO_CAST
444     BIO_puts(bio_out, "CAST\n");
445 #endif
446 #ifdef OPENSSL_NO_CMAC
447     BIO_puts(bio_out, "CMAC\n");
448 #endif
449 #ifdef OPENSSL_NO_CMS
450     BIO_puts(bio_out, "CMS\n");
451 #endif
452 #ifdef OPENSSL_NO_COMP
453     BIO_puts(bio_out, "COMP\n");
454 #endif
455 #ifdef OPENSSL_NO_DES
456     BIO_puts(bio_out, "DES\n");
457 #endif
458 #ifdef OPENSSL_NO_DGRAM
459     BIO_puts(bio_out, "DGRAM\n");
460 #endif
461 #ifdef OPENSSL_NO_DH
462     BIO_puts(bio_out, "DH\n");
463 #endif
464 #ifdef OPENSSL_NO_DSA
465     BIO_puts(bio_out, "DSA\n");
466 #endif
467 #if defined(OPENSSL_NO_DTLS)
468     BIO_puts(bio_out, "DTLS\n");
469 #endif
470 #if defined(OPENSSL_NO_DTLS1)
471     BIO_puts(bio_out, "DTLS1\n");
472 #endif
473 #if defined(OPENSSL_NO_DTLS1_2)
474     BIO_puts(bio_out, "DTLS1_2\n");
475 #endif
476 #ifdef OPENSSL_NO_EC
477     BIO_puts(bio_out, "EC\n");
478 #endif
479 #ifdef OPENSSL_NO_EC2M
480     BIO_puts(bio_out, "EC2M\n");
481 #endif
482 #ifdef OPENSSL_NO_ENGINE
483     BIO_puts(bio_out, "ENGINE\n");
484 #endif
485 #ifdef OPENSSL_NO_GOST
486     BIO_puts(bio_out, "GOST\n");
487 #endif
488 #ifdef OPENSSL_NO_IDEA
489     BIO_puts(bio_out, "IDEA\n");
490 #endif
491 #ifdef OPENSSL_NO_MD2
492     BIO_puts(bio_out, "MD2\n");
493 #endif
494 #ifdef OPENSSL_NO_MD4
495     BIO_puts(bio_out, "MD4\n");
496 #endif
497 #ifdef OPENSSL_NO_MD5
498     BIO_puts(bio_out, "MD5\n");
499 #endif
500 #ifdef OPENSSL_NO_MDC2
501     BIO_puts(bio_out, "MDC2\n");
502 #endif
503 #ifdef OPENSSL_NO_OCB
504     BIO_puts(bio_out, "OCB\n");
505 #endif
506 #ifdef OPENSSL_NO_OCSP
507     BIO_puts(bio_out, "OCSP\n");
508 #endif
509 #ifdef OPENSSL_NO_PSK
510     BIO_puts(bio_out, "PSK\n");
511 #endif
512 #ifdef OPENSSL_NO_RC2
513     BIO_puts(bio_out, "RC2\n");
514 #endif
515 #ifdef OPENSSL_NO_RC4
516     BIO_puts(bio_out, "RC4\n");
517 #endif
518 #ifdef OPENSSL_NO_RC5
519     BIO_puts(bio_out, "RC5\n");
520 #endif
521 #ifdef OPENSSL_NO_RMD160
522     BIO_puts(bio_out, "RMD160\n");
523 #endif
524 #ifdef OPENSSL_NO_RSA
525     BIO_puts(bio_out, "RSA\n");
526 #endif
527 #ifdef OPENSSL_NO_SCRYPT
528     BIO_puts(bio_out, "SCRYPT\n");
529 #endif
530 #ifdef OPENSSL_NO_SCTP
531     BIO_puts(bio_out, "SCTP\n");
532 #endif
533 #ifdef OPENSSL_NO_SEED
534     BIO_puts(bio_out, "SEED\n");
535 #endif
536 #ifdef OPENSSL_NO_SM2
537     BIO_puts(bio_out, "SM2\n");
538 #endif
539 #ifdef OPENSSL_NO_SM3
540     BIO_puts(bio_out, "SM3\n");
541 #endif
542 #ifdef OPENSSL_NO_SM4
543     BIO_puts(bio_out, "SM4\n");
544 #endif
545 #ifdef OPENSSL_NO_SOCK
546     BIO_puts(bio_out, "SOCK\n");
547 #endif
548 #ifdef OPENSSL_NO_SRP
549     BIO_puts(bio_out, "SRP\n");
550 #endif
551 #ifdef OPENSSL_NO_SRTP
552     BIO_puts(bio_out, "SRTP\n");
553 #endif
554 #ifdef OPENSSL_NO_SSL3
555     BIO_puts(bio_out, "SSL3\n");
556 #endif
557 #ifdef OPENSSL_NO_TLS1
558     BIO_puts(bio_out, "TLS1\n");
559 #endif
560 #ifdef OPENSSL_NO_TLS1_1
561     BIO_puts(bio_out, "TLS1_1\n");
562 #endif
563 #ifdef OPENSSL_NO_TLS1_2
564     BIO_puts(bio_out, "TLS1_2\n");
565 #endif
566 #ifdef OPENSSL_NO_WHIRLPOOL
567     BIO_puts(bio_out, "WHIRLPOOL\n");
568 #endif
569 #ifndef ZLIB
570     BIO_puts(bio_out, "ZLIB\n");
571 #endif
572 }
573
574 /* Unified enum for help and list commands. */
575 typedef enum HELPLIST_CHOICE {
576     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE, OPT_VERBOSE,
577     OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
578     OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
579     OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
580     OPT_MISSING_HELP, OPT_OBJECTS
581 } HELPLIST_CHOICE;
582
583 const OPTIONS list_options[] = {
584     {"help", OPT_HELP, '-', "Display this summary"},
585     {"1", OPT_ONE, '-', "List in one column"},
586     {"verbose", OPT_VERBOSE, '-', "Verbose listing"},
587     {"commands", OPT_COMMANDS, '-', "List of standard commands"},
588     {"digest-commands", OPT_DIGEST_COMMANDS, '-',
589      "List of message digest commands"},
590     {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
591      "List of message digest algorithms"},
592     {"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
593      "List of message authentication code algorithms"},
594     {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
595     {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
596      "List of cipher algorithms"},
597     {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
598      "List of public key algorithms"},
599     {"public-key-methods", OPT_PK_METHOD, '-',
600      "List of public key methods"},
601     {"engines", OPT_ENGINES, '-',
602      "List of loaded engines"},
603     {"disabled", OPT_DISABLED, '-',
604      "List of disabled features"},
605     {"missing-help", OPT_MISSING_HELP, '-',
606      "List missing detailed help strings"},
607     {"options", OPT_OPTIONS, 's',
608      "List options for specified command"},
609     {"objects", OPT_OBJECTS, '-',
610      "List built in objects (OID<->name mappings)"},
611     {NULL}
612 };
613
614 int list_main(int argc, char **argv)
615 {
616     char *prog;
617     HELPLIST_CHOICE o;
618     int one = 0, done = 0;
619     struct {
620         unsigned int commands:1;
621         unsigned int digest_commands:1;
622         unsigned int digest_algorithms:1;
623         unsigned int mac_algorithms:1;
624         unsigned int cipher_commands:1;
625         unsigned int cipher_algorithms:1;
626         unsigned int pk_algorithms:1;
627         unsigned int pk_method:1;
628         unsigned int engines:1;
629         unsigned int disabled:1;
630         unsigned int missing_help:1;
631         unsigned int objects:1;
632         unsigned int options:1;
633     } todo = { 0, };
634
635     verbose = 0;                 /* Clear a possible previous call */
636
637     prog = opt_init(argc, argv, list_options);
638     while ((o = opt_next()) != OPT_EOF) {
639         switch (o) {
640         case OPT_EOF:  /* Never hit, but suppresses warning */
641         case OPT_ERR:
642 opthelp:
643             BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
644             return 1;
645         case OPT_HELP:
646             opt_help(list_options);
647             break;
648         case OPT_ONE:
649             one = 1;
650             break;
651         case OPT_COMMANDS:
652             todo.commands = 1;
653             break;
654         case OPT_DIGEST_COMMANDS:
655             todo.digest_commands = 1;
656             break;
657         case OPT_DIGEST_ALGORITHMS:
658             todo.digest_algorithms = 1;
659             break;
660         case OPT_MAC_ALGORITHMS:
661             todo.mac_algorithms = 1;
662             break;
663         case OPT_CIPHER_COMMANDS:
664             todo.cipher_commands = 1;
665             break;
666         case OPT_CIPHER_ALGORITHMS:
667             todo.cipher_algorithms = 1;
668             break;
669         case OPT_PK_ALGORITHMS:
670             todo.pk_algorithms = 1;
671             break;
672         case OPT_PK_METHOD:
673             todo.pk_method = 1;
674             break;
675         case OPT_ENGINES:
676             todo.engines = 1;
677             break;
678         case OPT_DISABLED:
679             todo.disabled = 1;
680             break;
681         case OPT_MISSING_HELP:
682             todo.missing_help = 1;
683             break;
684         case OPT_OBJECTS:
685             todo.objects = 1;
686             break;
687         case OPT_OPTIONS:
688             list_options_for_command(opt_arg());
689             break;
690         case OPT_VERBOSE:
691             verbose = 1;
692             break;
693         }
694         done = 1;
695     }
696     if (opt_num_rest() != 0) {
697         BIO_printf(bio_err, "Extra arguments given.\n");
698         goto opthelp;
699     }
700
701     if (todo.commands)
702         list_type(FT_general, one);
703     if (todo.digest_commands)
704         list_type(FT_md, one);
705     if (todo.digest_algorithms)
706         list_digests();
707     if (todo.mac_algorithms)
708         EVP_MAC_do_all_sorted(list_mac_fn, bio_out);
709     if (todo.cipher_commands)
710         list_type(FT_cipher, one);
711     if (todo.cipher_algorithms)
712         list_ciphers();
713     if (todo.pk_algorithms)
714         list_pkey();
715     if (todo.pk_method)
716         list_pkey_meth();
717     if (todo.engines)
718         list_engines();
719     if (todo.disabled)
720         list_disabled();
721     if (todo.missing_help)
722         list_missing_help();
723     if (todo.objects)
724         list_objects();
725
726     if (!done)
727         goto opthelp;
728
729     return 0;
730 }