version 1.16, 2022/11/11 17:07:39 |
version 1.17, 2023/03/06 14:32:06 |
|
|
const EVP_CIPHER *enc; |
const EVP_CIPHER *enc; |
char *outfile; |
char *outfile; |
char *passargout; |
char *passargout; |
} gendsa_config; |
} cfg; |
|
|
static const EVP_CIPHER *get_cipher_by_name(char *name) |
static const EVP_CIPHER *get_cipher_by_name(char *name) |
{ |
{ |
|
|
if (*name++ != '-') |
if (*name++ != '-') |
return (1); |
return (1); |
|
|
if ((gendsa_config.enc = get_cipher_by_name(name)) == NULL) |
if ((cfg.enc = get_cipher_by_name(name)) == NULL) |
return (1); |
return (1); |
|
|
*argsused = 1; |
*argsused = 1; |
|
|
.argname = "file", |
.argname = "file", |
.desc = "Output the key to 'file'", |
.desc = "Output the key to 'file'", |
.type = OPTION_ARG, |
.type = OPTION_ARG, |
.opt.arg = &gendsa_config.outfile, |
.opt.arg = &cfg.outfile, |
}, |
}, |
{ |
{ |
.name = "passout", |
.name = "passout", |
.argname = "src", |
.argname = "src", |
.desc = "Output file passphrase source", |
.desc = "Output file passphrase source", |
.type = OPTION_ARG, |
.type = OPTION_ARG, |
.opt.arg = &gendsa_config.passargout, |
.opt.arg = &cfg.passargout, |
}, |
}, |
{ NULL }, |
{ NULL }, |
}; |
}; |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
memset(&gendsa_config, 0, sizeof(gendsa_config)); |
memset(&cfg, 0, sizeof(cfg)); |
|
|
if (options_parse(argc, argv, gendsa_options, &dsaparams, NULL) != 0) { |
if (options_parse(argc, argv, gendsa_options, &dsaparams, NULL) != 0) { |
gendsa_usage(); |
gendsa_usage(); |
|
|
gendsa_usage(); |
gendsa_usage(); |
goto end; |
goto end; |
} |
} |
if (!app_passwd(bio_err, NULL, gendsa_config.passargout, NULL, |
if (!app_passwd(bio_err, NULL, cfg.passargout, NULL, |
&passout)) { |
&passout)) { |
BIO_printf(bio_err, "Error getting password\n"); |
BIO_printf(bio_err, "Error getting password\n"); |
goto end; |
goto end; |
|
|
if (out == NULL) |
if (out == NULL) |
goto end; |
goto end; |
|
|
if (gendsa_config.outfile == NULL) { |
if (cfg.outfile == NULL) { |
BIO_set_fp(out, stdout, BIO_NOCLOSE); |
BIO_set_fp(out, stdout, BIO_NOCLOSE); |
} else { |
} else { |
if (BIO_write_filename(out, gendsa_config.outfile) <= 0) { |
if (BIO_write_filename(out, cfg.outfile) <= 0) { |
perror(gendsa_config.outfile); |
perror(cfg.outfile); |
goto end; |
goto end; |
} |
} |
} |
} |
|
|
if (!DSA_generate_key(dsa)) |
if (!DSA_generate_key(dsa)) |
goto end; |
goto end; |
|
|
if (!PEM_write_bio_DSAPrivateKey(out, dsa, gendsa_config.enc, NULL, 0, |
if (!PEM_write_bio_DSAPrivateKey(out, dsa, cfg.enc, NULL, 0, |
NULL, passout)) |
NULL, passout)) |
goto end; |
goto end; |
ret = 0; |
ret = 0; |