Pass phrase reorganisation.
[openssl.git] / apps / gendsa.c
index 805f114..d69a93d 100644 (file)
@@ -81,7 +81,7 @@ int MAIN(int argc, char **argv)
        int ret=1;
        char *outfile=NULL;
        char *inrand=NULL,*dsaparams=NULL;
-       char *passout = NULL;
+       char *passargout = NULL, *passout = NULL;
        BIO *out=NULL,*in=NULL;
        EVP_CIPHER *enc=NULL;
 
@@ -101,21 +101,10 @@ int MAIN(int argc, char **argv)
                        if (--argc < 1) goto bad;
                        outfile= *(++argv);
                        }
-               else if (strcmp(*argv,"-envpassout") == 0)
-                       {
-                       if (--argc < 1) goto bad;
-                       if(!(passout= getenv(*(++argv))))
-                               {
-                               BIO_printf(bio_err,
-                                "Can't read environment variable %s\n",
-                                                               *argv);
-                               goto bad;
-                               }
-                       }
                else if (strcmp(*argv,"-passout") == 0)
                        {
                        if (--argc < 1) goto bad;
-                       passout= *(++argv);
+                       passargout= *(++argv);
                        }
                else if (strcmp(*argv,"-rand") == 0)
                        {
@@ -164,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)))
                {
@@ -207,7 +202,7 @@ bad:
 
        app_RAND_write_file(NULL, bio_err);
 
-       if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,PEM_cb, passout))
+       if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL, passout))
                goto end;
        ret=0;
 end:
@@ -216,6 +211,7 @@ end:
        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