diff options
author | tb <> | 2023-03-06 14:32:06 +0000 |
---|---|---|
committer | tb <> | 2023-03-06 14:32:06 +0000 |
commit | 6c965e26b1a93da63948edae6b68564be1ded507 (patch) | |
tree | bbe07d6e06b695cebe22802551f2db0a61354d7c /src/usr.bin/openssl/dgst.c | |
parent | 48e828ea26ee91710242131cd75cd9d1d20b773c (diff) | |
download | openbsd-6c965e26b1a93da63948edae6b68564be1ded507.tar.gz openbsd-6c965e26b1a93da63948edae6b68564be1ded507.tar.bz2 openbsd-6c965e26b1a93da63948edae6b68564be1ded507.zip |
Rename struct ${app}_config to plain cfg
All the structs are static and we need to reach into them many times.
Having a shorter name is more concise and results in less visual clutter.
It also avoids many overlong lines and we will be able to get rid of some
unfortunate line wrapping down the road.
Discussed with jsing
Diffstat (limited to 'src/usr.bin/openssl/dgst.c')
-rw-r--r-- | src/usr.bin/openssl/dgst.c | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/src/usr.bin/openssl/dgst.c b/src/usr.bin/openssl/dgst.c index d29bc6f98c..3979966481 100644 --- a/src/usr.bin/openssl/dgst.c +++ b/src/usr.bin/openssl/dgst.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dgst.c,v 1.20 2022/11/11 17:07:38 joshua Exp $ */ | 1 | /* $OpenBSD: dgst.c,v 1.21 2023/03/06 14:32:05 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -96,7 +96,7 @@ static struct { | |||
96 | char *sigfile; | 96 | char *sigfile; |
97 | STACK_OF(OPENSSL_STRING) *sigopts; | 97 | STACK_OF(OPENSSL_STRING) *sigopts; |
98 | int want_pub; | 98 | int want_pub; |
99 | } dgst_config; | 99 | } cfg; |
100 | 100 | ||
101 | static int | 101 | static int |
102 | dgst_opt_macopt(char *arg) | 102 | dgst_opt_macopt(char *arg) |
@@ -104,11 +104,11 @@ dgst_opt_macopt(char *arg) | |||
104 | if (arg == NULL) | 104 | if (arg == NULL) |
105 | return (1); | 105 | return (1); |
106 | 106 | ||
107 | if (dgst_config.macopts == NULL && | 107 | if (cfg.macopts == NULL && |
108 | (dgst_config.macopts = sk_OPENSSL_STRING_new_null()) == NULL) | 108 | (cfg.macopts = sk_OPENSSL_STRING_new_null()) == NULL) |
109 | return (1); | 109 | return (1); |
110 | 110 | ||
111 | if (!sk_OPENSSL_STRING_push(dgst_config.macopts, arg)) | 111 | if (!sk_OPENSSL_STRING_push(cfg.macopts, arg)) |
112 | return (1); | 112 | return (1); |
113 | 113 | ||
114 | return (0); | 114 | return (0); |
@@ -122,10 +122,10 @@ dgst_opt_md(int argc, char **argv, int *argsused) | |||
122 | if (*name++ != '-') | 122 | if (*name++ != '-') |
123 | return (1); | 123 | return (1); |
124 | 124 | ||
125 | if ((dgst_config.m = EVP_get_digestbyname(name)) == NULL) | 125 | if ((cfg.m = EVP_get_digestbyname(name)) == NULL) |
126 | return (1); | 126 | return (1); |
127 | 127 | ||
128 | dgst_config.md = dgst_config.m; | 128 | cfg.md = cfg.m; |
129 | 129 | ||
130 | *argsused = 1; | 130 | *argsused = 1; |
131 | return (0); | 131 | return (0); |
@@ -137,8 +137,8 @@ dgst_opt_prverify(char *arg) | |||
137 | if (arg == NULL) | 137 | if (arg == NULL) |
138 | return (1); | 138 | return (1); |
139 | 139 | ||
140 | dgst_config.keyfile = arg; | 140 | cfg.keyfile = arg; |
141 | dgst_config.do_verify = 1; | 141 | cfg.do_verify = 1; |
142 | return (0); | 142 | return (0); |
143 | } | 143 | } |
144 | 144 | ||
@@ -148,11 +148,11 @@ dgst_opt_sigopt(char *arg) | |||
148 | if (arg == NULL) | 148 | if (arg == NULL) |
149 | return (1); | 149 | return (1); |
150 | 150 | ||
151 | if (dgst_config.sigopts == NULL && | 151 | if (cfg.sigopts == NULL && |
152 | (dgst_config.sigopts = sk_OPENSSL_STRING_new_null()) == NULL) | 152 | (cfg.sigopts = sk_OPENSSL_STRING_new_null()) == NULL) |
153 | return (1); | 153 | return (1); |
154 | 154 | ||
155 | if (!sk_OPENSSL_STRING_push(dgst_config.sigopts, arg)) | 155 | if (!sk_OPENSSL_STRING_push(cfg.sigopts, arg)) |
156 | return (1); | 156 | return (1); |
157 | 157 | ||
158 | return (0); | 158 | return (0); |
@@ -164,9 +164,9 @@ dgst_opt_verify(char *arg) | |||
164 | if (arg == NULL) | 164 | if (arg == NULL) |
165 | return (1); | 165 | return (1); |
166 | 166 | ||
167 | dgst_config.keyfile = arg; | 167 | cfg.keyfile = arg; |
168 | dgst_config.want_pub = 1; | 168 | cfg.want_pub = 1; |
169 | dgst_config.do_verify = 1; | 169 | cfg.do_verify = 1; |
170 | return (0); | 170 | return (0); |
171 | } | 171 | } |
172 | 172 | ||
@@ -175,27 +175,27 @@ static const struct option dgst_options[] = { | |||
175 | .name = "binary", | 175 | .name = "binary", |
176 | .desc = "Output the digest or signature in binary form", | 176 | .desc = "Output the digest or signature in binary form", |
177 | .type = OPTION_VALUE, | 177 | .type = OPTION_VALUE, |
178 | .opt.value = &dgst_config.out_bin, | 178 | .opt.value = &cfg.out_bin, |
179 | .value = 1, | 179 | .value = 1, |
180 | }, | 180 | }, |
181 | { | 181 | { |
182 | .name = "c", | 182 | .name = "c", |
183 | .desc = "Print the digest in two-digit groups separated by colons", | 183 | .desc = "Print the digest in two-digit groups separated by colons", |
184 | .type = OPTION_VALUE, | 184 | .type = OPTION_VALUE, |
185 | .opt.value = &dgst_config.separator, | 185 | .opt.value = &cfg.separator, |
186 | .value = 1, | 186 | .value = 1, |
187 | }, | 187 | }, |
188 | { | 188 | { |
189 | .name = "d", | 189 | .name = "d", |
190 | .desc = "Print BIO debugging information", | 190 | .desc = "Print BIO debugging information", |
191 | .type = OPTION_FLAG, | 191 | .type = OPTION_FLAG, |
192 | .opt.flag = &dgst_config.debug, | 192 | .opt.flag = &cfg.debug, |
193 | }, | 193 | }, |
194 | { | 194 | { |
195 | .name = "hex", | 195 | .name = "hex", |
196 | .desc = "Output as hex dump", | 196 | .desc = "Output as hex dump", |
197 | .type = OPTION_VALUE, | 197 | .type = OPTION_VALUE, |
198 | .opt.value = &dgst_config.out_bin, | 198 | .opt.value = &cfg.out_bin, |
199 | .value = 0, | 199 | .value = 0, |
200 | }, | 200 | }, |
201 | { | 201 | { |
@@ -203,21 +203,21 @@ static const struct option dgst_options[] = { | |||
203 | .argname = "key", | 203 | .argname = "key", |
204 | .desc = "Create hashed MAC with key", | 204 | .desc = "Create hashed MAC with key", |
205 | .type = OPTION_ARG, | 205 | .type = OPTION_ARG, |
206 | .opt.arg = &dgst_config.hmac_key, | 206 | .opt.arg = &cfg.hmac_key, |
207 | }, | 207 | }, |
208 | { | 208 | { |
209 | .name = "keyform", | 209 | .name = "keyform", |
210 | .argname = "format", | 210 | .argname = "format", |
211 | .desc = "Key file format (PEM)", | 211 | .desc = "Key file format (PEM)", |
212 | .type = OPTION_ARG_FORMAT, | 212 | .type = OPTION_ARG_FORMAT, |
213 | .opt.value = &dgst_config.keyform, | 213 | .opt.value = &cfg.keyform, |
214 | }, | 214 | }, |
215 | { | 215 | { |
216 | .name = "mac", | 216 | .name = "mac", |
217 | .argname = "algorithm", | 217 | .argname = "algorithm", |
218 | .desc = "Create MAC (not necessarily HMAC)", | 218 | .desc = "Create MAC (not necessarily HMAC)", |
219 | .type = OPTION_ARG, | 219 | .type = OPTION_ARG, |
220 | .opt.arg = &dgst_config.mac_name, | 220 | .opt.arg = &cfg.mac_name, |
221 | }, | 221 | }, |
222 | { | 222 | { |
223 | .name = "macopt", | 223 | .name = "macopt", |
@@ -231,14 +231,14 @@ static const struct option dgst_options[] = { | |||
231 | .argname = "file", | 231 | .argname = "file", |
232 | .desc = "Output to file rather than stdout", | 232 | .desc = "Output to file rather than stdout", |
233 | .type = OPTION_ARG, | 233 | .type = OPTION_ARG, |
234 | .opt.arg = &dgst_config.outfile, | 234 | .opt.arg = &cfg.outfile, |
235 | }, | 235 | }, |
236 | { | 236 | { |
237 | .name = "passin", | 237 | .name = "passin", |
238 | .argname = "arg", | 238 | .argname = "arg", |
239 | .desc = "Input file passphrase source", | 239 | .desc = "Input file passphrase source", |
240 | .type = OPTION_ARG, | 240 | .type = OPTION_ARG, |
241 | .opt.arg = &dgst_config.passargin, | 241 | .opt.arg = &cfg.passargin, |
242 | }, | 242 | }, |
243 | { | 243 | { |
244 | .name = "prverify", | 244 | .name = "prverify", |
@@ -251,7 +251,7 @@ static const struct option dgst_options[] = { | |||
251 | .name = "r", | 251 | .name = "r", |
252 | .desc = "Output the digest in coreutils format", | 252 | .desc = "Output the digest in coreutils format", |
253 | .type = OPTION_VALUE, | 253 | .type = OPTION_VALUE, |
254 | .opt.value = &dgst_config.separator, | 254 | .opt.value = &cfg.separator, |
255 | .value = 2, | 255 | .value = 2, |
256 | }, | 256 | }, |
257 | { | 257 | { |
@@ -259,14 +259,14 @@ static const struct option dgst_options[] = { | |||
259 | .argname = "file", | 259 | .argname = "file", |
260 | .desc = "Sign digest using private key in file", | 260 | .desc = "Sign digest using private key in file", |
261 | .type = OPTION_ARG, | 261 | .type = OPTION_ARG, |
262 | .opt.arg = &dgst_config.keyfile, | 262 | .opt.arg = &cfg.keyfile, |
263 | }, | 263 | }, |
264 | { | 264 | { |
265 | .name = "signature", | 265 | .name = "signature", |
266 | .argname = "file", | 266 | .argname = "file", |
267 | .desc = "Signature to verify", | 267 | .desc = "Signature to verify", |
268 | .type = OPTION_ARG, | 268 | .type = OPTION_ARG, |
269 | .opt.arg = &dgst_config.sigfile, | 269 | .opt.arg = &cfg.sigfile, |
270 | }, | 270 | }, |
271 | { | 271 | { |
272 | .name = "sigopt", | 272 | .name = "sigopt", |
@@ -348,24 +348,24 @@ dgst_main(int argc, char **argv) | |||
348 | goto end; | 348 | goto end; |
349 | } | 349 | } |
350 | 350 | ||
351 | memset(&dgst_config, 0, sizeof(dgst_config)); | 351 | memset(&cfg, 0, sizeof(cfg)); |
352 | dgst_config.keyform = FORMAT_PEM; | 352 | cfg.keyform = FORMAT_PEM; |
353 | dgst_config.out_bin = -1; | 353 | cfg.out_bin = -1; |
354 | 354 | ||
355 | /* first check the program name */ | 355 | /* first check the program name */ |
356 | program_name(argv[0], pname, sizeof pname); | 356 | program_name(argv[0], pname, sizeof pname); |
357 | 357 | ||
358 | dgst_config.md = EVP_get_digestbyname(pname); | 358 | cfg.md = EVP_get_digestbyname(pname); |
359 | 359 | ||
360 | if (options_parse(argc, argv, dgst_options, NULL, | 360 | if (options_parse(argc, argv, dgst_options, NULL, |
361 | &dgst_config.argsused) != 0) { | 361 | &cfg.argsused) != 0) { |
362 | dgst_usage(); | 362 | dgst_usage(); |
363 | goto end; | 363 | goto end; |
364 | } | 364 | } |
365 | argc -= dgst_config.argsused; | 365 | argc -= cfg.argsused; |
366 | argv += dgst_config.argsused; | 366 | argv += cfg.argsused; |
367 | 367 | ||
368 | if (dgst_config.do_verify && !dgst_config.sigfile) { | 368 | if (cfg.do_verify && !cfg.sigfile) { |
369 | BIO_printf(bio_err, | 369 | BIO_printf(bio_err, |
370 | "No signature to verify: use the -signature option\n"); | 370 | "No signature to verify: use the -signature option\n"); |
371 | goto end; | 371 | goto end; |
@@ -378,50 +378,50 @@ dgst_main(int argc, char **argv) | |||
378 | goto end; | 378 | goto end; |
379 | } | 379 | } |
380 | 380 | ||
381 | if (dgst_config.debug) { | 381 | if (cfg.debug) { |
382 | BIO_set_callback(in, BIO_debug_callback); | 382 | BIO_set_callback(in, BIO_debug_callback); |
383 | /* needed for windows 3.1 */ | 383 | /* needed for windows 3.1 */ |
384 | BIO_set_callback_arg(in, (char *) bio_err); | 384 | BIO_set_callback_arg(in, (char *) bio_err); |
385 | } | 385 | } |
386 | if (!app_passwd(bio_err, dgst_config.passargin, NULL, &passin, NULL)) { | 386 | if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { |
387 | BIO_printf(bio_err, "Error getting password\n"); | 387 | BIO_printf(bio_err, "Error getting password\n"); |
388 | goto end; | 388 | goto end; |
389 | } | 389 | } |
390 | if (dgst_config.out_bin == -1) { | 390 | if (cfg.out_bin == -1) { |
391 | if (dgst_config.keyfile) | 391 | if (cfg.keyfile) |
392 | dgst_config.out_bin = 1; | 392 | cfg.out_bin = 1; |
393 | else | 393 | else |
394 | dgst_config.out_bin = 0; | 394 | cfg.out_bin = 0; |
395 | } | 395 | } |
396 | 396 | ||
397 | if (dgst_config.outfile) { | 397 | if (cfg.outfile) { |
398 | if (dgst_config.out_bin) | 398 | if (cfg.out_bin) |
399 | out = BIO_new_file(dgst_config.outfile, "wb"); | 399 | out = BIO_new_file(cfg.outfile, "wb"); |
400 | else | 400 | else |
401 | out = BIO_new_file(dgst_config.outfile, "w"); | 401 | out = BIO_new_file(cfg.outfile, "w"); |
402 | } else { | 402 | } else { |
403 | out = BIO_new_fp(stdout, BIO_NOCLOSE); | 403 | out = BIO_new_fp(stdout, BIO_NOCLOSE); |
404 | } | 404 | } |
405 | 405 | ||
406 | if (!out) { | 406 | if (!out) { |
407 | BIO_printf(bio_err, "Error opening output file %s\n", | 407 | BIO_printf(bio_err, "Error opening output file %s\n", |
408 | dgst_config.outfile ? dgst_config.outfile : "(stdout)"); | 408 | cfg.outfile ? cfg.outfile : "(stdout)"); |
409 | ERR_print_errors(bio_err); | 409 | ERR_print_errors(bio_err); |
410 | goto end; | 410 | goto end; |
411 | } | 411 | } |
412 | if ((!!dgst_config.mac_name + !!dgst_config.keyfile + | 412 | if ((!!cfg.mac_name + !!cfg.keyfile + |
413 | !!dgst_config.hmac_key) > 1) { | 413 | !!cfg.hmac_key) > 1) { |
414 | BIO_printf(bio_err, | 414 | BIO_printf(bio_err, |
415 | "MAC and Signing key cannot both be specified\n"); | 415 | "MAC and Signing key cannot both be specified\n"); |
416 | goto end; | 416 | goto end; |
417 | } | 417 | } |
418 | if (dgst_config.keyfile) { | 418 | if (cfg.keyfile) { |
419 | if (dgst_config.want_pub) | 419 | if (cfg.want_pub) |
420 | sigkey = load_pubkey(bio_err, dgst_config.keyfile, | 420 | sigkey = load_pubkey(bio_err, cfg.keyfile, |
421 | dgst_config.keyform, 0, NULL, "key file"); | 421 | cfg.keyform, 0, NULL, "key file"); |
422 | else | 422 | else |
423 | sigkey = load_key(bio_err, dgst_config.keyfile, | 423 | sigkey = load_key(bio_err, cfg.keyfile, |
424 | dgst_config.keyform, 0, passin, "key file"); | 424 | cfg.keyform, 0, passin, "key file"); |
425 | if (!sigkey) { | 425 | if (!sigkey) { |
426 | /* | 426 | /* |
427 | * load_[pub]key() has already printed an appropriate | 427 | * load_[pub]key() has already printed an appropriate |
@@ -430,17 +430,17 @@ dgst_main(int argc, char **argv) | |||
430 | goto end; | 430 | goto end; |
431 | } | 431 | } |
432 | } | 432 | } |
433 | if (dgst_config.mac_name) { | 433 | if (cfg.mac_name) { |
434 | EVP_PKEY_CTX *mac_ctx = NULL; | 434 | EVP_PKEY_CTX *mac_ctx = NULL; |
435 | int r = 0; | 435 | int r = 0; |
436 | if (!init_gen_str(bio_err, &mac_ctx, dgst_config.mac_name, 0)) | 436 | if (!init_gen_str(bio_err, &mac_ctx, cfg.mac_name, 0)) |
437 | goto mac_end; | 437 | goto mac_end; |
438 | if (dgst_config.macopts) { | 438 | if (cfg.macopts) { |
439 | char *macopt; | 439 | char *macopt; |
440 | for (i = 0; i < sk_OPENSSL_STRING_num( | 440 | for (i = 0; i < sk_OPENSSL_STRING_num( |
441 | dgst_config.macopts); i++) { | 441 | cfg.macopts); i++) { |
442 | macopt = sk_OPENSSL_STRING_value( | 442 | macopt = sk_OPENSSL_STRING_value( |
443 | dgst_config.macopts, i); | 443 | cfg.macopts, i); |
444 | if (pkey_ctrl_string(mac_ctx, macopt) <= 0) { | 444 | if (pkey_ctrl_string(mac_ctx, macopt) <= 0) { |
445 | BIO_printf(bio_err, | 445 | BIO_printf(bio_err, |
446 | "MAC parameter error \"%s\"\n", | 446 | "MAC parameter error \"%s\"\n", |
@@ -461,9 +461,9 @@ dgst_main(int argc, char **argv) | |||
461 | if (r == 0) | 461 | if (r == 0) |
462 | goto end; | 462 | goto end; |
463 | } | 463 | } |
464 | if (dgst_config.hmac_key) { | 464 | if (cfg.hmac_key) { |
465 | sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, | 465 | sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, |
466 | (unsigned char *) dgst_config.hmac_key, -1); | 466 | (unsigned char *) cfg.hmac_key, -1); |
467 | if (!sigkey) | 467 | if (!sigkey) |
468 | goto end; | 468 | goto end; |
469 | } | 469 | } |
@@ -476,23 +476,23 @@ dgst_main(int argc, char **argv) | |||
476 | ERR_print_errors(bio_err); | 476 | ERR_print_errors(bio_err); |
477 | goto end; | 477 | goto end; |
478 | } | 478 | } |
479 | if (dgst_config.do_verify) | 479 | if (cfg.do_verify) |
480 | r = EVP_DigestVerifyInit(mctx, &pctx, dgst_config.md, | 480 | r = EVP_DigestVerifyInit(mctx, &pctx, cfg.md, |
481 | NULL, sigkey); | 481 | NULL, sigkey); |
482 | else | 482 | else |
483 | r = EVP_DigestSignInit(mctx, &pctx, dgst_config.md, | 483 | r = EVP_DigestSignInit(mctx, &pctx, cfg.md, |
484 | NULL, sigkey); | 484 | NULL, sigkey); |
485 | if (!r) { | 485 | if (!r) { |
486 | BIO_printf(bio_err, "Error setting context\n"); | 486 | BIO_printf(bio_err, "Error setting context\n"); |
487 | ERR_print_errors(bio_err); | 487 | ERR_print_errors(bio_err); |
488 | goto end; | 488 | goto end; |
489 | } | 489 | } |
490 | if (dgst_config.sigopts) { | 490 | if (cfg.sigopts) { |
491 | char *sigopt; | 491 | char *sigopt; |
492 | for (i = 0; i < sk_OPENSSL_STRING_num( | 492 | for (i = 0; i < sk_OPENSSL_STRING_num( |
493 | dgst_config.sigopts); i++) { | 493 | cfg.sigopts); i++) { |
494 | sigopt = sk_OPENSSL_STRING_value( | 494 | sigopt = sk_OPENSSL_STRING_value( |
495 | dgst_config.sigopts, i); | 495 | cfg.sigopts, i); |
496 | if (pkey_ctrl_string(pctx, sigopt) <= 0) { | 496 | if (pkey_ctrl_string(pctx, sigopt) <= 0) { |
497 | BIO_printf(bio_err, | 497 | BIO_printf(bio_err, |
498 | "parameter error \"%s\"\n", | 498 | "parameter error \"%s\"\n", |
@@ -505,16 +505,16 @@ dgst_main(int argc, char **argv) | |||
505 | } | 505 | } |
506 | /* we use md as a filter, reading from 'in' */ | 506 | /* we use md as a filter, reading from 'in' */ |
507 | else { | 507 | else { |
508 | if (dgst_config.md == NULL) | 508 | if (cfg.md == NULL) |
509 | dgst_config.md = EVP_sha256(); | 509 | cfg.md = EVP_sha256(); |
510 | if (!BIO_set_md(bmd, dgst_config.md)) { | 510 | if (!BIO_set_md(bmd, cfg.md)) { |
511 | BIO_printf(bio_err, "Error setting digest %s\n", pname); | 511 | BIO_printf(bio_err, "Error setting digest %s\n", pname); |
512 | ERR_print_errors(bio_err); | 512 | ERR_print_errors(bio_err); |
513 | goto end; | 513 | goto end; |
514 | } | 514 | } |
515 | } | 515 | } |
516 | 516 | ||
517 | if (dgst_config.sigfile && sigkey) { | 517 | if (cfg.sigfile && sigkey) { |
518 | BIO *sigbio; | 518 | BIO *sigbio; |
519 | siglen = EVP_PKEY_size(sigkey); | 519 | siglen = EVP_PKEY_size(sigkey); |
520 | sigbuf = malloc(siglen); | 520 | sigbuf = malloc(siglen); |
@@ -523,10 +523,10 @@ dgst_main(int argc, char **argv) | |||
523 | ERR_print_errors(bio_err); | 523 | ERR_print_errors(bio_err); |
524 | goto end; | 524 | goto end; |
525 | } | 525 | } |
526 | sigbio = BIO_new_file(dgst_config.sigfile, "rb"); | 526 | sigbio = BIO_new_file(cfg.sigfile, "rb"); |
527 | if (!sigbio) { | 527 | if (!sigbio) { |
528 | BIO_printf(bio_err, "Error opening signature file %s\n", | 528 | BIO_printf(bio_err, "Error opening signature file %s\n", |
529 | dgst_config.sigfile); | 529 | cfg.sigfile); |
530 | ERR_print_errors(bio_err); | 530 | ERR_print_errors(bio_err); |
531 | goto end; | 531 | goto end; |
532 | } | 532 | } |
@@ -534,26 +534,26 @@ dgst_main(int argc, char **argv) | |||
534 | BIO_free(sigbio); | 534 | BIO_free(sigbio); |
535 | if (siglen <= 0) { | 535 | if (siglen <= 0) { |
536 | BIO_printf(bio_err, "Error reading signature file %s\n", | 536 | BIO_printf(bio_err, "Error reading signature file %s\n", |
537 | dgst_config.sigfile); | 537 | cfg.sigfile); |
538 | ERR_print_errors(bio_err); | 538 | ERR_print_errors(bio_err); |
539 | goto end; | 539 | goto end; |
540 | } | 540 | } |
541 | } | 541 | } |
542 | inp = BIO_push(bmd, in); | 542 | inp = BIO_push(bmd, in); |
543 | 543 | ||
544 | if (dgst_config.md == NULL) { | 544 | if (cfg.md == NULL) { |
545 | EVP_MD_CTX *tctx; | 545 | EVP_MD_CTX *tctx; |
546 | BIO_get_md_ctx(bmd, &tctx); | 546 | BIO_get_md_ctx(bmd, &tctx); |
547 | dgst_config.md = EVP_MD_CTX_md(tctx); | 547 | cfg.md = EVP_MD_CTX_md(tctx); |
548 | } | 548 | } |
549 | if (argc == 0) { | 549 | if (argc == 0) { |
550 | BIO_set_fp(in, stdin, BIO_NOCLOSE); | 550 | BIO_set_fp(in, stdin, BIO_NOCLOSE); |
551 | err = do_fp(out, buf, inp, dgst_config.separator, | 551 | err = do_fp(out, buf, inp, cfg.separator, |
552 | dgst_config.out_bin, sigkey, sigbuf, siglen, NULL, NULL, | 552 | cfg.out_bin, sigkey, sigbuf, siglen, NULL, NULL, |
553 | "stdin", bmd); | 553 | "stdin", bmd); |
554 | } else { | 554 | } else { |
555 | const char *md_name = NULL, *sig_name = NULL; | 555 | const char *md_name = NULL, *sig_name = NULL; |
556 | if (!dgst_config.out_bin) { | 556 | if (!cfg.out_bin) { |
557 | if (sigkey) { | 557 | if (sigkey) { |
558 | const EVP_PKEY_ASN1_METHOD *ameth; | 558 | const EVP_PKEY_ASN1_METHOD *ameth; |
559 | ameth = EVP_PKEY_get0_asn1(sigkey); | 559 | ameth = EVP_PKEY_get0_asn1(sigkey); |
@@ -561,7 +561,7 @@ dgst_main(int argc, char **argv) | |||
561 | EVP_PKEY_asn1_get0_info(NULL, NULL, | 561 | EVP_PKEY_asn1_get0_info(NULL, NULL, |
562 | NULL, NULL, &sig_name, ameth); | 562 | NULL, NULL, &sig_name, ameth); |
563 | } | 563 | } |
564 | md_name = EVP_MD_name(dgst_config.md); | 564 | md_name = EVP_MD_name(cfg.md); |
565 | } | 565 | } |
566 | err = 0; | 566 | err = 0; |
567 | for (i = 0; i < argc; i++) { | 567 | for (i = 0; i < argc; i++) { |
@@ -571,8 +571,8 @@ dgst_main(int argc, char **argv) | |||
571 | err++; | 571 | err++; |
572 | continue; | 572 | continue; |
573 | } else { | 573 | } else { |
574 | r = do_fp(out, buf, inp, dgst_config.separator, | 574 | r = do_fp(out, buf, inp, cfg.separator, |
575 | dgst_config.out_bin, sigkey, sigbuf, siglen, | 575 | cfg.out_bin, sigkey, sigbuf, siglen, |
576 | sig_name, md_name, argv[i], bmd); | 576 | sig_name, md_name, argv[i], bmd); |
577 | } | 577 | } |
578 | if (r) | 578 | if (r) |
@@ -587,8 +587,8 @@ dgst_main(int argc, char **argv) | |||
587 | free(passin); | 587 | free(passin); |
588 | BIO_free_all(out); | 588 | BIO_free_all(out); |
589 | EVP_PKEY_free(sigkey); | 589 | EVP_PKEY_free(sigkey); |
590 | sk_OPENSSL_STRING_free(dgst_config.sigopts); | 590 | sk_OPENSSL_STRING_free(cfg.sigopts); |
591 | sk_OPENSSL_STRING_free(dgst_config.macopts); | 591 | sk_OPENSSL_STRING_free(cfg.macopts); |
592 | free(sigbuf); | 592 | free(sigbuf); |
593 | BIO_free(bmd); | 593 | BIO_free(bmd); |
594 | 594 | ||