X-Git-Url: https://git.openssl.org/?a=blobdiff_plain;f=apps%2Fgendsa.c;h=d69a93da45127f13b2f6b46f26ceb0eeca45b42c;hb=9f7f1ff75e347577c9b93840ef33bd06422edc18;hp=44d2b42a0579213b0f6d8301e6c22142fea91e53;hpb=a31011e8e0ea18f1cc79d7eb53238768ae9369c6;p=openssl.git diff --git a/apps/gendsa.c b/apps/gendsa.c index 44d2b42a05..d69a93da45 100644 --- a/apps/gendsa.c +++ b/apps/gendsa.c @@ -73,12 +73,15 @@ #undef PROG #define PROG gendsa_main +int MAIN(int, char **); + int MAIN(int argc, char **argv) { DSA *dsa=NULL; int ret=1; char *outfile=NULL; char *inrand=NULL,*dsaparams=NULL; + char *passargout = NULL, *passout = NULL; BIO *out=NULL,*in=NULL; EVP_CIPHER *enc=NULL; @@ -98,6 +101,11 @@ int MAIN(int argc, char **argv) if (--argc < 1) goto bad; outfile= *(++argv); } + else if (strcmp(*argv,"-passout") == 0) + { + if (--argc < 1) goto bad; + passargout= *(++argv); + } else if (strcmp(*argv,"-rand") == 0) { if (--argc < 1) goto bad; @@ -145,6 +153,12 @@ bad: goto end; } + if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { + BIO_printf(bio_err, "Error getting password\n"); + goto end; + } + + in=BIO_new(BIO_s_file()); if (!(BIO_read_filename(in,dsaparams))) { @@ -158,6 +172,7 @@ bad: goto end; } BIO_free(in); + in = NULL; out=BIO_new(BIO_s_file()); if (out == NULL) goto end; @@ -187,14 +202,16 @@ bad: app_RAND_write_file(NULL, bio_err); - if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL,NULL)) + if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL, passout)) goto end; ret=0; end: if (ret != 0) ERR_print_errors(bio_err); + if (in != NULL) BIO_free(in); if (out != NULL) BIO_free(out); if (dsa != NULL) DSA_free(dsa); + if(passout) Free(passout); EXIT(ret); } #endif