=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/dhparam.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- src/usr.bin/openssl/dhparam.c 2023/03/05 13:12:53 1.16 +++ src/usr.bin/openssl/dhparam.c 2023/03/06 14:32:06 1.17 @@ -1,4 +1,4 @@ -/* $OpenBSD: dhparam.c,v 1.16 2023/03/05 13:12:53 tb Exp $ */ +/* $OpenBSD: dhparam.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -142,7 +142,7 @@ char *outfile; int outformat; int text; -} dhparam_config; +} cfg; static const struct option dhparam_options[] = { { @@ -150,73 +150,73 @@ .desc = "Generate DH parameters with a generator value of 2 " "(default)", .type = OPTION_VALUE, - .opt.value = &dhparam_config.g, + .opt.value = &cfg.g, .value = 2, }, { .name = "5", .desc = "Generate DH parameters with a generator value of 5", .type = OPTION_VALUE, - .opt.value = &dhparam_config.g, + .opt.value = &cfg.g, .value = 5, }, { .name = "C", .desc = "Convert DH parameters into C code", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.C, + .opt.flag = &cfg.C, }, { .name = "check", .desc = "Check the DH parameters", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.check, + .opt.flag = &cfg.check, }, { .name = "dsaparam", .desc = "Read or generate DSA parameters and convert to DH", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.dsaparam, + .opt.flag = &cfg.dsaparam, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &dhparam_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dhparam_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "Do not output encoded version of DH parameters", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &dhparam_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dhparam_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "text", .desc = "Print DH parameters in plain text", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.text, + .opt.flag = &cfg.text, }, { NULL }, }; @@ -249,10 +249,10 @@ exit(1); } - memset(&dhparam_config, 0, sizeof(dhparam_config)); + memset(&cfg, 0, sizeof(cfg)); - dhparam_config.informat = FORMAT_PEM; - dhparam_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, dhparam_options, &num_bits, NULL) != 0) { dhparam_usage(); @@ -267,18 +267,18 @@ } } - if (dhparam_config.g && !num) + if (cfg.g && !num) num = DEFBITS; - if (dhparam_config.dsaparam) { - if (dhparam_config.g) { + if (cfg.dsaparam) { + if (cfg.g) { BIO_printf(bio_err, "generator may not be chosen for DSA parameters\n"); goto end; } } else { /* DH parameters */ - if (num && !dhparam_config.g) - dhparam_config.g = 2; + if (num && !cfg.g) + cfg.g = 2; } if (num) { @@ -289,7 +289,7 @@ } BN_GENCB_set(cb, dh_cb, bio_err); - if (dhparam_config.dsaparam) { + if (cfg.dsaparam) { DSA *dsa = DSA_new(); BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", num); @@ -307,9 +307,9 @@ } } else { dh = DH_new(); - BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, dhparam_config.g); + BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, cfg.g); BIO_printf(bio_err, "This is going to take a long time\n"); - if (!dh || !DH_generate_parameters_ex(dh, num, dhparam_config.g, cb)) { + if (!dh || !DH_generate_parameters_ex(dh, num, cfg.g, cb)) { ERR_print_errors(bio_err); goto end; } @@ -321,24 +321,24 @@ ERR_print_errors(bio_err); goto end; } - if (dhparam_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, dhparam_config.infile) <= 0) { - perror(dhparam_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (dhparam_config.informat != FORMAT_ASN1 && - dhparam_config.informat != FORMAT_PEM) { + if (cfg.informat != FORMAT_ASN1 && + cfg.informat != FORMAT_PEM) { BIO_printf(bio_err, "bad input format specified\n"); goto end; } - if (dhparam_config.dsaparam) { + if (cfg.dsaparam) { DSA *dsa; - if (dhparam_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) dsa = d2i_DSAparams_bio(in, NULL); else /* informat == FORMAT_PEM */ dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL); @@ -356,7 +356,7 @@ } } else { - if (dhparam_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) dh = d2i_DHparams_bio(in, NULL); else /* informat == FORMAT_PEM */ dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL); @@ -376,20 +376,20 @@ ERR_print_errors(bio_err); goto end; } - if (dhparam_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, dhparam_config.outfile) <= 0) { - perror(dhparam_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (dhparam_config.text) { + if (cfg.text) { DHparams_print(out, dh); } - if (dhparam_config.check) { + if (cfg.check) { if (!DH_check(dh, &i)) { ERR_print_errors(bio_err); goto end; @@ -405,7 +405,7 @@ if (i == 0) printf("DH parameters appear to be ok.\n"); } - if (dhparam_config.C) { + if (cfg.C) { unsigned char *data; int len, l, bits; @@ -454,10 +454,10 @@ printf("\treturn(dh);\n\t}\n"); free(data); } - if (!dhparam_config.noout) { - if (dhparam_config.outformat == FORMAT_ASN1) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_DHparams_bio(out, dh); - else if (dhparam_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_DHparams(out, dh); else { BIO_printf(bio_err, "bad output format specified for outfile\n");