=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/genrsa.c,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** src/usr.bin/openssl/genrsa.c 2022/11/11 17:07:39 1.21 --- src/usr.bin/openssl/genrsa.c 2023/03/06 14:32:06 1.22 *************** *** 1,4 **** ! /* $OpenBSD: genrsa.c,v 1.21 2022/11/11 17:07:39 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * --- 1,4 ---- ! /* $OpenBSD: genrsa.c,v 1.22 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * *************** *** 90,96 **** unsigned long f4; char *outfile; char *passargout; ! } genrsa_config; static int set_public_exponent(int argc, char **argv, int *argsused) --- 90,96 ---- unsigned long f4; char *outfile; char *passargout; ! } cfg; static int set_public_exponent(int argc, char **argv, int *argsused) *************** *** 98,106 **** char *option = argv[0]; if (strcmp(option, "-3") == 0) ! genrsa_config.f4 = 3; else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0) ! genrsa_config.f4 = RSA_F4; else return (1); --- 98,106 ---- char *option = argv[0]; if (strcmp(option, "-3") == 0) ! cfg.f4 = 3; else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0) ! cfg.f4 = RSA_F4; else return (1); *************** *** 150,156 **** if (*name++ != '-') return (1); ! if ((genrsa_config.enc = get_cipher_by_name(name)) == NULL) return (1); *argsused = 1; --- 150,156 ---- if (*name++ != '-') return (1); ! if ((cfg.enc = get_cipher_by_name(name)) == NULL) return (1); *argsused = 1; *************** *** 243,256 **** .argname = "file", .desc = "Output the key to 'file'", .type = OPTION_ARG, ! .opt.arg = &genrsa_config.outfile, }, { .name = "passout", .argname = "arg", .desc = "Output file passphrase source", .type = OPTION_ARG, ! .opt.arg = &genrsa_config.passargout, }, { NULL }, }; --- 243,256 ---- .argname = "file", .desc = "Output the key to 'file'", .type = OPTION_ARG, ! .opt.arg = &cfg.outfile, }, { .name = "passout", .argname = "arg", .desc = "Output file passphrase source", .type = OPTION_ARG, ! .opt.arg = &cfg.passargout, }, { NULL }, }; *************** *** 300,307 **** goto err; } ! memset(&genrsa_config, 0, sizeof(genrsa_config)); ! genrsa_config.f4 = RSA_F4; if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) { genrsa_usage(); --- 300,307 ---- goto err; } ! memset(&cfg, 0, sizeof(cfg)); ! cfg.f4 = RSA_F4; if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) { genrsa_usage(); *************** *** 314,330 **** goto err; } ! if (!app_passwd(bio_err, NULL, genrsa_config.passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password\n"); goto err; } ! if (genrsa_config.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { ! if (BIO_write_filename(out, genrsa_config.outfile) <= 0) { ! perror(genrsa_config.outfile); goto err; } } --- 314,330 ---- goto err; } ! if (!app_passwd(bio_err, NULL, cfg.passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password\n"); goto err; } ! if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { ! if (BIO_write_filename(out, cfg.outfile) <= 0) { ! perror(cfg.outfile); goto err; } } *************** *** 335,341 **** if (!rsa) goto err; ! if (!BN_set_word(bn, genrsa_config.f4) || !RSA_generate_key_ex(rsa, num, bn, cb)) goto err; --- 335,341 ---- if (!rsa) goto err; ! if (!BN_set_word(bn, cfg.f4) || !RSA_generate_key_ex(rsa, num, bn, cb)) goto err; *************** *** 348,355 **** { PW_CB_DATA cb_data; cb_data.password = passout; ! cb_data.prompt_info = genrsa_config.outfile; ! if (!PEM_write_bio_RSAPrivateKey(out, rsa, genrsa_config.enc, NULL, 0, password_callback, &cb_data)) goto err; } --- 348,355 ---- { PW_CB_DATA cb_data; cb_data.password = passout; ! cb_data.prompt_info = cfg.outfile; ! if (!PEM_write_bio_RSAPrivateKey(out, rsa, cfg.enc, NULL, 0, password_callback, &cb_data)) goto err; }