]> git.ipfire.org Git - thirdparty/openssl.git/blob - apps/list.c
Prepare EVP_MAC infrastructure for moving all MACs to providers
[thirdparty/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 #if 0 /* Temporarly disabled */
233 static void list_mac_fn(const EVP_MAC *m,
234 const char *from, const char *to, void *arg)
235 {
236 if (m != NULL) {
237 BIO_printf(arg, "%s\n", EVP_MAC_name(m));
238 } else {
239 if (from == NULL)
240 from = "<undefined>";
241 if (to == NULL)
242 to = "<undefined>";
243 BIO_printf(arg, "%s => %s\n", from, to);
244 }
245 }
246 #endif
247
248 static void list_missing_help(void)
249 {
250 const FUNCTION *fp;
251 const OPTIONS *o;
252
253 for (fp = functions; fp->name != NULL; fp++) {
254 if ((o = fp->help) != NULL) {
255 /* If there is help, list what flags are not documented. */
256 for ( ; o->name != NULL; o++) {
257 if (o->helpstr == NULL)
258 BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
259 }
260 } else if (fp->func != dgst_main) {
261 /* If not aliased to the dgst command, */
262 BIO_printf(bio_out, "%s *\n", fp->name);
263 }
264 }
265 }
266
267 static void list_objects(void)
268 {
269 int max_nid = OBJ_new_nid(0);
270 int i;
271 char *oid_buf = NULL;
272 int oid_size = 0;
273
274 /* Skip 0, since that's NID_undef */
275 for (i = 1; i < max_nid; i++) {
276 const ASN1_OBJECT *obj = OBJ_nid2obj(i);
277 const char *sn = OBJ_nid2sn(i);
278 const char *ln = OBJ_nid2ln(i);
279 int n = 0;
280
281 /*
282 * If one of the retrieved objects somehow generated an error,
283 * we ignore it. The check for NID_undef below will detect the
284 * error and simply skip to the next NID.
285 */
286 ERR_clear_error();
287
288 if (OBJ_obj2nid(obj) == NID_undef)
289 continue;
290
291 if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
292 BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
293 continue;
294 }
295 if (n < 0)
296 break; /* Error */
297
298 if (n > oid_size) {
299 oid_buf = OPENSSL_realloc(oid_buf, n + 1);
300 if (oid_buf == NULL) {
301 BIO_printf(bio_err, "ERROR: Memory allocation\n");
302 break; /* Error */
303 }
304 oid_size = n + 1;
305 }
306 if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
307 break; /* Error */
308 if (ln == NULL || strcmp(sn, ln) == 0)
309 BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
310 else
311 BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
312 }
313
314 OPENSSL_free(oid_buf);
315 }
316
317 static void list_options_for_command(const char *command)
318 {
319 const FUNCTION *fp;
320 const OPTIONS *o;
321
322 for (fp = functions; fp->name != NULL; fp++)
323 if (strcmp(fp->name, command) == 0)
324 break;
325 if (fp->name == NULL) {
326 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
327 command);
328 return;
329 }
330
331 if ((o = fp->help) == NULL)
332 return;
333
334 for ( ; o->name != NULL; o++) {
335 if (o->name == OPT_HELP_STR
336 || o->name == OPT_MORE_STR
337 || o->name[0] == '\0')
338 continue;
339 BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);
340 }
341 }
342
343 static void list_type(FUNC_TYPE ft, int one)
344 {
345 FUNCTION *fp;
346 int i = 0;
347 DISPLAY_COLUMNS dc;
348
349 memset(&dc, 0, sizeof(dc));
350 if (!one)
351 calculate_columns(functions, &dc);
352
353 for (fp = functions; fp->name != NULL; fp++) {
354 if (fp->type != ft)
355 continue;
356 if (one) {
357 BIO_printf(bio_out, "%s\n", fp->name);
358 } else {
359 if (i % dc.columns == 0 && i > 0)
360 BIO_printf(bio_out, "\n");
361 BIO_printf(bio_out, "%-*s", dc.width, fp->name);
362 i++;
363 }
364 }
365 if (!one)
366 BIO_printf(bio_out, "\n\n");
367 }
368
369 static void list_pkey(void)
370 {
371 int i;
372
373 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
374 const EVP_PKEY_ASN1_METHOD *ameth;
375 int pkey_id, pkey_base_id, pkey_flags;
376 const char *pinfo, *pem_str;
377 ameth = EVP_PKEY_asn1_get0(i);
378 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
379 &pinfo, &pem_str, ameth);
380 if (pkey_flags & ASN1_PKEY_ALIAS) {
381 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
382 BIO_printf(bio_out, "\tAlias for: %s\n",
383 OBJ_nid2ln(pkey_base_id));
384 } else {
385 BIO_printf(bio_out, "Name: %s\n", pinfo);
386 BIO_printf(bio_out, "\tType: %s Algorithm\n",
387 pkey_flags & ASN1_PKEY_DYNAMIC ?
388 "External" : "Builtin");
389 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
390 if (pem_str == NULL)
391 pem_str = "(none)";
392 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
393 }
394
395 }
396 }
397
398 static void list_pkey_meth(void)
399 {
400 size_t i;
401 size_t meth_count = EVP_PKEY_meth_get_count();
402
403 for (i = 0; i < meth_count; i++) {
404 const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
405 int pkey_id, pkey_flags;
406
407 EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
408 BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
409 BIO_printf(bio_out, "\tType: %s Algorithm\n",
410 pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
411 }
412 }
413
414 static void list_engines(void)
415 {
416 #ifndef OPENSSL_NO_ENGINE
417 ENGINE *e;
418
419 BIO_puts(bio_out, "Engines:\n");
420 e = ENGINE_get_first();
421 while (e) {
422 BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
423 e = ENGINE_get_next(e);
424 }
425 #else
426 BIO_puts(bio_out, "Engine support is disabled.\n");
427 #endif
428 }
429
430 static void list_disabled(void)
431 {
432 BIO_puts(bio_out, "Disabled algorithms:\n");
433 #ifdef OPENSSL_NO_ARIA
434 BIO_puts(bio_out, "ARIA\n");
435 #endif
436 #ifdef OPENSSL_NO_BF
437 BIO_puts(bio_out, "BF\n");
438 #endif
439 #ifdef OPENSSL_NO_BLAKE2
440 BIO_puts(bio_out, "BLAKE2\n");
441 #endif
442 #ifdef OPENSSL_NO_CAMELLIA
443 BIO_puts(bio_out, "CAMELLIA\n");
444 #endif
445 #ifdef OPENSSL_NO_CAST
446 BIO_puts(bio_out, "CAST\n");
447 #endif
448 #ifdef OPENSSL_NO_CMAC
449 BIO_puts(bio_out, "CMAC\n");
450 #endif
451 #ifdef OPENSSL_NO_CMS
452 BIO_puts(bio_out, "CMS\n");
453 #endif
454 #ifdef OPENSSL_NO_COMP
455 BIO_puts(bio_out, "COMP\n");
456 #endif
457 #ifdef OPENSSL_NO_DES
458 BIO_puts(bio_out, "DES\n");
459 #endif
460 #ifdef OPENSSL_NO_DGRAM
461 BIO_puts(bio_out, "DGRAM\n");
462 #endif
463 #ifdef OPENSSL_NO_DH
464 BIO_puts(bio_out, "DH\n");
465 #endif
466 #ifdef OPENSSL_NO_DSA
467 BIO_puts(bio_out, "DSA\n");
468 #endif
469 #if defined(OPENSSL_NO_DTLS)
470 BIO_puts(bio_out, "DTLS\n");
471 #endif
472 #if defined(OPENSSL_NO_DTLS1)
473 BIO_puts(bio_out, "DTLS1\n");
474 #endif
475 #if defined(OPENSSL_NO_DTLS1_2)
476 BIO_puts(bio_out, "DTLS1_2\n");
477 #endif
478 #ifdef OPENSSL_NO_EC
479 BIO_puts(bio_out, "EC\n");
480 #endif
481 #ifdef OPENSSL_NO_EC2M
482 BIO_puts(bio_out, "EC2M\n");
483 #endif
484 #ifdef OPENSSL_NO_ENGINE
485 BIO_puts(bio_out, "ENGINE\n");
486 #endif
487 #ifdef OPENSSL_NO_GOST
488 BIO_puts(bio_out, "GOST\n");
489 #endif
490 #ifdef OPENSSL_NO_IDEA
491 BIO_puts(bio_out, "IDEA\n");
492 #endif
493 #ifdef OPENSSL_NO_MD2
494 BIO_puts(bio_out, "MD2\n");
495 #endif
496 #ifdef OPENSSL_NO_MD4
497 BIO_puts(bio_out, "MD4\n");
498 #endif
499 #ifdef OPENSSL_NO_MD5
500 BIO_puts(bio_out, "MD5\n");
501 #endif
502 #ifdef OPENSSL_NO_MDC2
503 BIO_puts(bio_out, "MDC2\n");
504 #endif
505 #ifdef OPENSSL_NO_OCB
506 BIO_puts(bio_out, "OCB\n");
507 #endif
508 #ifdef OPENSSL_NO_OCSP
509 BIO_puts(bio_out, "OCSP\n");
510 #endif
511 #ifdef OPENSSL_NO_PSK
512 BIO_puts(bio_out, "PSK\n");
513 #endif
514 #ifdef OPENSSL_NO_RC2
515 BIO_puts(bio_out, "RC2\n");
516 #endif
517 #ifdef OPENSSL_NO_RC4
518 BIO_puts(bio_out, "RC4\n");
519 #endif
520 #ifdef OPENSSL_NO_RC5
521 BIO_puts(bio_out, "RC5\n");
522 #endif
523 #ifdef OPENSSL_NO_RMD160
524 BIO_puts(bio_out, "RMD160\n");
525 #endif
526 #ifdef OPENSSL_NO_RSA
527 BIO_puts(bio_out, "RSA\n");
528 #endif
529 #ifdef OPENSSL_NO_SCRYPT
530 BIO_puts(bio_out, "SCRYPT\n");
531 #endif
532 #ifdef OPENSSL_NO_SCTP
533 BIO_puts(bio_out, "SCTP\n");
534 #endif
535 #ifdef OPENSSL_NO_SEED
536 BIO_puts(bio_out, "SEED\n");
537 #endif
538 #ifdef OPENSSL_NO_SM2
539 BIO_puts(bio_out, "SM2\n");
540 #endif
541 #ifdef OPENSSL_NO_SM3
542 BIO_puts(bio_out, "SM3\n");
543 #endif
544 #ifdef OPENSSL_NO_SM4
545 BIO_puts(bio_out, "SM4\n");
546 #endif
547 #ifdef OPENSSL_NO_SOCK
548 BIO_puts(bio_out, "SOCK\n");
549 #endif
550 #ifdef OPENSSL_NO_SRP
551 BIO_puts(bio_out, "SRP\n");
552 #endif
553 #ifdef OPENSSL_NO_SRTP
554 BIO_puts(bio_out, "SRTP\n");
555 #endif
556 #ifdef OPENSSL_NO_SSL3
557 BIO_puts(bio_out, "SSL3\n");
558 #endif
559 #ifdef OPENSSL_NO_TLS1
560 BIO_puts(bio_out, "TLS1\n");
561 #endif
562 #ifdef OPENSSL_NO_TLS1_1
563 BIO_puts(bio_out, "TLS1_1\n");
564 #endif
565 #ifdef OPENSSL_NO_TLS1_2
566 BIO_puts(bio_out, "TLS1_2\n");
567 #endif
568 #ifdef OPENSSL_NO_WHIRLPOOL
569 BIO_puts(bio_out, "WHIRLPOOL\n");
570 #endif
571 #ifndef ZLIB
572 BIO_puts(bio_out, "ZLIB\n");
573 #endif
574 }
575
576 /* Unified enum for help and list commands. */
577 typedef enum HELPLIST_CHOICE {
578 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE, OPT_VERBOSE,
579 OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
580 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
581 OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
582 OPT_MISSING_HELP, OPT_OBJECTS
583 } HELPLIST_CHOICE;
584
585 const OPTIONS list_options[] = {
586 {"help", OPT_HELP, '-', "Display this summary"},
587 {"1", OPT_ONE, '-', "List in one column"},
588 {"verbose", OPT_VERBOSE, '-', "Verbose listing"},
589 {"commands", OPT_COMMANDS, '-', "List of standard commands"},
590 {"digest-commands", OPT_DIGEST_COMMANDS, '-',
591 "List of message digest commands"},
592 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
593 "List of message digest algorithms"},
594 {"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
595 "List of message authentication code algorithms"},
596 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
597 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
598 "List of cipher algorithms"},
599 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
600 "List of public key algorithms"},
601 {"public-key-methods", OPT_PK_METHOD, '-',
602 "List of public key methods"},
603 {"engines", OPT_ENGINES, '-',
604 "List of loaded engines"},
605 {"disabled", OPT_DISABLED, '-',
606 "List of disabled features"},
607 {"missing-help", OPT_MISSING_HELP, '-',
608 "List missing detailed help strings"},
609 {"options", OPT_OPTIONS, 's',
610 "List options for specified command"},
611 {"objects", OPT_OBJECTS, '-',
612 "List built in objects (OID<->name mappings)"},
613 {NULL}
614 };
615
616 int list_main(int argc, char **argv)
617 {
618 char *prog;
619 HELPLIST_CHOICE o;
620 int one = 0, done = 0;
621 struct {
622 unsigned int commands:1;
623 unsigned int digest_commands:1;
624 unsigned int digest_algorithms:1;
625 unsigned int mac_algorithms:1;
626 unsigned int cipher_commands:1;
627 unsigned int cipher_algorithms:1;
628 unsigned int pk_algorithms:1;
629 unsigned int pk_method:1;
630 unsigned int engines:1;
631 unsigned int disabled:1;
632 unsigned int missing_help:1;
633 unsigned int objects:1;
634 unsigned int options:1;
635 } todo = { 0, };
636
637 verbose = 0; /* Clear a possible previous call */
638
639 prog = opt_init(argc, argv, list_options);
640 while ((o = opt_next()) != OPT_EOF) {
641 switch (o) {
642 case OPT_EOF: /* Never hit, but suppresses warning */
643 case OPT_ERR:
644 opthelp:
645 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
646 return 1;
647 case OPT_HELP:
648 opt_help(list_options);
649 break;
650 case OPT_ONE:
651 one = 1;
652 break;
653 case OPT_COMMANDS:
654 todo.commands = 1;
655 break;
656 case OPT_DIGEST_COMMANDS:
657 todo.digest_commands = 1;
658 break;
659 case OPT_DIGEST_ALGORITHMS:
660 todo.digest_algorithms = 1;
661 break;
662 case OPT_MAC_ALGORITHMS:
663 todo.mac_algorithms = 1;
664 break;
665 case OPT_CIPHER_COMMANDS:
666 todo.cipher_commands = 1;
667 break;
668 case OPT_CIPHER_ALGORITHMS:
669 todo.cipher_algorithms = 1;
670 break;
671 case OPT_PK_ALGORITHMS:
672 todo.pk_algorithms = 1;
673 break;
674 case OPT_PK_METHOD:
675 todo.pk_method = 1;
676 break;
677 case OPT_ENGINES:
678 todo.engines = 1;
679 break;
680 case OPT_DISABLED:
681 todo.disabled = 1;
682 break;
683 case OPT_MISSING_HELP:
684 todo.missing_help = 1;
685 break;
686 case OPT_OBJECTS:
687 todo.objects = 1;
688 break;
689 case OPT_OPTIONS:
690 list_options_for_command(opt_arg());
691 break;
692 case OPT_VERBOSE:
693 verbose = 1;
694 break;
695 }
696 done = 1;
697 }
698 if (opt_num_rest() != 0) {
699 BIO_printf(bio_err, "Extra arguments given.\n");
700 goto opthelp;
701 }
702
703 if (todo.commands)
704 list_type(FT_general, one);
705 if (todo.digest_commands)
706 list_type(FT_md, one);
707 if (todo.digest_algorithms)
708 list_digests();
709 #if 0 /* Temporarly disabled */
710 if (todo.mac_algorithms)
711 EVP_MAC_do_all_sorted(list_mac_fn, bio_out);
712 #endif
713 if (todo.cipher_commands)
714 list_type(FT_cipher, one);
715 if (todo.cipher_algorithms)
716 list_ciphers();
717 if (todo.pk_algorithms)
718 list_pkey();
719 if (todo.pk_method)
720 list_pkey_meth();
721 if (todo.engines)
722 list_engines();
723 if (todo.disabled)
724 list_disabled();
725 if (todo.missing_help)
726 list_missing_help();
727 if (todo.objects)
728 list_objects();
729
730 if (!done)
731 goto opthelp;
732
733 return 0;
734 }