X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Fgendsa.c;h=f1e1f54b8a463f3f8d845b262d5041129151b586;hp=75bd802e6634abe74fa860d298ad2b293b0dee50;hb=54180592d7259382bd6ed1198cdbcb0b3be50749;hpb=b548a1f11c06ccdfa4f52a539912d22d77ee309e diff --git a/apps/gendsa.c b/apps/gendsa.c index 75bd802e66..f1e1f54b8a 100644 --- a/apps/gendsa.c +++ b/apps/gendsa.c @@ -84,10 +84,10 @@ OPTIONS gendsa_options[] = { {"passout", OPT_PASSOUT, 's'}, {"rand", OPT_RAND, 's', "Load the file(s) into the random number generator"}, + {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, # ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, # endif - {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, {NULL} }; @@ -99,7 +99,7 @@ int gendsa_main(int argc, char **argv) char *inrand = NULL, *dsaparams = NULL; char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog; OPTION_CHOICE o; - int ret = 1; + int ret = 1, private = 0; prog = opt_init(argc, argv, gendsa_options); while ((o = opt_next()) != OPT_EOF) { @@ -133,6 +133,7 @@ int gendsa_main(int argc, char **argv) } argc = opt_num_rest(); argv = opt_rest(); + private = 1; if (argc != 1) goto opthelp; @@ -143,7 +144,10 @@ int gendsa_main(int argc, char **argv) goto end; } - in = bio_open_default(dsaparams, "r"); + if (!app_load_modules(NULL)) + goto end; + + in = bio_open_default(dsaparams, 'r', FORMAT_PEM); if (in == NULL) goto end2; @@ -154,7 +158,7 @@ int gendsa_main(int argc, char **argv) BIO_free(in); in = NULL; - out = bio_open_default(outfile, "w"); + out = bio_open_owner(outfile, FORMAT_PEM, private); if (out == NULL) goto end2; @@ -172,6 +176,7 @@ int gendsa_main(int argc, char **argv) app_RAND_write_file(NULL); + assert(private); if (!PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout)) goto end; ret = 0;