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
2
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
3
3
* project 2002.
4
4
*/
@@ -80,39 +80,34 @@ static ASN1_OBJECT *txt2obj(const char *oid);
80
80
static CONF * load_config_file (const char * configfile );
81
81
82
82
/* Query related functions. */
83
- static int query_command (const char * data , char * digest ,
84
- const EVP_MD * md , const char * policy , int no_nonce ,
85
- int cert , const char * in , const char * out , int text );
83
+ static int query_command (const char * data , char * digest , const EVP_MD * md ,
84
+ const char * policy , int no_nonce , int cert , const char * in , const char * out ,
85
+ int text );
86
86
static BIO * BIO_open_with_default (const char * file , const char * mode ,
87
87
FILE * default_fp );
88
88
static TS_REQ * create_query (BIO * data_bio , char * digest , const EVP_MD * md ,
89
89
const char * policy , int no_nonce , int cert );
90
- static int create_digest (BIO * input , char * digest ,
91
- const EVP_MD * md , unsigned char * * md_value );
90
+ static int create_digest (BIO * input , char * digest , const EVP_MD * md ,
91
+ unsigned char * * md_value );
92
92
static ASN1_INTEGER * create_nonce (int bits );
93
93
94
94
/* Reply related functions. */
95
- static int reply_command (CONF * conf , char * section ,
96
- char * queryfile , char * passin , char * inkey ,
97
- char * signer , char * chain , const char * policy ,
98
- char * in , int token_in , char * out , int token_out ,
99
- int text );
95
+ static int reply_command (CONF * conf , char * section , char * queryfile ,
96
+ char * passin , char * inkey , char * signer , char * chain , const char * policy ,
97
+ char * in , int token_in , char * out , int token_out , int text );
100
98
static TS_RESP * read_PKCS7 (BIO * in_bio );
101
99
static TS_RESP * create_response (CONF * conf , const char * section ,
102
- char * queryfile , char * passin , char * inkey ,
103
- char * signer , char * chain , const char * policy );
100
+ char * queryfile , char * passin , char * inkey , char * signer , char * chain ,
101
+ const char * policy );
104
102
static ASN1_INTEGER * serial_cb (TS_RESP_CTX * ctx , void * data );
105
103
static ASN1_INTEGER * next_serial (const char * serialfile );
106
104
static int save_ts_serial (const char * serialfile , ASN1_INTEGER * serial );
107
105
108
106
/* Verify related functions. */
109
- static int verify_command (char * data , char * digest , char * queryfile ,
110
- char * in , int token_in ,
111
- char * ca_path , char * ca_file , char * untrusted );
107
+ static int verify_command (char * data , char * digest , char * queryfile , char * in ,
108
+ int token_in , char * ca_path , char * ca_file , char * untrusted );
112
109
static TS_VERIFY_CTX * create_verify_ctx (char * data , char * digest ,
113
- char * queryfile ,
114
- char * ca_path , char * ca_file ,
115
- char * untrusted );
110
+ char * queryfile , char * ca_path , char * ca_file , char * untrusted );
116
111
static X509_STORE * create_cert_store (char * ca_path , char * ca_file );
117
112
static int verify_cb (int ok , X509_STORE_CTX * ctx );
118
113
@@ -418,13 +413,16 @@ ts_main(int argc, char **argv)
418
413
goto usage ;
419
414
/* Load the config file for possible policy OIDs. */
420
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 ,
422
- ts_config .in , ts_config .out , ts_config .text );
416
+ ret = !query_command (ts_config .data , ts_config .digest ,
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
420
break ;
424
421
case CMD_REPLY :
425
422
conf = load_config_file (ts_config .configfile );
426
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
426
if (ret )
429
427
goto usage ;
430
428
} else {
@@ -434,18 +432,25 @@ ts_main(int argc, char **argv)
434
432
goto usage ;
435
433
}
436
434
437
- ret = !reply_command (conf , ts_config .section , ts_config .queryfile ,
438
- password , ts_config .inkey , ts_config .signer , ts_config .chain , ts_config .policy ,
439
- ts_config .in , ts_config .token_in , ts_config .out , ts_config .token_out , ts_config .text );
435
+ ret = !reply_command (conf , ts_config .section ,
436
+ ts_config .queryfile , password , ts_config .inkey ,
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
440
break ;
441
441
case CMD_VERIFY :
442
- ret = !(((ts_config .queryfile && !ts_config .data && !ts_config .digest ) ||
443
- (!ts_config .queryfile && ts_config .data && !ts_config .digest ) ||
444
- (!ts_config .queryfile && !ts_config .data && ts_config .digest )) && ts_config .in != NULL );
442
+ ret = !(((ts_config .queryfile && !ts_config .data &&
443
+ !ts_config .digest ) ||
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
449
if (ret )
446
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
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
531
static int
527
532
query_command (const char * data , char * digest , const EVP_MD * md ,
528
- const char * policy , int no_nonce , int cert , const char * in ,
529
- const char * out , int text )
533
+ const char * policy , int no_nonce , int cert , const char * in , const char * out ,
534
+ int text )
530
535
{
531
536
int ret = 0 ;
532
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
594
static TS_REQ *
590
- create_query (BIO * data_bio , char * digest , const EVP_MD * md ,
591
- const char * policy , int no_nonce , int cert )
595
+ create_query (BIO * data_bio , char * digest , const EVP_MD * md , const char * policy ,
596
+ int no_nonce , int cert )
592
597
{
593
598
int ret = 0 ;
594
599
TS_REQ * ts_req = NULL ;
@@ -747,14 +752,15 @@ create_nonce(int bits)
747
752
ASN1_INTEGER_free (nonce );
748
753
return NULL ;
749
754
}
755
+
750
756
/*
751
757
* Reply-related method definitions.
752
758
*/
753
759
754
760
static int
755
- reply_command (CONF * conf , char * section , char * queryfile ,
756
- char * passin , char * inkey , char * signer , char * chain , const char * policy ,
757
- char * in , int token_in , char * out , int token_out , int text )
761
+ reply_command (CONF * conf , char * section , char * queryfile , char * passin ,
762
+ char * inkey , char * signer , char * chain , const char * policy , char * in ,
763
+ int token_in , char * out , int token_out , int text )
758
764
{
759
765
int ret = 0 ;
760
766
TS_RESP * response = NULL ;
@@ -877,9 +883,8 @@ read_PKCS7(BIO *in_bio)
877
883
}
878
884
879
885
static TS_RESP *
880
- create_response (CONF * conf , const char * section ,
881
- char * queryfile , char * passin , char * inkey ,
882
- char * signer , char * chain , const char * policy )
886
+ create_response (CONF * conf , const char * section , char * queryfile , char * passin ,
887
+ char * inkey , char * signer , char * chain , const char * policy )
883
888
{
884
889
int ret = 0 ;
885
890
TS_RESP * response = NULL ;
0 commit comments