summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/dh.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/dh.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/dh.c')
-rw-r--r--src/usr.bin/openssl/dh.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/usr.bin/openssl/dh.c b/src/usr.bin/openssl/dh.c
index 200233c0f2..a4c02235f2 100644
--- a/src/usr.bin/openssl/dh.c
+++ b/src/usr.bin/openssl/dh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.c,v 1.14 2022/11/11 17:07:38 joshua Exp $ */ 1/* $OpenBSD: dh.c,v 1.15 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 *
@@ -83,60 +83,60 @@ static struct {
83 char *outfile; 83 char *outfile;
84 int outformat; 84 int outformat;
85 int text; 85 int text;
86} dh_config; 86} cfg;
87 87
88static const struct option dh_options[] = { 88static const struct option dh_options[] = {
89 { 89 {
90 .name = "C", 90 .name = "C",
91 .desc = "Convert DH parameters into C code", 91 .desc = "Convert DH parameters into C code",
92 .type = OPTION_FLAG, 92 .type = OPTION_FLAG,
93 .opt.flag = &dh_config.C, 93 .opt.flag = &cfg.C,
94 }, 94 },
95 { 95 {
96 .name = "check", 96 .name = "check",
97 .desc = "Check the DH parameters", 97 .desc = "Check the DH parameters",
98 .type = OPTION_FLAG, 98 .type = OPTION_FLAG,
99 .opt.flag = &dh_config.check, 99 .opt.flag = &cfg.check,
100 }, 100 },
101 { 101 {
102 .name = "in", 102 .name = "in",
103 .argname = "file", 103 .argname = "file",
104 .desc = "Input file (default stdin)", 104 .desc = "Input file (default stdin)",
105 .type = OPTION_ARG, 105 .type = OPTION_ARG,
106 .opt.arg = &dh_config.infile, 106 .opt.arg = &cfg.infile,
107 }, 107 },
108 { 108 {
109 .name = "inform", 109 .name = "inform",
110 .argname = "format", 110 .argname = "format",
111 .desc = "Input format (DER or PEM (default))", 111 .desc = "Input format (DER or PEM (default))",
112 .type = OPTION_ARG_FORMAT, 112 .type = OPTION_ARG_FORMAT,
113 .opt.value = &dh_config.informat, 113 .opt.value = &cfg.informat,
114 }, 114 },
115 { 115 {
116 .name = "noout", 116 .name = "noout",
117 .desc = "No output", 117 .desc = "No output",
118 .type = OPTION_FLAG, 118 .type = OPTION_FLAG,
119 .opt.flag = &dh_config.noout, 119 .opt.flag = &cfg.noout,
120 }, 120 },
121 { 121 {
122 .name = "out", 122 .name = "out",
123 .argname = "file", 123 .argname = "file",
124 .desc = "Output file (default stdout)", 124 .desc = "Output file (default stdout)",
125 .type = OPTION_ARG, 125 .type = OPTION_ARG,
126 .opt.arg = &dh_config.outfile, 126 .opt.arg = &cfg.outfile,
127 }, 127 },
128 { 128 {
129 .name = "outform", 129 .name = "outform",
130 .argname = "format", 130 .argname = "format",
131 .desc = "Output format (DER or PEM (default))", 131 .desc = "Output format (DER or PEM (default))",
132 .type = OPTION_ARG_FORMAT, 132 .type = OPTION_ARG_FORMAT,
133 .opt.value = &dh_config.outformat, 133 .opt.value = &cfg.outformat,
134 }, 134 },
135 { 135 {
136 .name = "text", 136 .name = "text",
137 .desc = "Print a text form of the DH parameters", 137 .desc = "Print a text form of the DH parameters",
138 .type = OPTION_FLAG, 138 .type = OPTION_FLAG,
139 .opt.flag = &dh_config.text, 139 .opt.flag = &cfg.text,
140 }, 140 },
141 { NULL }, 141 { NULL },
142}; 142};
@@ -163,10 +163,10 @@ dh_main(int argc, char **argv)
163 exit(1); 163 exit(1);
164 } 164 }
165 165
166 memset(&dh_config, 0, sizeof(dh_config)); 166 memset(&cfg, 0, sizeof(cfg));
167 167
168 dh_config.informat = FORMAT_PEM; 168 cfg.informat = FORMAT_PEM;
169 dh_config.outformat = FORMAT_PEM; 169 cfg.outformat = FORMAT_PEM;
170 170
171 if (options_parse(argc, argv, dh_options, NULL, NULL) != 0) { 171 if (options_parse(argc, argv, dh_options, NULL, NULL) != 0) {
172 dh_usage(); 172 dh_usage();
@@ -179,26 +179,26 @@ dh_main(int argc, char **argv)
179 ERR_print_errors(bio_err); 179 ERR_print_errors(bio_err);
180 goto end; 180 goto end;
181 } 181 }
182 if (dh_config.infile == NULL) 182 if (cfg.infile == NULL)
183 BIO_set_fp(in, stdin, BIO_NOCLOSE); 183 BIO_set_fp(in, stdin, BIO_NOCLOSE);
184 else { 184 else {
185 if (BIO_read_filename(in, dh_config.infile) <= 0) { 185 if (BIO_read_filename(in, cfg.infile) <= 0) {
186 perror(dh_config.infile); 186 perror(cfg.infile);
187 goto end; 187 goto end;
188 } 188 }
189 } 189 }
190 if (dh_config.outfile == NULL) { 190 if (cfg.outfile == NULL) {
191 BIO_set_fp(out, stdout, BIO_NOCLOSE); 191 BIO_set_fp(out, stdout, BIO_NOCLOSE);
192 } else { 192 } else {
193 if (BIO_write_filename(out, dh_config.outfile) <= 0) { 193 if (BIO_write_filename(out, cfg.outfile) <= 0) {
194 perror(dh_config.outfile); 194 perror(cfg.outfile);
195 goto end; 195 goto end;
196 } 196 }
197 } 197 }
198 198
199 if (dh_config.informat == FORMAT_ASN1) 199 if (cfg.informat == FORMAT_ASN1)
200 dh = d2i_DHparams_bio(in, NULL); 200 dh = d2i_DHparams_bio(in, NULL);
201 else if (dh_config.informat == FORMAT_PEM) 201 else if (cfg.informat == FORMAT_PEM)
202 dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL); 202 dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
203 else { 203 else {
204 BIO_printf(bio_err, "bad input format specified\n"); 204 BIO_printf(bio_err, "bad input format specified\n");
@@ -209,10 +209,10 @@ dh_main(int argc, char **argv)
209 ERR_print_errors(bio_err); 209 ERR_print_errors(bio_err);
210 goto end; 210 goto end;
211 } 211 }
212 if (dh_config.text) { 212 if (cfg.text) {
213 DHparams_print(out, dh); 213 DHparams_print(out, dh);
214 } 214 }
215 if (dh_config.check) { 215 if (cfg.check) {
216 if (!DH_check(dh, &i)) { 216 if (!DH_check(dh, &i)) {
217 ERR_print_errors(bio_err); 217 ERR_print_errors(bio_err);
218 goto end; 218 goto end;
@@ -228,7 +228,7 @@ dh_main(int argc, char **argv)
228 if (i == 0) 228 if (i == 0)
229 printf("DH parameters appear to be ok.\n"); 229 printf("DH parameters appear to be ok.\n");
230 } 230 }
231 if (dh_config.C) { 231 if (cfg.C) {
232 unsigned char *data; 232 unsigned char *data;
233 int len, l, bits; 233 int len, l, bits;
234 234
@@ -271,10 +271,10 @@ dh_main(int argc, char **argv)
271 printf("\treturn(dh);\n\t}\n"); 271 printf("\treturn(dh);\n\t}\n");
272 free(data); 272 free(data);
273 } 273 }
274 if (!dh_config.noout) { 274 if (!cfg.noout) {
275 if (dh_config.outformat == FORMAT_ASN1) 275 if (cfg.outformat == FORMAT_ASN1)
276 i = i2d_DHparams_bio(out, dh); 276 i = i2d_DHparams_bio(out, dh);
277 else if (dh_config.outformat == FORMAT_PEM) 277 else if (cfg.outformat == FORMAT_PEM)
278 i = PEM_write_bio_DHparams(out, dh); 278 i = PEM_write_bio_DHparams(out, dh);
279 else { 279 else {
280 BIO_printf(bio_err, "bad output format specified for outfile\n"); 280 BIO_printf(bio_err, "bad output format specified for outfile\n");