summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/genrsa.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/genrsa.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/genrsa.c')
-rw-r--r--src/usr.bin/openssl/genrsa.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/usr.bin/openssl/genrsa.c b/src/usr.bin/openssl/genrsa.c
index e1628a682e..0b5323fa5f 100644
--- a/src/usr.bin/openssl/genrsa.c
+++ b/src/usr.bin/openssl/genrsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: genrsa.c,v 1.21 2022/11/11 17:07:39 joshua Exp $ */ 1/* $OpenBSD: genrsa.c,v 1.22 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 *
@@ -90,7 +90,7 @@ static struct {
90 unsigned long f4; 90 unsigned long f4;
91 char *outfile; 91 char *outfile;
92 char *passargout; 92 char *passargout;
93} genrsa_config; 93} cfg;
94 94
95static int 95static int
96set_public_exponent(int argc, char **argv, int *argsused) 96set_public_exponent(int argc, char **argv, int *argsused)
@@ -98,9 +98,9 @@ set_public_exponent(int argc, char **argv, int *argsused)
98 char *option = argv[0]; 98 char *option = argv[0];
99 99
100 if (strcmp(option, "-3") == 0) 100 if (strcmp(option, "-3") == 0)
101 genrsa_config.f4 = 3; 101 cfg.f4 = 3;
102 else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0) 102 else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0)
103 genrsa_config.f4 = RSA_F4; 103 cfg.f4 = RSA_F4;
104 else 104 else
105 return (1); 105 return (1);
106 106
@@ -150,7 +150,7 @@ set_enc(int argc, char **argv, int *argsused)
150 if (*name++ != '-') 150 if (*name++ != '-')
151 return (1); 151 return (1);
152 152
153 if ((genrsa_config.enc = get_cipher_by_name(name)) == NULL) 153 if ((cfg.enc = get_cipher_by_name(name)) == NULL)
154 return (1); 154 return (1);
155 155
156 *argsused = 1; 156 *argsused = 1;
@@ -243,14 +243,14 @@ static const struct option genrsa_options[] = {
243 .argname = "file", 243 .argname = "file",
244 .desc = "Output the key to 'file'", 244 .desc = "Output the key to 'file'",
245 .type = OPTION_ARG, 245 .type = OPTION_ARG,
246 .opt.arg = &genrsa_config.outfile, 246 .opt.arg = &cfg.outfile,
247 }, 247 },
248 { 248 {
249 .name = "passout", 249 .name = "passout",
250 .argname = "arg", 250 .argname = "arg",
251 .desc = "Output file passphrase source", 251 .desc = "Output file passphrase source",
252 .type = OPTION_ARG, 252 .type = OPTION_ARG,
253 .opt.arg = &genrsa_config.passargout, 253 .opt.arg = &cfg.passargout,
254 }, 254 },
255 { NULL }, 255 { NULL },
256}; 256};
@@ -300,8 +300,8 @@ genrsa_main(int argc, char **argv)
300 goto err; 300 goto err;
301 } 301 }
302 302
303 memset(&genrsa_config, 0, sizeof(genrsa_config)); 303 memset(&cfg, 0, sizeof(cfg));
304 genrsa_config.f4 = RSA_F4; 304 cfg.f4 = RSA_F4;
305 305
306 if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) { 306 if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) {
307 genrsa_usage(); 307 genrsa_usage();
@@ -314,17 +314,17 @@ genrsa_main(int argc, char **argv)
314 goto err; 314 goto err;
315 } 315 }
316 316
317 if (!app_passwd(bio_err, NULL, genrsa_config.passargout, NULL, 317 if (!app_passwd(bio_err, NULL, cfg.passargout, NULL,
318 &passout)) { 318 &passout)) {
319 BIO_printf(bio_err, "Error getting password\n"); 319 BIO_printf(bio_err, "Error getting password\n");
320 goto err; 320 goto err;
321 } 321 }
322 322
323 if (genrsa_config.outfile == NULL) { 323 if (cfg.outfile == NULL) {
324 BIO_set_fp(out, stdout, BIO_NOCLOSE); 324 BIO_set_fp(out, stdout, BIO_NOCLOSE);
325 } else { 325 } else {
326 if (BIO_write_filename(out, genrsa_config.outfile) <= 0) { 326 if (BIO_write_filename(out, cfg.outfile) <= 0) {
327 perror(genrsa_config.outfile); 327 perror(cfg.outfile);
328 goto err; 328 goto err;
329 } 329 }
330 } 330 }
@@ -335,7 +335,7 @@ genrsa_main(int argc, char **argv)
335 if (!rsa) 335 if (!rsa)
336 goto err; 336 goto err;
337 337
338 if (!BN_set_word(bn, genrsa_config.f4) || 338 if (!BN_set_word(bn, cfg.f4) ||
339 !RSA_generate_key_ex(rsa, num, bn, cb)) 339 !RSA_generate_key_ex(rsa, num, bn, cb))
340 goto err; 340 goto err;
341 341
@@ -348,8 +348,8 @@ genrsa_main(int argc, char **argv)
348 { 348 {
349 PW_CB_DATA cb_data; 349 PW_CB_DATA cb_data;
350 cb_data.password = passout; 350 cb_data.password = passout;
351 cb_data.prompt_info = genrsa_config.outfile; 351 cb_data.prompt_info = cfg.outfile;
352 if (!PEM_write_bio_RSAPrivateKey(out, rsa, genrsa_config.enc, 352 if (!PEM_write_bio_RSAPrivateKey(out, rsa, cfg.enc,
353 NULL, 0, password_callback, &cb_data)) 353 NULL, 0, password_callback, &cb_data))
354 goto err; 354 goto err;
355 } 355 }