2 * Copyright 1995-2022 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/store.h>
22 #include <openssl/core_names.h>
23 #include <openssl/rand.h>
25 #include "app_params.h"
30 static int verbose
= 0;
31 static const char *select_name
= NULL
;
33 /* Checks to see if algorithms are fetchable */
34 #define IS_FETCHABLE(type, TYPE) \
35 static int is_ ## type ## _fetchable(const TYPE *alg) \
38 const char *propq = app_get0_propq(); \
39 OSSL_LIB_CTX *libctx = app_get0_libctx(); \
40 const char *name = TYPE ## _get0_name(alg); \
43 impl = TYPE ## _fetch(libctx, name, propq); \
47 TYPE ## _free(impl); \
50 IS_FETCHABLE(cipher
, EVP_CIPHER
)
51 IS_FETCHABLE(digest
, EVP_MD
)
52 IS_FETCHABLE(mac
, EVP_MAC
)
53 IS_FETCHABLE(kdf
, EVP_KDF
)
54 IS_FETCHABLE(rand
, EVP_RAND
)
55 IS_FETCHABLE(keymgmt
, EVP_KEYMGMT
)
56 IS_FETCHABLE(signature
, EVP_SIGNATURE
)
57 IS_FETCHABLE(kem
, EVP_KEM
)
58 IS_FETCHABLE(asym_cipher
, EVP_ASYM_CIPHER
)
59 IS_FETCHABLE(keyexch
, EVP_KEYEXCH
)
60 IS_FETCHABLE(decoder
, OSSL_DECODER
)
61 IS_FETCHABLE(encoder
, OSSL_ENCODER
)
63 #ifndef OPENSSL_NO_DEPRECATED_3_0
64 static int include_legacy(void)
66 return app_get0_propq() == NULL
;
69 static void legacy_cipher_fn(const EVP_CIPHER
*c
,
70 const char *from
, const char *to
, void *arg
)
72 if (select_name
!= NULL
74 || OPENSSL_strcasecmp(select_name
, EVP_CIPHER_get0_name(c
)) != 0))
77 BIO_printf(arg
, " %s\n", EVP_CIPHER_get0_name(c
));
83 BIO_printf(arg
, " %s => %s\n", from
, to
);
88 DEFINE_STACK_OF(EVP_CIPHER
)
89 static int cipher_cmp(const EVP_CIPHER
* const *a
,
90 const EVP_CIPHER
* const *b
)
92 return strcmp(OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(*a
)),
93 OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(*b
)));
96 static void collect_ciphers(EVP_CIPHER
*cipher
, void *stack
)
98 STACK_OF(EVP_CIPHER
) *cipher_stack
= stack
;
100 if (is_cipher_fetchable(cipher
)
101 && sk_EVP_CIPHER_push(cipher_stack
, cipher
) > 0)
102 EVP_CIPHER_up_ref(cipher
);
105 static void list_ciphers(const char *prefix
)
107 STACK_OF(EVP_CIPHER
) *ciphers
= sk_EVP_CIPHER_new(cipher_cmp
);
110 if (ciphers
== NULL
) {
111 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
114 #ifndef OPENSSL_NO_DEPRECATED_3_0
115 if (include_legacy()) {
116 BIO_printf(bio_out
, "%sLegacy:\n", prefix
);
117 EVP_CIPHER_do_all_sorted(legacy_cipher_fn
, bio_out
);
121 BIO_printf(bio_out
, "%sProvided:\n", prefix
);
122 EVP_CIPHER_do_all_provided(app_get0_libctx(), collect_ciphers
, ciphers
);
123 sk_EVP_CIPHER_sort(ciphers
);
124 for (i
= 0; i
< sk_EVP_CIPHER_num(ciphers
); i
++) {
125 const EVP_CIPHER
*c
= sk_EVP_CIPHER_value(ciphers
, i
);
126 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
128 if (select_name
!= NULL
&& !EVP_CIPHER_is_a(c
, select_name
))
131 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
132 if (names
!= NULL
&& EVP_CIPHER_names_do_all(c
, collect_names
, names
)) {
133 BIO_printf(bio_out
, " ");
134 print_names(bio_out
, names
);
136 BIO_printf(bio_out
, " @ %s\n",
137 OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(c
)));
140 const char *desc
= EVP_CIPHER_get0_description(c
);
143 BIO_printf(bio_out
, " description: %s\n", desc
);
144 print_param_types("retrievable algorithm parameters",
145 EVP_CIPHER_gettable_params(c
), 4);
146 print_param_types("retrievable operation parameters",
147 EVP_CIPHER_gettable_ctx_params(c
), 4);
148 print_param_types("settable operation parameters",
149 EVP_CIPHER_settable_ctx_params(c
), 4);
152 sk_OPENSSL_CSTRING_free(names
);
154 sk_EVP_CIPHER_pop_free(ciphers
, EVP_CIPHER_free
);
157 #ifndef OPENSSL_NO_DEPRECATED_3_0
158 static void legacy_md_fn(const EVP_MD
*m
,
159 const char *from
, const char *to
, void *arg
)
162 BIO_printf(arg
, " %s\n", EVP_MD_get0_name(m
));
165 from
= "<undefined>";
168 BIO_printf((BIO
*)arg
, " %s => %s\n", from
, to
);
173 DEFINE_STACK_OF(EVP_MD
)
174 static int md_cmp(const EVP_MD
* const *a
, const EVP_MD
* const *b
)
176 return strcmp(OSSL_PROVIDER_get0_name(EVP_MD_get0_provider(*a
)),
177 OSSL_PROVIDER_get0_name(EVP_MD_get0_provider(*b
)));
180 static void collect_digests(EVP_MD
*digest
, void *stack
)
182 STACK_OF(EVP_MD
) *digest_stack
= stack
;
184 if (is_digest_fetchable(digest
)
185 && sk_EVP_MD_push(digest_stack
, digest
) > 0)
186 EVP_MD_up_ref(digest
);
189 static void list_digests(const char *prefix
)
191 STACK_OF(EVP_MD
) *digests
= sk_EVP_MD_new(md_cmp
);
194 if (digests
== NULL
) {
195 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
198 #ifndef OPENSSL_NO_DEPRECATED_3_0
199 if (include_legacy()) {
200 BIO_printf(bio_out
, "%sLegacy:\n", prefix
);
201 EVP_MD_do_all_sorted(legacy_md_fn
, bio_out
);
205 BIO_printf(bio_out
, "%sProvided:\n", prefix
);
206 EVP_MD_do_all_provided(app_get0_libctx(), collect_digests
, digests
);
207 sk_EVP_MD_sort(digests
);
208 for (i
= 0; i
< sk_EVP_MD_num(digests
); i
++) {
209 const EVP_MD
*m
= sk_EVP_MD_value(digests
, i
);
210 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
212 if (select_name
!= NULL
&& !EVP_MD_is_a(m
, select_name
))
215 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
216 if (names
!= NULL
&& EVP_MD_names_do_all(m
, collect_names
, names
)) {
217 BIO_printf(bio_out
, " ");
218 print_names(bio_out
, names
);
220 BIO_printf(bio_out
, " @ %s\n",
221 OSSL_PROVIDER_get0_name(EVP_MD_get0_provider(m
)));
224 const char *desc
= EVP_MD_get0_description(m
);
227 BIO_printf(bio_out
, " description: %s\n", desc
);
228 print_param_types("retrievable algorithm parameters",
229 EVP_MD_gettable_params(m
), 4);
230 print_param_types("retrievable operation parameters",
231 EVP_MD_gettable_ctx_params(m
), 4);
232 print_param_types("settable operation parameters",
233 EVP_MD_settable_ctx_params(m
), 4);
236 sk_OPENSSL_CSTRING_free(names
);
238 sk_EVP_MD_pop_free(digests
, EVP_MD_free
);
241 DEFINE_STACK_OF(EVP_MAC
)
242 static int mac_cmp(const EVP_MAC
* const *a
, const EVP_MAC
* const *b
)
244 return strcmp(OSSL_PROVIDER_get0_name(EVP_MAC_get0_provider(*a
)),
245 OSSL_PROVIDER_get0_name(EVP_MAC_get0_provider(*b
)));
248 static void collect_macs(EVP_MAC
*mac
, void *stack
)
250 STACK_OF(EVP_MAC
) *mac_stack
= stack
;
252 if (is_mac_fetchable(mac
)
253 && sk_EVP_MAC_push(mac_stack
, mac
) > 0)
257 static void list_macs(void)
259 STACK_OF(EVP_MAC
) *macs
= sk_EVP_MAC_new(mac_cmp
);
263 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
266 BIO_printf(bio_out
, "Provided MACs:\n");
267 EVP_MAC_do_all_provided(app_get0_libctx(), collect_macs
, macs
);
268 sk_EVP_MAC_sort(macs
);
269 for (i
= 0; i
< sk_EVP_MAC_num(macs
); i
++) {
270 const EVP_MAC
*m
= sk_EVP_MAC_value(macs
, i
);
271 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
273 if (select_name
!= NULL
&& !EVP_MAC_is_a(m
, select_name
))
276 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
277 if (names
!= NULL
&& EVP_MAC_names_do_all(m
, collect_names
, names
)) {
278 BIO_printf(bio_out
, " ");
279 print_names(bio_out
, names
);
281 BIO_printf(bio_out
, " @ %s\n",
282 OSSL_PROVIDER_get0_name(EVP_MAC_get0_provider(m
)));
285 const char *desc
= EVP_MAC_get0_description(m
);
288 BIO_printf(bio_out
, " description: %s\n", desc
);
289 print_param_types("retrievable algorithm parameters",
290 EVP_MAC_gettable_params(m
), 4);
291 print_param_types("retrievable operation parameters",
292 EVP_MAC_gettable_ctx_params(m
), 4);
293 print_param_types("settable operation parameters",
294 EVP_MAC_settable_ctx_params(m
), 4);
297 sk_OPENSSL_CSTRING_free(names
);
299 sk_EVP_MAC_pop_free(macs
, EVP_MAC_free
);
305 DEFINE_STACK_OF(EVP_KDF
)
306 static int kdf_cmp(const EVP_KDF
* const *a
, const EVP_KDF
* const *b
)
308 return strcmp(OSSL_PROVIDER_get0_name(EVP_KDF_get0_provider(*a
)),
309 OSSL_PROVIDER_get0_name(EVP_KDF_get0_provider(*b
)));
312 static void collect_kdfs(EVP_KDF
*kdf
, void *stack
)
314 STACK_OF(EVP_KDF
) *kdf_stack
= stack
;
316 if (is_kdf_fetchable(kdf
)
317 && sk_EVP_KDF_push(kdf_stack
, kdf
) > 0)
321 static void list_kdfs(void)
323 STACK_OF(EVP_KDF
) *kdfs
= sk_EVP_KDF_new(kdf_cmp
);
327 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
330 BIO_printf(bio_out
, "Provided KDFs and PDFs:\n");
331 EVP_KDF_do_all_provided(app_get0_libctx(), collect_kdfs
, kdfs
);
332 sk_EVP_KDF_sort(kdfs
);
333 for (i
= 0; i
< sk_EVP_KDF_num(kdfs
); i
++) {
334 const EVP_KDF
*k
= sk_EVP_KDF_value(kdfs
, i
);
335 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
337 if (select_name
!= NULL
&& !EVP_KDF_is_a(k
, select_name
))
340 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
341 if (names
!= NULL
&& EVP_KDF_names_do_all(k
, collect_names
, names
)) {
342 BIO_printf(bio_out
, " ");
343 print_names(bio_out
, names
);
345 BIO_printf(bio_out
, " @ %s\n",
346 OSSL_PROVIDER_get0_name(EVP_KDF_get0_provider(k
)));
349 const char *desc
= EVP_KDF_get0_description(k
);
352 BIO_printf(bio_out
, " description: %s\n", desc
);
353 print_param_types("retrievable algorithm parameters",
354 EVP_KDF_gettable_params(k
), 4);
355 print_param_types("retrievable operation parameters",
356 EVP_KDF_gettable_ctx_params(k
), 4);
357 print_param_types("settable operation parameters",
358 EVP_KDF_settable_ctx_params(k
), 4);
361 sk_OPENSSL_CSTRING_free(names
);
363 sk_EVP_KDF_pop_free(kdfs
, EVP_KDF_free
);
369 DEFINE_STACK_OF(EVP_RAND
)
371 static int rand_cmp(const EVP_RAND
* const *a
, const EVP_RAND
* const *b
)
373 int ret
= OPENSSL_strcasecmp(EVP_RAND_get0_name(*a
), EVP_RAND_get0_name(*b
));
376 ret
= strcmp(OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(*a
)),
377 OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(*b
)));
382 static void collect_rands(EVP_RAND
*rand
, void *stack
)
384 STACK_OF(EVP_RAND
) *rand_stack
= stack
;
386 if (is_rand_fetchable(rand
)
387 && sk_EVP_RAND_push(rand_stack
, rand
) > 0)
388 EVP_RAND_up_ref(rand
);
391 static void list_random_generators(void)
393 STACK_OF(EVP_RAND
) *rands
= sk_EVP_RAND_new(rand_cmp
);
397 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
400 BIO_printf(bio_out
, "Provided RNGs and seed sources:\n");
401 EVP_RAND_do_all_provided(app_get0_libctx(), collect_rands
, rands
);
402 sk_EVP_RAND_sort(rands
);
403 for (i
= 0; i
< sk_EVP_RAND_num(rands
); i
++) {
404 const EVP_RAND
*m
= sk_EVP_RAND_value(rands
, i
);
406 if (select_name
!= NULL
407 && OPENSSL_strcasecmp(EVP_RAND_get0_name(m
), select_name
) != 0)
409 BIO_printf(bio_out
, " %s", EVP_RAND_get0_name(m
));
410 BIO_printf(bio_out
, " @ %s\n",
411 OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(m
)));
414 const char *desc
= EVP_RAND_get0_description(m
);
417 BIO_printf(bio_out
, " description: %s\n", desc
);
418 print_param_types("retrievable algorithm parameters",
419 EVP_RAND_gettable_params(m
), 4);
420 print_param_types("retrievable operation parameters",
421 EVP_RAND_gettable_ctx_params(m
), 4);
422 print_param_types("settable operation parameters",
423 EVP_RAND_settable_ctx_params(m
), 4);
426 sk_EVP_RAND_pop_free(rands
, EVP_RAND_free
);
429 static void display_random(const char *name
, EVP_RAND_CTX
*drbg
)
434 const OSSL_PARAM
*gettables
;
435 OSSL_PARAM params
[2] = { OSSL_PARAM_END
, OSSL_PARAM_END
};
436 unsigned char buf
[1000];
438 BIO_printf(bio_out
, "%s:\n", name
);
440 rand
= EVP_RAND_CTX_get0_rand(drbg
);
442 BIO_printf(bio_out
, " %s", EVP_RAND_get0_name(rand
));
443 BIO_printf(bio_out
, " @ %s\n",
444 OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(rand
)));
446 switch (EVP_RAND_get_state(drbg
)) {
447 case EVP_RAND_STATE_UNINITIALISED
:
450 case EVP_RAND_STATE_READY
:
453 case EVP_RAND_STATE_ERROR
:
460 BIO_printf(bio_out
, " state = %s\n", p
);
462 gettables
= EVP_RAND_gettable_ctx_params(rand
);
463 if (gettables
!= NULL
)
464 for (; gettables
->key
!= NULL
; gettables
++) {
465 /* State has been dealt with already, so ignore */
466 if (OPENSSL_strcasecmp(gettables
->key
, OSSL_RAND_PARAM_STATE
) == 0)
468 /* Outside of verbose mode, we skip non-string values */
469 if (gettables
->data_type
!= OSSL_PARAM_UTF8_STRING
470 && gettables
->data_type
!= OSSL_PARAM_UTF8_PTR
473 params
->key
= gettables
->key
;
474 params
->data_type
= gettables
->data_type
;
475 if (gettables
->data_type
== OSSL_PARAM_UNSIGNED_INTEGER
476 || gettables
->data_type
== OSSL_PARAM_INTEGER
) {
478 params
->data_size
= sizeof(u
);
481 params
->data_size
= sizeof(buf
);
483 params
->return_size
= 0;
484 if (EVP_RAND_CTX_get_params(drbg
, params
))
485 print_param_value(params
, 2);
490 static void list_random_instances(void)
492 display_random("primary", RAND_get0_primary(NULL
));
493 display_random("public", RAND_get0_public(NULL
));
494 display_random("private", RAND_get0_private(NULL
));
500 DEFINE_STACK_OF(OSSL_ENCODER
)
501 static int encoder_cmp(const OSSL_ENCODER
* const *a
,
502 const OSSL_ENCODER
* const *b
)
504 return strcmp(OSSL_PROVIDER_get0_name(OSSL_ENCODER_get0_provider(*a
)),
505 OSSL_PROVIDER_get0_name(OSSL_ENCODER_get0_provider(*b
)));
508 static void collect_encoders(OSSL_ENCODER
*encoder
, void *stack
)
510 STACK_OF(OSSL_ENCODER
) *encoder_stack
= stack
;
512 if (is_encoder_fetchable(encoder
)
513 && sk_OSSL_ENCODER_push(encoder_stack
, encoder
) > 0)
514 OSSL_ENCODER_up_ref(encoder
);
517 static void list_encoders(void)
519 STACK_OF(OSSL_ENCODER
) *encoders
;
522 encoders
= sk_OSSL_ENCODER_new(encoder_cmp
);
523 if (encoders
== NULL
) {
524 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
527 BIO_printf(bio_out
, "Provided ENCODERs:\n");
528 OSSL_ENCODER_do_all_provided(app_get0_libctx(), collect_encoders
,
530 sk_OSSL_ENCODER_sort(encoders
);
532 for (i
= 0; i
< sk_OSSL_ENCODER_num(encoders
); i
++) {
533 OSSL_ENCODER
*k
= sk_OSSL_ENCODER_value(encoders
, i
);
534 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
536 if (select_name
!= NULL
&& !OSSL_ENCODER_is_a(k
, select_name
))
539 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
540 if (names
!= NULL
&& OSSL_ENCODER_names_do_all(k
, collect_names
, names
)) {
541 BIO_printf(bio_out
, " ");
542 print_names(bio_out
, names
);
544 BIO_printf(bio_out
, " @ %s (%s)\n",
545 OSSL_PROVIDER_get0_name(OSSL_ENCODER_get0_provider(k
)),
546 OSSL_ENCODER_get0_properties(k
));
549 const char *desc
= OSSL_ENCODER_get0_description(k
);
552 BIO_printf(bio_out
, " description: %s\n", desc
);
553 print_param_types("settable operation parameters",
554 OSSL_ENCODER_settable_ctx_params(k
), 4);
557 sk_OPENSSL_CSTRING_free(names
);
559 sk_OSSL_ENCODER_pop_free(encoders
, OSSL_ENCODER_free
);
565 DEFINE_STACK_OF(OSSL_DECODER
)
566 static int decoder_cmp(const OSSL_DECODER
* const *a
,
567 const OSSL_DECODER
* const *b
)
569 return strcmp(OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(*a
)),
570 OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(*b
)));
573 static void collect_decoders(OSSL_DECODER
*decoder
, void *stack
)
575 STACK_OF(OSSL_DECODER
) *decoder_stack
= stack
;
577 if (is_decoder_fetchable(decoder
)
578 && sk_OSSL_DECODER_push(decoder_stack
, decoder
) > 0)
579 OSSL_DECODER_up_ref(decoder
);
582 static void list_decoders(void)
584 STACK_OF(OSSL_DECODER
) *decoders
;
587 decoders
= sk_OSSL_DECODER_new(decoder_cmp
);
588 if (decoders
== NULL
) {
589 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
592 BIO_printf(bio_out
, "Provided DECODERs:\n");
593 OSSL_DECODER_do_all_provided(app_get0_libctx(), collect_decoders
,
595 sk_OSSL_DECODER_sort(decoders
);
597 for (i
= 0; i
< sk_OSSL_DECODER_num(decoders
); i
++) {
598 OSSL_DECODER
*k
= sk_OSSL_DECODER_value(decoders
, i
);
599 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
601 if (select_name
!= NULL
&& !OSSL_DECODER_is_a(k
, select_name
))
604 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
605 if (names
!= NULL
&& OSSL_DECODER_names_do_all(k
, collect_names
, names
)) {
606 BIO_printf(bio_out
, " ");
607 print_names(bio_out
, names
);
609 BIO_printf(bio_out
, " @ %s (%s)\n",
610 OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(k
)),
611 OSSL_DECODER_get0_properties(k
));
614 const char *desc
= OSSL_DECODER_get0_description(k
);
617 BIO_printf(bio_out
, " description: %s\n", desc
);
618 print_param_types("settable operation parameters",
619 OSSL_DECODER_settable_ctx_params(k
), 4);
622 sk_OPENSSL_CSTRING_free(names
);
624 sk_OSSL_DECODER_pop_free(decoders
, OSSL_DECODER_free
);
627 DEFINE_STACK_OF(EVP_KEYMGMT
)
628 static int keymanager_cmp(const EVP_KEYMGMT
* const *a
,
629 const EVP_KEYMGMT
* const *b
)
631 return strcmp(OSSL_PROVIDER_get0_name(EVP_KEYMGMT_get0_provider(*a
)),
632 OSSL_PROVIDER_get0_name(EVP_KEYMGMT_get0_provider(*b
)));
635 static void collect_keymanagers(EVP_KEYMGMT
*km
, void *stack
)
637 STACK_OF(EVP_KEYMGMT
) *km_stack
= stack
;
639 if (is_keymgmt_fetchable(km
)
640 && sk_EVP_KEYMGMT_push(km_stack
, km
) > 0)
641 EVP_KEYMGMT_up_ref(km
);
644 static void list_keymanagers(void)
647 STACK_OF(EVP_KEYMGMT
) *km_stack
= sk_EVP_KEYMGMT_new(keymanager_cmp
);
649 EVP_KEYMGMT_do_all_provided(app_get0_libctx(), collect_keymanagers
,
651 sk_EVP_KEYMGMT_sort(km_stack
);
653 for (i
= 0; i
< sk_EVP_KEYMGMT_num(km_stack
); i
++) {
654 EVP_KEYMGMT
*k
= sk_EVP_KEYMGMT_value(km_stack
, i
);
655 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
657 if (select_name
!= NULL
&& !EVP_KEYMGMT_is_a(k
, select_name
))
660 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
661 if (names
!= NULL
&& EVP_KEYMGMT_names_do_all(k
, collect_names
, names
)) {
662 const char *desc
= EVP_KEYMGMT_get0_description(k
);
664 BIO_printf(bio_out
, " Name: ");
666 BIO_printf(bio_out
, "%s", desc
);
668 BIO_printf(bio_out
, "%s", sk_OPENSSL_CSTRING_value(names
, 0));
669 BIO_printf(bio_out
, "\n");
670 BIO_printf(bio_out
, " Type: Provider Algorithm\n");
671 BIO_printf(bio_out
, " IDs: ");
672 print_names(bio_out
, names
);
673 BIO_printf(bio_out
, " @ %s\n",
674 OSSL_PROVIDER_get0_name(EVP_KEYMGMT_get0_provider(k
)));
677 print_param_types("settable key generation parameters",
678 EVP_KEYMGMT_gen_settable_params(k
), 4);
679 print_param_types("settable operation parameters",
680 EVP_KEYMGMT_settable_params(k
), 4);
681 print_param_types("retrievable operation parameters",
682 EVP_KEYMGMT_gettable_params(k
), 4);
685 sk_OPENSSL_CSTRING_free(names
);
687 sk_EVP_KEYMGMT_pop_free(km_stack
, EVP_KEYMGMT_free
);
690 DEFINE_STACK_OF(EVP_SIGNATURE
)
691 static int signature_cmp(const EVP_SIGNATURE
* const *a
,
692 const EVP_SIGNATURE
* const *b
)
694 return strcmp(OSSL_PROVIDER_get0_name(EVP_SIGNATURE_get0_provider(*a
)),
695 OSSL_PROVIDER_get0_name(EVP_SIGNATURE_get0_provider(*b
)));
698 static void collect_signatures(EVP_SIGNATURE
*sig
, void *stack
)
700 STACK_OF(EVP_SIGNATURE
) *sig_stack
= stack
;
702 if (is_signature_fetchable(sig
)
703 && sk_EVP_SIGNATURE_push(sig_stack
, sig
) > 0)
704 EVP_SIGNATURE_up_ref(sig
);
707 static void list_signatures(void)
710 STACK_OF(EVP_SIGNATURE
) *sig_stack
= sk_EVP_SIGNATURE_new(signature_cmp
);
712 EVP_SIGNATURE_do_all_provided(app_get0_libctx(), collect_signatures
,
714 sk_EVP_SIGNATURE_sort(sig_stack
);
716 for (i
= 0; i
< sk_EVP_SIGNATURE_num(sig_stack
); i
++) {
717 EVP_SIGNATURE
*k
= sk_EVP_SIGNATURE_value(sig_stack
, i
);
718 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
720 if (select_name
!= NULL
&& !EVP_SIGNATURE_is_a(k
, select_name
))
723 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
724 if (names
!= NULL
&& EVP_SIGNATURE_names_do_all(k
, collect_names
, names
)) {
726 BIO_printf(bio_out
, " ");
727 print_names(bio_out
, names
);
729 BIO_printf(bio_out
, " @ %s\n",
730 OSSL_PROVIDER_get0_name(EVP_SIGNATURE_get0_provider(k
)));
733 const char *desc
= EVP_SIGNATURE_get0_description(k
);
736 BIO_printf(bio_out
, " description: %s\n", desc
);
737 print_param_types("settable operation parameters",
738 EVP_SIGNATURE_settable_ctx_params(k
), 4);
739 print_param_types("retrievable operation parameters",
740 EVP_SIGNATURE_gettable_ctx_params(k
), 4);
743 sk_OPENSSL_CSTRING_free(names
);
745 sk_EVP_SIGNATURE_pop_free(sig_stack
, EVP_SIGNATURE_free
);
747 BIO_printf(bio_out
, " -\n");
750 DEFINE_STACK_OF(EVP_KEM
)
751 static int kem_cmp(const EVP_KEM
* const *a
,
752 const EVP_KEM
* const *b
)
754 return strcmp(OSSL_PROVIDER_get0_name(EVP_KEM_get0_provider(*a
)),
755 OSSL_PROVIDER_get0_name(EVP_KEM_get0_provider(*b
)));
758 static void collect_kem(EVP_KEM
*kem
, void *stack
)
760 STACK_OF(EVP_KEM
) *kem_stack
= stack
;
762 if (is_kem_fetchable(kem
)
763 && sk_EVP_KEM_push(kem_stack
, kem
) > 0)
767 static void list_kems(void)
770 STACK_OF(EVP_KEM
) *kem_stack
= sk_EVP_KEM_new(kem_cmp
);
772 EVP_KEM_do_all_provided(app_get0_libctx(), collect_kem
, kem_stack
);
773 sk_EVP_KEM_sort(kem_stack
);
775 for (i
= 0; i
< sk_EVP_KEM_num(kem_stack
); i
++) {
776 EVP_KEM
*k
= sk_EVP_KEM_value(kem_stack
, i
);
777 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
779 if (select_name
!= NULL
&& !EVP_KEM_is_a(k
, select_name
))
782 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
783 if (names
!= NULL
&& EVP_KEM_names_do_all(k
, collect_names
, names
)) {
785 BIO_printf(bio_out
, " ");
786 print_names(bio_out
, names
);
788 BIO_printf(bio_out
, " @ %s\n",
789 OSSL_PROVIDER_get0_name(EVP_KEM_get0_provider(k
)));
792 const char *desc
= EVP_KEM_get0_description(k
);
795 BIO_printf(bio_out
, " description: %s\n", desc
);
796 print_param_types("settable operation parameters",
797 EVP_KEM_settable_ctx_params(k
), 4);
798 print_param_types("retrievable operation parameters",
799 EVP_KEM_gettable_ctx_params(k
), 4);
802 sk_OPENSSL_CSTRING_free(names
);
804 sk_EVP_KEM_pop_free(kem_stack
, EVP_KEM_free
);
806 BIO_printf(bio_out
, " -\n");
809 DEFINE_STACK_OF(EVP_ASYM_CIPHER
)
810 static int asymcipher_cmp(const EVP_ASYM_CIPHER
* const *a
,
811 const EVP_ASYM_CIPHER
* const *b
)
813 return strcmp(OSSL_PROVIDER_get0_name(EVP_ASYM_CIPHER_get0_provider(*a
)),
814 OSSL_PROVIDER_get0_name(EVP_ASYM_CIPHER_get0_provider(*b
)));
817 static void collect_asymciph(EVP_ASYM_CIPHER
*asym_cipher
, void *stack
)
819 STACK_OF(EVP_ASYM_CIPHER
) *asym_cipher_stack
= stack
;
821 if (is_asym_cipher_fetchable(asym_cipher
)
822 && sk_EVP_ASYM_CIPHER_push(asym_cipher_stack
, asym_cipher
) > 0)
823 EVP_ASYM_CIPHER_up_ref(asym_cipher
);
826 static void list_asymciphers(void)
829 STACK_OF(EVP_ASYM_CIPHER
) *asymciph_stack
=
830 sk_EVP_ASYM_CIPHER_new(asymcipher_cmp
);
832 EVP_ASYM_CIPHER_do_all_provided(app_get0_libctx(), collect_asymciph
,
834 sk_EVP_ASYM_CIPHER_sort(asymciph_stack
);
836 for (i
= 0; i
< sk_EVP_ASYM_CIPHER_num(asymciph_stack
); i
++) {
837 EVP_ASYM_CIPHER
*k
= sk_EVP_ASYM_CIPHER_value(asymciph_stack
, i
);
838 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
840 if (select_name
!= NULL
&& !EVP_ASYM_CIPHER_is_a(k
, select_name
))
843 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
845 && EVP_ASYM_CIPHER_names_do_all(k
, collect_names
, names
)) {
847 BIO_printf(bio_out
, " ");
848 print_names(bio_out
, names
);
850 BIO_printf(bio_out
, " @ %s\n",
851 OSSL_PROVIDER_get0_name(EVP_ASYM_CIPHER_get0_provider(k
)));
854 const char *desc
= EVP_ASYM_CIPHER_get0_description(k
);
857 BIO_printf(bio_out
, " description: %s\n", desc
);
858 print_param_types("settable operation parameters",
859 EVP_ASYM_CIPHER_settable_ctx_params(k
), 4);
860 print_param_types("retrievable operation parameters",
861 EVP_ASYM_CIPHER_gettable_ctx_params(k
), 4);
864 sk_OPENSSL_CSTRING_free(names
);
866 sk_EVP_ASYM_CIPHER_pop_free(asymciph_stack
, EVP_ASYM_CIPHER_free
);
868 BIO_printf(bio_out
, " -\n");
871 DEFINE_STACK_OF(EVP_KEYEXCH
)
872 static int kex_cmp(const EVP_KEYEXCH
* const *a
,
873 const EVP_KEYEXCH
* const *b
)
875 return strcmp(OSSL_PROVIDER_get0_name(EVP_KEYEXCH_get0_provider(*a
)),
876 OSSL_PROVIDER_get0_name(EVP_KEYEXCH_get0_provider(*b
)));
879 static void collect_kex(EVP_KEYEXCH
*kex
, void *stack
)
881 STACK_OF(EVP_KEYEXCH
) *kex_stack
= stack
;
883 if (is_keyexch_fetchable(kex
)
884 && sk_EVP_KEYEXCH_push(kex_stack
, kex
) > 0)
885 EVP_KEYEXCH_up_ref(kex
);
888 static void list_keyexchanges(void)
891 STACK_OF(EVP_KEYEXCH
) *kex_stack
= sk_EVP_KEYEXCH_new(kex_cmp
);
893 EVP_KEYEXCH_do_all_provided(app_get0_libctx(), collect_kex
, kex_stack
);
894 sk_EVP_KEYEXCH_sort(kex_stack
);
896 for (i
= 0; i
< sk_EVP_KEYEXCH_num(kex_stack
); i
++) {
897 EVP_KEYEXCH
*k
= sk_EVP_KEYEXCH_value(kex_stack
, i
);
898 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
900 if (select_name
!= NULL
&& !EVP_KEYEXCH_is_a(k
, select_name
))
903 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
904 if (names
!= NULL
&& EVP_KEYEXCH_names_do_all(k
, collect_names
, names
)) {
906 BIO_printf(bio_out
, " ");
907 print_names(bio_out
, names
);
909 BIO_printf(bio_out
, " @ %s\n",
910 OSSL_PROVIDER_get0_name(EVP_KEYEXCH_get0_provider(k
)));
913 const char *desc
= EVP_KEYEXCH_get0_description(k
);
916 BIO_printf(bio_out
, " description: %s\n", desc
);
917 print_param_types("settable operation parameters",
918 EVP_KEYEXCH_settable_ctx_params(k
), 4);
919 print_param_types("retrievable operation parameters",
920 EVP_KEYEXCH_gettable_ctx_params(k
), 4);
923 sk_OPENSSL_CSTRING_free(names
);
925 sk_EVP_KEYEXCH_pop_free(kex_stack
, EVP_KEYEXCH_free
);
927 BIO_printf(bio_out
, " -\n");
930 static void list_objects(void)
932 int max_nid
= OBJ_new_nid(0);
934 char *oid_buf
= NULL
;
937 /* Skip 0, since that's NID_undef */
938 for (i
= 1; i
< max_nid
; i
++) {
939 const ASN1_OBJECT
*obj
= OBJ_nid2obj(i
);
940 const char *sn
= OBJ_nid2sn(i
);
941 const char *ln
= OBJ_nid2ln(i
);
945 * If one of the retrieved objects somehow generated an error,
946 * we ignore it. The check for NID_undef below will detect the
947 * error and simply skip to the next NID.
951 if (OBJ_obj2nid(obj
) == NID_undef
)
954 if ((n
= OBJ_obj2txt(NULL
, 0, obj
, 1)) == 0) {
955 BIO_printf(bio_out
, "# None-OID object: %s, %s\n", sn
, ln
);
962 oid_buf
= OPENSSL_realloc(oid_buf
, n
+ 1);
963 if (oid_buf
== NULL
) {
964 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
969 if (OBJ_obj2txt(oid_buf
, oid_size
, obj
, 1) < 0)
971 if (ln
== NULL
|| strcmp(sn
, ln
) == 0)
972 BIO_printf(bio_out
, "%s = %s\n", sn
, oid_buf
);
974 BIO_printf(bio_out
, "%s = %s, %s\n", sn
, ln
, oid_buf
);
977 OPENSSL_free(oid_buf
);
980 static void list_options_for_command(const char *command
)
985 for (fp
= functions
; fp
->name
!= NULL
; fp
++)
986 if (strcmp(fp
->name
, command
) == 0)
988 if (fp
->name
== NULL
) {
989 BIO_printf(bio_err
, "Invalid command '%s'; type \"help\" for a list.\n",
994 if ((o
= fp
->help
) == NULL
)
997 for ( ; o
->name
!= NULL
; o
++) {
1000 if (o
->name
== OPT_PARAM_STR
)
1003 if (o
->name
== OPT_HELP_STR
1004 || o
->name
== OPT_MORE_STR
1005 || o
->name
== OPT_SECTION_STR
1006 || o
->name
[0] == '\0')
1008 BIO_printf(bio_out
, "%s %c\n", o
->name
, c
== '\0' ? '-' : c
);
1010 /* Always output the -- marker since it is sometimes documented. */
1011 BIO_printf(bio_out
, "- -\n");
1014 static int is_md_available(const char *name
)
1017 const char *propq
= app_get0_propq();
1019 /* Look through providers' digests */
1021 md
= EVP_MD_fetch(app_get0_libctx(), name
, propq
);
1028 return propq
!= NULL
|| get_digest_from_engine(name
) == NULL
? 0 : 1;
1031 static int is_cipher_available(const char *name
)
1034 const char *propq
= app_get0_propq();
1036 /* Look through providers' ciphers */
1038 cipher
= EVP_CIPHER_fetch(app_get0_libctx(), name
, propq
);
1040 if (cipher
!= NULL
) {
1041 EVP_CIPHER_free(cipher
);
1045 return propq
!= NULL
|| get_cipher_from_engine(name
) == NULL
? 0 : 1;
1048 static void list_type(FUNC_TYPE ft
, int one
)
1054 memset(&dc
, 0, sizeof(dc
));
1056 calculate_columns(functions
, &dc
);
1058 for (fp
= functions
; fp
->name
!= NULL
; fp
++) {
1063 if (!is_cipher_available(fp
->name
))
1067 if (!is_md_available(fp
->name
))
1074 BIO_printf(bio_out
, "%s\n", fp
->name
);
1076 if (i
% dc
.columns
== 0 && i
> 0)
1077 BIO_printf(bio_out
, "\n");
1078 BIO_printf(bio_out
, "%-*s", dc
.width
, fp
->name
);
1083 BIO_printf(bio_out
, "\n\n");
1086 static void list_pkey(void)
1088 #ifndef OPENSSL_NO_DEPRECATED_3_0
1091 if (select_name
== NULL
&& include_legacy()) {
1092 BIO_printf(bio_out
, "Legacy:\n");
1093 for (i
= 0; i
< EVP_PKEY_asn1_get_count(); i
++) {
1094 const EVP_PKEY_ASN1_METHOD
*ameth
;
1095 int pkey_id
, pkey_base_id
, pkey_flags
;
1096 const char *pinfo
, *pem_str
;
1097 ameth
= EVP_PKEY_asn1_get0(i
);
1098 EVP_PKEY_asn1_get0_info(&pkey_id
, &pkey_base_id
, &pkey_flags
,
1099 &pinfo
, &pem_str
, ameth
);
1100 if (pkey_flags
& ASN1_PKEY_ALIAS
) {
1101 BIO_printf(bio_out
, " Name: %s\n", OBJ_nid2ln(pkey_id
));
1102 BIO_printf(bio_out
, "\tAlias for: %s\n",
1103 OBJ_nid2ln(pkey_base_id
));
1105 BIO_printf(bio_out
, " Name: %s\n", pinfo
);
1106 BIO_printf(bio_out
, "\tType: %s Algorithm\n",
1107 pkey_flags
& ASN1_PKEY_DYNAMIC
?
1108 "External" : "Builtin");
1109 BIO_printf(bio_out
, "\tOID: %s\n", OBJ_nid2ln(pkey_id
));
1110 if (pem_str
== NULL
)
1112 BIO_printf(bio_out
, "\tPEM string: %s\n", pem_str
);
1117 BIO_printf(bio_out
, "Provided:\n");
1118 BIO_printf(bio_out
, " Key Managers:\n");
1122 static void list_pkey_meth(void)
1124 #ifndef OPENSSL_NO_DEPRECATED_3_0
1126 size_t meth_count
= EVP_PKEY_meth_get_count();
1128 if (select_name
== NULL
&& include_legacy()) {
1129 BIO_printf(bio_out
, "Legacy:\n");
1130 for (i
= 0; i
< meth_count
; i
++) {
1131 const EVP_PKEY_METHOD
*pmeth
= EVP_PKEY_meth_get0(i
);
1132 int pkey_id
, pkey_flags
;
1134 EVP_PKEY_meth_get0_info(&pkey_id
, &pkey_flags
, pmeth
);
1135 BIO_printf(bio_out
, " %s\n", OBJ_nid2ln(pkey_id
));
1136 BIO_printf(bio_out
, "\tType: %s Algorithm\n",
1137 pkey_flags
& ASN1_PKEY_DYNAMIC
? "External" : "Builtin");
1141 BIO_printf(bio_out
, "Provided:\n");
1142 BIO_printf(bio_out
, " Encryption:\n");
1144 BIO_printf(bio_out
, " Key Exchange:\n");
1145 list_keyexchanges();
1146 BIO_printf(bio_out
, " Signatures:\n");
1148 BIO_printf(bio_out
, " Key encapsulation:\n");
1152 DEFINE_STACK_OF(OSSL_STORE_LOADER
)
1153 static int store_cmp(const OSSL_STORE_LOADER
* const *a
,
1154 const OSSL_STORE_LOADER
* const *b
)
1156 return strcmp(OSSL_PROVIDER_get0_name(OSSL_STORE_LOADER_get0_provider(*a
)),
1157 OSSL_PROVIDER_get0_name(OSSL_STORE_LOADER_get0_provider(*b
)));
1160 static void collect_store_loaders(OSSL_STORE_LOADER
*store
, void *stack
)
1162 STACK_OF(OSSL_STORE_LOADER
) *store_stack
= stack
;
1164 if (sk_OSSL_STORE_LOADER_push(store_stack
, store
) > 0)
1165 OSSL_STORE_LOADER_up_ref(store
);
1168 static void list_store_loaders(void)
1170 STACK_OF(OSSL_STORE_LOADER
) *stores
= sk_OSSL_STORE_LOADER_new(store_cmp
);
1173 if (stores
== NULL
) {
1174 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
1177 BIO_printf(bio_out
, "Provided STORE LOADERs:\n");
1178 OSSL_STORE_LOADER_do_all_provided(app_get0_libctx(), collect_store_loaders
,
1180 sk_OSSL_STORE_LOADER_sort(stores
);
1181 for (i
= 0; i
< sk_OSSL_STORE_LOADER_num(stores
); i
++) {
1182 const OSSL_STORE_LOADER
*m
= sk_OSSL_STORE_LOADER_value(stores
, i
);
1183 STACK_OF(OPENSSL_CSTRING
) *names
= NULL
;
1185 if (select_name
!= NULL
&& !OSSL_STORE_LOADER_is_a(m
, select_name
))
1188 names
= sk_OPENSSL_CSTRING_new(name_cmp
);
1189 if (names
!= NULL
&& OSSL_STORE_LOADER_names_do_all(m
, collect_names
,
1191 BIO_printf(bio_out
, " ");
1192 print_names(bio_out
, names
);
1194 BIO_printf(bio_out
, " @ %s\n",
1195 OSSL_PROVIDER_get0_name(OSSL_STORE_LOADER_get0_provider(m
)));
1197 sk_OPENSSL_CSTRING_free(names
);
1199 sk_OSSL_STORE_LOADER_pop_free(stores
, OSSL_STORE_LOADER_free
);
1202 DEFINE_STACK_OF(OSSL_PROVIDER
)
1203 static int provider_cmp(const OSSL_PROVIDER
* const *a
,
1204 const OSSL_PROVIDER
* const *b
)
1206 return strcmp(OSSL_PROVIDER_get0_name(*a
), OSSL_PROVIDER_get0_name(*b
));
1209 static int collect_providers(OSSL_PROVIDER
*provider
, void *stack
)
1211 STACK_OF(OSSL_PROVIDER
) *provider_stack
= stack
;
1213 sk_OSSL_PROVIDER_push(provider_stack
, provider
);
1217 static void list_provider_info(void)
1219 STACK_OF(OSSL_PROVIDER
) *providers
= sk_OSSL_PROVIDER_new(provider_cmp
);
1220 OSSL_PARAM params
[5];
1221 char *name
, *version
, *buildinfo
;
1225 if (providers
== NULL
) {
1226 BIO_printf(bio_err
, "ERROR: Memory allocation\n");
1229 BIO_printf(bio_out
, "Providers:\n");
1230 OSSL_PROVIDER_do_all(NULL
, &collect_providers
, providers
);
1231 sk_OSSL_PROVIDER_sort(providers
);
1232 for (i
= 0; i
< sk_OSSL_PROVIDER_num(providers
); i
++) {
1233 const OSSL_PROVIDER
*prov
= sk_OSSL_PROVIDER_value(providers
, i
);
1235 /* Query the "known" information parameters, the order matches below */
1236 params
[0] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_NAME
,
1238 params
[1] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_VERSION
,
1240 params
[2] = OSSL_PARAM_construct_int(OSSL_PROV_PARAM_STATUS
, &status
);
1241 params
[3] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_BUILDINFO
,
1243 params
[4] = OSSL_PARAM_construct_end();
1244 OSSL_PARAM_set_all_unmodified(params
);
1245 if (!OSSL_PROVIDER_get_params(prov
, params
)) {
1246 BIO_printf(bio_err
, "ERROR: Unable to query provider parameters\n");
1250 /* Print out the provider information, the params order matches above */
1251 BIO_printf(bio_out
, " %s\n", OSSL_PROVIDER_get0_name(prov
));
1252 if (OSSL_PARAM_modified(params
))
1253 BIO_printf(bio_out
, " name: %s\n", name
);
1254 if (OSSL_PARAM_modified(params
+ 1))
1255 BIO_printf(bio_out
, " version: %s\n", version
);
1256 if (OSSL_PARAM_modified(params
+ 2))
1257 BIO_printf(bio_out
, " status: %sactive\n", status
? "" : "in");
1259 if (OSSL_PARAM_modified(params
+ 3))
1260 BIO_printf(bio_out
, " build info: %s\n", buildinfo
);
1261 print_param_types("gettable provider parameters",
1262 OSSL_PROVIDER_gettable_params(prov
), 4);
1265 sk_OSSL_PROVIDER_free(providers
);
1268 #ifndef OPENSSL_NO_DEPRECATED_3_0
1269 static void list_engines(void)
1271 # ifndef OPENSSL_NO_ENGINE
1274 BIO_puts(bio_out
, "Engines:\n");
1275 e
= ENGINE_get_first();
1277 BIO_printf(bio_out
, "%s\n", ENGINE_get_id(e
));
1278 e
= ENGINE_get_next(e
);
1281 BIO_puts(bio_out
, "Engine support is disabled.\n");
1286 static void list_disabled(void)
1288 BIO_puts(bio_out
, "Disabled algorithms:\n");
1289 #ifdef OPENSSL_NO_ARIA
1290 BIO_puts(bio_out
, "ARIA\n");
1292 #ifdef OPENSSL_NO_BF
1293 BIO_puts(bio_out
, "BF\n");
1295 #ifdef OPENSSL_NO_BLAKE2
1296 BIO_puts(bio_out
, "BLAKE2\n");
1298 #ifdef OPENSSL_NO_CAMELLIA
1299 BIO_puts(bio_out
, "CAMELLIA\n");
1301 #ifdef OPENSSL_NO_CAST
1302 BIO_puts(bio_out
, "CAST\n");
1304 #ifdef OPENSSL_NO_CMAC
1305 BIO_puts(bio_out
, "CMAC\n");
1307 #ifdef OPENSSL_NO_CMS
1308 BIO_puts(bio_out
, "CMS\n");
1310 #ifdef OPENSSL_NO_COMP
1311 BIO_puts(bio_out
, "COMP\n");
1313 #ifdef OPENSSL_NO_DES
1314 BIO_puts(bio_out
, "DES\n");
1316 #ifdef OPENSSL_NO_DGRAM
1317 BIO_puts(bio_out
, "DGRAM\n");
1319 #ifdef OPENSSL_NO_DH
1320 BIO_puts(bio_out
, "DH\n");
1322 #ifdef OPENSSL_NO_DSA
1323 BIO_puts(bio_out
, "DSA\n");
1325 #if defined(OPENSSL_NO_DTLS)
1326 BIO_puts(bio_out
, "DTLS\n");
1328 #if defined(OPENSSL_NO_DTLS1)
1329 BIO_puts(bio_out
, "DTLS1\n");
1331 #if defined(OPENSSL_NO_DTLS1_2)
1332 BIO_puts(bio_out
, "DTLS1_2\n");
1334 #ifdef OPENSSL_NO_EC
1335 BIO_puts(bio_out
, "EC\n");
1337 #ifdef OPENSSL_NO_EC2M
1338 BIO_puts(bio_out
, "EC2M\n");
1340 #if defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
1341 BIO_puts(bio_out
, "ENGINE\n");
1343 #ifdef OPENSSL_NO_GOST
1344 BIO_puts(bio_out
, "GOST\n");
1346 #ifdef OPENSSL_NO_IDEA
1347 BIO_puts(bio_out
, "IDEA\n");
1349 #ifdef OPENSSL_NO_MD2
1350 BIO_puts(bio_out
, "MD2\n");
1352 #ifdef OPENSSL_NO_MD4
1353 BIO_puts(bio_out
, "MD4\n");
1355 #ifdef OPENSSL_NO_MD5
1356 BIO_puts(bio_out
, "MD5\n");
1358 #ifdef OPENSSL_NO_MDC2
1359 BIO_puts(bio_out
, "MDC2\n");
1361 #ifdef OPENSSL_NO_OCB
1362 BIO_puts(bio_out
, "OCB\n");
1364 #ifdef OPENSSL_NO_OCSP
1365 BIO_puts(bio_out
, "OCSP\n");
1367 #ifdef OPENSSL_NO_PSK
1368 BIO_puts(bio_out
, "PSK\n");
1370 #ifdef OPENSSL_NO_RC2
1371 BIO_puts(bio_out
, "RC2\n");
1373 #ifdef OPENSSL_NO_RC4
1374 BIO_puts(bio_out
, "RC4\n");
1376 #ifdef OPENSSL_NO_RC5
1377 BIO_puts(bio_out
, "RC5\n");
1379 #ifdef OPENSSL_NO_RMD160
1380 BIO_puts(bio_out
, "RMD160\n");
1382 #ifdef OPENSSL_NO_SCRYPT
1383 BIO_puts(bio_out
, "SCRYPT\n");
1385 #ifdef OPENSSL_NO_SCTP
1386 BIO_puts(bio_out
, "SCTP\n");
1388 #ifdef OPENSSL_NO_SEED
1389 BIO_puts(bio_out
, "SEED\n");
1391 #ifdef OPENSSL_NO_SM2
1392 BIO_puts(bio_out
, "SM2\n");
1394 #ifdef OPENSSL_NO_SM3
1395 BIO_puts(bio_out
, "SM3\n");
1397 #ifdef OPENSSL_NO_SM4
1398 BIO_puts(bio_out
, "SM4\n");
1400 #ifdef OPENSSL_NO_SOCK
1401 BIO_puts(bio_out
, "SOCK\n");
1403 #ifdef OPENSSL_NO_SRP
1404 BIO_puts(bio_out
, "SRP\n");
1406 #ifdef OPENSSL_NO_SRTP
1407 BIO_puts(bio_out
, "SRTP\n");
1409 #ifdef OPENSSL_NO_SSL3
1410 BIO_puts(bio_out
, "SSL3\n");
1412 #ifdef OPENSSL_NO_TLS1
1413 BIO_puts(bio_out
, "TLS1\n");
1415 #ifdef OPENSSL_NO_TLS1_1
1416 BIO_puts(bio_out
, "TLS1_1\n");
1418 #ifdef OPENSSL_NO_TLS1_2
1419 BIO_puts(bio_out
, "TLS1_2\n");
1421 #ifdef OPENSSL_NO_WHIRLPOOL
1422 BIO_puts(bio_out
, "WHIRLPOOL\n");
1425 BIO_puts(bio_out
, "ZLIB\n");
1427 #ifdef OPENSSL_NO_BROTLI
1428 BIO_puts(bio_out
, "BROTLI\n");
1432 /* Unified enum for help and list commands. */
1433 typedef enum HELPLIST_CHOICE
{
1435 OPT_ONE
, OPT_VERBOSE
,
1437 OPT_COMMANDS
, OPT_DIGEST_COMMANDS
, OPT_MAC_ALGORITHMS
, OPT_OPTIONS
,
1438 OPT_DIGEST_ALGORITHMS
, OPT_CIPHER_COMMANDS
, OPT_CIPHER_ALGORITHMS
,
1439 OPT_PK_ALGORITHMS
, OPT_PK_METHOD
, OPT_DISABLED
,
1440 OPT_KDF_ALGORITHMS
, OPT_RANDOM_INSTANCES
, OPT_RANDOM_GENERATORS
,
1441 OPT_ENCODERS
, OPT_DECODERS
, OPT_KEYMANAGERS
, OPT_KEYEXCHANGE_ALGORITHMS
,
1442 OPT_KEM_ALGORITHMS
, OPT_SIGNATURE_ALGORITHMS
, OPT_ASYM_CIPHER_ALGORITHMS
,
1443 OPT_STORE_LOADERS
, OPT_PROVIDER_INFO
,
1444 OPT_OBJECTS
, OPT_SELECT_NAME
,
1445 #ifndef OPENSSL_NO_DEPRECATED_3_0
1451 const OPTIONS list_options
[] = {
1453 OPT_SECTION("General"),
1454 {"help", OPT_HELP
, '-', "Display this summary"},
1456 OPT_SECTION("Output"),
1457 {"1", OPT_ONE
, '-', "List in one column"},
1458 {"verbose", OPT_VERBOSE
, '-', "Verbose listing"},
1459 {"select", OPT_SELECT_NAME
, 's', "Select a single algorithm"},
1460 {"commands", OPT_COMMANDS
, '-', "List of standard commands"},
1461 {"standard-commands", OPT_COMMANDS
, '-', "List of standard commands"},
1462 {"all-algorithms", OPT_ALL_ARGORITHMS
, '-', "List of all algorithms"},
1463 #ifndef OPENSSL_NO_DEPRECATED_3_0
1464 {"digest-commands", OPT_DIGEST_COMMANDS
, '-',
1465 "List of message digest commands (deprecated)"},
1467 {"digest-algorithms", OPT_DIGEST_ALGORITHMS
, '-',
1468 "List of message digest algorithms"},
1469 {"kdf-algorithms", OPT_KDF_ALGORITHMS
, '-',
1470 "List of key derivation and pseudo random function algorithms"},
1471 {"random-instances", OPT_RANDOM_INSTANCES
, '-',
1472 "List the primary, public and private random number generator details"},
1473 {"random-generators", OPT_RANDOM_GENERATORS
, '-',
1474 "List of random number generators"},
1475 {"mac-algorithms", OPT_MAC_ALGORITHMS
, '-',
1476 "List of message authentication code algorithms"},
1477 #ifndef OPENSSL_NO_DEPRECATED_3_0
1478 {"cipher-commands", OPT_CIPHER_COMMANDS
, '-',
1479 "List of cipher commands (deprecated)"},
1481 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS
, '-',
1482 "List of cipher algorithms"},
1483 {"encoders", OPT_ENCODERS
, '-', "List of encoding methods" },
1484 {"decoders", OPT_DECODERS
, '-', "List of decoding methods" },
1485 {"key-managers", OPT_KEYMANAGERS
, '-', "List of key managers" },
1486 {"key-exchange-algorithms", OPT_KEYEXCHANGE_ALGORITHMS
, '-',
1487 "List of key exchange algorithms" },
1488 {"kem-algorithms", OPT_KEM_ALGORITHMS
, '-',
1489 "List of key encapsulation mechanism algorithms" },
1490 {"signature-algorithms", OPT_SIGNATURE_ALGORITHMS
, '-',
1491 "List of signature algorithms" },
1492 {"asymcipher-algorithms", OPT_ASYM_CIPHER_ALGORITHMS
, '-',
1493 "List of asymmetric cipher algorithms" },
1494 {"public-key-algorithms", OPT_PK_ALGORITHMS
, '-',
1495 "List of public key algorithms"},
1496 {"public-key-methods", OPT_PK_METHOD
, '-',
1497 "List of public key methods"},
1498 {"store-loaders", OPT_STORE_LOADERS
, '-',
1499 "List of store loaders"},
1500 {"providers", OPT_PROVIDER_INFO
, '-',
1501 "List of provider information"},
1502 #ifndef OPENSSL_NO_DEPRECATED_3_0
1503 {"engines", OPT_ENGINES
, '-',
1504 "List of loaded engines"},
1506 {"disabled", OPT_DISABLED
, '-', "List of disabled features"},
1507 {"options", OPT_OPTIONS
, 's',
1508 "List options for specified command"},
1509 {"objects", OPT_OBJECTS
, '-',
1510 "List built in objects (OID<->name mappings)"},
1516 int list_main(int argc
, char **argv
)
1520 int one
= 0, done
= 0;
1522 unsigned int commands
:1;
1523 unsigned int all_algorithms
:1;
1524 unsigned int random_instances
:1;
1525 unsigned int random_generators
:1;
1526 unsigned int digest_commands
:1;
1527 unsigned int digest_algorithms
:1;
1528 unsigned int kdf_algorithms
:1;
1529 unsigned int mac_algorithms
:1;
1530 unsigned int cipher_commands
:1;
1531 unsigned int cipher_algorithms
:1;
1532 unsigned int encoder_algorithms
:1;
1533 unsigned int decoder_algorithms
:1;
1534 unsigned int keymanager_algorithms
:1;
1535 unsigned int signature_algorithms
:1;
1536 unsigned int keyexchange_algorithms
:1;
1537 unsigned int kem_algorithms
:1;
1538 unsigned int asym_cipher_algorithms
:1;
1539 unsigned int pk_algorithms
:1;
1540 unsigned int pk_method
:1;
1541 unsigned int store_loaders
:1;
1542 unsigned int provider_info
:1;
1543 #ifndef OPENSSL_NO_DEPRECATED_3_0
1544 unsigned int engines
:1;
1546 unsigned int disabled
:1;
1547 unsigned int objects
:1;
1548 unsigned int options
:1;
1551 verbose
= 0; /* Clear a possible previous call */
1553 prog
= opt_init(argc
, argv
, list_options
);
1554 while ((o
= opt_next()) != OPT_EOF
) {
1556 case OPT_EOF
: /* Never hit, but suppresses warning */
1559 BIO_printf(bio_err
, "%s: Use -help for summary.\n", prog
);
1562 opt_help(list_options
);
1567 case OPT_ALL_ARGORITHMS
:
1568 todo
.all_algorithms
= 1;
1573 case OPT_DIGEST_COMMANDS
:
1574 todo
.digest_commands
= 1;
1576 case OPT_DIGEST_ALGORITHMS
:
1577 todo
.digest_algorithms
= 1;
1579 case OPT_KDF_ALGORITHMS
:
1580 todo
.kdf_algorithms
= 1;
1582 case OPT_RANDOM_INSTANCES
:
1583 todo
.random_instances
= 1;
1585 case OPT_RANDOM_GENERATORS
:
1586 todo
.random_generators
= 1;
1588 case OPT_MAC_ALGORITHMS
:
1589 todo
.mac_algorithms
= 1;
1591 case OPT_CIPHER_COMMANDS
:
1592 todo
.cipher_commands
= 1;
1594 case OPT_CIPHER_ALGORITHMS
:
1595 todo
.cipher_algorithms
= 1;
1598 todo
.encoder_algorithms
= 1;
1601 todo
.decoder_algorithms
= 1;
1603 case OPT_KEYMANAGERS
:
1604 todo
.keymanager_algorithms
= 1;
1606 case OPT_SIGNATURE_ALGORITHMS
:
1607 todo
.signature_algorithms
= 1;
1609 case OPT_KEYEXCHANGE_ALGORITHMS
:
1610 todo
.keyexchange_algorithms
= 1;
1612 case OPT_KEM_ALGORITHMS
:
1613 todo
.kem_algorithms
= 1;
1615 case OPT_ASYM_CIPHER_ALGORITHMS
:
1616 todo
.asym_cipher_algorithms
= 1;
1618 case OPT_PK_ALGORITHMS
:
1619 todo
.pk_algorithms
= 1;
1624 case OPT_STORE_LOADERS
:
1625 todo
.store_loaders
= 1;
1627 case OPT_PROVIDER_INFO
:
1628 todo
.provider_info
= 1;
1630 #ifndef OPENSSL_NO_DEPRECATED_3_0
1642 list_options_for_command(opt_arg());
1647 case OPT_SELECT_NAME
:
1648 select_name
= opt_arg();
1650 case OPT_PROV_CASES
:
1651 if (!opt_provider(o
))
1658 /* No extra arguments. */
1659 if (!opt_check_rest_arg(NULL
))
1663 list_type(FT_general
, one
);
1664 if (todo
.all_algorithms
) {
1665 BIO_printf(bio_out
, "Digests:\n");
1667 BIO_printf(bio_out
, "Symmetric Ciphers:\n");
1672 BIO_printf(bio_out
, "Provided Asymmetric Encryption:\n");
1674 BIO_printf(bio_out
, "Provided Key Exchange:\n");
1675 list_keyexchanges();
1676 BIO_printf(bio_out
, "Provided Signatures:\n");
1678 BIO_printf(bio_out
, "Provided Key encapsulation:\n");
1680 BIO_printf(bio_out
, "Provided Key managers:\n");
1685 list_store_loaders();
1687 if (todo
.random_instances
)
1688 list_random_instances();
1689 if (todo
.random_generators
)
1690 list_random_generators();
1691 if (todo
.digest_commands
)
1692 list_type(FT_md
, one
);
1693 if (todo
.digest_algorithms
)
1695 if (todo
.kdf_algorithms
)
1697 if (todo
.mac_algorithms
)
1699 if (todo
.cipher_commands
)
1700 list_type(FT_cipher
, one
);
1701 if (todo
.cipher_algorithms
)
1703 if (todo
.encoder_algorithms
)
1705 if (todo
.decoder_algorithms
)
1707 if (todo
.keymanager_algorithms
)
1709 if (todo
.signature_algorithms
)
1711 if (todo
.asym_cipher_algorithms
)
1713 if (todo
.keyexchange_algorithms
)
1714 list_keyexchanges();
1715 if (todo
.kem_algorithms
)
1717 if (todo
.pk_algorithms
)
1721 if (todo
.store_loaders
)
1722 list_store_loaders();
1723 if (todo
.provider_info
)
1724 list_provider_info();
1725 #ifndef OPENSSL_NO_DEPRECATED_3_0