diff options
author | inoguchi <> | 2022-03-24 12:00:17 +0000 |
---|---|---|
committer | inoguchi <> | 2022-03-24 12:00:17 +0000 |
commit | fc7571a8dd4185d61f94a126fa60b851c3a65ba4 (patch) | |
tree | 28bbe7a9cd32b7bdc02f0cfff997c1ec867c21fb /src | |
parent | 202239e6bfa165d7447c7516e927e2c0077ebfcf (diff) | |
download | openbsd-fc7571a8dd4185d61f94a126fa60b851c3a65ba4.tar.gz openbsd-fc7571a8dd4185d61f94a126fa60b851c3a65ba4.tar.bz2 openbsd-fc7571a8dd4185d61f94a126fa60b851c3a65ba4.zip |
Wrap long lines
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/ts.c | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/src/usr.bin/openssl/ts.c b/src/usr.bin/openssl/ts.c index a57a17c622..1af2645fd1 100644 --- a/src/usr.bin/openssl/ts.c +++ b/src/usr.bin/openssl/ts.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ts.c,v 1.19 2022/03/24 11:40:07 inoguchi Exp $ */ | 1 | /* $OpenBSD: ts.c,v 1.20 2022/03/24 12:00:17 inoguchi Exp $ */ |
2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL | 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL |
3 | * project 2002. | 3 | * project 2002. |
4 | */ | 4 | */ |
@@ -80,39 +80,34 @@ static ASN1_OBJECT *txt2obj(const char *oid); | |||
80 | static CONF *load_config_file(const char *configfile); | 80 | static CONF *load_config_file(const char *configfile); |
81 | 81 | ||
82 | /* Query related functions. */ | 82 | /* Query related functions. */ |
83 | static int query_command(const char *data, char *digest, | 83 | static int query_command(const char *data, char *digest, const EVP_MD *md, |
84 | const EVP_MD *md, const char *policy, int no_nonce, | 84 | const char *policy, int no_nonce, int cert, const char *in, const char *out, |
85 | int cert, const char *in, const char *out, int text); | 85 | int text); |
86 | static BIO *BIO_open_with_default(const char *file, const char *mode, | 86 | static BIO *BIO_open_with_default(const char *file, const char *mode, |
87 | FILE *default_fp); | 87 | FILE *default_fp); |
88 | static TS_REQ *create_query(BIO *data_bio, char *digest, const EVP_MD *md, | 88 | static TS_REQ *create_query(BIO *data_bio, char *digest, const EVP_MD *md, |
89 | const char *policy, int no_nonce, int cert); | 89 | const char *policy, int no_nonce, int cert); |
90 | static int create_digest(BIO *input, char *digest, | 90 | static int create_digest(BIO *input, char *digest, const EVP_MD *md, |
91 | const EVP_MD *md, unsigned char **md_value); | 91 | unsigned char **md_value); |
92 | static ASN1_INTEGER *create_nonce(int bits); | 92 | static ASN1_INTEGER *create_nonce(int bits); |
93 | 93 | ||
94 | /* Reply related functions. */ | 94 | /* Reply related functions. */ |
95 | static int reply_command(CONF *conf, char *section, | 95 | static int reply_command(CONF *conf, char *section, char *queryfile, |
96 | char *queryfile, char *passin, char *inkey, | 96 | char *passin, char *inkey, char *signer, char *chain, const char *policy, |
97 | char *signer, char *chain, const char *policy, | 97 | char *in, int token_in, char *out, int token_out, int text); |
98 | char *in, int token_in, char *out, int token_out, | ||
99 | int text); | ||
100 | static TS_RESP *read_PKCS7(BIO *in_bio); | 98 | static TS_RESP *read_PKCS7(BIO *in_bio); |
101 | static TS_RESP *create_response(CONF *conf, const char *section, | 99 | static TS_RESP *create_response(CONF *conf, const char *section, |
102 | char *queryfile, char *passin, char *inkey, | 100 | char *queryfile, char *passin, char *inkey, char *signer, char *chain, |
103 | char *signer, char *chain, const char *policy); | 101 | const char *policy); |
104 | static ASN1_INTEGER *serial_cb(TS_RESP_CTX *ctx, void *data); | 102 | static ASN1_INTEGER *serial_cb(TS_RESP_CTX *ctx, void *data); |
105 | static ASN1_INTEGER *next_serial(const char *serialfile); | 103 | static ASN1_INTEGER *next_serial(const char *serialfile); |
106 | static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial); | 104 | static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial); |
107 | 105 | ||
108 | /* Verify related functions. */ | 106 | /* Verify related functions. */ |
109 | static int verify_command(char *data, char *digest, char *queryfile, | 107 | static int verify_command(char *data, char *digest, char *queryfile, char *in, |
110 | char *in, int token_in, | 108 | int token_in, char *ca_path, char *ca_file, char *untrusted); |
111 | char *ca_path, char *ca_file, char *untrusted); | ||
112 | static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest, | 109 | static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest, |
113 | char *queryfile, | 110 | char *queryfile, char *ca_path, char *ca_file, char *untrusted); |
114 | char *ca_path, char *ca_file, | ||
115 | char *untrusted); | ||
116 | static X509_STORE *create_cert_store(char *ca_path, char *ca_file); | 111 | static X509_STORE *create_cert_store(char *ca_path, char *ca_file); |
117 | static int verify_cb(int ok, X509_STORE_CTX *ctx); | 112 | static int verify_cb(int ok, X509_STORE_CTX *ctx); |
118 | 113 | ||
@@ -418,13 +413,16 @@ ts_main(int argc, char **argv) | |||
418 | goto usage; | 413 | goto usage; |
419 | /* Load the config file for possible policy OIDs. */ | 414 | /* Load the config file for possible policy OIDs. */ |
420 | conf = load_config_file(ts_config.configfile); | 415 | conf = load_config_file(ts_config.configfile); |
421 | ret = !query_command(ts_config.data, ts_config.digest, ts_config.md, ts_config.policy, ts_config.no_nonce, ts_config.cert, | 416 | ret = !query_command(ts_config.data, ts_config.digest, |
422 | ts_config.in, ts_config.out, ts_config.text); | 417 | ts_config.md, ts_config.policy, ts_config.no_nonce, |
418 | ts_config.cert, ts_config.in, ts_config.out, | ||
419 | ts_config.text); | ||
423 | break; | 420 | break; |
424 | case CMD_REPLY: | 421 | case CMD_REPLY: |
425 | conf = load_config_file(ts_config.configfile); | 422 | conf = load_config_file(ts_config.configfile); |
426 | if (ts_config.in == NULL) { | 423 | if (ts_config.in == NULL) { |
427 | ret = !(ts_config.queryfile != NULL && conf != NULL && !ts_config.token_in); | 424 | ret = !(ts_config.queryfile != NULL && conf != NULL && |
425 | !ts_config.token_in); | ||
428 | if (ret) | 426 | if (ret) |
429 | goto usage; | 427 | goto usage; |
430 | } else { | 428 | } else { |
@@ -434,18 +432,25 @@ ts_main(int argc, char **argv) | |||
434 | goto usage; | 432 | goto usage; |
435 | } | 433 | } |
436 | 434 | ||
437 | ret = !reply_command(conf, ts_config.section, ts_config.queryfile, | 435 | ret = !reply_command(conf, ts_config.section, |
438 | password, ts_config.inkey, ts_config.signer, ts_config.chain, ts_config.policy, | 436 | ts_config.queryfile, password, ts_config.inkey, |
439 | ts_config.in, ts_config.token_in, ts_config.out, ts_config.token_out, ts_config.text); | 437 | ts_config.signer, ts_config.chain, ts_config.policy, |
438 | ts_config.in, ts_config.token_in, ts_config.out, | ||
439 | ts_config.token_out, ts_config.text); | ||
440 | break; | 440 | break; |
441 | case CMD_VERIFY: | 441 | case CMD_VERIFY: |
442 | ret = !(((ts_config.queryfile && !ts_config.data && !ts_config.digest) || | 442 | ret = !(((ts_config.queryfile && !ts_config.data && |
443 | (!ts_config.queryfile && ts_config.data && !ts_config.digest) || | 443 | !ts_config.digest) || |
444 | (!ts_config.queryfile && !ts_config.data && ts_config.digest)) && ts_config.in != NULL); | 444 | (!ts_config.queryfile && ts_config.data && |
445 | !ts_config.digest) || | ||
446 | (!ts_config.queryfile && !ts_config.data && | ||
447 | ts_config.digest)) && | ||
448 | ts_config.in != NULL); | ||
445 | if (ret) | 449 | if (ret) |
446 | goto usage; | 450 | goto usage; |
447 | 451 | ||
448 | ret = !verify_command(ts_config.data, ts_config.digest, ts_config.queryfile, ts_config.in, ts_config.token_in, | 452 | ret = !verify_command(ts_config.data, ts_config.digest, |
453 | ts_config.queryfile, ts_config.in, ts_config.token_in, | ||
449 | ts_config.ca_path, ts_config.ca_file, ts_config.untrusted); | 454 | ts_config.ca_path, ts_config.ca_file, ts_config.untrusted); |
450 | } | 455 | } |
451 | 456 | ||
@@ -525,8 +530,8 @@ load_config_file(const char *configfile) | |||
525 | 530 | ||
526 | static int | 531 | static int |
527 | query_command(const char *data, char *digest, const EVP_MD *md, | 532 | query_command(const char *data, char *digest, const EVP_MD *md, |
528 | const char *policy, int no_nonce, int cert, const char *in, | 533 | const char *policy, int no_nonce, int cert, const char *in, const char *out, |
529 | const char *out, int text) | 534 | int text) |
530 | { | 535 | { |
531 | int ret = 0; | 536 | int ret = 0; |
532 | TS_REQ *query = NULL; | 537 | TS_REQ *query = NULL; |
@@ -587,8 +592,8 @@ BIO_open_with_default(const char *file, const char *mode, FILE *default_fp) | |||
587 | } | 592 | } |
588 | 593 | ||
589 | static TS_REQ * | 594 | static TS_REQ * |
590 | create_query(BIO *data_bio, char *digest, const EVP_MD *md, | 595 | create_query(BIO *data_bio, char *digest, const EVP_MD *md, const char *policy, |
591 | const char *policy, int no_nonce, int cert) | 596 | int no_nonce, int cert) |
592 | { | 597 | { |
593 | int ret = 0; | 598 | int ret = 0; |
594 | TS_REQ *ts_req = NULL; | 599 | TS_REQ *ts_req = NULL; |
@@ -747,14 +752,15 @@ create_nonce(int bits) | |||
747 | ASN1_INTEGER_free(nonce); | 752 | ASN1_INTEGER_free(nonce); |
748 | return NULL; | 753 | return NULL; |
749 | } | 754 | } |
755 | |||
750 | /* | 756 | /* |
751 | * Reply-related method definitions. | 757 | * Reply-related method definitions. |
752 | */ | 758 | */ |
753 | 759 | ||
754 | static int | 760 | static int |
755 | reply_command(CONF *conf, char *section, char *queryfile, | 761 | reply_command(CONF *conf, char *section, char *queryfile, char *passin, |
756 | char *passin, char *inkey, char *signer, char *chain, const char *policy, | 762 | char *inkey, char *signer, char *chain, const char *policy, char *in, |
757 | char *in, int token_in, char *out, int token_out, int text) | 763 | int token_in, char *out, int token_out, int text) |
758 | { | 764 | { |
759 | int ret = 0; | 765 | int ret = 0; |
760 | TS_RESP *response = NULL; | 766 | TS_RESP *response = NULL; |
@@ -877,9 +883,8 @@ read_PKCS7(BIO *in_bio) | |||
877 | } | 883 | } |
878 | 884 | ||
879 | static TS_RESP * | 885 | static TS_RESP * |
880 | create_response(CONF *conf, const char *section, | 886 | create_response(CONF *conf, const char *section, char *queryfile, char *passin, |
881 | char *queryfile, char *passin, char *inkey, | 887 | char *inkey, char *signer, char *chain, const char *policy) |
882 | char *signer, char *chain, const char *policy) | ||
883 | { | 888 | { |
884 | int ret = 0; | 889 | int ret = 0; |
885 | TS_RESP *response = NULL; | 890 | TS_RESP *response = NULL; |