diff options
-rw-r--r-- | src/lib/libssl/src/apps/openssl.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c index 008bbdc08b..03376667dd 100644 --- a/src/lib/libssl/src/apps/openssl.c +++ b/src/lib/libssl/src/apps/openssl.c | |||
@@ -109,7 +109,6 @@ | |||
109 | * | 109 | * |
110 | */ | 110 | */ |
111 | 111 | ||
112 | |||
113 | #include <stdio.h> | 112 | #include <stdio.h> |
114 | #include <string.h> | 113 | #include <string.h> |
115 | #include <stdlib.h> | 114 | #include <stdlib.h> |
@@ -146,7 +145,7 @@ char *default_config_file = NULL; | |||
146 | CONF *config = NULL; | 145 | CONF *config = NULL; |
147 | BIO *bio_err = NULL; | 146 | BIO *bio_err = NULL; |
148 | 147 | ||
149 | static void | 148 | static void |
150 | lock_dbg_cb(int mode, int type, const char *file, int line) | 149 | lock_dbg_cb(int mode, int type, const char *file, int line) |
151 | { | 150 | { |
152 | static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ | 151 | static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ |
@@ -198,7 +197,7 @@ err: | |||
198 | 197 | ||
199 | #define ARGV Argv | 198 | #define ARGV Argv |
200 | 199 | ||
201 | int | 200 | int |
202 | main(int Argc, char *ARGV[]) | 201 | main(int Argc, char *ARGV[]) |
203 | { | 202 | { |
204 | ARGS arg; | 203 | ARGS arg; |
@@ -271,8 +270,8 @@ main(int Argc, char *ARGV[]) | |||
271 | config = NCONF_new(NULL); | 270 | config = NCONF_new(NULL); |
272 | i = NCONF_load(config, p, &errline); | 271 | i = NCONF_load(config, p, &errline); |
273 | if (i == 0) { | 272 | if (i == 0) { |
274 | if (ERR_GET_REASON(ERR_peek_last_error()) | 273 | if (ERR_GET_REASON(ERR_peek_last_error()) == |
275 | == CONF_R_NO_SUCH_FILE) { | 274 | CONF_R_NO_SUCH_FILE) { |
276 | BIO_printf(bio_err, | 275 | BIO_printf(bio_err, |
277 | "WARNING: can't open config file: %s\n", p); | 276 | "WARNING: can't open config file: %s\n", p); |
278 | ERR_clear_error(); | 277 | ERR_clear_error(); |
@@ -350,6 +349,7 @@ main(int Argc, char *ARGV[]) | |||
350 | } | 349 | } |
351 | BIO_printf(bio_err, "bad exit\n"); | 350 | BIO_printf(bio_err, "bad exit\n"); |
352 | ret = 1; | 351 | ret = 1; |
352 | |||
353 | end: | 353 | end: |
354 | if (to_free) | 354 | if (to_free) |
355 | free(to_free); | 355 | free(to_free); |
@@ -380,7 +380,7 @@ end: | |||
380 | #define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms" | 380 | #define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms" |
381 | 381 | ||
382 | 382 | ||
383 | static int | 383 | static int |
384 | do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) | 384 | do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) |
385 | { | 385 | { |
386 | FUNCTION f, *fp; | 386 | FUNCTION f, *fp; |
@@ -416,16 +416,16 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) | |||
416 | BIO_free_all(bio_stdout); | 416 | BIO_free_all(bio_stdout); |
417 | goto end; | 417 | goto end; |
418 | } else if ((strcmp(argv[0], "quit") == 0) || | 418 | } else if ((strcmp(argv[0], "quit") == 0) || |
419 | (strcmp(argv[0], "q") == 0) || | 419 | (strcmp(argv[0], "q") == 0) || |
420 | (strcmp(argv[0], "exit") == 0) || | 420 | (strcmp(argv[0], "exit") == 0) || |
421 | (strcmp(argv[0], "bye") == 0)) { | 421 | (strcmp(argv[0], "bye") == 0)) { |
422 | ret = -1; | 422 | ret = -1; |
423 | goto end; | 423 | goto end; |
424 | } else if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) || | 424 | } else if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) || |
425 | (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) || | 425 | (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) || |
426 | (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) || | 426 | (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) || |
427 | (strcmp(argv[0], LIST_CIPHER_COMMANDS) == 0) || | 427 | (strcmp(argv[0], LIST_CIPHER_COMMANDS) == 0) || |
428 | (strcmp(argv[0], LIST_CIPHER_ALGORITHMS) == 0) || | 428 | (strcmp(argv[0], LIST_CIPHER_ALGORITHMS) == 0) || |
429 | (strcmp(argv[0], LIST_PUBLIC_KEY_ALGORITHMS) == 0)) { | 429 | (strcmp(argv[0], LIST_PUBLIC_KEY_ALGORITHMS) == 0)) { |
430 | int list_type; | 430 | int list_type; |
431 | BIO *bio_stdout; | 431 | BIO *bio_stdout; |
@@ -463,7 +463,8 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) | |||
463 | ret = 0; | 463 | ret = 0; |
464 | goto end; | 464 | goto end; |
465 | } else { | 465 | } else { |
466 | BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n", | 466 | BIO_printf(bio_err, |
467 | "openssl:Error: '%s' is an invalid command.\n", | ||
467 | argv[0]); | 468 | argv[0]); |
468 | BIO_printf(bio_err, "\nStandard commands"); | 469 | BIO_printf(bio_err, "\nStandard commands"); |
469 | i = 0; | 470 | i = 0; |
@@ -505,7 +506,7 @@ end: | |||
505 | return (ret); | 506 | return (ret); |
506 | } | 507 | } |
507 | 508 | ||
508 | static int | 509 | static int |
509 | SortFnByName(const void *_f1, const void *_f2) | 510 | SortFnByName(const void *_f1, const void *_f2) |
510 | { | 511 | { |
511 | const FUNCTION *f1 = _f1; | 512 | const FUNCTION *f1 = _f1; |
@@ -516,10 +517,11 @@ SortFnByName(const void *_f1, const void *_f2) | |||
516 | return strcmp(f1->name, f2->name); | 517 | return strcmp(f1->name, f2->name); |
517 | } | 518 | } |
518 | 519 | ||
519 | static void | 520 | static void |
520 | list_pkey(BIO * out) | 521 | list_pkey(BIO * out) |
521 | { | 522 | { |
522 | int i; | 523 | int i; |
524 | |||
523 | for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) { | 525 | for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) { |
524 | const EVP_PKEY_ASN1_METHOD *ameth; | 526 | const EVP_PKEY_ASN1_METHOD *ameth; |
525 | int pkey_id, pkey_base_id, pkey_flags; | 527 | int pkey_id, pkey_base_id, pkey_flags; |
@@ -546,9 +548,9 @@ list_pkey(BIO * out) | |||
546 | } | 548 | } |
547 | } | 549 | } |
548 | 550 | ||
549 | static void | 551 | static void |
550 | list_cipher_fn(const EVP_CIPHER * c, | 552 | list_cipher_fn(const EVP_CIPHER * c, const char *from, const char *to, |
551 | const char *from, const char *to, void *arg) | 553 | void *arg) |
552 | { | 554 | { |
553 | if (c) | 555 | if (c) |
554 | BIO_printf(arg, "%s\n", EVP_CIPHER_name(c)); | 556 | BIO_printf(arg, "%s\n", EVP_CIPHER_name(c)); |
@@ -561,15 +563,14 @@ list_cipher_fn(const EVP_CIPHER * c, | |||
561 | } | 563 | } |
562 | } | 564 | } |
563 | 565 | ||
564 | static void | 566 | static void |
565 | list_cipher(BIO * out) | 567 | list_cipher(BIO * out) |
566 | { | 568 | { |
567 | EVP_CIPHER_do_all_sorted(list_cipher_fn, out); | 569 | EVP_CIPHER_do_all_sorted(list_cipher_fn, out); |
568 | } | 570 | } |
569 | 571 | ||
570 | static void | 572 | static void |
571 | list_md_fn(const EVP_MD * m, | 573 | list_md_fn(const EVP_MD * m, const char *from, const char *to, void *arg) |
572 | const char *from, const char *to, void *arg) | ||
573 | { | 574 | { |
574 | if (m) | 575 | if (m) |
575 | BIO_printf(arg, "%s\n", EVP_MD_name(m)); | 576 | BIO_printf(arg, "%s\n", EVP_MD_name(m)); |
@@ -582,33 +583,38 @@ list_md_fn(const EVP_MD * m, | |||
582 | } | 583 | } |
583 | } | 584 | } |
584 | 585 | ||
585 | static void | 586 | static void |
586 | list_md(BIO * out) | 587 | list_md(BIO * out) |
587 | { | 588 | { |
588 | EVP_MD_do_all_sorted(list_md_fn, out); | 589 | EVP_MD_do_all_sorted(list_md_fn, out); |
589 | } | 590 | } |
590 | 591 | ||
591 | static int | 592 | static int |
592 | function_cmp(const FUNCTION * a, const FUNCTION * b) | 593 | function_cmp(const FUNCTION * a, const FUNCTION * b) |
593 | { | 594 | { |
594 | return strncmp(a->name, b->name, 8); | 595 | return strncmp(a->name, b->name, 8); |
595 | } | 596 | } |
596 | static | 597 | |
597 | IMPLEMENT_LHASH_COMP_FN(function, FUNCTION) | 598 | static IMPLEMENT_LHASH_COMP_FN(function, FUNCTION) |
598 | static unsigned long function_hash(const FUNCTION * a) | 599 | |
600 | static unsigned long | ||
601 | function_hash(const FUNCTION * a) | ||
599 | { | 602 | { |
600 | return lh_strhash(a->name); | 603 | return lh_strhash(a->name); |
601 | } | 604 | } |
602 | static | 605 | |
603 | IMPLEMENT_LHASH_HASH_FN(function, FUNCTION) | 606 | static IMPLEMENT_LHASH_HASH_FN(function, FUNCTION) |
604 | static LHASH_OF(FUNCTION) * prog_init(void) | 607 | |
608 | static LHASH_OF(FUNCTION) * | ||
609 | prog_init(void) | ||
605 | { | 610 | { |
606 | LHASH_OF(FUNCTION) * ret; | 611 | LHASH_OF(FUNCTION) * ret; |
607 | FUNCTION *f; | 612 | FUNCTION *f; |
608 | size_t i; | 613 | size_t i; |
609 | 614 | ||
610 | /* Purely so it looks nice when the user hits ? */ | 615 | /* Purely so it looks nice when the user hits ? */ |
611 | for (i = 0, f = functions; f->name != NULL; ++f, ++i); | 616 | for (i = 0, f = functions; f->name != NULL; ++f, ++i) |
617 | ; | ||
612 | qsort(functions, i, sizeof *functions, SortFnByName); | 618 | qsort(functions, i, sizeof *functions, SortFnByName); |
613 | 619 | ||
614 | if ((ret = lh_FUNCTION_new()) == NULL) | 620 | if ((ret = lh_FUNCTION_new()) == NULL) |