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/serializer.h>
20 #include <openssl/deserializer.h>
21 #include <openssl/core_names.h>
23 #include "app_params.h"
28 DEFINE_STACK_OF_CSTRING()
30 static int verbose = 0;
32 static void legacy_cipher_fn(const EVP_CIPHER *c,
33 const char *from, const char *to, void *arg)
36 BIO_printf(arg, " %s\n", EVP_CIPHER_name(c));
42 BIO_printf(arg, " %s => %s\n", from, to);
46 DEFINE_STACK_OF(EVP_CIPHER)
47 static int cipher_cmp(const EVP_CIPHER * const *a,
48 const EVP_CIPHER * const *b)
50 int ret = EVP_CIPHER_number(*a) - EVP_CIPHER_number(*b);
53 ret = strcmp(OSSL_PROVIDER_name(EVP_CIPHER_provider(*a)),
54 OSSL_PROVIDER_name(EVP_CIPHER_provider(*b)));
59 static void collect_ciphers(EVP_CIPHER *cipher, void *stack)
61 STACK_OF(EVP_CIPHER) *cipher_stack = stack;
63 if (sk_EVP_CIPHER_push(cipher_stack, cipher) > 0)
64 EVP_CIPHER_up_ref(cipher);
67 static void list_ciphers(void)
69 STACK_OF(EVP_CIPHER) *ciphers = sk_EVP_CIPHER_new(cipher_cmp);
72 if (ciphers == NULL) {
73 BIO_printf(bio_err, "ERROR: Memory allocation\n");
76 BIO_printf(bio_out, "Legacy:\n");
77 EVP_CIPHER_do_all_sorted(legacy_cipher_fn, bio_out);
79 BIO_printf(bio_out, "Provided:\n");
80 EVP_CIPHER_do_all_provided(NULL, collect_ciphers, ciphers);
81 sk_EVP_CIPHER_sort(ciphers);
82 for (i = 0; i < sk_EVP_CIPHER_num(ciphers); i++) {
83 const EVP_CIPHER *c = sk_EVP_CIPHER_value(ciphers, i);
84 STACK_OF(OPENSSL_CSTRING) *names =
85 sk_OPENSSL_CSTRING_new(name_cmp);
87 EVP_CIPHER_names_do_all(c, collect_names, names);
89 BIO_printf(bio_out, " ");
90 print_names(bio_out, names);
91 BIO_printf(bio_out, " @ %s\n",
92 OSSL_PROVIDER_name(EVP_CIPHER_provider(c)));
94 sk_OPENSSL_CSTRING_free(names);
97 print_param_types("retrievable algorithm parameters",
98 EVP_CIPHER_gettable_params(c), 4);
99 print_param_types("retrievable operation parameters",
100 EVP_CIPHER_gettable_ctx_params(c), 4);
101 print_param_types("settable operation parameters",
102 EVP_CIPHER_settable_ctx_params(c), 4);
105 sk_EVP_CIPHER_pop_free(ciphers, EVP_CIPHER_free);
108 static void list_md_fn(const EVP_MD *m,
109 const char *from, const char *to, void *arg)
112 BIO_printf(arg, " %s\n", EVP_MD_name(m));
115 from = "<undefined>";
118 BIO_printf((BIO *)arg, " %s => %s\n", from, to);
122 DEFINE_STACK_OF(EVP_MD)
123 static int md_cmp(const EVP_MD * const *a, const EVP_MD * const *b)
125 int ret = EVP_MD_number(*a) - EVP_MD_number(*b);
128 ret = strcmp(OSSL_PROVIDER_name(EVP_MD_provider(*a)),
129 OSSL_PROVIDER_name(EVP_MD_provider(*b)));
134 static void collect_digests(EVP_MD *md, void *stack)
136 STACK_OF(EVP_MD) *digest_stack = stack;
138 if (sk_EVP_MD_push(digest_stack, md) > 0)
142 static void list_digests(void)
144 STACK_OF(EVP_MD) *digests = sk_EVP_MD_new(md_cmp);
147 if (digests == NULL) {
148 BIO_printf(bio_err, "ERROR: Memory allocation\n");
151 BIO_printf(bio_out, "Legacy:\n");
152 EVP_MD_do_all_sorted(list_md_fn, bio_out);
154 BIO_printf(bio_out, "Provided:\n");
155 EVP_MD_do_all_provided(NULL, collect_digests, digests);
156 sk_EVP_MD_sort(digests);
157 for (i = 0; i < sk_EVP_MD_num(digests); i++) {
158 const EVP_MD *m = sk_EVP_MD_value(digests, i);
159 STACK_OF(OPENSSL_CSTRING) *names =
160 sk_OPENSSL_CSTRING_new(name_cmp);
162 EVP_MD_names_do_all(m, collect_names, names);
164 BIO_printf(bio_out, " ");
165 print_names(bio_out, names);
166 BIO_printf(bio_out, " @ %s\n",
167 OSSL_PROVIDER_name(EVP_MD_provider(m)));
169 sk_OPENSSL_CSTRING_free(names);
172 print_param_types("retrievable algorithm parameters",
173 EVP_MD_gettable_params(m), 4);
174 print_param_types("retrievable operation parameters",
175 EVP_MD_gettable_ctx_params(m), 4);
176 print_param_types("settable operation parameters",
177 EVP_MD_settable_ctx_params(m), 4);
180 sk_EVP_MD_pop_free(digests, EVP_MD_free);
183 DEFINE_STACK_OF(EVP_MAC)
184 static int mac_cmp(const EVP_MAC * const *a, const EVP_MAC * const *b)
186 int ret = EVP_MAC_number(*a) - EVP_MAC_number(*b);
189 ret = strcmp(OSSL_PROVIDER_name(EVP_MAC_provider(*a)),
190 OSSL_PROVIDER_name(EVP_MAC_provider(*b)));
195 static void collect_macs(EVP_MAC *mac, void *stack)
197 STACK_OF(EVP_MAC) *mac_stack = stack;
199 if (sk_EVP_MAC_push(mac_stack, mac) > 0)
203 static void list_macs(void)
205 STACK_OF(EVP_MAC) *macs = sk_EVP_MAC_new(mac_cmp);
209 BIO_printf(bio_err, "ERROR: Memory allocation\n");
212 BIO_printf(bio_out, "Provided MACs:\n");
213 EVP_MAC_do_all_provided(NULL, collect_macs, macs);
214 sk_EVP_MAC_sort(macs);
215 for (i = 0; i < sk_EVP_MAC_num(macs); i++) {
216 const EVP_MAC *m = sk_EVP_MAC_value(macs, i);
217 STACK_OF(OPENSSL_CSTRING) *names =
218 sk_OPENSSL_CSTRING_new(name_cmp);
220 EVP_MAC_names_do_all(m, collect_names, names);
222 BIO_printf(bio_out, " ");
223 print_names(bio_out, names);
224 BIO_printf(bio_out, " @ %s\n",
225 OSSL_PROVIDER_name(EVP_MAC_provider(m)));
227 sk_OPENSSL_CSTRING_free(names);
230 print_param_types("retrievable algorithm parameters",
231 EVP_MAC_gettable_params(m), 4);
232 print_param_types("retrievable operation parameters",
233 EVP_MAC_gettable_ctx_params(m), 4);
234 print_param_types("settable operation parameters",
235 EVP_MAC_settable_ctx_params(m), 4);
238 sk_EVP_MAC_pop_free(macs, EVP_MAC_free);
244 DEFINE_STACK_OF(EVP_KDF)
245 static int kdf_cmp(const EVP_KDF * const *a, const EVP_KDF * const *b)
247 int ret = EVP_KDF_number(*a) - EVP_KDF_number(*b);
250 ret = strcmp(OSSL_PROVIDER_name(EVP_KDF_provider(*a)),
251 OSSL_PROVIDER_name(EVP_KDF_provider(*b)));
256 static void collect_kdfs(EVP_KDF *kdf, void *stack)
258 STACK_OF(EVP_KDF) *kdf_stack = stack;
260 sk_EVP_KDF_push(kdf_stack, kdf);
264 static void list_kdfs(void)
266 STACK_OF(EVP_KDF) *kdfs = sk_EVP_KDF_new(kdf_cmp);
270 BIO_printf(bio_err, "ERROR: Memory allocation\n");
273 BIO_printf(bio_out, "Provided KDFs and PDFs:\n");
274 EVP_KDF_do_all_provided(NULL, collect_kdfs, kdfs);
275 sk_EVP_KDF_sort(kdfs);
276 for (i = 0; i < sk_EVP_KDF_num(kdfs); i++) {
277 const EVP_KDF *k = sk_EVP_KDF_value(kdfs, i);
278 STACK_OF(OPENSSL_CSTRING) *names =
279 sk_OPENSSL_CSTRING_new(name_cmp);
281 EVP_KDF_names_do_all(k, collect_names, names);
283 BIO_printf(bio_out, " ");
284 print_names(bio_out, names);
285 BIO_printf(bio_out, " @ %s\n",
286 OSSL_PROVIDER_name(EVP_KDF_provider(k)));
288 sk_OPENSSL_CSTRING_free(names);
291 print_param_types("retrievable algorithm parameters",
292 EVP_KDF_gettable_params(k), 4);
293 print_param_types("retrievable operation parameters",
294 EVP_KDF_gettable_ctx_params(k), 4);
295 print_param_types("settable operation parameters",
296 EVP_KDF_settable_ctx_params(k), 4);
299 sk_EVP_KDF_pop_free(kdfs, EVP_KDF_free);
305 DEFINE_STACK_OF(EVP_RAND)
307 static int rand_cmp(const EVP_RAND * const *a, const EVP_RAND * const *b)
309 int ret = strcasecmp(EVP_RAND_name(*a), EVP_RAND_name(*b));
312 ret = strcmp(OSSL_PROVIDER_name(EVP_RAND_provider(*a)),
313 OSSL_PROVIDER_name(EVP_RAND_provider(*b)));
318 static void collect_rands(EVP_RAND *rand, void *stack)
320 STACK_OF(EVP_RAND) *rand_stack = stack;
322 sk_EVP_RAND_push(rand_stack, rand);
323 EVP_RAND_up_ref(rand);
326 static void list_random_generators(void)
328 STACK_OF(EVP_RAND) *rands = sk_EVP_RAND_new(rand_cmp);
332 BIO_printf(bio_err, "ERROR: Memory allocation\n");
335 BIO_printf(bio_out, "Provided RNGs and seed sources:\n");
336 EVP_RAND_do_all_provided(NULL, collect_rands, rands);
337 sk_EVP_RAND_sort(rands);
338 for (i = 0; i < sk_EVP_RAND_num(rands); i++) {
339 const EVP_RAND *m = sk_EVP_RAND_value(rands, i);
341 BIO_printf(bio_out, " %s", EVP_RAND_name(m));
342 BIO_printf(bio_out, " @ %s\n",
343 OSSL_PROVIDER_name(EVP_RAND_provider(m)));
346 print_param_types("retrievable algorithm parameters",
347 EVP_RAND_gettable_params(m), 4);
348 print_param_types("retrievable operation parameters",
349 EVP_RAND_gettable_ctx_params(m), 4);
350 print_param_types("settable operation parameters",
351 EVP_RAND_settable_ctx_params(m), 4);
354 sk_EVP_RAND_pop_free(rands, EVP_RAND_free);
360 DEFINE_STACK_OF(OSSL_SERIALIZER)
361 static int serializer_cmp(const OSSL_SERIALIZER * const *a,
362 const OSSL_SERIALIZER * const *b)
364 int ret = OSSL_SERIALIZER_number(*a) - OSSL_SERIALIZER_number(*b);
367 ret = strcmp(OSSL_PROVIDER_name(OSSL_SERIALIZER_provider(*a)),
368 OSSL_PROVIDER_name(OSSL_SERIALIZER_provider(*b)));
372 static void collect_serializers(OSSL_SERIALIZER *serializer, void *stack)
374 STACK_OF(OSSL_SERIALIZER) *serializer_stack = stack;
376 sk_OSSL_SERIALIZER_push(serializer_stack, serializer);
377 OSSL_SERIALIZER_up_ref(serializer);
380 static void list_serializers(void)
382 STACK_OF(OSSL_SERIALIZER) *serializers;
385 serializers = sk_OSSL_SERIALIZER_new(serializer_cmp);
386 if (serializers == NULL) {
387 BIO_printf(bio_err, "ERROR: Memory allocation\n");
390 BIO_printf(bio_out, "Provided SERIALIZERs:\n");
391 OSSL_SERIALIZER_do_all_provided(NULL, collect_serializers, serializers);
392 sk_OSSL_SERIALIZER_sort(serializers);
394 for (i = 0; i < sk_OSSL_SERIALIZER_num(serializers); i++) {
395 OSSL_SERIALIZER *k = sk_OSSL_SERIALIZER_value(serializers, i);
396 STACK_OF(OPENSSL_CSTRING) *names =
397 sk_OPENSSL_CSTRING_new(name_cmp);
399 OSSL_SERIALIZER_names_do_all(k, collect_names, names);
401 BIO_printf(bio_out, " ");
402 print_names(bio_out, names);
403 BIO_printf(bio_out, " @ %s (%s)\n",
404 OSSL_PROVIDER_name(OSSL_SERIALIZER_provider(k)),
405 OSSL_SERIALIZER_properties(k));
407 sk_OPENSSL_CSTRING_free(names);
410 print_param_types("settable operation parameters",
411 OSSL_SERIALIZER_settable_ctx_params(k), 4);
414 sk_OSSL_SERIALIZER_pop_free(serializers, OSSL_SERIALIZER_free);
420 DEFINE_STACK_OF(OSSL_DESERIALIZER)
421 static int deserializer_cmp(const OSSL_DESERIALIZER * const *a,
422 const OSSL_DESERIALIZER * const *b)
424 int ret = OSSL_DESERIALIZER_number(*a) - OSSL_DESERIALIZER_number(*b);
427 ret = strcmp(OSSL_PROVIDER_name(OSSL_DESERIALIZER_provider(*a)),
428 OSSL_PROVIDER_name(OSSL_DESERIALIZER_provider(*b)));
432 static void collect_deserializers(OSSL_DESERIALIZER *deserializer, void *stack)
434 STACK_OF(OSSL_DESERIALIZER) *deserializer_stack = stack;
436 sk_OSSL_DESERIALIZER_push(deserializer_stack, deserializer);
437 OSSL_DESERIALIZER_up_ref(deserializer);
440 static void list_deserializers(void)
442 STACK_OF(OSSL_DESERIALIZER) *deserializers;
445 deserializers = sk_OSSL_DESERIALIZER_new(deserializer_cmp);
446 if (deserializers == NULL) {
447 BIO_printf(bio_err, "ERROR: Memory allocation\n");
450 BIO_printf(bio_out, "Provided DESERIALIZERs:\n");
451 OSSL_DESERIALIZER_do_all_provided(NULL, collect_deserializers,
453 sk_OSSL_DESERIALIZER_sort(deserializers);
455 for (i = 0; i < sk_OSSL_DESERIALIZER_num(deserializers); i++) {
456 OSSL_DESERIALIZER *k = sk_OSSL_DESERIALIZER_value(deserializers, i);
457 STACK_OF(OPENSSL_CSTRING) *names =
458 sk_OPENSSL_CSTRING_new(name_cmp);
460 OSSL_DESERIALIZER_names_do_all(k, collect_names, names);
462 BIO_printf(bio_out, " ");
463 print_names(bio_out, names);
464 BIO_printf(bio_out, " @ %s (%s)\n",
465 OSSL_PROVIDER_name(OSSL_DESERIALIZER_provider(k)),
466 OSSL_DESERIALIZER_properties(k));
468 sk_OPENSSL_CSTRING_free(names);
471 print_param_types("settable operation parameters",
472 OSSL_DESERIALIZER_settable_ctx_params(k), 4);
475 sk_OSSL_DESERIALIZER_pop_free(deserializers, OSSL_DESERIALIZER_free);
478 static void list_missing_help(void)
483 for (fp = functions; fp->name != NULL; fp++) {
484 if ((o = fp->help) != NULL) {
485 /* If there is help, list what flags are not documented. */
486 for ( ; o->name != NULL; o++) {
487 if (o->helpstr == NULL)
488 BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
490 } else if (fp->func != dgst_main) {
491 /* If not aliased to the dgst command, */
492 BIO_printf(bio_out, "%s *\n", fp->name);
497 static void list_objects(void)
499 int max_nid = OBJ_new_nid(0);
501 char *oid_buf = NULL;
504 /* Skip 0, since that's NID_undef */
505 for (i = 1; i < max_nid; i++) {
506 const ASN1_OBJECT *obj = OBJ_nid2obj(i);
507 const char *sn = OBJ_nid2sn(i);
508 const char *ln = OBJ_nid2ln(i);
512 * If one of the retrieved objects somehow generated an error,
513 * we ignore it. The check for NID_undef below will detect the
514 * error and simply skip to the next NID.
518 if (OBJ_obj2nid(obj) == NID_undef)
521 if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
522 BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
529 oid_buf = OPENSSL_realloc(oid_buf, n + 1);
530 if (oid_buf == NULL) {
531 BIO_printf(bio_err, "ERROR: Memory allocation\n");
536 if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
538 if (ln == NULL || strcmp(sn, ln) == 0)
539 BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
541 BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
544 OPENSSL_free(oid_buf);
547 static void list_options_for_command(const char *command)
552 for (fp = functions; fp->name != NULL; fp++)
553 if (strcmp(fp->name, command) == 0)
555 if (fp->name == NULL) {
556 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
561 if ((o = fp->help) == NULL)
564 for ( ; o->name != NULL; o++) {
567 if (o->name == OPT_PARAM_STR)
570 if (o->name == OPT_HELP_STR
571 || o->name == OPT_MORE_STR
572 || o->name == OPT_SECTION_STR
573 || o->name[0] == '\0')
575 BIO_printf(bio_out, "%s %c\n", o->name, c == '\0' ? '-' : c);
577 /* Always output the -- marker since it is sometimes documented. */
578 BIO_printf(bio_out, "- -\n");
581 static void list_type(FUNC_TYPE ft, int one)
587 memset(&dc, 0, sizeof(dc));
589 calculate_columns(functions, &dc);
591 for (fp = functions; fp->name != NULL; fp++) {
595 BIO_printf(bio_out, "%s\n", fp->name);
597 if (i % dc.columns == 0 && i > 0)
598 BIO_printf(bio_out, "\n");
599 BIO_printf(bio_out, "%-*s", dc.width, fp->name);
604 BIO_printf(bio_out, "\n\n");
607 static void list_pkey(void)
611 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
612 const EVP_PKEY_ASN1_METHOD *ameth;
613 int pkey_id, pkey_base_id, pkey_flags;
614 const char *pinfo, *pem_str;
615 ameth = EVP_PKEY_asn1_get0(i);
616 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
617 &pinfo, &pem_str, ameth);
618 if (pkey_flags & ASN1_PKEY_ALIAS) {
619 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
620 BIO_printf(bio_out, "\tAlias for: %s\n",
621 OBJ_nid2ln(pkey_base_id));
623 BIO_printf(bio_out, "Name: %s\n", pinfo);
624 BIO_printf(bio_out, "\tType: %s Algorithm\n",
625 pkey_flags & ASN1_PKEY_DYNAMIC ?
626 "External" : "Builtin");
627 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
630 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
636 #ifndef OPENSSL_NO_DEPRECATED_3_0
637 static void list_pkey_meth(void)
640 size_t meth_count = EVP_PKEY_meth_get_count();
642 for (i = 0; i < meth_count; i++) {
643 const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
644 int pkey_id, pkey_flags;
646 EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
647 BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
648 BIO_printf(bio_out, "\tType: %s Algorithm\n",
649 pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
654 #ifndef OPENSSL_NO_DEPRECATED_3_0
655 static void list_engines(void)
657 # ifndef OPENSSL_NO_ENGINE
660 BIO_puts(bio_out, "Engines:\n");
661 e = ENGINE_get_first();
663 BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
664 e = ENGINE_get_next(e);
667 BIO_puts(bio_out, "Engine support is disabled.\n");
672 static void list_disabled(void)
674 BIO_puts(bio_out, "Disabled algorithms:\n");
675 #ifdef OPENSSL_NO_ARIA
676 BIO_puts(bio_out, "ARIA\n");
679 BIO_puts(bio_out, "BF\n");
681 #ifdef OPENSSL_NO_BLAKE2
682 BIO_puts(bio_out, "BLAKE2\n");
684 #ifdef OPENSSL_NO_CAMELLIA
685 BIO_puts(bio_out, "CAMELLIA\n");
687 #ifdef OPENSSL_NO_CAST
688 BIO_puts(bio_out, "CAST\n");
690 #ifdef OPENSSL_NO_CMAC
691 BIO_puts(bio_out, "CMAC\n");
693 #ifdef OPENSSL_NO_CMS
694 BIO_puts(bio_out, "CMS\n");
696 #ifdef OPENSSL_NO_COMP
697 BIO_puts(bio_out, "COMP\n");
699 #ifdef OPENSSL_NO_DES
700 BIO_puts(bio_out, "DES\n");
702 #ifdef OPENSSL_NO_DGRAM
703 BIO_puts(bio_out, "DGRAM\n");
706 BIO_puts(bio_out, "DH\n");
708 #ifdef OPENSSL_NO_DSA
709 BIO_puts(bio_out, "DSA\n");
711 #if defined(OPENSSL_NO_DTLS)
712 BIO_puts(bio_out, "DTLS\n");
714 #if defined(OPENSSL_NO_DTLS1)
715 BIO_puts(bio_out, "DTLS1\n");
717 #if defined(OPENSSL_NO_DTLS1_2)
718 BIO_puts(bio_out, "DTLS1_2\n");
721 BIO_puts(bio_out, "EC\n");
723 #ifdef OPENSSL_NO_EC2M
724 BIO_puts(bio_out, "EC2M\n");
726 #if defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
727 BIO_puts(bio_out, "ENGINE\n");
729 #ifdef OPENSSL_NO_GOST
730 BIO_puts(bio_out, "GOST\n");
732 #ifdef OPENSSL_NO_IDEA
733 BIO_puts(bio_out, "IDEA\n");
735 #ifdef OPENSSL_NO_MD2
736 BIO_puts(bio_out, "MD2\n");
738 #ifdef OPENSSL_NO_MD4
739 BIO_puts(bio_out, "MD4\n");
741 #ifdef OPENSSL_NO_MD5
742 BIO_puts(bio_out, "MD5\n");
744 #ifdef OPENSSL_NO_MDC2
745 BIO_puts(bio_out, "MDC2\n");
747 #ifdef OPENSSL_NO_OCB
748 BIO_puts(bio_out, "OCB\n");
750 #ifdef OPENSSL_NO_OCSP
751 BIO_puts(bio_out, "OCSP\n");
753 #ifdef OPENSSL_NO_PSK
754 BIO_puts(bio_out, "PSK\n");
756 #ifdef OPENSSL_NO_RC2
757 BIO_puts(bio_out, "RC2\n");
759 #ifdef OPENSSL_NO_RC4
760 BIO_puts(bio_out, "RC4\n");
762 #ifdef OPENSSL_NO_RC5
763 BIO_puts(bio_out, "RC5\n");
765 #ifdef OPENSSL_NO_RMD160
766 BIO_puts(bio_out, "RMD160\n");
768 #ifdef OPENSSL_NO_RSA
769 BIO_puts(bio_out, "RSA\n");
771 #ifdef OPENSSL_NO_SCRYPT
772 BIO_puts(bio_out, "SCRYPT\n");
774 #ifdef OPENSSL_NO_SCTP
775 BIO_puts(bio_out, "SCTP\n");
777 #ifdef OPENSSL_NO_SEED
778 BIO_puts(bio_out, "SEED\n");
780 #ifdef OPENSSL_NO_SM2
781 BIO_puts(bio_out, "SM2\n");
783 #ifdef OPENSSL_NO_SM3
784 BIO_puts(bio_out, "SM3\n");
786 #ifdef OPENSSL_NO_SM4
787 BIO_puts(bio_out, "SM4\n");
789 #ifdef OPENSSL_NO_SOCK
790 BIO_puts(bio_out, "SOCK\n");
792 #ifdef OPENSSL_NO_SRP
793 BIO_puts(bio_out, "SRP\n");
795 #ifdef OPENSSL_NO_SRTP
796 BIO_puts(bio_out, "SRTP\n");
798 #ifdef OPENSSL_NO_SSL3
799 BIO_puts(bio_out, "SSL3\n");
801 #ifdef OPENSSL_NO_TLS1
802 BIO_puts(bio_out, "TLS1\n");
804 #ifdef OPENSSL_NO_TLS1_1
805 BIO_puts(bio_out, "TLS1_1\n");
807 #ifdef OPENSSL_NO_TLS1_2
808 BIO_puts(bio_out, "TLS1_2\n");
810 #ifdef OPENSSL_NO_WHIRLPOOL
811 BIO_puts(bio_out, "WHIRLPOOL\n");
814 BIO_puts(bio_out, "ZLIB\n");
818 /* Unified enum for help and list commands. */
819 typedef enum HELPLIST_CHOICE {
820 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE, OPT_VERBOSE,
821 OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
822 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
823 OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED,
824 OPT_KDF_ALGORITHMS, OPT_RANDOM_GENERATORS, OPT_SERIALIZERS,
826 OPT_MISSING_HELP, OPT_OBJECTS,
827 #ifndef OPENSSL_NO_DEPRECATED_3_0
833 const OPTIONS list_options[] = {
835 OPT_SECTION("General"),
836 {"help", OPT_HELP, '-', "Display this summary"},
838 OPT_SECTION("Output"),
839 {"1", OPT_ONE, '-', "List in one column"},
840 {"verbose", OPT_VERBOSE, '-', "Verbose listing"},
841 {"commands", OPT_COMMANDS, '-', "List of standard commands"},
842 {"standard-commands", OPT_COMMANDS, '-', "List of standard commands"},
843 {"digest-commands", OPT_DIGEST_COMMANDS, '-',
844 "List of message digest commands"},
845 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
846 "List of message digest algorithms"},
847 {"kdf-algorithms", OPT_KDF_ALGORITHMS, '-',
848 "List of key derivation and pseudo random function algorithms"},
849 {"random-generators", OPT_RANDOM_GENERATORS, '-',
850 "List of random number generators"},
851 {"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
852 "List of message authentication code algorithms"},
853 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
854 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
855 "List of cipher algorithms"},
856 {"serializers", OPT_SERIALIZERS, '-', "List of serialization methods" },
857 {"deserializers", OPT_DESERIALIZERS, '-',
858 "List of deserialization methods" },
859 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
860 "List of public key algorithms"},
861 #ifndef OPENSSL_NO_DEPRECATED_3_0
862 {"public-key-methods", OPT_PK_METHOD, '-',
863 "List of public key methods"},
864 {"engines", OPT_ENGINES, '-',
865 "List of loaded engines"},
867 {"disabled", OPT_DISABLED, '-', "List of disabled features"},
868 {"missing-help", OPT_MISSING_HELP, '-',
869 "List missing detailed help strings"},
870 {"options", OPT_OPTIONS, 's',
871 "List options for specified command"},
872 {"objects", OPT_OBJECTS, '-',
873 "List built in objects (OID<->name mappings)"},
879 int list_main(int argc, char **argv)
883 int one = 0, done = 0;
885 unsigned int commands:1;
886 unsigned int random_generators:1;
887 unsigned int digest_commands:1;
888 unsigned int digest_algorithms:1;
889 unsigned int kdf_algorithms:1;
890 unsigned int mac_algorithms:1;
891 unsigned int cipher_commands:1;
892 unsigned int cipher_algorithms:1;
893 unsigned int serializer_algorithms:1;
894 unsigned int deserializer_algorithms:1;
895 unsigned int pk_algorithms:1;
896 unsigned int pk_method:1;
897 #ifndef OPENSSL_NO_DEPRECATED_3_0
898 unsigned int engines:1;
900 unsigned int disabled:1;
901 unsigned int missing_help:1;
902 unsigned int objects:1;
903 unsigned int options:1;
906 verbose = 0; /* Clear a possible previous call */
908 prog = opt_init(argc, argv, list_options);
909 while ((o = opt_next()) != OPT_EOF) {
911 case OPT_EOF: /* Never hit, but suppresses warning */
914 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
917 opt_help(list_options);
925 case OPT_DIGEST_COMMANDS:
926 todo.digest_commands = 1;
928 case OPT_DIGEST_ALGORITHMS:
929 todo.digest_algorithms = 1;
931 case OPT_KDF_ALGORITHMS:
932 todo.kdf_algorithms = 1;
934 case OPT_RANDOM_GENERATORS:
935 todo.random_generators = 1;
937 case OPT_MAC_ALGORITHMS:
938 todo.mac_algorithms = 1;
940 case OPT_CIPHER_COMMANDS:
941 todo.cipher_commands = 1;
943 case OPT_CIPHER_ALGORITHMS:
944 todo.cipher_algorithms = 1;
946 case OPT_SERIALIZERS:
947 todo.serializer_algorithms = 1;
949 case OPT_DESERIALIZERS:
950 todo.deserializer_algorithms = 1;
952 case OPT_PK_ALGORITHMS:
953 todo.pk_algorithms = 1;
958 #ifndef OPENSSL_NO_DEPRECATED_3_0
966 case OPT_MISSING_HELP:
967 todo.missing_help = 1;
973 list_options_for_command(opt_arg());
979 if (!opt_provider(o))
985 if (opt_num_rest() != 0) {
986 BIO_printf(bio_err, "Extra arguments given.\n");
991 list_type(FT_general, one);
992 if (todo.random_generators)
993 list_random_generators();
994 if (todo.digest_commands)
995 list_type(FT_md, one);
996 if (todo.digest_algorithms)
998 if (todo.kdf_algorithms)
1000 if (todo.mac_algorithms)
1002 if (todo.cipher_commands)
1003 list_type(FT_cipher, one);
1004 if (todo.cipher_algorithms)
1006 if (todo.serializer_algorithms)
1008 if (todo.deserializer_algorithms)
1009 list_deserializers();
1010 if (todo.pk_algorithms)
1012 #ifndef OPENSSL_NO_DEPRECATED_3_0
1020 if (todo.missing_help)
1021 list_missing_help();