Changeset 94082 in vbox for trunk/src/libs/openssl-3.0.1/apps/openssl.c
- Timestamp:
- Mar 3, 2022 7:17:34 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150325
- Location:
- trunk/src/libs/openssl-3.0.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/openssl-3.0.1
- Property svn:mergeinfo
-
old new 12 12 /vendor/openssl/1.1.1c:131722-131725 13 13 /vendor/openssl/1.1.1k:145841-145843 14 /vendor/openssl/3.0.1:150323-150324 15 /vendor/openssl/current:147554-150322
-
- Property svn:mergeinfo
-
trunk/src/libs/openssl-3.0.1/apps/openssl.c
r91772 r94082 1 1 /* 2 * Copyright 1995-20 19The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 8 8 */ 9 9 10 #include <internal/cryptlib.h>11 10 #include <stdio.h> 12 11 #include <string.h> … … 14 13 #include <openssl/bio.h> 15 14 #include <openssl/crypto.h> 15 #include <openssl/trace.h> 16 16 #include <openssl/lhash.h> 17 17 #include <openssl/conf.h> … … 28 28 #endif 29 29 #include "apps.h" 30 #define INCLUDE_FUNCTION_TABLE31 30 #include "progs.h" 32 33 /* Structure to hold the number of columns to be displayed and the34 * field width used to display them.35 */36 typedef struct {37 int columns;38 int width;39 } DISPLAY_COLUMNS;40 41 /* Special sentinel to exit the program. */42 #define EXIT_THE_PROGRAM (-1)43 31 44 32 /* … … 50 38 static LHASH_OF(FUNCTION) *prog_init(void); 51 39 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); 52 static void list_pkey(void);53 static void list_pkey_meth(void);54 static void list_type(FUNC_TYPE ft, int one);55 static void list_disabled(void);56 40 char *default_config_file = NULL; 57 41 … … 60 44 BIO *bio_err = NULL; 61 45 62 static void calculate_columns(DISPLAY_COLUMNS *dc) 63 { 64 FUNCTION *f; 65 int len, maxlen = 0; 66 67 for (f = functions; f->name != NULL; ++f) 68 if (f->type == FT_general || f->type == FT_md || f->type == FT_cipher) 69 if ((len = strlen(f->name)) > maxlen) 70 maxlen = len; 71 72 dc->width = maxlen + 2; 73 dc->columns = (80 - 1) / dc->width; 46 static void warn_deprecated(const FUNCTION *fp) 47 { 48 if (fp->deprecated_version != NULL) 49 BIO_printf(bio_err, "The command %s was deprecated in version %s.", 50 fp->name, fp->deprecated_version); 51 else 52 BIO_printf(bio_err, "The command %s is deprecated.", fp->name); 53 if (strcmp(fp->deprecated_alternative, DEPRECATED_NO_ALTERNATIVE) != 0) 54 BIO_printf(bio_err, " Use '%s' instead.", fp->deprecated_alternative); 55 BIO_printf(bio_err, "\n"); 74 56 } 75 57 76 58 static int apps_startup(void) 77 59 { 60 const char *use_libctx = NULL; 78 61 #ifdef SIGPIPE 79 62 signal(SIGPIPE, SIG_IGN); … … 85 68 return 0; 86 69 87 setup_ui_method(); 70 (void)setup_ui_method(); 71 (void)setup_engine_loader(); 72 73 /* 74 * NOTE: This is an undocumented feature required for testing only. 75 * There are no guarantees that it will exist in future builds. 76 */ 77 use_libctx = getenv("OPENSSL_TEST_LIBCTX"); 78 if (use_libctx != NULL) { 79 /* Set this to "1" to create a global libctx */ 80 if (strcmp(use_libctx, "1") == 0) { 81 if (app_create_libctx() == NULL) 82 return 0; 83 } 84 } 88 85 89 86 return 1; … … 92 89 static void apps_shutdown(void) 93 90 { 91 app_providers_cleanup(); 92 OSSL_LIB_CTX_free(app_get0_libctx()); 93 destroy_engine_loader(); 94 94 destroy_ui_method(); 95 destroy_prefix_method(); 96 } 97 98 static char *make_config_name(void) 99 { 100 const char *t; 101 size_t len; 102 char *p; 103 104 if ((t = getenv("OPENSSL_CONF")) != NULL) 105 return OPENSSL_strdup(t); 106 107 t = X509_get_default_cert_area(); 108 len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1; 109 p = app_malloc(len, "config filename buffer"); 110 strcpy(p, t); 111 #ifndef OPENSSL_SYS_VMS 112 strcat(p, "/"); 113 #endif 114 strcat(p, OPENSSL_CONF); 115 116 return p; 117 } 95 } 96 97 98 #ifndef OPENSSL_NO_TRACE 99 typedef struct tracedata_st { 100 BIO *bio; 101 unsigned int ingroup:1; 102 } tracedata; 103 104 static size_t internal_trace_cb(const char *buf, size_t cnt, 105 int category, int cmd, void *vdata) 106 { 107 int ret = 0; 108 tracedata *trace_data = vdata; 109 char buffer[256], *hex; 110 CRYPTO_THREAD_ID tid; 111 112 switch (cmd) { 113 case OSSL_TRACE_CTRL_BEGIN: 114 if (trace_data->ingroup) { 115 BIO_printf(bio_err, "ERROR: tracing already started\n"); 116 return 0; 117 } 118 trace_data->ingroup = 1; 119 120 tid = CRYPTO_THREAD_get_current_id(); 121 hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid)); 122 BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ", 123 hex == NULL ? "<null>" : hex, 124 OSSL_trace_get_category_name(category)); 125 OPENSSL_free(hex); 126 BIO_set_prefix(trace_data->bio, buffer); 127 break; 128 case OSSL_TRACE_CTRL_WRITE: 129 if (!trace_data->ingroup) { 130 BIO_printf(bio_err, "ERROR: writing when tracing not started\n"); 131 return 0; 132 } 133 134 ret = BIO_write(trace_data->bio, buf, cnt); 135 break; 136 case OSSL_TRACE_CTRL_END: 137 if (!trace_data->ingroup) { 138 BIO_printf(bio_err, "ERROR: finishing when tracing not started\n"); 139 return 0; 140 } 141 trace_data->ingroup = 0; 142 143 BIO_set_prefix(trace_data->bio, NULL); 144 145 break; 146 } 147 148 return ret < 0 ? 0 : ret; 149 } 150 151 DEFINE_STACK_OF(tracedata) 152 static STACK_OF(tracedata) *trace_data_stack; 153 154 static void tracedata_free(tracedata *data) 155 { 156 BIO_free_all(data->bio); 157 OPENSSL_free(data); 158 } 159 160 static STACK_OF(tracedata) *trace_data_stack; 161 162 static void cleanup_trace(void) 163 { 164 sk_tracedata_pop_free(trace_data_stack, tracedata_free); 165 } 166 167 static void setup_trace_category(int category) 168 { 169 BIO *channel; 170 tracedata *trace_data; 171 BIO *bio = NULL; 172 173 if (OSSL_trace_enabled(category)) 174 return; 175 176 bio = BIO_new(BIO_f_prefix()); 177 channel = BIO_push(bio, dup_bio_err(FORMAT_TEXT)); 178 trace_data = OPENSSL_zalloc(sizeof(*trace_data)); 179 180 if (trace_data == NULL 181 || bio == NULL 182 || (trace_data->bio = channel) == NULL 183 || OSSL_trace_set_callback(category, internal_trace_cb, 184 trace_data) == 0 185 || sk_tracedata_push(trace_data_stack, trace_data) == 0) { 186 187 fprintf(stderr, 188 "warning: unable to setup trace callback for category '%s'.\n", 189 OSSL_trace_get_category_name(category)); 190 191 OSSL_trace_set_callback(category, NULL, NULL); 192 BIO_free_all(channel); 193 } 194 } 195 196 static void setup_trace(const char *str) 197 { 198 char *val; 199 200 /* 201 * We add this handler as early as possible to ensure it's executed 202 * as late as possible, i.e. after the TRACE code has done its cleanup 203 * (which happens last in OPENSSL_cleanup). 204 */ 205 atexit(cleanup_trace); 206 207 trace_data_stack = sk_tracedata_new_null(); 208 val = OPENSSL_strdup(str); 209 210 if (val != NULL) { 211 char *valp = val; 212 char *item; 213 214 for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) { 215 int category = OSSL_trace_get_category_num(item); 216 217 if (category == OSSL_TRACE_CATEGORY_ALL) { 218 while (++category < OSSL_TRACE_CATEGORY_NUM) 219 setup_trace_category(category); 220 break; 221 } else if (category > 0) { 222 setup_trace_category(category); 223 } else { 224 fprintf(stderr, 225 "warning: unknown trace category: '%s'.\n", item); 226 } 227 } 228 } 229 230 OPENSSL_free(val); 231 } 232 #endif /* OPENSSL_NO_TRACE */ 233 234 static char *help_argv[] = { "help", NULL }; 118 235 119 236 int main(int argc, char *argv[]) … … 121 238 FUNCTION f, *fp; 122 239 LHASH_OF(FUNCTION) *prog = NULL; 123 char **copied_argv = NULL; 124 char *p, *pname; 125 char buf[1024]; 126 const char *prompt; 240 char *pname; 241 const char *fname; 127 242 ARGS arg; 128 int first, n, i, ret = 0; 243 int global_help = 0; 244 int ret = 0; 129 245 130 246 arg.argv = NULL; … … 132 248 133 249 /* Set up some of the environment. */ 134 default_config_file = make_config_name();135 250 bio_in = dup_bio_in(FORMAT_TEXT); 136 251 bio_out = dup_bio_out(FORMAT_TEXT); … … 138 253 139 254 #if defined(OPENSSL_SYS_VMS) && defined(__DECC) 140 copied_argv =argv = copy_argv(&argc, argv);255 argv = copy_argv(&argc, argv); 141 256 #elif defined(_WIN32) 142 /* 143 * Replace argv[] with UTF-8 encoded strings. 144 */ 257 /* Replace argv[] with UTF-8 encoded strings. */ 145 258 win32_utf8argv(&argc, &argv); 146 259 #endif 147 260 148 p = getenv("OPENSSL_DEBUG_MEMORY"); 149 if (p != NULL && strcmp(p, "on") == 0) 150 CRYPTO_set_mem_debug(1); 151 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 152 153 if (getenv("OPENSSL_FIPS")) { 154 BIO_printf(bio_err, "FIPS mode not supported.\n"); 155 return 1; 156 } 157 158 if (!apps_startup()) { 261 #ifndef OPENSSL_NO_TRACE 262 setup_trace(getenv("OPENSSL_TRACE")); 263 #endif 264 265 if ((fname = "apps_startup", !apps_startup()) 266 || (fname = "prog_init", (prog = prog_init()) == NULL)) { 159 267 BIO_printf(bio_err, 160 "FATAL: Startup failure (dev note: apps_startup() failed)\n"); 268 "FATAL: Startup failure (dev note: %s()) for %s\n", 269 fname, argv[0]); 161 270 ERR_print_errors(bio_err); 162 271 ret = 1; 163 272 goto end; 164 273 } 165 166 prog = prog_init();167 if (prog == NULL) {168 BIO_printf(bio_err,169 "FATAL: Startup failure (dev note: prog_init() failed)\n");170 ERR_print_errors(bio_err);171 ret = 1;172 goto end;173 }174 274 pname = opt_progname(argv[0]); 275 276 default_config_file = CONF_get1_default_config_file(); 277 if (default_config_file == NULL) 278 app_bail_out("%s: could not get default config file\n", pname); 175 279 176 280 /* first check the program name */ 177 281 f.name = pname; 178 282 fp = lh_FUNCTION_retrieve(prog, &f); 179 if (fp != NULL) { 180 argv[0] = pname; 181 ret = fp->func(argc, argv); 182 goto end; 183 } 184 185 /* If there is stuff on the command line, run with that. */ 186 if (argc != 1) { 283 if (fp == NULL) { 284 /* We assume we've been called as 'openssl ...' */ 285 global_help = argc > 1 286 && (strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0 287 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0); 187 288 argc--; 188 289 argv++; 189 ret = do_cmd(prog, argc, argv); 190 if (ret < 0) 191 ret = 0; 192 goto end; 193 } 194 195 /* ok, lets enter interactive mode */ 196 for (;;) { 197 ret = 0; 198 /* Read a line, continue reading if line ends with \ */ 199 for (p = buf, n = sizeof(buf), i = 0, first = 1; n > 0; first = 0) { 200 prompt = first ? "OpenSSL> " : "> "; 201 p[0] = '\0'; 202 #ifndef READLINE 203 fputs(prompt, stdout); 204 fflush(stdout); 205 if (!fgets(p, n, stdin)) 206 goto end; 207 if (p[0] == '\0') 208 goto end; 209 i = strlen(p); 210 if (i <= 1) 211 break; 212 if (p[i - 2] != '\\') 213 break; 214 i -= 2; 215 p += i; 216 n -= i; 217 #else 218 { 219 extern char *readline(const char *); 220 extern void add_history(const char *cp); 221 char *text; 222 223 text = readline(prompt); 224 if (text == NULL) 225 goto end; 226 i = strlen(text); 227 if (i == 0 || i > n) 228 break; 229 if (text[i - 1] != '\\') { 230 p += strlen(strcpy(p, text)); 231 free(text); 232 add_history(buf); 233 break; 234 } 235 236 text[i - 1] = '\0'; 237 p += strlen(strcpy(p, text)); 238 free(text); 239 n -= i; 240 } 241 #endif 242 } 243 244 if (!chopup_args(&arg, buf)) { 245 BIO_printf(bio_err, "Can't parse (no memory?)\n"); 246 break; 247 } 248 249 ret = do_cmd(prog, arg.argc, arg.argv); 250 if (ret == EXIT_THE_PROGRAM) { 251 ret = 0; 252 goto end; 253 } 254 if (ret != 0) 255 BIO_printf(bio_err, "error in %s\n", arg.argv[0]); 256 (void)BIO_flush(bio_out); 257 (void)BIO_flush(bio_err); 258 } 259 ret = 1; 290 opt_appname(argc == 1 || global_help ? "help" : argv[0]); 291 } else { 292 argv[0] = pname; 293 } 294 295 /* If there's a command, run with that, otherwise "help". */ 296 ret = argc == 0 || global_help 297 ? do_cmd(prog, 1, help_argv) 298 : do_cmd(prog, argc, argv); 299 260 300 end: 261 OPENSSL_free(copied_argv);262 301 OPENSSL_free(default_config_file); 263 302 lh_FUNCTION_free(prog); 264 303 OPENSSL_free(arg.argv); 265 app_RAND_write(); 304 if (!app_RAND_write()) 305 ret = EXIT_FAILURE; 266 306 267 307 BIO_free(bio_in); 268 308 BIO_free_all(bio_out); 269 309 apps_shutdown(); 270 #ifndef OPENSSL_NO_CRYPTO_MDEBUG271 if (CRYPTO_mem_leaks(bio_err) <= 0)272 ret = 1;273 #endif274 310 BIO_free(bio_err); 275 311 EXIT(ret); 276 }277 278 static void list_cipher_fn(const EVP_CIPHER *c,279 const char *from, const char *to, void *arg)280 {281 if (c != NULL) {282 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));283 } else {284 if (from == NULL)285 from = "<undefined>";286 if (to == NULL)287 to = "<undefined>";288 BIO_printf(arg, "%s => %s\n", from, to);289 }290 }291 292 static void list_md_fn(const EVP_MD *m,293 const char *from, const char *to, void *arg)294 {295 if (m != NULL) {296 BIO_printf(arg, "%s\n", EVP_MD_name(m));297 } else {298 if (from == NULL)299 from = "<undefined>";300 if (to == NULL)301 to = "<undefined>";302 BIO_printf((BIO *)arg, "%s => %s\n", from, to);303 }304 }305 306 static void list_missing_help(void)307 {308 const FUNCTION *fp;309 const OPTIONS *o;310 311 for (fp = functions; fp->name != NULL; fp++) {312 if ((o = fp->help) != NULL) {313 /* If there is help, list what flags are not documented. */314 for ( ; o->name != NULL; o++) {315 if (o->helpstr == NULL)316 BIO_printf(bio_out, "%s %s\n", fp->name, o->name);317 }318 } else if (fp->func != dgst_main) {319 /* If not aliased to the dgst command, */320 BIO_printf(bio_out, "%s *\n", fp->name);321 }322 }323 }324 325 static void list_options_for_command(const char *command)326 {327 const FUNCTION *fp;328 const OPTIONS *o;329 330 for (fp = functions; fp->name != NULL; fp++)331 if (strcmp(fp->name, command) == 0)332 break;333 if (fp->name == NULL) {334 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",335 command);336 return;337 }338 339 if ((o = fp->help) == NULL)340 return;341 342 for ( ; o->name != NULL; o++) {343 if (o->name == OPT_HELP_STR344 || o->name == OPT_MORE_STR345 || o->name[0] == '\0')346 continue;347 BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);348 }349 }350 351 352 /* Unified enum for help and list commands. */353 typedef enum HELPLIST_CHOICE {354 OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,355 OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_OPTIONS,356 OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,357 OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED, OPT_MISSING_HELP358 } HELPLIST_CHOICE;359 360 const OPTIONS list_options[] = {361 {"help", OPT_HELP, '-', "Display this summary"},362 {"1", OPT_ONE, '-', "List in one column"},363 {"commands", OPT_COMMANDS, '-', "List of standard commands"},364 {"digest-commands", OPT_DIGEST_COMMANDS, '-',365 "List of message digest commands"},366 {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',367 "List of message digest algorithms"},368 {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},369 {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',370 "List of cipher algorithms"},371 {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',372 "List of public key algorithms"},373 {"public-key-methods", OPT_PK_METHOD, '-',374 "List of public key methods"},375 {"disabled", OPT_DISABLED, '-',376 "List of disabled features"},377 {"missing-help", OPT_MISSING_HELP, '-',378 "List missing detailed help strings"},379 {"options", OPT_OPTIONS, 's',380 "List options for specified command"},381 {NULL}382 };383 384 int list_main(int argc, char **argv)385 {386 char *prog;387 HELPLIST_CHOICE o;388 int one = 0, done = 0;389 390 prog = opt_init(argc, argv, list_options);391 while ((o = opt_next()) != OPT_EOF) {392 switch (o) {393 case OPT_EOF: /* Never hit, but suppresses warning */394 case OPT_ERR:395 opthelp:396 BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);397 return 1;398 case OPT_HELP:399 opt_help(list_options);400 break;401 case OPT_ONE:402 one = 1;403 break;404 case OPT_COMMANDS:405 list_type(FT_general, one);406 break;407 case OPT_DIGEST_COMMANDS:408 list_type(FT_md, one);409 break;410 case OPT_DIGEST_ALGORITHMS:411 EVP_MD_do_all_sorted(list_md_fn, bio_out);412 break;413 case OPT_CIPHER_COMMANDS:414 list_type(FT_cipher, one);415 break;416 case OPT_CIPHER_ALGORITHMS:417 EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);418 break;419 case OPT_PK_ALGORITHMS:420 list_pkey();421 break;422 case OPT_PK_METHOD:423 list_pkey_meth();424 break;425 case OPT_DISABLED:426 list_disabled();427 break;428 case OPT_MISSING_HELP:429 list_missing_help();430 break;431 case OPT_OPTIONS:432 list_options_for_command(opt_arg());433 break;434 }435 done = 1;436 }437 if (opt_num_rest() != 0) {438 BIO_printf(bio_err, "Extra arguments given.\n");439 goto opthelp;440 }441 442 if (!done)443 goto opthelp;444 445 return 0;446 312 } 447 313 … … 451 317 452 318 const OPTIONS help_options[] = { 453 {OPT_HELP_STR, 1, '-', "Usage: help [options]\n"}, 454 {OPT_HELP_STR, 1, '-', " help [command]\n"}, 319 {OPT_HELP_STR, 1, '-', "Usage: help [options] [command]\n"}, 320 321 OPT_SECTION("General"), 455 322 {"help", OPT_hHELP, '-', "Display this summary"}, 323 324 OPT_PARAMETERS(), 325 {"command", 0, 0, "Name of command to display help (optional)"}, 456 326 {NULL} 457 327 }; … … 466 336 HELP_CHOICE o; 467 337 DISPLAY_COLUMNS dc; 338 char *new_argv[3]; 468 339 469 340 prog = opt_init(argc, argv, help_options); … … 480 351 } 481 352 353 /* One optional argument, the command to get help for. */ 482 354 if (opt_num_rest() == 1) { 483 char *new_argv[3];484 485 355 new_argv[0] = opt_rest()[0]; 486 356 new_argv[1] = "--help"; … … 493 363 } 494 364 495 calculate_columns( &dc);496 BIO_printf(bio_err, " Standard commands");365 calculate_columns(functions, &dc); 366 BIO_printf(bio_err, "%s:\n\nStandard commands", prog); 497 367 i = 0; 498 368 tp = FT_none; … … 523 393 } 524 394 525 static void list_type(FUNC_TYPE ft, int one)526 {527 FUNCTION *fp;528 int i = 0;529 DISPLAY_COLUMNS dc = {0};530 531 if (!one)532 calculate_columns(&dc);533 534 for (fp = functions; fp->name != NULL; fp++) {535 if (fp->type != ft)536 continue;537 if (one) {538 BIO_printf(bio_out, "%s\n", fp->name);539 } else {540 if (i % dc.columns == 0 && i > 0)541 BIO_printf(bio_out, "\n");542 BIO_printf(bio_out, "%-*s", dc.width, fp->name);543 i++;544 }545 }546 if (!one)547 BIO_printf(bio_out, "\n\n");548 }549 550 395 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]) 551 396 { … … 554 399 if (argc <= 0 || argv[0] == NULL) 555 400 return 0; 401 memset(&f, 0, sizeof(f)); 556 402 f.name = argv[0]; 557 403 fp = lh_FUNCTION_retrieve(prog, &f); … … 568 414 } 569 415 if (fp != NULL) { 416 if (fp->deprecated_alternative != NULL) 417 warn_deprecated(fp); 570 418 return fp->func(argc, argv); 571 419 } … … 583 431 return 1; 584 432 } 585 if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||586 strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)587 /* Special value to mean "exit the program. */588 return EXIT_THE_PROGRAM;589 433 590 434 BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n", … … 593 437 } 594 438 595 static void list_pkey(void)596 {597 int i;598 599 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {600 const EVP_PKEY_ASN1_METHOD *ameth;601 int pkey_id, pkey_base_id, pkey_flags;602 const char *pinfo, *pem_str;603 ameth = EVP_PKEY_asn1_get0(i);604 EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,605 &pinfo, &pem_str, ameth);606 if (pkey_flags & ASN1_PKEY_ALIAS) {607 BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));608 BIO_printf(bio_out, "\tAlias for: %s\n",609 OBJ_nid2ln(pkey_base_id));610 } else {611 BIO_printf(bio_out, "Name: %s\n", pinfo);612 BIO_printf(bio_out, "\tType: %s Algorithm\n",613 pkey_flags & ASN1_PKEY_DYNAMIC ?614 "External" : "Builtin");615 BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));616 if (pem_str == NULL)617 pem_str = "(none)";618 BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);619 }620 621 }622 }623 624 static void list_pkey_meth(void)625 {626 size_t i;627 size_t meth_count = EVP_PKEY_meth_get_count();628 629 for (i = 0; i < meth_count; i++) {630 const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);631 int pkey_id, pkey_flags;632 633 EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);634 BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));635 BIO_printf(bio_out, "\tType: %s Algorithm\n",636 pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");637 }638 }639 640 439 static int function_cmp(const FUNCTION * a, const FUNCTION * b) 641 440 { … … 656 455 return f1->type - f2->type; 657 456 return strcmp(f1->name, f2->name); 658 }659 660 static void list_disabled(void)661 {662 BIO_puts(bio_out, "Disabled algorithms:\n");663 #ifdef OPENSSL_NO_ARIA664 BIO_puts(bio_out, "ARIA\n");665 #endif666 #ifdef OPENSSL_NO_BF667 BIO_puts(bio_out, "BF\n");668 #endif669 #ifdef OPENSSL_NO_BLAKE2670 BIO_puts(bio_out, "BLAKE2\n");671 #endif672 #ifdef OPENSSL_NO_CAMELLIA673 BIO_puts(bio_out, "CAMELLIA\n");674 #endif675 #ifdef OPENSSL_NO_CAST676 BIO_puts(bio_out, "CAST\n");677 #endif678 #ifdef OPENSSL_NO_CMAC679 BIO_puts(bio_out, "CMAC\n");680 #endif681 #ifdef OPENSSL_NO_CMS682 BIO_puts(bio_out, "CMS\n");683 #endif684 #ifdef OPENSSL_NO_COMP685 BIO_puts(bio_out, "COMP\n");686 #endif687 #ifdef OPENSSL_NO_DES688 BIO_puts(bio_out, "DES\n");689 #endif690 #ifdef OPENSSL_NO_DGRAM691 BIO_puts(bio_out, "DGRAM\n");692 #endif693 #ifdef OPENSSL_NO_DH694 BIO_puts(bio_out, "DH\n");695 #endif696 #ifdef OPENSSL_NO_DSA697 BIO_puts(bio_out, "DSA\n");698 #endif699 #if defined(OPENSSL_NO_DTLS)700 BIO_puts(bio_out, "DTLS\n");701 #endif702 #if defined(OPENSSL_NO_DTLS1)703 BIO_puts(bio_out, "DTLS1\n");704 #endif705 #if defined(OPENSSL_NO_DTLS1_2)706 BIO_puts(bio_out, "DTLS1_2\n");707 #endif708 #ifdef OPENSSL_NO_EC709 BIO_puts(bio_out, "EC\n");710 #endif711 #ifdef OPENSSL_NO_EC2M712 BIO_puts(bio_out, "EC2M\n");713 #endif714 #ifdef OPENSSL_NO_ENGINE715 BIO_puts(bio_out, "ENGINE\n");716 #endif717 #ifdef OPENSSL_NO_GOST718 BIO_puts(bio_out, "GOST\n");719 #endif720 #ifdef OPENSSL_NO_HEARTBEATS721 BIO_puts(bio_out, "HEARTBEATS\n");722 #endif723 #ifdef OPENSSL_NO_IDEA724 BIO_puts(bio_out, "IDEA\n");725 #endif726 #ifdef OPENSSL_NO_MD2727 BIO_puts(bio_out, "MD2\n");728 #endif729 #ifdef OPENSSL_NO_MD4730 BIO_puts(bio_out, "MD4\n");731 #endif732 #ifdef OPENSSL_NO_MD5733 BIO_puts(bio_out, "MD5\n");734 #endif735 #ifdef OPENSSL_NO_MDC2736 BIO_puts(bio_out, "MDC2\n");737 #endif738 #ifdef OPENSSL_NO_OCB739 BIO_puts(bio_out, "OCB\n");740 #endif741 #ifdef OPENSSL_NO_OCSP742 BIO_puts(bio_out, "OCSP\n");743 #endif744 #ifdef OPENSSL_NO_PSK745 BIO_puts(bio_out, "PSK\n");746 #endif747 #ifdef OPENSSL_NO_RC2748 BIO_puts(bio_out, "RC2\n");749 #endif750 #ifdef OPENSSL_NO_RC4751 BIO_puts(bio_out, "RC4\n");752 #endif753 #ifdef OPENSSL_NO_RC5754 BIO_puts(bio_out, "RC5\n");755 #endif756 #ifdef OPENSSL_NO_RMD160757 BIO_puts(bio_out, "RMD160\n");758 #endif759 #ifdef OPENSSL_NO_RSA760 BIO_puts(bio_out, "RSA\n");761 #endif762 #ifdef OPENSSL_NO_SCRYPT763 BIO_puts(bio_out, "SCRYPT\n");764 #endif765 #ifdef OPENSSL_NO_SCTP766 BIO_puts(bio_out, "SCTP\n");767 #endif768 #ifdef OPENSSL_NO_SEED769 BIO_puts(bio_out, "SEED\n");770 #endif771 #ifdef OPENSSL_NO_SM2772 BIO_puts(bio_out, "SM2\n");773 #endif774 #ifdef OPENSSL_NO_SM3775 BIO_puts(bio_out, "SM3\n");776 #endif777 #ifdef OPENSSL_NO_SM4778 BIO_puts(bio_out, "SM4\n");779 #endif780 #ifdef OPENSSL_NO_SOCK781 BIO_puts(bio_out, "SOCK\n");782 #endif783 #ifdef OPENSSL_NO_SRP784 BIO_puts(bio_out, "SRP\n");785 #endif786 #ifdef OPENSSL_NO_SRTP787 BIO_puts(bio_out, "SRTP\n");788 #endif789 #ifdef OPENSSL_NO_SSL3790 BIO_puts(bio_out, "SSL3\n");791 #endif792 #ifdef OPENSSL_NO_TLS1793 BIO_puts(bio_out, "TLS1\n");794 #endif795 #ifdef OPENSSL_NO_TLS1_1796 BIO_puts(bio_out, "TLS1_1\n");797 #endif798 #ifdef OPENSSL_NO_TLS1_2799 BIO_puts(bio_out, "TLS1_2\n");800 #endif801 #ifdef OPENSSL_NO_WHIRLPOOL802 BIO_puts(bio_out, "WHIRLPOOL\n");803 #endif804 #ifndef ZLIB805 BIO_puts(bio_out, "ZLIB\n");806 #endif807 457 } 808 458
Note:
See TracChangeset
for help on using the changeset viewer.