If an engine comes up explicitely, it must also come down explicitely
[openssl.git] / apps / gendsa.c
index 5dacf1b9fcf14086e6f029d188b564452ff386a2..c9563a74f7e50741d212035120a560ea70c8ce00 100644 (file)
@@ -29,12 +29,12 @@ typedef enum OPTION_choice {
     OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_RAND, OPT_CIPHER
 } OPTION_CHOICE;
 
-OPTIONS gendsa_options[] = {
+const OPTIONS gendsa_options[] = {
     {OPT_HELP_STR, 1, '-', "Usage: %s [args] dsaparam-file\n"},
     {OPT_HELP_STR, 1, '-', "Valid options are:\n"},
     {"help", OPT_HELP, '-', "Display this summary"},
     {"out", OPT_OUT, '>', "Output the key to the specified file"},
-    {"passout", OPT_PASSOUT, 's'},
+    {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
     {"rand", OPT_RAND, 's',
      "Load the file(s) into the random number generator"},
     {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
@@ -46,6 +46,7 @@ OPTIONS gendsa_options[] = {
 
 int gendsa_main(int argc, char **argv)
 {
+    ENGINE *e = NULL;
     BIO *out = NULL, *in = NULL;
     DSA *dsa = NULL;
     const EVP_CIPHER *enc = NULL;
@@ -74,7 +75,7 @@ int gendsa_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            (void)setup_engine(opt_arg(), 0);
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_RAND:
             inrand = opt_arg();
@@ -139,6 +140,7 @@ int gendsa_main(int argc, char **argv)
     BIO_free(in);
     BIO_free_all(out);
     DSA_free(dsa);
+    release_engine(e);
     OPENSSL_free(passout);
     return (ret);
 }