summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/dsaparam.c
diff options
context:
space:
mode:
authortb <>2023-03-06 14:32:06 +0000
committertb <>2023-03-06 14:32:06 +0000
commit6c965e26b1a93da63948edae6b68564be1ded507 (patch)
treebbe07d6e06b695cebe22802551f2db0a61354d7c /src/usr.bin/openssl/dsaparam.c
parent48e828ea26ee91710242131cd75cd9d1d20b773c (diff)
downloadopenbsd-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/dsaparam.c')
-rw-r--r--src/usr.bin/openssl/dsaparam.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/usr.bin/openssl/dsaparam.c b/src/usr.bin/openssl/dsaparam.c
index 892ae72ba1..bc9ccd14d8 100644
--- a/src/usr.bin/openssl/dsaparam.c
+++ b/src/usr.bin/openssl/dsaparam.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsaparam.c,v 1.14 2022/11/11 17:07:38 joshua Exp $ */ 1/* $OpenBSD: dsaparam.c,v 1.15 2023/03/06 14:32:06 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 *
@@ -88,60 +88,60 @@ static struct {
88 char *outfile; 88 char *outfile;
89 int outformat; 89 int outformat;
90 int text; 90 int text;
91} dsaparam_config; 91} cfg;
92 92
93static const struct option dsaparam_options[] = { 93static const struct option dsaparam_options[] = {
94 { 94 {
95 .name = "C", 95 .name = "C",
96 .desc = "Convert DSA parameters into C code", 96 .desc = "Convert DSA parameters into C code",
97 .type = OPTION_FLAG, 97 .type = OPTION_FLAG,
98 .opt.flag = &dsaparam_config.C, 98 .opt.flag = &cfg.C,
99 }, 99 },
100 { 100 {
101 .name = "genkey", 101 .name = "genkey",
102 .desc = "Generate a DSA key", 102 .desc = "Generate a DSA key",
103 .type = OPTION_FLAG, 103 .type = OPTION_FLAG,
104 .opt.flag = &dsaparam_config.genkey, 104 .opt.flag = &cfg.genkey,
105 }, 105 },
106 { 106 {
107 .name = "in", 107 .name = "in",
108 .argname = "file", 108 .argname = "file",
109 .desc = "Input file (default stdin)", 109 .desc = "Input file (default stdin)",
110 .type = OPTION_ARG, 110 .type = OPTION_ARG,
111 .opt.arg = &dsaparam_config.infile, 111 .opt.arg = &cfg.infile,
112 }, 112 },
113 { 113 {
114 .name = "inform", 114 .name = "inform",
115 .argname = "format", 115 .argname = "format",
116 .desc = "Input format (DER or PEM (default))", 116 .desc = "Input format (DER or PEM (default))",
117 .type = OPTION_ARG_FORMAT, 117 .type = OPTION_ARG_FORMAT,
118 .opt.value = &dsaparam_config.informat, 118 .opt.value = &cfg.informat,
119 }, 119 },
120 { 120 {
121 .name = "noout", 121 .name = "noout",
122 .desc = "No output", 122 .desc = "No output",
123 .type = OPTION_FLAG, 123 .type = OPTION_FLAG,
124 .opt.flag = &dsaparam_config.noout, 124 .opt.flag = &cfg.noout,
125 }, 125 },
126 { 126 {
127 .name = "out", 127 .name = "out",
128 .argname = "file", 128 .argname = "file",
129 .desc = "Output file (default stdout)", 129 .desc = "Output file (default stdout)",
130 .type = OPTION_ARG, 130 .type = OPTION_ARG,
131 .opt.arg = &dsaparam_config.outfile, 131 .opt.arg = &cfg.outfile,
132 }, 132 },
133 { 133 {
134 .name = "outform", 134 .name = "outform",
135 .argname = "format", 135 .argname = "format",
136 .desc = "Output format (DER or PEM (default))", 136 .desc = "Output format (DER or PEM (default))",
137 .type = OPTION_ARG_FORMAT, 137 .type = OPTION_ARG_FORMAT,
138 .opt.value = &dsaparam_config.outformat, 138 .opt.value = &cfg.outformat,
139 }, 139 },
140 { 140 {
141 .name = "text", 141 .name = "text",
142 .desc = "Print as text", 142 .desc = "Print as text",
143 .type = OPTION_FLAG, 143 .type = OPTION_FLAG,
144 .opt.flag = &dsaparam_config.text, 144 .opt.flag = &cfg.text,
145 }, 145 },
146 { NULL }, 146 { NULL },
147}; 147};
@@ -174,10 +174,10 @@ dsaparam_main(int argc, char **argv)
174 exit(1); 174 exit(1);
175 } 175 }
176 176
177 memset(&dsaparam_config, 0, sizeof(dsaparam_config)); 177 memset(&cfg, 0, sizeof(cfg));
178 178
179 dsaparam_config.informat = FORMAT_PEM; 179 cfg.informat = FORMAT_PEM;
180 dsaparam_config.outformat = FORMAT_PEM; 180 cfg.outformat = FORMAT_PEM;
181 181
182 if (options_parse(argc, argv, dsaparam_options, &strbits, NULL) != 0) { 182 if (options_parse(argc, argv, dsaparam_options, &strbits, NULL) != 0) {
183 dsaparam_usage(); 183 dsaparam_usage();
@@ -199,19 +199,19 @@ dsaparam_main(int argc, char **argv)
199 ERR_print_errors(bio_err); 199 ERR_print_errors(bio_err);
200 goto end; 200 goto end;
201 } 201 }
202 if (dsaparam_config.infile == NULL) 202 if (cfg.infile == NULL)
203 BIO_set_fp(in, stdin, BIO_NOCLOSE); 203 BIO_set_fp(in, stdin, BIO_NOCLOSE);
204 else { 204 else {
205 if (BIO_read_filename(in, dsaparam_config.infile) <= 0) { 205 if (BIO_read_filename(in, cfg.infile) <= 0) {
206 perror(dsaparam_config.infile); 206 perror(cfg.infile);
207 goto end; 207 goto end;
208 } 208 }
209 } 209 }
210 if (dsaparam_config.outfile == NULL) { 210 if (cfg.outfile == NULL) {
211 BIO_set_fp(out, stdout, BIO_NOCLOSE); 211 BIO_set_fp(out, stdout, BIO_NOCLOSE);
212 } else { 212 } else {
213 if (BIO_write_filename(out, dsaparam_config.outfile) <= 0) { 213 if (BIO_write_filename(out, cfg.outfile) <= 0) {
214 perror(dsaparam_config.outfile); 214 perror(cfg.outfile);
215 goto end; 215 goto end;
216 } 216 }
217 } 217 }
@@ -237,9 +237,9 @@ dsaparam_main(int argc, char **argv)
237 BIO_printf(bio_err, "Error, DSA key generation failed\n"); 237 BIO_printf(bio_err, "Error, DSA key generation failed\n");
238 goto end; 238 goto end;
239 } 239 }
240 } else if (dsaparam_config.informat == FORMAT_ASN1) 240 } else if (cfg.informat == FORMAT_ASN1)
241 dsa = d2i_DSAparams_bio(in, NULL); 241 dsa = d2i_DSAparams_bio(in, NULL);
242 else if (dsaparam_config.informat == FORMAT_PEM) 242 else if (cfg.informat == FORMAT_PEM)
243 dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL); 243 dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL);
244 else { 244 else {
245 BIO_printf(bio_err, "bad input format specified\n"); 245 BIO_printf(bio_err, "bad input format specified\n");
@@ -250,10 +250,10 @@ dsaparam_main(int argc, char **argv)
250 ERR_print_errors(bio_err); 250 ERR_print_errors(bio_err);
251 goto end; 251 goto end;
252 } 252 }
253 if (dsaparam_config.text) { 253 if (cfg.text) {
254 DSAparams_print(out, dsa); 254 DSAparams_print(out, dsa);
255 } 255 }
256 if (dsaparam_config.C) { 256 if (cfg.C) {
257 unsigned char *data; 257 unsigned char *data;
258 int l, len, bits_p; 258 int l, len, bits_p;
259 259
@@ -307,10 +307,10 @@ dsaparam_main(int argc, char **argv)
307 printf("\tDSA_set0_pqg(dsa, p, q, g);\n"); 307 printf("\tDSA_set0_pqg(dsa, p, q, g);\n");
308 printf("\treturn(dsa);\n\t}\n"); 308 printf("\treturn(dsa);\n\t}\n");
309 } 309 }
310 if (!dsaparam_config.noout) { 310 if (!cfg.noout) {
311 if (dsaparam_config.outformat == FORMAT_ASN1) 311 if (cfg.outformat == FORMAT_ASN1)
312 i = i2d_DSAparams_bio(out, dsa); 312 i = i2d_DSAparams_bio(out, dsa);
313 else if (dsaparam_config.outformat == FORMAT_PEM) 313 else if (cfg.outformat == FORMAT_PEM)
314 i = PEM_write_bio_DSAparams(out, dsa); 314 i = PEM_write_bio_DSAparams(out, dsa);
315 else { 315 else {
316 BIO_printf(bio_err, "bad output format specified for outfile\n"); 316 BIO_printf(bio_err, "bad output format specified for outfile\n");
@@ -322,7 +322,7 @@ dsaparam_main(int argc, char **argv)
322 goto end; 322 goto end;
323 } 323 }
324 } 324 }
325 if (dsaparam_config.genkey) { 325 if (cfg.genkey) {
326 DSA *dsakey; 326 DSA *dsakey;
327 327
328 if ((dsakey = DSAparams_dup(dsa)) == NULL) 328 if ((dsakey = DSAparams_dup(dsa)) == NULL)
@@ -332,9 +332,9 @@ dsaparam_main(int argc, char **argv)
332 DSA_free(dsakey); 332 DSA_free(dsakey);
333 goto end; 333 goto end;
334 } 334 }
335 if (dsaparam_config.outformat == FORMAT_ASN1) 335 if (cfg.outformat == FORMAT_ASN1)
336 i = i2d_DSAPrivateKey_bio(out, dsakey); 336 i = i2d_DSAPrivateKey_bio(out, dsakey);
337 else if (dsaparam_config.outformat == FORMAT_PEM) 337 else if (cfg.outformat == FORMAT_PEM)
338 i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL, NULL); 338 i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL, NULL);
339 else { 339 else {
340 BIO_printf(bio_err, "bad output format specified for outfile\n"); 340 BIO_printf(bio_err, "bad output format specified for outfile\n");