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