list.c 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. /*
  2. * Copyright 1995-2021 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. /* We need to use some deprecated APIs */
  10. #define OPENSSL_SUPPRESS_DEPRECATED
  11. #include <string.h>
  12. #include <openssl/evp.h>
  13. #include <openssl/err.h>
  14. #include <openssl/provider.h>
  15. #include <openssl/safestack.h>
  16. #include <openssl/kdf.h>
  17. #include <openssl/encoder.h>
  18. #include <openssl/decoder.h>
  19. #include <openssl/store.h>
  20. #include <openssl/core_names.h>
  21. #include <openssl/rand.h>
  22. #include "apps.h"
  23. #include "app_params.h"
  24. #include "progs.h"
  25. #include "opt.h"
  26. #include "names.h"
  27. static int verbose = 0;
  28. static const char *select_name = NULL;
  29. /* Checks to see if algorithms are fetchable */
  30. #define IS_FETCHABLE(type, TYPE) \
  31. static int is_ ## type ## _fetchable(const TYPE *alg) \
  32. { \
  33. TYPE *impl; \
  34. const char *propq = app_get0_propq(); \
  35. const char *name = TYPE ## _get0_name(alg); \
  36. \
  37. ERR_set_mark(); \
  38. impl = TYPE ## _fetch(NULL, name, propq); \
  39. ERR_pop_to_mark(); \
  40. if (impl == NULL) \
  41. return 0; \
  42. TYPE ## _free(impl); \
  43. return 1; \
  44. }
  45. IS_FETCHABLE(cipher, EVP_CIPHER)
  46. IS_FETCHABLE(digest, EVP_MD)
  47. IS_FETCHABLE(mac, EVP_MAC)
  48. IS_FETCHABLE(kdf, EVP_KDF)
  49. IS_FETCHABLE(rand, EVP_RAND)
  50. IS_FETCHABLE(keymgmt, EVP_KEYMGMT)
  51. IS_FETCHABLE(signature, EVP_SIGNATURE)
  52. IS_FETCHABLE(kem, EVP_KEM)
  53. IS_FETCHABLE(asym_cipher, EVP_ASYM_CIPHER)
  54. IS_FETCHABLE(keyexch, EVP_KEYEXCH)
  55. IS_FETCHABLE(decoder, OSSL_DECODER)
  56. IS_FETCHABLE(encoder, OSSL_ENCODER)
  57. #ifndef OPENSSL_NO_DEPRECATED_3_0
  58. static int include_legacy(void)
  59. {
  60. return app_get0_propq() == NULL;
  61. }
  62. static void legacy_cipher_fn(const EVP_CIPHER *c,
  63. const char *from, const char *to, void *arg)
  64. {
  65. if (select_name != NULL
  66. && (c == NULL
  67. || strcasecmp(select_name, EVP_CIPHER_get0_name(c)) != 0))
  68. return;
  69. if (c != NULL) {
  70. BIO_printf(arg, " %s\n", EVP_CIPHER_get0_name(c));
  71. } else {
  72. if (from == NULL)
  73. from = "<undefined>";
  74. if (to == NULL)
  75. to = "<undefined>";
  76. BIO_printf(arg, " %s => %s\n", from, to);
  77. }
  78. }
  79. #endif
  80. DEFINE_STACK_OF(EVP_CIPHER)
  81. static int cipher_cmp(const EVP_CIPHER * const *a,
  82. const EVP_CIPHER * const *b)
  83. {
  84. return strcmp(OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(*a)),
  85. OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(*b)));
  86. }
  87. static void collect_ciphers(EVP_CIPHER *cipher, void *stack)
  88. {
  89. STACK_OF(EVP_CIPHER) *cipher_stack = stack;
  90. if (is_cipher_fetchable(cipher)
  91. && sk_EVP_CIPHER_push(cipher_stack, cipher) > 0)
  92. EVP_CIPHER_up_ref(cipher);
  93. }
  94. static void list_ciphers(void)
  95. {
  96. STACK_OF(EVP_CIPHER) *ciphers = sk_EVP_CIPHER_new(cipher_cmp);
  97. int i;
  98. if (ciphers == NULL) {
  99. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  100. return;
  101. }
  102. #ifndef OPENSSL_NO_DEPRECATED_3_0
  103. if (include_legacy()) {
  104. BIO_printf(bio_out, "Legacy:\n");
  105. EVP_CIPHER_do_all_sorted(legacy_cipher_fn, bio_out);
  106. }
  107. #endif
  108. BIO_printf(bio_out, "Provided:\n");
  109. EVP_CIPHER_do_all_provided(NULL, collect_ciphers, ciphers);
  110. sk_EVP_CIPHER_sort(ciphers);
  111. for (i = 0; i < sk_EVP_CIPHER_num(ciphers); i++) {
  112. const EVP_CIPHER *c = sk_EVP_CIPHER_value(ciphers, i);
  113. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  114. if (select_name != NULL && !EVP_CIPHER_is_a(c, select_name))
  115. continue;
  116. names = sk_OPENSSL_CSTRING_new(name_cmp);
  117. if (names != NULL && EVP_CIPHER_names_do_all(c, collect_names, names)) {
  118. BIO_printf(bio_out, " ");
  119. print_names(bio_out, names);
  120. BIO_printf(bio_out, " @ %s\n",
  121. OSSL_PROVIDER_get0_name(EVP_CIPHER_get0_provider(c)));
  122. if (verbose) {
  123. const char *desc = EVP_CIPHER_get0_description(c);
  124. if (desc != NULL)
  125. BIO_printf(bio_out, " description: %s\n", desc);
  126. print_param_types("retrievable algorithm parameters",
  127. EVP_CIPHER_gettable_params(c), 4);
  128. print_param_types("retrievable operation parameters",
  129. EVP_CIPHER_gettable_ctx_params(c), 4);
  130. print_param_types("settable operation parameters",
  131. EVP_CIPHER_settable_ctx_params(c), 4);
  132. }
  133. }
  134. sk_OPENSSL_CSTRING_free(names);
  135. }
  136. sk_EVP_CIPHER_pop_free(ciphers, EVP_CIPHER_free);
  137. }
  138. #ifndef OPENSSL_NO_DEPRECATED_3_0
  139. static void legacy_md_fn(const EVP_MD *m,
  140. const char *from, const char *to, void *arg)
  141. {
  142. if (m != NULL) {
  143. BIO_printf(arg, " %s\n", EVP_MD_get0_name(m));
  144. } else {
  145. if (from == NULL)
  146. from = "<undefined>";
  147. if (to == NULL)
  148. to = "<undefined>";
  149. BIO_printf((BIO *)arg, " %s => %s\n", from, to);
  150. }
  151. }
  152. #endif
  153. DEFINE_STACK_OF(EVP_MD)
  154. static int md_cmp(const EVP_MD * const *a, const EVP_MD * const *b)
  155. {
  156. return strcmp(OSSL_PROVIDER_get0_name(EVP_MD_get0_provider(*a)),
  157. OSSL_PROVIDER_get0_name(EVP_MD_get0_provider(*b)));
  158. }
  159. static void collect_digests(EVP_MD *digest, void *stack)
  160. {
  161. STACK_OF(EVP_MD) *digest_stack = stack;
  162. if (is_digest_fetchable(digest)
  163. && sk_EVP_MD_push(digest_stack, digest) > 0)
  164. EVP_MD_up_ref(digest);
  165. }
  166. static void list_digests(void)
  167. {
  168. STACK_OF(EVP_MD) *digests = sk_EVP_MD_new(md_cmp);
  169. int i;
  170. if (digests == NULL) {
  171. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  172. return;
  173. }
  174. #ifndef OPENSSL_NO_DEPRECATED_3_0
  175. if (include_legacy()) {
  176. BIO_printf(bio_out, "Legacy:\n");
  177. EVP_MD_do_all_sorted(legacy_md_fn, bio_out);
  178. }
  179. #endif
  180. BIO_printf(bio_out, "Provided:\n");
  181. EVP_MD_do_all_provided(NULL, collect_digests, digests);
  182. sk_EVP_MD_sort(digests);
  183. for (i = 0; i < sk_EVP_MD_num(digests); i++) {
  184. const EVP_MD *m = sk_EVP_MD_value(digests, i);
  185. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  186. if (select_name != NULL && !EVP_MD_is_a(m, select_name))
  187. continue;
  188. names = sk_OPENSSL_CSTRING_new(name_cmp);
  189. if (names != NULL && EVP_MD_names_do_all(m, collect_names, names)) {
  190. BIO_printf(bio_out, " ");
  191. print_names(bio_out, names);
  192. BIO_printf(bio_out, " @ %s\n",
  193. OSSL_PROVIDER_get0_name(EVP_MD_get0_provider(m)));
  194. if (verbose) {
  195. const char *desc = EVP_MD_get0_description(m);
  196. if (desc != NULL)
  197. BIO_printf(bio_out, " description: %s\n", desc);
  198. print_param_types("retrievable algorithm parameters",
  199. EVP_MD_gettable_params(m), 4);
  200. print_param_types("retrievable operation parameters",
  201. EVP_MD_gettable_ctx_params(m), 4);
  202. print_param_types("settable operation parameters",
  203. EVP_MD_settable_ctx_params(m), 4);
  204. }
  205. }
  206. sk_OPENSSL_CSTRING_free(names);
  207. }
  208. sk_EVP_MD_pop_free(digests, EVP_MD_free);
  209. }
  210. DEFINE_STACK_OF(EVP_MAC)
  211. static int mac_cmp(const EVP_MAC * const *a, const EVP_MAC * const *b)
  212. {
  213. return strcmp(OSSL_PROVIDER_get0_name(EVP_MAC_get0_provider(*a)),
  214. OSSL_PROVIDER_get0_name(EVP_MAC_get0_provider(*b)));
  215. }
  216. static void collect_macs(EVP_MAC *mac, void *stack)
  217. {
  218. STACK_OF(EVP_MAC) *mac_stack = stack;
  219. if (is_mac_fetchable(mac)
  220. && sk_EVP_MAC_push(mac_stack, mac) > 0)
  221. EVP_MAC_up_ref(mac);
  222. }
  223. static void list_macs(void)
  224. {
  225. STACK_OF(EVP_MAC) *macs = sk_EVP_MAC_new(mac_cmp);
  226. int i;
  227. if (macs == NULL) {
  228. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  229. return;
  230. }
  231. BIO_printf(bio_out, "Provided MACs:\n");
  232. EVP_MAC_do_all_provided(NULL, collect_macs, macs);
  233. sk_EVP_MAC_sort(macs);
  234. for (i = 0; i < sk_EVP_MAC_num(macs); i++) {
  235. const EVP_MAC *m = sk_EVP_MAC_value(macs, i);
  236. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  237. if (select_name != NULL && !EVP_MAC_is_a(m, select_name))
  238. continue;
  239. names = sk_OPENSSL_CSTRING_new(name_cmp);
  240. if (names != NULL && EVP_MAC_names_do_all(m, collect_names, names)) {
  241. BIO_printf(bio_out, " ");
  242. print_names(bio_out, names);
  243. BIO_printf(bio_out, " @ %s\n",
  244. OSSL_PROVIDER_get0_name(EVP_MAC_get0_provider(m)));
  245. if (verbose) {
  246. const char *desc = EVP_MAC_get0_description(m);
  247. if (desc != NULL)
  248. BIO_printf(bio_out, " description: %s\n", desc);
  249. print_param_types("retrievable algorithm parameters",
  250. EVP_MAC_gettable_params(m), 4);
  251. print_param_types("retrievable operation parameters",
  252. EVP_MAC_gettable_ctx_params(m), 4);
  253. print_param_types("settable operation parameters",
  254. EVP_MAC_settable_ctx_params(m), 4);
  255. }
  256. }
  257. sk_OPENSSL_CSTRING_free(names);
  258. }
  259. sk_EVP_MAC_pop_free(macs, EVP_MAC_free);
  260. }
  261. /*
  262. * KDFs and PRFs
  263. */
  264. DEFINE_STACK_OF(EVP_KDF)
  265. static int kdf_cmp(const EVP_KDF * const *a, const EVP_KDF * const *b)
  266. {
  267. return strcmp(OSSL_PROVIDER_get0_name(EVP_KDF_get0_provider(*a)),
  268. OSSL_PROVIDER_get0_name(EVP_KDF_get0_provider(*b)));
  269. }
  270. static void collect_kdfs(EVP_KDF *kdf, void *stack)
  271. {
  272. STACK_OF(EVP_KDF) *kdf_stack = stack;
  273. if (is_kdf_fetchable(kdf)
  274. && sk_EVP_KDF_push(kdf_stack, kdf) > 0)
  275. EVP_KDF_up_ref(kdf);
  276. }
  277. static void list_kdfs(void)
  278. {
  279. STACK_OF(EVP_KDF) *kdfs = sk_EVP_KDF_new(kdf_cmp);
  280. int i;
  281. if (kdfs == NULL) {
  282. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  283. return;
  284. }
  285. BIO_printf(bio_out, "Provided KDFs and PDFs:\n");
  286. EVP_KDF_do_all_provided(NULL, collect_kdfs, kdfs);
  287. sk_EVP_KDF_sort(kdfs);
  288. for (i = 0; i < sk_EVP_KDF_num(kdfs); i++) {
  289. const EVP_KDF *k = sk_EVP_KDF_value(kdfs, i);
  290. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  291. if (select_name != NULL && !EVP_KDF_is_a(k, select_name))
  292. continue;
  293. names = sk_OPENSSL_CSTRING_new(name_cmp);
  294. if (names != NULL && EVP_KDF_names_do_all(k, collect_names, names)) {
  295. BIO_printf(bio_out, " ");
  296. print_names(bio_out, names);
  297. BIO_printf(bio_out, " @ %s\n",
  298. OSSL_PROVIDER_get0_name(EVP_KDF_get0_provider(k)));
  299. if (verbose) {
  300. const char *desc = EVP_KDF_get0_description(k);
  301. if (desc != NULL)
  302. BIO_printf(bio_out, " description: %s\n", desc);
  303. print_param_types("retrievable algorithm parameters",
  304. EVP_KDF_gettable_params(k), 4);
  305. print_param_types("retrievable operation parameters",
  306. EVP_KDF_gettable_ctx_params(k), 4);
  307. print_param_types("settable operation parameters",
  308. EVP_KDF_settable_ctx_params(k), 4);
  309. }
  310. }
  311. sk_OPENSSL_CSTRING_free(names);
  312. }
  313. sk_EVP_KDF_pop_free(kdfs, EVP_KDF_free);
  314. }
  315. /*
  316. * RANDs
  317. */
  318. DEFINE_STACK_OF(EVP_RAND)
  319. static int rand_cmp(const EVP_RAND * const *a, const EVP_RAND * const *b)
  320. {
  321. int ret = strcasecmp(EVP_RAND_get0_name(*a), EVP_RAND_get0_name(*b));
  322. if (ret == 0)
  323. ret = strcmp(OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(*a)),
  324. OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(*b)));
  325. return ret;
  326. }
  327. static void collect_rands(EVP_RAND *rand, void *stack)
  328. {
  329. STACK_OF(EVP_RAND) *rand_stack = stack;
  330. if (is_rand_fetchable(rand)
  331. && sk_EVP_RAND_push(rand_stack, rand) > 0)
  332. EVP_RAND_up_ref(rand);
  333. }
  334. static void list_random_generators(void)
  335. {
  336. STACK_OF(EVP_RAND) *rands = sk_EVP_RAND_new(rand_cmp);
  337. int i;
  338. if (rands == NULL) {
  339. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  340. return;
  341. }
  342. BIO_printf(bio_out, "Provided RNGs and seed sources:\n");
  343. EVP_RAND_do_all_provided(NULL, collect_rands, rands);
  344. sk_EVP_RAND_sort(rands);
  345. for (i = 0; i < sk_EVP_RAND_num(rands); i++) {
  346. const EVP_RAND *m = sk_EVP_RAND_value(rands, i);
  347. if (select_name != NULL
  348. && strcasecmp(EVP_RAND_get0_name(m), select_name) != 0)
  349. continue;
  350. BIO_printf(bio_out, " %s", EVP_RAND_get0_name(m));
  351. BIO_printf(bio_out, " @ %s\n",
  352. OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(m)));
  353. if (verbose) {
  354. const char *desc = EVP_RAND_get0_description(m);
  355. if (desc != NULL)
  356. BIO_printf(bio_out, " description: %s\n", desc);
  357. print_param_types("retrievable algorithm parameters",
  358. EVP_RAND_gettable_params(m), 4);
  359. print_param_types("retrievable operation parameters",
  360. EVP_RAND_gettable_ctx_params(m), 4);
  361. print_param_types("settable operation parameters",
  362. EVP_RAND_settable_ctx_params(m), 4);
  363. }
  364. }
  365. sk_EVP_RAND_pop_free(rands, EVP_RAND_free);
  366. }
  367. static void display_random(const char *name, EVP_RAND_CTX *drbg)
  368. {
  369. EVP_RAND *rand;
  370. uint64_t u;
  371. const char *p;
  372. const OSSL_PARAM *gettables;
  373. OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
  374. unsigned char buf[1000];
  375. BIO_printf(bio_out, "%s:\n", name);
  376. if (drbg != NULL) {
  377. rand = EVP_RAND_CTX_get0_rand(drbg);
  378. BIO_printf(bio_out, " %s", EVP_RAND_get0_name(rand));
  379. BIO_printf(bio_out, " @ %s\n",
  380. OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(rand)));
  381. switch (EVP_RAND_get_state(drbg)) {
  382. case EVP_RAND_STATE_UNINITIALISED:
  383. p = "uninitialised";
  384. break;
  385. case EVP_RAND_STATE_READY:
  386. p = "ready";
  387. break;
  388. case EVP_RAND_STATE_ERROR:
  389. p = "error";
  390. break;
  391. default:
  392. p = "unknown";
  393. break;
  394. }
  395. BIO_printf(bio_out, " state = %s\n", p);
  396. gettables = EVP_RAND_gettable_ctx_params(rand);
  397. if (gettables != NULL)
  398. for (; gettables->key != NULL; gettables++) {
  399. /* State has been dealt with already, so ignore */
  400. if (strcasecmp(gettables->key, OSSL_RAND_PARAM_STATE) == 0)
  401. continue;
  402. /* Outside of verbose mode, we skip non-string values */
  403. if (gettables->data_type != OSSL_PARAM_UTF8_STRING
  404. && gettables->data_type != OSSL_PARAM_UTF8_PTR
  405. && !verbose)
  406. continue;
  407. params->key = gettables->key;
  408. params->data_type = gettables->data_type;
  409. if (gettables->data_type == OSSL_PARAM_UNSIGNED_INTEGER
  410. || gettables->data_type == OSSL_PARAM_INTEGER) {
  411. params->data = &u;
  412. params->data_size = sizeof(u);
  413. } else {
  414. params->data = buf;
  415. params->data_size = sizeof(buf);
  416. }
  417. params->return_size = 0;
  418. if (EVP_RAND_CTX_get_params(drbg, params))
  419. print_param_value(params, 2);
  420. }
  421. }
  422. }
  423. static void list_random_instances(void)
  424. {
  425. display_random("primary", RAND_get0_primary(NULL));
  426. display_random("public", RAND_get0_public(NULL));
  427. display_random("private", RAND_get0_private(NULL));
  428. }
  429. /*
  430. * Encoders
  431. */
  432. DEFINE_STACK_OF(OSSL_ENCODER)
  433. static int encoder_cmp(const OSSL_ENCODER * const *a,
  434. const OSSL_ENCODER * const *b)
  435. {
  436. return strcmp(OSSL_PROVIDER_get0_name(OSSL_ENCODER_get0_provider(*a)),
  437. OSSL_PROVIDER_get0_name(OSSL_ENCODER_get0_provider(*b)));
  438. }
  439. static void collect_encoders(OSSL_ENCODER *encoder, void *stack)
  440. {
  441. STACK_OF(OSSL_ENCODER) *encoder_stack = stack;
  442. if (is_encoder_fetchable(encoder)
  443. && sk_OSSL_ENCODER_push(encoder_stack, encoder) > 0)
  444. OSSL_ENCODER_up_ref(encoder);
  445. }
  446. static void list_encoders(void)
  447. {
  448. STACK_OF(OSSL_ENCODER) *encoders;
  449. int i;
  450. encoders = sk_OSSL_ENCODER_new(encoder_cmp);
  451. if (encoders == NULL) {
  452. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  453. return;
  454. }
  455. BIO_printf(bio_out, "Provided ENCODERs:\n");
  456. OSSL_ENCODER_do_all_provided(NULL, collect_encoders, encoders);
  457. sk_OSSL_ENCODER_sort(encoders);
  458. for (i = 0; i < sk_OSSL_ENCODER_num(encoders); i++) {
  459. OSSL_ENCODER *k = sk_OSSL_ENCODER_value(encoders, i);
  460. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  461. if (select_name != NULL && !OSSL_ENCODER_is_a(k, select_name))
  462. continue;
  463. names = sk_OPENSSL_CSTRING_new(name_cmp);
  464. if (names != NULL && OSSL_ENCODER_names_do_all(k, collect_names, names)) {
  465. BIO_printf(bio_out, " ");
  466. print_names(bio_out, names);
  467. BIO_printf(bio_out, " @ %s (%s)\n",
  468. OSSL_PROVIDER_get0_name(OSSL_ENCODER_get0_provider(k)),
  469. OSSL_ENCODER_get0_properties(k));
  470. if (verbose) {
  471. const char *desc = OSSL_ENCODER_get0_description(k);
  472. if (desc != NULL)
  473. BIO_printf(bio_out, " description: %s\n", desc);
  474. print_param_types("settable operation parameters",
  475. OSSL_ENCODER_settable_ctx_params(k), 4);
  476. }
  477. }
  478. sk_OPENSSL_CSTRING_free(names);
  479. }
  480. sk_OSSL_ENCODER_pop_free(encoders, OSSL_ENCODER_free);
  481. }
  482. /*
  483. * Decoders
  484. */
  485. DEFINE_STACK_OF(OSSL_DECODER)
  486. static int decoder_cmp(const OSSL_DECODER * const *a,
  487. const OSSL_DECODER * const *b)
  488. {
  489. return strcmp(OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(*a)),
  490. OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(*b)));
  491. }
  492. static void collect_decoders(OSSL_DECODER *decoder, void *stack)
  493. {
  494. STACK_OF(OSSL_DECODER) *decoder_stack = stack;
  495. if (is_decoder_fetchable(decoder)
  496. && sk_OSSL_DECODER_push(decoder_stack, decoder) > 0)
  497. OSSL_DECODER_up_ref(decoder);
  498. }
  499. static void list_decoders(void)
  500. {
  501. STACK_OF(OSSL_DECODER) *decoders;
  502. int i;
  503. decoders = sk_OSSL_DECODER_new(decoder_cmp);
  504. if (decoders == NULL) {
  505. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  506. return;
  507. }
  508. BIO_printf(bio_out, "Provided DECODERs:\n");
  509. OSSL_DECODER_do_all_provided(NULL, collect_decoders,
  510. decoders);
  511. sk_OSSL_DECODER_sort(decoders);
  512. for (i = 0; i < sk_OSSL_DECODER_num(decoders); i++) {
  513. OSSL_DECODER *k = sk_OSSL_DECODER_value(decoders, i);
  514. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  515. if (select_name != NULL && !OSSL_DECODER_is_a(k, select_name))
  516. continue;
  517. names = sk_OPENSSL_CSTRING_new(name_cmp);
  518. if (names != NULL && OSSL_DECODER_names_do_all(k, collect_names, names)) {
  519. BIO_printf(bio_out, " ");
  520. print_names(bio_out, names);
  521. BIO_printf(bio_out, " @ %s (%s)\n",
  522. OSSL_PROVIDER_get0_name(OSSL_DECODER_get0_provider(k)),
  523. OSSL_DECODER_get0_properties(k));
  524. if (verbose) {
  525. const char *desc = OSSL_DECODER_get0_description(k);
  526. if (desc != NULL)
  527. BIO_printf(bio_out, " description: %s\n", desc);
  528. print_param_types("settable operation parameters",
  529. OSSL_DECODER_settable_ctx_params(k), 4);
  530. }
  531. }
  532. sk_OPENSSL_CSTRING_free(names);
  533. }
  534. sk_OSSL_DECODER_pop_free(decoders, OSSL_DECODER_free);
  535. }
  536. DEFINE_STACK_OF(EVP_KEYMGMT)
  537. static int keymanager_cmp(const EVP_KEYMGMT * const *a,
  538. const EVP_KEYMGMT * const *b)
  539. {
  540. return strcmp(OSSL_PROVIDER_get0_name(EVP_KEYMGMT_get0_provider(*a)),
  541. OSSL_PROVIDER_get0_name(EVP_KEYMGMT_get0_provider(*b)));
  542. }
  543. static void collect_keymanagers(EVP_KEYMGMT *km, void *stack)
  544. {
  545. STACK_OF(EVP_KEYMGMT) *km_stack = stack;
  546. if (is_keymgmt_fetchable(km)
  547. && sk_EVP_KEYMGMT_push(km_stack, km) > 0)
  548. EVP_KEYMGMT_up_ref(km);
  549. }
  550. static void list_keymanagers(void)
  551. {
  552. int i;
  553. STACK_OF(EVP_KEYMGMT) *km_stack = sk_EVP_KEYMGMT_new(keymanager_cmp);
  554. EVP_KEYMGMT_do_all_provided(NULL, collect_keymanagers, km_stack);
  555. sk_EVP_KEYMGMT_sort(km_stack);
  556. for (i = 0; i < sk_EVP_KEYMGMT_num(km_stack); i++) {
  557. EVP_KEYMGMT *k = sk_EVP_KEYMGMT_value(km_stack, i);
  558. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  559. if (select_name != NULL && !EVP_KEYMGMT_is_a(k, select_name))
  560. continue;
  561. names = sk_OPENSSL_CSTRING_new(name_cmp);
  562. if (names != NULL && EVP_KEYMGMT_names_do_all(k, collect_names, names)) {
  563. const char *desc = EVP_KEYMGMT_get0_description(k);
  564. BIO_printf(bio_out, " Name: ");
  565. if (desc != NULL)
  566. BIO_printf(bio_out, "%s", desc);
  567. else
  568. BIO_printf(bio_out, "%s", sk_OPENSSL_CSTRING_value(names, 0));
  569. BIO_printf(bio_out, "\n");
  570. BIO_printf(bio_out, " Type: Provider Algorithm\n");
  571. BIO_printf(bio_out, " IDs: ");
  572. print_names(bio_out, names);
  573. BIO_printf(bio_out, " @ %s\n",
  574. OSSL_PROVIDER_get0_name(EVP_KEYMGMT_get0_provider(k)));
  575. if (verbose) {
  576. print_param_types("settable key generation parameters",
  577. EVP_KEYMGMT_gen_settable_params(k), 4);
  578. print_param_types("settable operation parameters",
  579. EVP_KEYMGMT_settable_params(k), 4);
  580. print_param_types("retrievable operation parameters",
  581. EVP_KEYMGMT_gettable_params(k), 4);
  582. }
  583. }
  584. sk_OPENSSL_CSTRING_free(names);
  585. }
  586. sk_EVP_KEYMGMT_pop_free(km_stack, EVP_KEYMGMT_free);
  587. }
  588. DEFINE_STACK_OF(EVP_SIGNATURE)
  589. static int signature_cmp(const EVP_SIGNATURE * const *a,
  590. const EVP_SIGNATURE * const *b)
  591. {
  592. return strcmp(OSSL_PROVIDER_get0_name(EVP_SIGNATURE_get0_provider(*a)),
  593. OSSL_PROVIDER_get0_name(EVP_SIGNATURE_get0_provider(*b)));
  594. }
  595. static void collect_signatures(EVP_SIGNATURE *sig, void *stack)
  596. {
  597. STACK_OF(EVP_SIGNATURE) *sig_stack = stack;
  598. if (is_signature_fetchable(sig)
  599. && sk_EVP_SIGNATURE_push(sig_stack, sig) > 0)
  600. EVP_SIGNATURE_up_ref(sig);
  601. }
  602. static void list_signatures(void)
  603. {
  604. int i, count = 0;
  605. STACK_OF(EVP_SIGNATURE) *sig_stack = sk_EVP_SIGNATURE_new(signature_cmp);
  606. EVP_SIGNATURE_do_all_provided(NULL, collect_signatures, sig_stack);
  607. sk_EVP_SIGNATURE_sort(sig_stack);
  608. for (i = 0; i < sk_EVP_SIGNATURE_num(sig_stack); i++) {
  609. EVP_SIGNATURE *k = sk_EVP_SIGNATURE_value(sig_stack, i);
  610. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  611. if (select_name != NULL && !EVP_SIGNATURE_is_a(k, select_name))
  612. continue;
  613. names = sk_OPENSSL_CSTRING_new(name_cmp);
  614. if (names != NULL && EVP_SIGNATURE_names_do_all(k, collect_names, names)) {
  615. count++;
  616. BIO_printf(bio_out, " ");
  617. print_names(bio_out, names);
  618. BIO_printf(bio_out, " @ %s\n",
  619. OSSL_PROVIDER_get0_name(EVP_SIGNATURE_get0_provider(k)));
  620. if (verbose) {
  621. const char *desc = EVP_SIGNATURE_get0_description(k);
  622. if (desc != NULL)
  623. BIO_printf(bio_out, " description: %s\n", desc);
  624. print_param_types("settable operation parameters",
  625. EVP_SIGNATURE_settable_ctx_params(k), 4);
  626. print_param_types("retrievable operation parameters",
  627. EVP_SIGNATURE_gettable_ctx_params(k), 4);
  628. }
  629. }
  630. sk_OPENSSL_CSTRING_free(names);
  631. }
  632. sk_EVP_SIGNATURE_pop_free(sig_stack, EVP_SIGNATURE_free);
  633. if (count == 0)
  634. BIO_printf(bio_out, " -\n");
  635. }
  636. DEFINE_STACK_OF(EVP_KEM)
  637. static int kem_cmp(const EVP_KEM * const *a,
  638. const EVP_KEM * const *b)
  639. {
  640. return strcmp(OSSL_PROVIDER_get0_name(EVP_KEM_get0_provider(*a)),
  641. OSSL_PROVIDER_get0_name(EVP_KEM_get0_provider(*b)));
  642. }
  643. static void collect_kem(EVP_KEM *kem, void *stack)
  644. {
  645. STACK_OF(EVP_KEM) *kem_stack = stack;
  646. if (is_kem_fetchable(kem)
  647. && sk_EVP_KEM_push(kem_stack, kem) > 0)
  648. EVP_KEM_up_ref(kem);
  649. }
  650. static void list_kems(void)
  651. {
  652. int i, count = 0;
  653. STACK_OF(EVP_KEM) *kem_stack = sk_EVP_KEM_new(kem_cmp);
  654. EVP_KEM_do_all_provided(NULL, collect_kem, kem_stack);
  655. sk_EVP_KEM_sort(kem_stack);
  656. for (i = 0; i < sk_EVP_KEM_num(kem_stack); i++) {
  657. EVP_KEM *k = sk_EVP_KEM_value(kem_stack, i);
  658. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  659. if (select_name != NULL && !EVP_KEM_is_a(k, select_name))
  660. continue;
  661. names = sk_OPENSSL_CSTRING_new(name_cmp);
  662. if (names != NULL && EVP_KEM_names_do_all(k, collect_names, names)) {
  663. count++;
  664. BIO_printf(bio_out, " ");
  665. print_names(bio_out, names);
  666. BIO_printf(bio_out, " @ %s\n",
  667. OSSL_PROVIDER_get0_name(EVP_KEM_get0_provider(k)));
  668. if (verbose) {
  669. const char *desc = EVP_KEM_get0_description(k);
  670. if (desc != NULL)
  671. BIO_printf(bio_out, " description: %s\n", desc);
  672. print_param_types("settable operation parameters",
  673. EVP_KEM_settable_ctx_params(k), 4);
  674. print_param_types("retrievable operation parameters",
  675. EVP_KEM_gettable_ctx_params(k), 4);
  676. }
  677. }
  678. sk_OPENSSL_CSTRING_free(names);
  679. }
  680. sk_EVP_KEM_pop_free(kem_stack, EVP_KEM_free);
  681. if (count == 0)
  682. BIO_printf(bio_out, " -\n");
  683. }
  684. DEFINE_STACK_OF(EVP_ASYM_CIPHER)
  685. static int asymcipher_cmp(const EVP_ASYM_CIPHER * const *a,
  686. const EVP_ASYM_CIPHER * const *b)
  687. {
  688. return strcmp(OSSL_PROVIDER_get0_name(EVP_ASYM_CIPHER_get0_provider(*a)),
  689. OSSL_PROVIDER_get0_name(EVP_ASYM_CIPHER_get0_provider(*b)));
  690. }
  691. static void collect_asymciph(EVP_ASYM_CIPHER *asym_cipher, void *stack)
  692. {
  693. STACK_OF(EVP_ASYM_CIPHER) *asym_cipher_stack = stack;
  694. if (is_asym_cipher_fetchable(asym_cipher)
  695. && sk_EVP_ASYM_CIPHER_push(asym_cipher_stack, asym_cipher) > 0)
  696. EVP_ASYM_CIPHER_up_ref(asym_cipher);
  697. }
  698. static void list_asymciphers(void)
  699. {
  700. int i, count = 0;
  701. STACK_OF(EVP_ASYM_CIPHER) *asymciph_stack =
  702. sk_EVP_ASYM_CIPHER_new(asymcipher_cmp);
  703. EVP_ASYM_CIPHER_do_all_provided(NULL, collect_asymciph, asymciph_stack);
  704. sk_EVP_ASYM_CIPHER_sort(asymciph_stack);
  705. for (i = 0; i < sk_EVP_ASYM_CIPHER_num(asymciph_stack); i++) {
  706. EVP_ASYM_CIPHER *k = sk_EVP_ASYM_CIPHER_value(asymciph_stack, i);
  707. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  708. if (select_name != NULL && !EVP_ASYM_CIPHER_is_a(k, select_name))
  709. continue;
  710. names = sk_OPENSSL_CSTRING_new(name_cmp);
  711. if (names != NULL
  712. && EVP_ASYM_CIPHER_names_do_all(k, collect_names, names)) {
  713. count++;
  714. BIO_printf(bio_out, " ");
  715. print_names(bio_out, names);
  716. BIO_printf(bio_out, " @ %s\n",
  717. OSSL_PROVIDER_get0_name(EVP_ASYM_CIPHER_get0_provider(k)));
  718. if (verbose) {
  719. const char *desc = EVP_ASYM_CIPHER_get0_description(k);
  720. if (desc != NULL)
  721. BIO_printf(bio_out, " description: %s\n", desc);
  722. print_param_types("settable operation parameters",
  723. EVP_ASYM_CIPHER_settable_ctx_params(k), 4);
  724. print_param_types("retrievable operation parameters",
  725. EVP_ASYM_CIPHER_gettable_ctx_params(k), 4);
  726. }
  727. }
  728. sk_OPENSSL_CSTRING_free(names);
  729. }
  730. sk_EVP_ASYM_CIPHER_pop_free(asymciph_stack, EVP_ASYM_CIPHER_free);
  731. if (count == 0)
  732. BIO_printf(bio_out, " -\n");
  733. }
  734. DEFINE_STACK_OF(EVP_KEYEXCH)
  735. static int kex_cmp(const EVP_KEYEXCH * const *a,
  736. const EVP_KEYEXCH * const *b)
  737. {
  738. return strcmp(OSSL_PROVIDER_get0_name(EVP_KEYEXCH_get0_provider(*a)),
  739. OSSL_PROVIDER_get0_name(EVP_KEYEXCH_get0_provider(*b)));
  740. }
  741. static void collect_kex(EVP_KEYEXCH *kex, void *stack)
  742. {
  743. STACK_OF(EVP_KEYEXCH) *kex_stack = stack;
  744. if (is_keyexch_fetchable(kex)
  745. && sk_EVP_KEYEXCH_push(kex_stack, kex) > 0)
  746. EVP_KEYEXCH_up_ref(kex);
  747. }
  748. static void list_keyexchanges(void)
  749. {
  750. int i, count = 0;
  751. STACK_OF(EVP_KEYEXCH) *kex_stack = sk_EVP_KEYEXCH_new(kex_cmp);
  752. EVP_KEYEXCH_do_all_provided(NULL, collect_kex, kex_stack);
  753. sk_EVP_KEYEXCH_sort(kex_stack);
  754. for (i = 0; i < sk_EVP_KEYEXCH_num(kex_stack); i++) {
  755. EVP_KEYEXCH *k = sk_EVP_KEYEXCH_value(kex_stack, i);
  756. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  757. if (select_name != NULL && !EVP_KEYEXCH_is_a(k, select_name))
  758. continue;
  759. names = sk_OPENSSL_CSTRING_new(name_cmp);
  760. if (names != NULL && EVP_KEYEXCH_names_do_all(k, collect_names, names)) {
  761. count++;
  762. BIO_printf(bio_out, " ");
  763. print_names(bio_out, names);
  764. BIO_printf(bio_out, " @ %s\n",
  765. OSSL_PROVIDER_get0_name(EVP_KEYEXCH_get0_provider(k)));
  766. if (verbose) {
  767. const char *desc = EVP_KEYEXCH_get0_description(k);
  768. if (desc != NULL)
  769. BIO_printf(bio_out, " description: %s\n", desc);
  770. print_param_types("settable operation parameters",
  771. EVP_KEYEXCH_settable_ctx_params(k), 4);
  772. print_param_types("retrievable operation parameters",
  773. EVP_KEYEXCH_gettable_ctx_params(k), 4);
  774. }
  775. }
  776. sk_OPENSSL_CSTRING_free(names);
  777. }
  778. sk_EVP_KEYEXCH_pop_free(kex_stack, EVP_KEYEXCH_free);
  779. if (count == 0)
  780. BIO_printf(bio_out, " -\n");
  781. }
  782. static void list_objects(void)
  783. {
  784. int max_nid = OBJ_new_nid(0);
  785. int i;
  786. char *oid_buf = NULL;
  787. int oid_size = 0;
  788. /* Skip 0, since that's NID_undef */
  789. for (i = 1; i < max_nid; i++) {
  790. const ASN1_OBJECT *obj = OBJ_nid2obj(i);
  791. const char *sn = OBJ_nid2sn(i);
  792. const char *ln = OBJ_nid2ln(i);
  793. int n = 0;
  794. /*
  795. * If one of the retrieved objects somehow generated an error,
  796. * we ignore it. The check for NID_undef below will detect the
  797. * error and simply skip to the next NID.
  798. */
  799. ERR_clear_error();
  800. if (OBJ_obj2nid(obj) == NID_undef)
  801. continue;
  802. if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
  803. BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
  804. continue;
  805. }
  806. if (n < 0)
  807. break; /* Error */
  808. if (n > oid_size) {
  809. oid_buf = OPENSSL_realloc(oid_buf, n + 1);
  810. if (oid_buf == NULL) {
  811. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  812. break; /* Error */
  813. }
  814. oid_size = n + 1;
  815. }
  816. if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
  817. break; /* Error */
  818. if (ln == NULL || strcmp(sn, ln) == 0)
  819. BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
  820. else
  821. BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
  822. }
  823. OPENSSL_free(oid_buf);
  824. }
  825. static void list_options_for_command(const char *command)
  826. {
  827. const FUNCTION *fp;
  828. const OPTIONS *o;
  829. for (fp = functions; fp->name != NULL; fp++)
  830. if (strcmp(fp->name, command) == 0)
  831. break;
  832. if (fp->name == NULL) {
  833. BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
  834. command);
  835. return;
  836. }
  837. if ((o = fp->help) == NULL)
  838. return;
  839. for ( ; o->name != NULL; o++) {
  840. char c = o->valtype;
  841. if (o->name == OPT_PARAM_STR)
  842. break;
  843. if (o->name == OPT_HELP_STR
  844. || o->name == OPT_MORE_STR
  845. || o->name == OPT_SECTION_STR
  846. || o->name[0] == '\0')
  847. continue;
  848. BIO_printf(bio_out, "%s %c\n", o->name, c == '\0' ? '-' : c);
  849. }
  850. /* Always output the -- marker since it is sometimes documented. */
  851. BIO_printf(bio_out, "- -\n");
  852. }
  853. static int is_md_available(const char *name)
  854. {
  855. EVP_MD *md;
  856. const char *propq = app_get0_propq();
  857. /* Look through providers' digests */
  858. ERR_set_mark();
  859. md = EVP_MD_fetch(NULL, name, propq);
  860. ERR_pop_to_mark();
  861. if (md != NULL) {
  862. EVP_MD_free(md);
  863. return 1;
  864. }
  865. return propq != NULL || get_digest_from_engine(name) == NULL ? 0 : 1;
  866. }
  867. static int is_cipher_available(const char *name)
  868. {
  869. EVP_CIPHER *cipher;
  870. const char *propq = app_get0_propq();
  871. /* Look through providers' ciphers */
  872. ERR_set_mark();
  873. cipher = EVP_CIPHER_fetch(NULL, name, propq);
  874. ERR_pop_to_mark();
  875. if (cipher != NULL) {
  876. EVP_CIPHER_free(cipher);
  877. return 1;
  878. }
  879. return propq != NULL || get_cipher_from_engine(name) == NULL ? 0 : 1;
  880. }
  881. static void list_type(FUNC_TYPE ft, int one)
  882. {
  883. FUNCTION *fp;
  884. int i = 0;
  885. DISPLAY_COLUMNS dc;
  886. memset(&dc, 0, sizeof(dc));
  887. if (!one)
  888. calculate_columns(functions, &dc);
  889. for (fp = functions; fp->name != NULL; fp++) {
  890. if (fp->type != ft)
  891. continue;
  892. switch (ft) {
  893. case FT_cipher:
  894. if (!is_cipher_available(fp->name))
  895. continue;
  896. break;
  897. case FT_md:
  898. if (!is_md_available(fp->name))
  899. continue;
  900. break;
  901. default:
  902. break;
  903. }
  904. if (one) {
  905. BIO_printf(bio_out, "%s\n", fp->name);
  906. } else {
  907. if (i % dc.columns == 0 && i > 0)
  908. BIO_printf(bio_out, "\n");
  909. BIO_printf(bio_out, "%-*s", dc.width, fp->name);
  910. i++;
  911. }
  912. }
  913. if (!one)
  914. BIO_printf(bio_out, "\n\n");
  915. }
  916. static void list_pkey(void)
  917. {
  918. #ifndef OPENSSL_NO_DEPRECATED_3_0
  919. int i;
  920. if (select_name == NULL && include_legacy()) {
  921. BIO_printf(bio_out, "Legacy:\n");
  922. for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
  923. const EVP_PKEY_ASN1_METHOD *ameth;
  924. int pkey_id, pkey_base_id, pkey_flags;
  925. const char *pinfo, *pem_str;
  926. ameth = EVP_PKEY_asn1_get0(i);
  927. EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
  928. &pinfo, &pem_str, ameth);
  929. if (pkey_flags & ASN1_PKEY_ALIAS) {
  930. BIO_printf(bio_out, " Name: %s\n", OBJ_nid2ln(pkey_id));
  931. BIO_printf(bio_out, "\tAlias for: %s\n",
  932. OBJ_nid2ln(pkey_base_id));
  933. } else {
  934. BIO_printf(bio_out, " Name: %s\n", pinfo);
  935. BIO_printf(bio_out, "\tType: %s Algorithm\n",
  936. pkey_flags & ASN1_PKEY_DYNAMIC ?
  937. "External" : "Builtin");
  938. BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
  939. if (pem_str == NULL)
  940. pem_str = "(none)";
  941. BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
  942. }
  943. }
  944. }
  945. #endif
  946. BIO_printf(bio_out, "Provided:\n");
  947. BIO_printf(bio_out, " Key Managers:\n");
  948. list_keymanagers();
  949. }
  950. static void list_pkey_meth(void)
  951. {
  952. #ifndef OPENSSL_NO_DEPRECATED_3_0
  953. size_t i;
  954. size_t meth_count = EVP_PKEY_meth_get_count();
  955. if (select_name == NULL && include_legacy()) {
  956. BIO_printf(bio_out, "Legacy:\n");
  957. for (i = 0; i < meth_count; i++) {
  958. const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
  959. int pkey_id, pkey_flags;
  960. EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
  961. BIO_printf(bio_out, " %s\n", OBJ_nid2ln(pkey_id));
  962. BIO_printf(bio_out, "\tType: %s Algorithm\n",
  963. pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
  964. }
  965. }
  966. #endif
  967. BIO_printf(bio_out, "Provided:\n");
  968. BIO_printf(bio_out, " Encryption:\n");
  969. list_asymciphers();
  970. BIO_printf(bio_out, " Key Exchange:\n");
  971. list_keyexchanges();
  972. BIO_printf(bio_out, " Signatures:\n");
  973. list_signatures();
  974. BIO_printf(bio_out, " Key encapsulation:\n");
  975. list_kems();
  976. }
  977. DEFINE_STACK_OF(OSSL_STORE_LOADER)
  978. static int store_cmp(const OSSL_STORE_LOADER * const *a,
  979. const OSSL_STORE_LOADER * const *b)
  980. {
  981. return strcmp(OSSL_PROVIDER_get0_name(OSSL_STORE_LOADER_get0_provider(*a)),
  982. OSSL_PROVIDER_get0_name(OSSL_STORE_LOADER_get0_provider(*b)));
  983. }
  984. static void collect_store_loaders(OSSL_STORE_LOADER *store, void *stack)
  985. {
  986. STACK_OF(OSSL_STORE_LOADER) *store_stack = stack;
  987. if (sk_OSSL_STORE_LOADER_push(store_stack, store) > 0)
  988. OSSL_STORE_LOADER_up_ref(store);
  989. }
  990. static void list_store_loaders(void)
  991. {
  992. STACK_OF(OSSL_STORE_LOADER) *stores = sk_OSSL_STORE_LOADER_new(store_cmp);
  993. int i;
  994. if (stores == NULL) {
  995. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  996. return;
  997. }
  998. BIO_printf(bio_out, "Provided STORE LOADERs:\n");
  999. OSSL_STORE_LOADER_do_all_provided(NULL, collect_store_loaders, stores);
  1000. sk_OSSL_STORE_LOADER_sort(stores);
  1001. for (i = 0; i < sk_OSSL_STORE_LOADER_num(stores); i++) {
  1002. const OSSL_STORE_LOADER *m = sk_OSSL_STORE_LOADER_value(stores, i);
  1003. STACK_OF(OPENSSL_CSTRING) *names = NULL;
  1004. if (select_name != NULL && !OSSL_STORE_LOADER_is_a(m, select_name))
  1005. continue;
  1006. names = sk_OPENSSL_CSTRING_new(name_cmp);
  1007. if (names != NULL && OSSL_STORE_LOADER_names_do_all(m, collect_names,
  1008. names)) {
  1009. BIO_printf(bio_out, " ");
  1010. print_names(bio_out, names);
  1011. BIO_printf(bio_out, " @ %s\n",
  1012. OSSL_PROVIDER_get0_name(OSSL_STORE_LOADER_get0_provider(m)));
  1013. }
  1014. sk_OPENSSL_CSTRING_free(names);
  1015. }
  1016. sk_OSSL_STORE_LOADER_pop_free(stores, OSSL_STORE_LOADER_free);
  1017. }
  1018. DEFINE_STACK_OF(OSSL_PROVIDER)
  1019. static int provider_cmp(const OSSL_PROVIDER * const *a,
  1020. const OSSL_PROVIDER * const *b)
  1021. {
  1022. return strcmp(OSSL_PROVIDER_get0_name(*a), OSSL_PROVIDER_get0_name(*b));
  1023. }
  1024. static int collect_providers(OSSL_PROVIDER *provider, void *stack)
  1025. {
  1026. STACK_OF(OSSL_PROVIDER) *provider_stack = stack;
  1027. sk_OSSL_PROVIDER_push(provider_stack, provider);
  1028. return 1;
  1029. }
  1030. static void list_provider_info(void)
  1031. {
  1032. STACK_OF(OSSL_PROVIDER) *providers = sk_OSSL_PROVIDER_new(provider_cmp);
  1033. OSSL_PARAM params[5];
  1034. char *name, *version, *buildinfo;
  1035. int status;
  1036. int i;
  1037. if (providers == NULL) {
  1038. BIO_printf(bio_err, "ERROR: Memory allocation\n");
  1039. return;
  1040. }
  1041. BIO_printf(bio_out, "Providers:\n");
  1042. OSSL_PROVIDER_do_all(NULL, &collect_providers, providers);
  1043. sk_OSSL_PROVIDER_sort(providers);
  1044. for (i = 0; i < sk_OSSL_PROVIDER_num(providers); i++) {
  1045. const OSSL_PROVIDER *prov = sk_OSSL_PROVIDER_value(providers, i);
  1046. /* Query the "known" information parameters, the order matches below */
  1047. params[0] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_NAME,
  1048. &name, 0);
  1049. params[1] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_VERSION,
  1050. &version, 0);
  1051. params[2] = OSSL_PARAM_construct_int(OSSL_PROV_PARAM_STATUS, &status);
  1052. params[3] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_BUILDINFO,
  1053. &buildinfo, 0);
  1054. params[4] = OSSL_PARAM_construct_end();
  1055. OSSL_PARAM_set_all_unmodified(params);
  1056. if (!OSSL_PROVIDER_get_params(prov, params)) {
  1057. BIO_printf(bio_err, "ERROR: Unable to query provider parameters\n");
  1058. return;
  1059. }
  1060. /* Print out the provider information, the params order matches above */
  1061. BIO_printf(bio_out, " %s\n", OSSL_PROVIDER_get0_name(prov));
  1062. if (OSSL_PARAM_modified(params))
  1063. BIO_printf(bio_out, " name: %s\n", name);
  1064. if (OSSL_PARAM_modified(params + 1))
  1065. BIO_printf(bio_out, " version: %s\n", version);
  1066. if (OSSL_PARAM_modified(params + 2))
  1067. BIO_printf(bio_out, " status: %sactive\n", status ? "" : "in");
  1068. if (verbose) {
  1069. if (OSSL_PARAM_modified(params + 3))
  1070. BIO_printf(bio_out, " build info: %s\n", buildinfo);
  1071. print_param_types("gettable provider parameters",
  1072. OSSL_PROVIDER_gettable_params(prov), 4);
  1073. }
  1074. }
  1075. sk_OSSL_PROVIDER_free(providers);
  1076. }
  1077. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1078. static void list_engines(void)
  1079. {
  1080. # ifndef OPENSSL_NO_ENGINE
  1081. ENGINE *e;
  1082. BIO_puts(bio_out, "Engines:\n");
  1083. e = ENGINE_get_first();
  1084. while (e) {
  1085. BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
  1086. e = ENGINE_get_next(e);
  1087. }
  1088. # else
  1089. BIO_puts(bio_out, "Engine support is disabled.\n");
  1090. # endif
  1091. }
  1092. #endif
  1093. static void list_disabled(void)
  1094. {
  1095. BIO_puts(bio_out, "Disabled algorithms:\n");
  1096. #ifdef OPENSSL_NO_ARIA
  1097. BIO_puts(bio_out, "ARIA\n");
  1098. #endif
  1099. #ifdef OPENSSL_NO_BF
  1100. BIO_puts(bio_out, "BF\n");
  1101. #endif
  1102. #ifdef OPENSSL_NO_BLAKE2
  1103. BIO_puts(bio_out, "BLAKE2\n");
  1104. #endif
  1105. #ifdef OPENSSL_NO_CAMELLIA
  1106. BIO_puts(bio_out, "CAMELLIA\n");
  1107. #endif
  1108. #ifdef OPENSSL_NO_CAST
  1109. BIO_puts(bio_out, "CAST\n");
  1110. #endif
  1111. #ifdef OPENSSL_NO_CMAC
  1112. BIO_puts(bio_out, "CMAC\n");
  1113. #endif
  1114. #ifdef OPENSSL_NO_CMS
  1115. BIO_puts(bio_out, "CMS\n");
  1116. #endif
  1117. #ifdef OPENSSL_NO_COMP
  1118. BIO_puts(bio_out, "COMP\n");
  1119. #endif
  1120. #ifdef OPENSSL_NO_DES
  1121. BIO_puts(bio_out, "DES\n");
  1122. #endif
  1123. #ifdef OPENSSL_NO_DGRAM
  1124. BIO_puts(bio_out, "DGRAM\n");
  1125. #endif
  1126. #ifdef OPENSSL_NO_DH
  1127. BIO_puts(bio_out, "DH\n");
  1128. #endif
  1129. #ifdef OPENSSL_NO_DSA
  1130. BIO_puts(bio_out, "DSA\n");
  1131. #endif
  1132. #if defined(OPENSSL_NO_DTLS)
  1133. BIO_puts(bio_out, "DTLS\n");
  1134. #endif
  1135. #if defined(OPENSSL_NO_DTLS1)
  1136. BIO_puts(bio_out, "DTLS1\n");
  1137. #endif
  1138. #if defined(OPENSSL_NO_DTLS1_2)
  1139. BIO_puts(bio_out, "DTLS1_2\n");
  1140. #endif
  1141. #ifdef OPENSSL_NO_EC
  1142. BIO_puts(bio_out, "EC\n");
  1143. #endif
  1144. #ifdef OPENSSL_NO_EC2M
  1145. BIO_puts(bio_out, "EC2M\n");
  1146. #endif
  1147. #if defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
  1148. BIO_puts(bio_out, "ENGINE\n");
  1149. #endif
  1150. #ifdef OPENSSL_NO_GOST
  1151. BIO_puts(bio_out, "GOST\n");
  1152. #endif
  1153. #ifdef OPENSSL_NO_IDEA
  1154. BIO_puts(bio_out, "IDEA\n");
  1155. #endif
  1156. #ifdef OPENSSL_NO_MD2
  1157. BIO_puts(bio_out, "MD2\n");
  1158. #endif
  1159. #ifdef OPENSSL_NO_MD4
  1160. BIO_puts(bio_out, "MD4\n");
  1161. #endif
  1162. #ifdef OPENSSL_NO_MD5
  1163. BIO_puts(bio_out, "MD5\n");
  1164. #endif
  1165. #ifdef OPENSSL_NO_MDC2
  1166. BIO_puts(bio_out, "MDC2\n");
  1167. #endif
  1168. #ifdef OPENSSL_NO_OCB
  1169. BIO_puts(bio_out, "OCB\n");
  1170. #endif
  1171. #ifdef OPENSSL_NO_OCSP
  1172. BIO_puts(bio_out, "OCSP\n");
  1173. #endif
  1174. #ifdef OPENSSL_NO_PSK
  1175. BIO_puts(bio_out, "PSK\n");
  1176. #endif
  1177. #ifdef OPENSSL_NO_RC2
  1178. BIO_puts(bio_out, "RC2\n");
  1179. #endif
  1180. #ifdef OPENSSL_NO_RC4
  1181. BIO_puts(bio_out, "RC4\n");
  1182. #endif
  1183. #ifdef OPENSSL_NO_RC5
  1184. BIO_puts(bio_out, "RC5\n");
  1185. #endif
  1186. #ifdef OPENSSL_NO_RMD160
  1187. BIO_puts(bio_out, "RMD160\n");
  1188. #endif
  1189. #ifdef OPENSSL_NO_SCRYPT
  1190. BIO_puts(bio_out, "SCRYPT\n");
  1191. #endif
  1192. #ifdef OPENSSL_NO_SCTP
  1193. BIO_puts(bio_out, "SCTP\n");
  1194. #endif
  1195. #ifdef OPENSSL_NO_SEED
  1196. BIO_puts(bio_out, "SEED\n");
  1197. #endif
  1198. #ifdef OPENSSL_NO_SM2
  1199. BIO_puts(bio_out, "SM2\n");
  1200. #endif
  1201. #ifdef OPENSSL_NO_SM3
  1202. BIO_puts(bio_out, "SM3\n");
  1203. #endif
  1204. #ifdef OPENSSL_NO_SM4
  1205. BIO_puts(bio_out, "SM4\n");
  1206. #endif
  1207. #ifdef OPENSSL_NO_SOCK
  1208. BIO_puts(bio_out, "SOCK\n");
  1209. #endif
  1210. #ifdef OPENSSL_NO_SRP
  1211. BIO_puts(bio_out, "SRP\n");
  1212. #endif
  1213. #ifdef OPENSSL_NO_SRTP
  1214. BIO_puts(bio_out, "SRTP\n");
  1215. #endif
  1216. #ifdef OPENSSL_NO_SSL3
  1217. BIO_puts(bio_out, "SSL3\n");
  1218. #endif
  1219. #ifdef OPENSSL_NO_TLS1
  1220. BIO_puts(bio_out, "TLS1\n");
  1221. #endif
  1222. #ifdef OPENSSL_NO_TLS1_1
  1223. BIO_puts(bio_out, "TLS1_1\n");
  1224. #endif
  1225. #ifdef OPENSSL_NO_TLS1_2
  1226. BIO_puts(bio_out, "TLS1_2\n");
  1227. #endif
  1228. #ifdef OPENSSL_NO_WHIRLPOOL
  1229. BIO_puts(bio_out, "WHIRLPOOL\n");
  1230. #endif
  1231. #ifndef ZLIB
  1232. BIO_puts(bio_out, "ZLIB\n");
  1233. #endif
  1234. }
  1235. /* Unified enum for help and list commands. */
  1236. typedef enum HELPLIST_CHOICE {
  1237. OPT_COMMON,
  1238. OPT_ONE, OPT_VERBOSE,
  1239. OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
  1240. OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
  1241. OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED,
  1242. OPT_KDF_ALGORITHMS, OPT_RANDOM_INSTANCES, OPT_RANDOM_GENERATORS,
  1243. OPT_ENCODERS, OPT_DECODERS, OPT_KEYMANAGERS, OPT_KEYEXCHANGE_ALGORITHMS,
  1244. OPT_KEM_ALGORITHMS, OPT_SIGNATURE_ALGORITHMS, OPT_ASYM_CIPHER_ALGORITHMS,
  1245. OPT_STORE_LOADERS, OPT_PROVIDER_INFO,
  1246. OPT_OBJECTS, OPT_SELECT_NAME,
  1247. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1248. OPT_ENGINES,
  1249. #endif
  1250. OPT_PROV_ENUM
  1251. } HELPLIST_CHOICE;
  1252. const OPTIONS list_options[] = {
  1253. OPT_SECTION("General"),
  1254. {"help", OPT_HELP, '-', "Display this summary"},
  1255. OPT_SECTION("Output"),
  1256. {"1", OPT_ONE, '-', "List in one column"},
  1257. {"verbose", OPT_VERBOSE, '-', "Verbose listing"},
  1258. {"select", OPT_SELECT_NAME, 's', "Select a single algorithm"},
  1259. {"commands", OPT_COMMANDS, '-', "List of standard commands"},
  1260. {"standard-commands", OPT_COMMANDS, '-', "List of standard commands"},
  1261. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1262. {"digest-commands", OPT_DIGEST_COMMANDS, '-',
  1263. "List of message digest commands (deprecated)"},
  1264. #endif
  1265. {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
  1266. "List of message digest algorithms"},
  1267. {"kdf-algorithms", OPT_KDF_ALGORITHMS, '-',
  1268. "List of key derivation and pseudo random function algorithms"},
  1269. {"random-instances", OPT_RANDOM_INSTANCES, '-',
  1270. "List the primary, public and private random number generator details"},
  1271. {"random-generators", OPT_RANDOM_GENERATORS, '-',
  1272. "List of random number generators"},
  1273. {"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
  1274. "List of message authentication code algorithms"},
  1275. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1276. {"cipher-commands", OPT_CIPHER_COMMANDS, '-',
  1277. "List of cipher commands (deprecated)"},
  1278. #endif
  1279. {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
  1280. "List of cipher algorithms"},
  1281. {"encoders", OPT_ENCODERS, '-', "List of encoding methods" },
  1282. {"decoders", OPT_DECODERS, '-', "List of decoding methods" },
  1283. {"key-managers", OPT_KEYMANAGERS, '-', "List of key managers" },
  1284. {"key-exchange-algorithms", OPT_KEYEXCHANGE_ALGORITHMS, '-',
  1285. "List of key exchange algorithms" },
  1286. {"kem-algorithms", OPT_KEM_ALGORITHMS, '-',
  1287. "List of key encapsulation mechanism algorithms" },
  1288. {"signature-algorithms", OPT_SIGNATURE_ALGORITHMS, '-',
  1289. "List of signature algorithms" },
  1290. {"asymcipher-algorithms", OPT_ASYM_CIPHER_ALGORITHMS, '-',
  1291. "List of asymmetric cipher algorithms" },
  1292. {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
  1293. "List of public key algorithms"},
  1294. {"public-key-methods", OPT_PK_METHOD, '-',
  1295. "List of public key methods"},
  1296. {"store-loaders", OPT_STORE_LOADERS, '-',
  1297. "List of store loaders"},
  1298. {"providers", OPT_PROVIDER_INFO, '-',
  1299. "List of provider information"},
  1300. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1301. {"engines", OPT_ENGINES, '-',
  1302. "List of loaded engines"},
  1303. #endif
  1304. {"disabled", OPT_DISABLED, '-', "List of disabled features"},
  1305. {"options", OPT_OPTIONS, 's',
  1306. "List options for specified command"},
  1307. {"objects", OPT_OBJECTS, '-',
  1308. "List built in objects (OID<->name mappings)"},
  1309. OPT_PROV_OPTIONS,
  1310. {NULL}
  1311. };
  1312. int list_main(int argc, char **argv)
  1313. {
  1314. char *prog;
  1315. HELPLIST_CHOICE o;
  1316. int one = 0, done = 0;
  1317. struct {
  1318. unsigned int commands:1;
  1319. unsigned int random_instances:1;
  1320. unsigned int random_generators:1;
  1321. unsigned int digest_commands:1;
  1322. unsigned int digest_algorithms:1;
  1323. unsigned int kdf_algorithms:1;
  1324. unsigned int mac_algorithms:1;
  1325. unsigned int cipher_commands:1;
  1326. unsigned int cipher_algorithms:1;
  1327. unsigned int encoder_algorithms:1;
  1328. unsigned int decoder_algorithms:1;
  1329. unsigned int keymanager_algorithms:1;
  1330. unsigned int signature_algorithms:1;
  1331. unsigned int keyexchange_algorithms:1;
  1332. unsigned int kem_algorithms:1;
  1333. unsigned int asym_cipher_algorithms:1;
  1334. unsigned int pk_algorithms:1;
  1335. unsigned int pk_method:1;
  1336. unsigned int store_loaders:1;
  1337. unsigned int provider_info:1;
  1338. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1339. unsigned int engines:1;
  1340. #endif
  1341. unsigned int disabled:1;
  1342. unsigned int objects:1;
  1343. unsigned int options:1;
  1344. } todo = { 0, };
  1345. verbose = 0; /* Clear a possible previous call */
  1346. prog = opt_init(argc, argv, list_options);
  1347. while ((o = opt_next()) != OPT_EOF) {
  1348. switch (o) {
  1349. case OPT_EOF: /* Never hit, but suppresses warning */
  1350. case OPT_ERR:
  1351. opthelp:
  1352. BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
  1353. return 1;
  1354. case OPT_HELP:
  1355. opt_help(list_options);
  1356. return 0;
  1357. case OPT_ONE:
  1358. one = 1;
  1359. break;
  1360. case OPT_COMMANDS:
  1361. todo.commands = 1;
  1362. break;
  1363. case OPT_DIGEST_COMMANDS:
  1364. todo.digest_commands = 1;
  1365. break;
  1366. case OPT_DIGEST_ALGORITHMS:
  1367. todo.digest_algorithms = 1;
  1368. break;
  1369. case OPT_KDF_ALGORITHMS:
  1370. todo.kdf_algorithms = 1;
  1371. break;
  1372. case OPT_RANDOM_INSTANCES:
  1373. todo.random_instances = 1;
  1374. break;
  1375. case OPT_RANDOM_GENERATORS:
  1376. todo.random_generators = 1;
  1377. break;
  1378. case OPT_MAC_ALGORITHMS:
  1379. todo.mac_algorithms = 1;
  1380. break;
  1381. case OPT_CIPHER_COMMANDS:
  1382. todo.cipher_commands = 1;
  1383. break;
  1384. case OPT_CIPHER_ALGORITHMS:
  1385. todo.cipher_algorithms = 1;
  1386. break;
  1387. case OPT_ENCODERS:
  1388. todo.encoder_algorithms = 1;
  1389. break;
  1390. case OPT_DECODERS:
  1391. todo.decoder_algorithms = 1;
  1392. break;
  1393. case OPT_KEYMANAGERS:
  1394. todo.keymanager_algorithms = 1;
  1395. break;
  1396. case OPT_SIGNATURE_ALGORITHMS:
  1397. todo.signature_algorithms = 1;
  1398. break;
  1399. case OPT_KEYEXCHANGE_ALGORITHMS:
  1400. todo.keyexchange_algorithms = 1;
  1401. break;
  1402. case OPT_KEM_ALGORITHMS:
  1403. todo.kem_algorithms = 1;
  1404. break;
  1405. case OPT_ASYM_CIPHER_ALGORITHMS:
  1406. todo.asym_cipher_algorithms = 1;
  1407. break;
  1408. case OPT_PK_ALGORITHMS:
  1409. todo.pk_algorithms = 1;
  1410. break;
  1411. case OPT_PK_METHOD:
  1412. todo.pk_method = 1;
  1413. break;
  1414. case OPT_STORE_LOADERS:
  1415. todo.store_loaders = 1;
  1416. break;
  1417. case OPT_PROVIDER_INFO:
  1418. todo.provider_info = 1;
  1419. break;
  1420. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1421. case OPT_ENGINES:
  1422. todo.engines = 1;
  1423. break;
  1424. #endif
  1425. case OPT_DISABLED:
  1426. todo.disabled = 1;
  1427. break;
  1428. case OPT_OBJECTS:
  1429. todo.objects = 1;
  1430. break;
  1431. case OPT_OPTIONS:
  1432. list_options_for_command(opt_arg());
  1433. break;
  1434. case OPT_VERBOSE:
  1435. verbose = 1;
  1436. break;
  1437. case OPT_SELECT_NAME:
  1438. select_name = opt_arg();
  1439. break;
  1440. case OPT_PROV_CASES:
  1441. if (!opt_provider(o))
  1442. return 1;
  1443. break;
  1444. }
  1445. done = 1;
  1446. }
  1447. /* No extra arguments. */
  1448. if (opt_num_rest() != 0)
  1449. goto opthelp;
  1450. if (todo.commands)
  1451. list_type(FT_general, one);
  1452. if (todo.random_instances)
  1453. list_random_instances();
  1454. if (todo.random_generators)
  1455. list_random_generators();
  1456. if (todo.digest_commands)
  1457. list_type(FT_md, one);
  1458. if (todo.digest_algorithms)
  1459. list_digests();
  1460. if (todo.kdf_algorithms)
  1461. list_kdfs();
  1462. if (todo.mac_algorithms)
  1463. list_macs();
  1464. if (todo.cipher_commands)
  1465. list_type(FT_cipher, one);
  1466. if (todo.cipher_algorithms)
  1467. list_ciphers();
  1468. if (todo.encoder_algorithms)
  1469. list_encoders();
  1470. if (todo.decoder_algorithms)
  1471. list_decoders();
  1472. if (todo.keymanager_algorithms)
  1473. list_keymanagers();
  1474. if (todo.signature_algorithms)
  1475. list_signatures();
  1476. if (todo.asym_cipher_algorithms)
  1477. list_asymciphers();
  1478. if (todo.keyexchange_algorithms)
  1479. list_keyexchanges();
  1480. if (todo.kem_algorithms)
  1481. list_kems();
  1482. if (todo.pk_algorithms)
  1483. list_pkey();
  1484. if (todo.pk_method)
  1485. list_pkey_meth();
  1486. if (todo.store_loaders)
  1487. list_store_loaders();
  1488. if (todo.provider_info)
  1489. list_provider_info();
  1490. #ifndef OPENSSL_NO_DEPRECATED_3_0
  1491. if (todo.engines)
  1492. list_engines();
  1493. #endif
  1494. if (todo.disabled)
  1495. list_disabled();
  1496. if (todo.objects)
  1497. list_objects();
  1498. if (!done)
  1499. goto opthelp;
  1500. return 0;
  1501. }