]>
git.ipfire.org Git - thirdparty/openssl.git/blob - apps/list.c
2 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
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
10 /* We need to use some deprecated APIs */
11 #define OPENSSL_SUPPRESS_DEPRECATED
14 #include <openssl/evp.h>
15 #include <openssl/err.h>
16 #include <openssl/provider.h>
17 #include <openssl/safestack.h>
18 #include <openssl/kdf.h>
19 #include <openssl/encoder.h>
20 #include <openssl/decoder.h>
21 #include <openssl/core_names.h>
23 #include "app_params.h"
28 static int verbose
= 0;
30 static void legacy_cipher_fn(const EVP_CIPHER
*c
,
31 const char *from
, const char *to
, void *arg
)
34 BIO_printf(arg
, " %s\n", EVP_CIPHER_name(c
));
40 BIO_printf(arg
, " %s => %s\n", from
, to
);
44 DEFINE_STACK_OF(EVP_CIPHER
)
45 static int cipher_cmp(const EVP_CIPHER
* const *a
,
46 const EVP_CIPHER
* const *b
)
48 int ret
= EVP_CIPHER_number(*a
) - EVP_CIPHER_number(*b
);
51 ret
= strcmp(OSSL_PROVIDER_name(EVP_CIPHER_provider(*a
)),
52 OSSL_PROVIDER_name(EVP_CIPHER_provider(*b
)));
57 static void collect_ciphers(EVP_CIPHER
*cipher
, void *stack
)
59 STACK_OF(EVP_CIPHER
) *cipher_stack
= stack
;
61 if (sk_EVP_CIPHER_push(cipher_stack
, cipher
) > 0)
62 EVP_CIPHER_up_ref(cipher
);
65 static void list_ciphers(void)
67 STACK_OF(EVP_CIPHER
) *ciphers
= sk_EVP_CIPHER_new(cipher_cmp
);
70 if (ciphers
== NULL
) {
71 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
74 BIO_printf(bio_out
, "Legacy:\n");
75 EVP_CIPHER_do_all_sorted(legacy_cipher_fn
, bio_out
);
77 BIO_printf(bio_out
, "Provided:\n");
78 EVP_CIPHER_do_all_provided(NULL
, collect_ciphers
, ciphers
);
79 sk_EVP_CIPHER_sort(ciphers
);
80 for (i
= 0; i
< sk_EVP_CIPHER_num(ciphers
); i
++) {
81 const EVP_CIPHER
*c
= sk_EVP_CIPHER_value(ciphers
, i
);
82 STACK_OF(OPENSSL_CSTRING
) *names
=
83 sk_OPENSSL_CSTRING_new(name_cmp
);
85 EVP_CIPHER_names_do_all(c
, collect_names
, names
);
87 BIO_printf(bio_out
, " ");
88 print_names(bio_out
, names
);
89 BIO_printf(bio_out
, " @ %s\n",
90 OSSL_PROVIDER_name(EVP_CIPHER_provider(c
)));
92 sk_OPENSSL_CSTRING_free(names
);
95 print_param_types("retrievable algorithm parameters",
96 EVP_CIPHER_gettable_params(c
), 4);
97 print_param_types("retrievable operation parameters",
98 EVP_CIPHER_gettable_ctx_params(c
), 4);
99 print_param_types("settable operation parameters",
100 EVP_CIPHER_settable_ctx_params(c
), 4);
103 sk_EVP_CIPHER_pop_free(ciphers
, EVP_CIPHER_free
);
106 static void list_md_fn(const EVP_MD
*m
,
107 const char *from
, const char *to
, void *arg
)
110 BIO_printf(arg
, " %s\n", EVP_MD_name(m
));
113 from
= "<undefined>";
116 BIO_printf((BIO
*)arg
, " %s => %s\n", from
, to
);
120 DEFINE_STACK_OF(EVP_MD
)
121 static int md_cmp(const EVP_MD
* const *a
, const EVP_MD
* const *b
)
123 int ret
= EVP_MD_number(*a
) - EVP_MD_number(*b
);
126 ret
= strcmp(OSSL_PROVIDER_name(EVP_MD_provider(*a
)),
127 OSSL_PROVIDER_name(EVP_MD_provider(*b
)));
132 static void collect_digests(EVP_MD
*md
, void *stack
)
134 STACK_OF(EVP_MD
) *digest_stack
= stack
;
136 if (sk_EVP_MD_push(digest_stack
, md
) > 0)
140 static void list_digests(void)
142 STACK_OF(EVP_MD
) *digests
= sk_EVP_MD_new(md_cmp
);
145 if (digests
== NULL
) {
146 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
149 BIO_printf(bio_out
, "Legacy:\n");
150 EVP_MD_do_all_sorted(list_md_fn
, bio_out
);
152 BIO_printf(bio_out
, "Provided:\n");
153 EVP_MD_do_all_provided(NULL
, collect_digests
, digests
);
154 sk_EVP_MD_sort(digests
);
155 for (i
= 0; i
< sk_EVP_MD_num(digests
); i
++) {
156 const EVP_MD
*m
= sk_EVP_MD_value(digests
, i
);
157 STACK_OF(OPENSSL_CSTRING
) *names
=
158 sk_OPENSSL_CSTRING_new(name_cmp
);
160 EVP_MD_names_do_all(m
, collect_names
, names
);
162 BIO_printf(bio_out
, " ");
163 print_names(bio_out
, names
);
164 BIO_printf(bio_out
, " @ %s\n",
165 OSSL_PROVIDER_name(EVP_MD_provider(m
)));
167 sk_OPENSSL_CSTRING_free(names
);
170 print_param_types("retrievable algorithm parameters",
171 EVP_MD_gettable_params(m
), 4);
172 print_param_types("retrievable operation parameters",
173 EVP_MD_gettable_ctx_params(m
), 4);
174 print_param_types("settable operation parameters",
175 EVP_MD_settable_ctx_params(m
), 4);
178 sk_EVP_MD_pop_free(digests
, EVP_MD_free
);
181 DEFINE_STACK_OF(EVP_MAC
)
182 static int mac_cmp(const EVP_MAC
* const *a
, const EVP_MAC
* const *b
)
184 int ret
= EVP_MAC_number(*a
) - EVP_MAC_number(*b
);
187 ret
= strcmp(OSSL_PROVIDER_name(EVP_MAC_provider(*a
)),
188 OSSL_PROVIDER_name(EVP_MAC_provider(*b
)));
193 static void collect_macs(EVP_MAC
*mac
, void *stack
)
195 STACK_OF(EVP_MAC
) *mac_stack
= stack
;
197 if (sk_EVP_MAC_push(mac_stack
, mac
) > 0)
201 static void list_macs(void)
203 STACK_OF(EVP_MAC
) *macs
= sk_EVP_MAC_new(mac_cmp
);
207 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
210 BIO_printf(bio_out
, "Provided MACs:\n");
211 EVP_MAC_do_all_provided(NULL
, collect_macs
, macs
);
212 sk_EVP_MAC_sort(macs
);
213 for (i
= 0; i
< sk_EVP_MAC_num(macs
); i
++) {
214 const EVP_MAC
*m
= sk_EVP_MAC_value(macs
, i
);
215 STACK_OF(OPENSSL_CSTRING
) *names
=
216 sk_OPENSSL_CSTRING_new(name_cmp
);
218 EVP_MAC_names_do_all(m
, collect_names
, names
);
220 BIO_printf(bio_out
, " ");
221 print_names(bio_out
, names
);
222 BIO_printf(bio_out
, " @ %s\n",
223 OSSL_PROVIDER_name(EVP_MAC_provider(m
)));
225 sk_OPENSSL_CSTRING_free(names
);
228 print_param_types("retrievable algorithm parameters",
229 EVP_MAC_gettable_params(m
), 4);
230 print_param_types("retrievable operation parameters",
231 EVP_MAC_gettable_ctx_params(m
), 4);
232 print_param_types("settable operation parameters",
233 EVP_MAC_settable_ctx_params(m
), 4);
236 sk_EVP_MAC_pop_free(macs
, EVP_MAC_free
);
242 DEFINE_STACK_OF(EVP_KDF
)
243 static int kdf_cmp(const EVP_KDF
* const *a
, const EVP_KDF
* const *b
)
245 int ret
= EVP_KDF_number(*a
) - EVP_KDF_number(*b
);
248 ret
= strcmp(OSSL_PROVIDER_name(EVP_KDF_provider(*a
)),
249 OSSL_PROVIDER_name(EVP_KDF_provider(*b
)));
254 static void collect_kdfs(EVP_KDF
*kdf
, void *stack
)
256 STACK_OF(EVP_KDF
) *kdf_stack
= stack
;
258 sk_EVP_KDF_push(kdf_stack
, kdf
);
262 static void list_kdfs(void)
264 STACK_OF(EVP_KDF
) *kdfs
= sk_EVP_KDF_new(kdf_cmp
);
268 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
271 BIO_printf(bio_out
, "Provided KDFs and PDFs:\n");
272 EVP_KDF_do_all_provided(NULL
, collect_kdfs
, kdfs
);
273 sk_EVP_KDF_sort(kdfs
);
274 for (i
= 0; i
< sk_EVP_KDF_num(kdfs
); i
++) {
275 const EVP_KDF
*k
= sk_EVP_KDF_value(kdfs
, i
);
276 STACK_OF(OPENSSL_CSTRING
) *names
=
277 sk_OPENSSL_CSTRING_new(name_cmp
);
279 EVP_KDF_names_do_all(k
, collect_names
, names
);
281 BIO_printf(bio_out
, " ");
282 print_names(bio_out
, names
);
283 BIO_printf(bio_out
, " @ %s\n",
284 OSSL_PROVIDER_name(EVP_KDF_provider(k
)));
286 sk_OPENSSL_CSTRING_free(names
);
289 print_param_types("retrievable algorithm parameters",
290 EVP_KDF_gettable_params(k
), 4);
291 print_param_types("retrievable operation parameters",
292 EVP_KDF_gettable_ctx_params(k
), 4);
293 print_param_types("settable operation parameters",
294 EVP_KDF_settable_ctx_params(k
), 4);
297 sk_EVP_KDF_pop_free(kdfs
, EVP_KDF_free
);
303 DEFINE_STACK_OF(EVP_RAND
)
305 static int rand_cmp(const EVP_RAND
* const *a
, const EVP_RAND
* const *b
)
307 int ret
= strcasecmp(EVP_RAND_name(*a
), EVP_RAND_name(*b
));
310 ret
= strcmp(OSSL_PROVIDER_name(EVP_RAND_provider(*a
)),
311 OSSL_PROVIDER_name(EVP_RAND_provider(*b
)));
316 static void collect_rands(EVP_RAND
*rand
, void *stack
)
318 STACK_OF(EVP_RAND
) *rand_stack
= stack
;
320 sk_EVP_RAND_push(rand_stack
, rand
);
321 EVP_RAND_up_ref(rand
);
324 static void list_random_generators(void)
326 STACK_OF(EVP_RAND
) *rands
= sk_EVP_RAND_new(rand_cmp
);
330 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
333 BIO_printf(bio_out
, "Provided RNGs and seed sources:\n");
334 EVP_RAND_do_all_provided(NULL
, collect_rands
, rands
);
335 sk_EVP_RAND_sort(rands
);
336 for (i
= 0; i
< sk_EVP_RAND_num(rands
); i
++) {
337 const EVP_RAND
*m
= sk_EVP_RAND_value(rands
, i
);
339 BIO_printf(bio_out
, " %s", EVP_RAND_name(m
));
340 BIO_printf(bio_out
, " @ %s\n",
341 OSSL_PROVIDER_name(EVP_RAND_provider(m
)));
344 print_param_types("retrievable algorithm parameters",
345 EVP_RAND_gettable_params(m
), 4);
346 print_param_types("retrievable operation parameters",
347 EVP_RAND_gettable_ctx_params(m
), 4);
348 print_param_types("settable operation parameters",
349 EVP_RAND_settable_ctx_params(m
), 4);
352 sk_EVP_RAND_pop_free(rands
, EVP_RAND_free
);
358 DEFINE_STACK_OF(OSSL_ENCODER
)
359 static int encoder_cmp(const OSSL_ENCODER
* const *a
,
360 const OSSL_ENCODER
* const *b
)
362 int ret
= OSSL_ENCODER_number(*a
) - OSSL_ENCODER_number(*b
);
365 ret
= strcmp(OSSL_PROVIDER_name(OSSL_ENCODER_provider(*a
)),
366 OSSL_PROVIDER_name(OSSL_ENCODER_provider(*b
)));
370 static void collect_encoders(OSSL_ENCODER
*encoder
, void *stack
)
372 STACK_OF(OSSL_ENCODER
) *encoder_stack
= stack
;
374 sk_OSSL_ENCODER_push(encoder_stack
, encoder
);
375 OSSL_ENCODER_up_ref(encoder
);
378 static void list_encoders(void)
380 STACK_OF(OSSL_ENCODER
) *encoders
;
383 encoders
= sk_OSSL_ENCODER_new(encoder_cmp
);
384 if (encoders
== NULL
) {
385 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
388 BIO_printf(bio_out
, "Provided ENCODERs:\n");
389 OSSL_ENCODER_do_all_provided(NULL
, collect_encoders
, encoders
);
390 sk_OSSL_ENCODER_sort(encoders
);
392 for (i
= 0; i
< sk_OSSL_ENCODER_num(encoders
); i
++) {
393 OSSL_ENCODER
*k
= sk_OSSL_ENCODER_value(encoders
, i
);
394 STACK_OF(OPENSSL_CSTRING
) *names
=
395 sk_OPENSSL_CSTRING_new(name_cmp
);
397 OSSL_ENCODER_names_do_all(k
, collect_names
, names
);
399 BIO_printf(bio_out
, " ");
400 print_names(bio_out
, names
);
401 BIO_printf(bio_out
, " @ %s (%s)\n",
402 OSSL_PROVIDER_name(OSSL_ENCODER_provider(k
)),
403 OSSL_ENCODER_properties(k
));
405 sk_OPENSSL_CSTRING_free(names
);
408 print_param_types("settable operation parameters",
409 OSSL_ENCODER_settable_ctx_params(k
), 4);
412 sk_OSSL_ENCODER_pop_free(encoders
, OSSL_ENCODER_free
);
418 DEFINE_STACK_OF(OSSL_DECODER
)
419 static int decoder_cmp(const OSSL_DECODER
* const *a
,
420 const OSSL_DECODER
* const *b
)
422 int ret
= OSSL_DECODER_number(*a
) - OSSL_DECODER_number(*b
);
425 ret
= strcmp(OSSL_PROVIDER_name(OSSL_DECODER_provider(*a
)),
426 OSSL_PROVIDER_name(OSSL_DECODER_provider(*b
)));
430 static void collect_decoders(OSSL_DECODER
*decoder
, void *stack
)
432 STACK_OF(OSSL_DECODER
) *decoder_stack
= stack
;
434 sk_OSSL_DECODER_push(decoder_stack
, decoder
);
435 OSSL_DECODER_up_ref(decoder
);
438 static void list_decoders(void)
440 STACK_OF(OSSL_DECODER
) *decoders
;
443 decoders
= sk_OSSL_DECODER_new(decoder_cmp
);
444 if (decoders
== NULL
) {
445 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
448 BIO_printf(bio_out
, "Provided DECODERs:\n");
449 OSSL_DECODER_do_all_provided(NULL
, collect_decoders
,
451 sk_OSSL_DECODER_sort(decoders
);
453 for (i
= 0; i
< sk_OSSL_DECODER_num(decoders
); i
++) {
454 OSSL_DECODER
*k
= sk_OSSL_DECODER_value(decoders
, i
);
455 STACK_OF(OPENSSL_CSTRING
) *names
=
456 sk_OPENSSL_CSTRING_new(name_cmp
);
458 OSSL_DECODER_names_do_all(k
, collect_names
, names
);
460 BIO_printf(bio_out
, " ");
461 print_names(bio_out
, names
);
462 BIO_printf(bio_out
, " @ %s (%s)\n",
463 OSSL_PROVIDER_name(OSSL_DECODER_provider(k
)),
464 OSSL_DECODER_properties(k
));
466 sk_OPENSSL_CSTRING_free(names
);
469 print_param_types("settable operation parameters",
470 OSSL_DECODER_settable_ctx_params(k
), 4);
473 sk_OSSL_DECODER_pop_free(decoders
, OSSL_DECODER_free
);
476 static void list_missing_help(void)
481 for (fp
= functions
; fp
->name
!= NULL
; fp
++) {
482 if ((o
= fp
->help
) != NULL
) {
483 /* If there is help, list what flags are not documented. */
484 for ( ; o
->name
!= NULL
; o
++) {
485 if (o
->helpstr
== NULL
)
486 BIO_printf(bio_out
, "%s %s\n", fp
->name
, o
->name
);
488 } else if (fp
->func
!= dgst_main
) {
489 /* If not aliased to the dgst command, */
490 BIO_printf(bio_out
, "%s *\n", fp
->name
);
495 static void list_objects(void)
497 int max_nid
= OBJ_new_nid(0);
499 char *oid_buf
= NULL
;
502 /* Skip 0, since that's NID_undef */
503 for (i
= 1; i
< max_nid
; i
++) {
504 const ASN1_OBJECT
*obj
= OBJ_nid2obj(i
);
505 const char *sn
= OBJ_nid2sn(i
);
506 const char *ln
= OBJ_nid2ln(i
);
510 * If one of the retrieved objects somehow generated an error,
511 * we ignore it. The check for NID_undef below will detect the
512 * error and simply skip to the next NID.
516 if (OBJ_obj2nid(obj
) == NID_undef
)
519 if ((n
= OBJ_obj2txt(NULL
, 0, obj
, 1)) == 0) {
520 BIO_printf(bio_out
, "# None-OID object: %s, %s\n", sn
, ln
);
527 oid_buf
= OPENSSL_realloc(oid_buf
, n
+ 1);
528 if (oid_buf
== NULL
) {
529 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
534 if (OBJ_obj2txt(oid_buf
, oid_size
, obj
, 1) < 0)
536 if (ln
== NULL
|| strcmp(sn
, ln
) == 0)
537 BIO_printf(bio_out
, "%s = %s\n", sn
, oid_buf
);
539 BIO_printf(bio_out
, "%s = %s, %s\n", sn
, ln
, oid_buf
);
542 OPENSSL_free(oid_buf
);
545 static void list_options_for_command(const char *command
)
550 for (fp
= functions
; fp
->name
!= NULL
; fp
++)
551 if (strcmp(fp
->name
, command
) == 0)
553 if (fp
->name
== NULL
) {
554 BIO_printf(bio_err
, "Invalid command '%s'; type \"help\" for a list.\n",
559 if ((o
= fp
->help
) == NULL
)
562 for ( ; o
->name
!= NULL
; o
++) {
565 if (o
->name
== OPT_PARAM_STR
)
568 if (o
->name
== OPT_HELP_STR
569 || o
->name
== OPT_MORE_STR
570 || o
->name
== OPT_SECTION_STR
571 || o
->name
[0] == '\0')
573 BIO_printf(bio_out
, "%s %c\n", o
->name
, c
== '\0' ? '-' : c
);
575 /* Always output the -- marker since it is sometimes documented. */
576 BIO_printf(bio_out
, "- -\n");
579 static void list_type(FUNC_TYPE ft
, int one
)
585 memset(&dc
, 0, sizeof(dc
));
587 calculate_columns(functions
, &dc
);
589 for (fp
= functions
; fp
->name
!= NULL
; fp
++) {
593 BIO_printf(bio_out
, "%s\n", fp
->name
);
595 if (i
% dc
.columns
== 0 && i
> 0)
596 BIO_printf(bio_out
, "\n");
597 BIO_printf(bio_out
, "%-*s", dc
.width
, fp
->name
);
602 BIO_printf(bio_out
, "\n\n");
605 static void list_pkey(void)
609 for (i
= 0; i
< EVP_PKEY_asn1_get_count(); i
++) {
610 const EVP_PKEY_ASN1_METHOD
*ameth
;
611 int pkey_id
, pkey_base_id
, pkey_flags
;
612 const char *pinfo
, *pem_str
;
613 ameth
= EVP_PKEY_asn1_get0(i
);
614 EVP_PKEY_asn1_get0_info(&pkey_id
, &pkey_base_id
, &pkey_flags
,
615 &pinfo
, &pem_str
, ameth
);
616 if (pkey_flags
& ASN1_PKEY_ALIAS
) {
617 BIO_printf(bio_out
, "Name: %s\n", OBJ_nid2ln(pkey_id
));
618 BIO_printf(bio_out
, "\tAlias for: %s\n",
619 OBJ_nid2ln(pkey_base_id
));
621 BIO_printf(bio_out
, "Name: %s\n", pinfo
);
622 BIO_printf(bio_out
, "\tType: %s Algorithm\n",
623 pkey_flags
& ASN1_PKEY_DYNAMIC
?
624 "External" : "Builtin");
625 BIO_printf(bio_out
, "\tOID: %s\n", OBJ_nid2ln(pkey_id
));
628 BIO_printf(bio_out
, "\tPEM string: %s\n", pem_str
);
634 #ifndef OPENSSL_NO_DEPRECATED_3_0
635 static void list_pkey_meth(void)
638 size_t meth_count
= EVP_PKEY_meth_get_count();
640 for (i
= 0; i
< meth_count
; i
++) {
641 const EVP_PKEY_METHOD
*pmeth
= EVP_PKEY_meth_get0(i
);
642 int pkey_id
, pkey_flags
;
644 EVP_PKEY_meth_get0_info(&pkey_id
, &pkey_flags
, pmeth
);
645 BIO_printf(bio_out
, "%s\n", OBJ_nid2ln(pkey_id
));
646 BIO_printf(bio_out
, "\tType: %s Algorithm\n",
647 pkey_flags
& ASN1_PKEY_DYNAMIC
? "External" : "Builtin");
652 #ifndef OPENSSL_NO_DEPRECATED_3_0
653 static void list_engines(void)
655 # ifndef OPENSSL_NO_ENGINE
658 BIO_puts(bio_out
, "Engines:\n");
659 e
= ENGINE_get_first();
661 BIO_printf(bio_out
, "%s\n", ENGINE_get_id(e
));
662 e
= ENGINE_get_next(e
);
665 BIO_puts(bio_out
, "Engine support is disabled.\n");
670 static void list_disabled(void)
672 BIO_puts(bio_out
, "Disabled algorithms:\n");
673 #ifdef OPENSSL_NO_ARIA
674 BIO_puts(bio_out
, "ARIA\n");
677 BIO_puts(bio_out
, "BF\n");
679 #ifdef OPENSSL_NO_BLAKE2
680 BIO_puts(bio_out
, "BLAKE2\n");
682 #ifdef OPENSSL_NO_CAMELLIA
683 BIO_puts(bio_out
, "CAMELLIA\n");
685 #ifdef OPENSSL_NO_CAST
686 BIO_puts(bio_out
, "CAST\n");
688 #ifdef OPENSSL_NO_CMAC
689 BIO_puts(bio_out
, "CMAC\n");
691 #ifdef OPENSSL_NO_CMS
692 BIO_puts(bio_out
, "CMS\n");
694 #ifdef OPENSSL_NO_COMP
695 BIO_puts(bio_out
, "COMP\n");
697 #ifdef OPENSSL_NO_DES
698 BIO_puts(bio_out
, "DES\n");
700 #ifdef OPENSSL_NO_DGRAM
701 BIO_puts(bio_out
, "DGRAM\n");
704 BIO_puts(bio_out
, "DH\n");
706 #ifdef OPENSSL_NO_DSA
707 BIO_puts(bio_out
, "DSA\n");
709 #if defined(OPENSSL_NO_DTLS)
710 BIO_puts(bio_out
, "DTLS\n");
712 #if defined(OPENSSL_NO_DTLS1)
713 BIO_puts(bio_out
, "DTLS1\n");
715 #if defined(OPENSSL_NO_DTLS1_2)
716 BIO_puts(bio_out
, "DTLS1_2\n");
719 BIO_puts(bio_out
, "EC\n");
721 #ifdef OPENSSL_NO_EC2M
722 BIO_puts(bio_out
, "EC2M\n");
724 #if defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
725 BIO_puts(bio_out
, "ENGINE\n");
727 #ifdef OPENSSL_NO_GOST
728 BIO_puts(bio_out
, "GOST\n");
730 #ifdef OPENSSL_NO_IDEA
731 BIO_puts(bio_out
, "IDEA\n");
733 #ifdef OPENSSL_NO_MD2
734 BIO_puts(bio_out
, "MD2\n");
736 #ifdef OPENSSL_NO_MD4
737 BIO_puts(bio_out
, "MD4\n");
739 #ifdef OPENSSL_NO_MD5
740 BIO_puts(bio_out
, "MD5\n");
742 #ifdef OPENSSL_NO_MDC2
743 BIO_puts(bio_out
, "MDC2\n");
745 #ifdef OPENSSL_NO_OCB
746 BIO_puts(bio_out
, "OCB\n");
748 #ifdef OPENSSL_NO_OCSP
749 BIO_puts(bio_out
, "OCSP\n");
751 #ifdef OPENSSL_NO_PSK
752 BIO_puts(bio_out
, "PSK\n");
754 #ifdef OPENSSL_NO_RC2
755 BIO_puts(bio_out
, "RC2\n");
757 #ifdef OPENSSL_NO_RC4
758 BIO_puts(bio_out
, "RC4\n");
760 #ifdef OPENSSL_NO_RC5
761 BIO_puts(bio_out
, "RC5\n");
763 #ifdef OPENSSL_NO_RMD160
764 BIO_puts(bio_out
, "RMD160\n");
766 #ifdef OPENSSL_NO_RSA
767 BIO_puts(bio_out
, "RSA\n");
769 #ifdef OPENSSL_NO_SCRYPT
770 BIO_puts(bio_out
, "SCRYPT\n");
772 #ifdef OPENSSL_NO_SCTP
773 BIO_puts(bio_out
, "SCTP\n");
775 #ifdef OPENSSL_NO_SEED
776 BIO_puts(bio_out
, "SEED\n");
778 #ifdef OPENSSL_NO_SM2
779 BIO_puts(bio_out
, "SM2\n");
781 #ifdef OPENSSL_NO_SM3
782 BIO_puts(bio_out
, "SM3\n");
784 #ifdef OPENSSL_NO_SM4
785 BIO_puts(bio_out
, "SM4\n");
787 #ifdef OPENSSL_NO_SOCK
788 BIO_puts(bio_out
, "SOCK\n");
790 #ifdef OPENSSL_NO_SRP
791 BIO_puts(bio_out
, "SRP\n");
793 #ifdef OPENSSL_NO_SRTP
794 BIO_puts(bio_out
, "SRTP\n");
796 #ifdef OPENSSL_NO_SSL3
797 BIO_puts(bio_out
, "SSL3\n");
799 #ifdef OPENSSL_NO_TLS1
800 BIO_puts(bio_out
, "TLS1\n");
802 #ifdef OPENSSL_NO_TLS1_1
803 BIO_puts(bio_out
, "TLS1_1\n");
805 #ifdef OPENSSL_NO_TLS1_2
806 BIO_puts(bio_out
, "TLS1_2\n");
808 #ifdef OPENSSL_NO_WHIRLPOOL
809 BIO_puts(bio_out
, "WHIRLPOOL\n");
812 BIO_puts(bio_out
, "ZLIB\n");
816 /* Unified enum for help and list commands. */
817 typedef enum HELPLIST_CHOICE
{
818 OPT_ERR
= -1, OPT_EOF
= 0, OPT_HELP
, OPT_ONE
, OPT_VERBOSE
,
819 OPT_COMMANDS
, OPT_DIGEST_COMMANDS
, OPT_MAC_ALGORITHMS
, OPT_OPTIONS
,
820 OPT_DIGEST_ALGORITHMS
, OPT_CIPHER_COMMANDS
, OPT_CIPHER_ALGORITHMS
,
821 OPT_PK_ALGORITHMS
, OPT_PK_METHOD
, OPT_DISABLED
,
822 OPT_KDF_ALGORITHMS
, OPT_RANDOM_GENERATORS
, OPT_ENCODERS
,
824 OPT_MISSING_HELP
, OPT_OBJECTS
,
825 #ifndef OPENSSL_NO_DEPRECATED_3_0
831 const OPTIONS list_options
[] = {
833 OPT_SECTION("General"),
834 {"help", OPT_HELP
, '-', "Display this summary"},
836 OPT_SECTION("Output"),
837 {"1", OPT_ONE
, '-', "List in one column"},
838 {"verbose", OPT_VERBOSE
, '-', "Verbose listing"},
839 {"commands", OPT_COMMANDS
, '-', "List of standard commands"},
840 {"standard-commands", OPT_COMMANDS
, '-', "List of standard commands"},
841 {"digest-commands", OPT_DIGEST_COMMANDS
, '-',
842 "List of message digest commands"},
843 {"digest-algorithms", OPT_DIGEST_ALGORITHMS
, '-',
844 "List of message digest algorithms"},
845 {"kdf-algorithms", OPT_KDF_ALGORITHMS
, '-',
846 "List of key derivation and pseudo random function algorithms"},
847 {"random-generators", OPT_RANDOM_GENERATORS
, '-',
848 "List of random number generators"},
849 {"mac-algorithms", OPT_MAC_ALGORITHMS
, '-',
850 "List of message authentication code algorithms"},
851 {"cipher-commands", OPT_CIPHER_COMMANDS
, '-', "List of cipher commands"},
852 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS
, '-',
853 "List of cipher algorithms"},
854 {"encoders", OPT_ENCODERS
, '-', "List of encoding methods" },
855 {"decoders", OPT_DECODERS
, '-', "List of decoding methods" },
856 {"public-key-algorithms", OPT_PK_ALGORITHMS
, '-',
857 "List of public key algorithms"},
858 #ifndef OPENSSL_NO_DEPRECATED_3_0
859 {"public-key-methods", OPT_PK_METHOD
, '-',
860 "List of public key methods"},
861 {"engines", OPT_ENGINES
, '-',
862 "List of loaded engines"},
864 {"disabled", OPT_DISABLED
, '-', "List of disabled features"},
865 {"missing-help", OPT_MISSING_HELP
, '-',
866 "List missing detailed help strings"},
867 {"options", OPT_OPTIONS
, 's',
868 "List options for specified command"},
869 {"objects", OPT_OBJECTS
, '-',
870 "List built in objects (OID<->name mappings)"},
876 int list_main(int argc
, char **argv
)
880 int one
= 0, done
= 0;
882 unsigned int commands
:1;
883 unsigned int random_generators
:1;
884 unsigned int digest_commands
:1;
885 unsigned int digest_algorithms
:1;
886 unsigned int kdf_algorithms
:1;
887 unsigned int mac_algorithms
:1;
888 unsigned int cipher_commands
:1;
889 unsigned int cipher_algorithms
:1;
890 unsigned int encoder_algorithms
:1;
891 unsigned int decoder_algorithms
:1;
892 unsigned int pk_algorithms
:1;
893 unsigned int pk_method
:1;
894 #ifndef OPENSSL_NO_DEPRECATED_3_0
895 unsigned int engines
:1;
897 unsigned int disabled
:1;
898 unsigned int missing_help
:1;
899 unsigned int objects
:1;
900 unsigned int options
:1;
903 verbose
= 0; /* Clear a possible previous call */
905 prog
= opt_init(argc
, argv
, list_options
);
906 while ((o
= opt_next()) != OPT_EOF
) {
908 case OPT_EOF
: /* Never hit, but suppresses warning */
911 BIO_printf(bio_err
, "%s: Use -help for summary.\n", prog
);
914 opt_help(list_options
);
922 case OPT_DIGEST_COMMANDS
:
923 todo
.digest_commands
= 1;
925 case OPT_DIGEST_ALGORITHMS
:
926 todo
.digest_algorithms
= 1;
928 case OPT_KDF_ALGORITHMS
:
929 todo
.kdf_algorithms
= 1;
931 case OPT_RANDOM_GENERATORS
:
932 todo
.random_generators
= 1;
934 case OPT_MAC_ALGORITHMS
:
935 todo
.mac_algorithms
= 1;
937 case OPT_CIPHER_COMMANDS
:
938 todo
.cipher_commands
= 1;
940 case OPT_CIPHER_ALGORITHMS
:
941 todo
.cipher_algorithms
= 1;
944 todo
.encoder_algorithms
= 1;
947 todo
.decoder_algorithms
= 1;
949 case OPT_PK_ALGORITHMS
:
950 todo
.pk_algorithms
= 1;
955 #ifndef OPENSSL_NO_DEPRECATED_3_0
963 case OPT_MISSING_HELP
:
964 todo
.missing_help
= 1;
970 list_options_for_command(opt_arg());
976 if (!opt_provider(o
))
982 if (opt_num_rest() != 0) {
983 BIO_printf(bio_err
, "Extra arguments given.\n");
988 list_type(FT_general
, one
);
989 if (todo
.random_generators
)
990 list_random_generators();
991 if (todo
.digest_commands
)
992 list_type(FT_md
, one
);
993 if (todo
.digest_algorithms
)
995 if (todo
.kdf_algorithms
)
997 if (todo
.mac_algorithms
)
999 if (todo
.cipher_commands
)
1000 list_type(FT_cipher
, one
);
1001 if (todo
.cipher_algorithms
)
1003 if (todo
.encoder_algorithms
)
1005 if (todo
.decoder_algorithms
)
1007 if (todo
.pk_algorithms
)
1009 #ifndef OPENSSL_NO_DEPRECATED_3_0
1017 if (todo
.missing_help
)
1018 list_missing_help();