[openssl] master update

Dr. Paul Dale pauli at openssl.org
Wed May 1 06:42:29 UTC 2019


The branch master has been updated
       via  b6a07f676071b2b9fdc0e625896ebd57563028cd (commit)
      from  c43fa566ea3918ec3b468d214fd9eb80d79e0d0d (commit)


- Log -----------------------------------------------------------------
commit b6a07f676071b2b9fdc0e625896ebd57563028cd
Author: Philip Prindeville <philipp at redfish-solutions.com>
Date:   Thu Aug 9 15:19:19 2018 -0600

    gendsa: dsaparam: introduce -verbose option to enable output
    
    Other commands like 'req' support -verbose, so why not gendsa and dsaparam?
    
    Part of a larger and more ambitious effort to add -verbose to all apps
    that might be used in scripts and need to otherwise run silently (well,
    without belching out anything that isn't a warning or error... which ties
    into a later scrub of using STDOUT were appropriate for informative
    messages instead of STDERR)... so that scripts also have the option of
    doing >/dev/null without losing anything critical.
    
    Signed-off-by: Philip Prindeville <philipp at redfish-solutions.com>
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/6908)

-----------------------------------------------------------------------

Summary of changes:
 apps/dsaparam.c       | 20 ++++++++++++++++----
 apps/gendsa.c         | 11 ++++++++---
 doc/man1/dsaparam.pod | 17 +++++++++++------
 doc/man1/gendsa.pod   |  5 +++++
 4 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index 70135a6..959c331 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -25,12 +25,15 @@ NON_EMPTY_TRANSLATION_UNIT
 # include <openssl/x509.h>
 # include <openssl/pem.h>
 
+static int verbose = 0;
+
 static int dsa_cb(int p, int n, BN_GENCB *cb);
 
 typedef enum OPTION_choice {
     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
     OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
-    OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_R_ENUM
+    OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_VERBOSE,
+    OPT_R_ENUM
 } OPTION_CHOICE;
 
 const OPTIONS dsaparam_options[] = {
@@ -47,6 +50,7 @@ const OPTIONS dsaparam_options[] = {
 # ifndef OPENSSL_NO_ENGINE
     {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
 # endif
+    {"verbose", OPT_VERBOSE, '-', "Verbose output"},
     {NULL}
 };
 
@@ -107,6 +111,9 @@ int dsaparam_main(int argc, char **argv)
         case OPT_NOOUT:
             noout = 1;
             break;
+        case OPT_VERBOSE:
+            verbose = 1;
+            break;
         }
     }
     argc = opt_num_rest();
@@ -145,9 +152,11 @@ int dsaparam_main(int argc, char **argv)
             BIO_printf(bio_err, "Error allocating DSA object\n");
             goto end;
         }
-        BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
-                   num);
-        BIO_printf(bio_err, "This could take some time\n");
+        if (verbose) {
+            BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
+                       num);
+            BIO_printf(bio_err, "This could take some time\n");
+        }
         if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, cb)) {
             ERR_print_errors(bio_err);
             BIO_printf(bio_err, "Error, DSA key generation failed\n");
@@ -251,6 +260,9 @@ static int dsa_cb(int p, int n, BN_GENCB *cb)
     static const char symbols[] = ".+*\n";
     char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
 
+    if (!verbose)
+        return 1;
+
     BIO_write(BN_GENCB_get_arg(cb), &c, 1);
     (void)BIO_flush(BN_GENCB_get_arg(cb));
     return 1;
diff --git a/apps/gendsa.c b/apps/gendsa.c
index c44311b..9671b23 100644
--- a/apps/gendsa.c
+++ b/apps/gendsa.c
@@ -27,7 +27,7 @@ NON_EMPTY_TRANSLATION_UNIT
 
 typedef enum OPTION_choice {
     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
-    OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER,
+    OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER, OPT_VERBOSE,
     OPT_R_ENUM
 } OPTION_CHOICE;
 
@@ -42,6 +42,7 @@ const OPTIONS gendsa_options[] = {
 # ifndef OPENSSL_NO_ENGINE
     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
 # endif
+    {"verbose", OPT_VERBOSE, '-', "Verbose output"},
     {NULL}
 };
 
@@ -54,7 +55,7 @@ int gendsa_main(int argc, char **argv)
     char *dsaparams = NULL;
     char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
     OPTION_CHOICE o;
-    int ret = 1, private = 0;
+    int ret = 1, private = 0, verbose = 0;
     const BIGNUM *p = NULL;
 
     prog = opt_init(argc, argv, gendsa_options);
@@ -86,6 +87,9 @@ int gendsa_main(int argc, char **argv)
             if (!opt_cipher(opt_unknown(), &enc))
                 goto end;
             break;
+        case OPT_VERBOSE:
+            verbose = 1;
+            break;
         }
     }
     argc = opt_num_rest();
@@ -124,7 +128,8 @@ int gendsa_main(int argc, char **argv)
                    "         Your key size is %d! Larger key size may behave not as expected.\n",
                    OPENSSL_DSA_MAX_MODULUS_BITS, BN_num_bits(p));
 
-    BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
+    if (verbose)
+        BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
     if (!DSA_generate_key(dsa))
         goto end;
 
diff --git a/doc/man1/dsaparam.pod b/doc/man1/dsaparam.pod
index 3545e68..795c52d 100644
--- a/doc/man1/dsaparam.pod
+++ b/doc/man1/dsaparam.pod
@@ -20,6 +20,7 @@ B<openssl dsaparam>
 [B<-writerand file>]
 [B<-genkey>]
 [B<-engine id>]
+[B<-verbose>]
 [B<numbits>]
 
 =head1 DESCRIPTION
@@ -89,12 +90,6 @@ all others.
 Writes random data to the specified I<file> upon exit.
 This can be used with a subsequent B<-rand> flag.
 
-=item B<numbits>
-
-This option specifies that a parameter set should be generated of size
-B<numbits>. It must be the last option. If this option is included then
-the input file (if any) is ignored.
-
 =item B<-engine id>
 
 Specifying an engine (by its unique B<id> string) will cause B<dsaparam>
@@ -102,6 +97,16 @@ to attempt to obtain a functional reference to the specified engine,
 thus initialising it if needed. The engine will then be set as the default
 for all available algorithms.
 
+=item B<-verbose>
+
+Print extra details about the operations being performed.
+
+=item B<numbits>
+
+This option specifies that a parameter set should be generated of size
+B<numbits>. It must be the last option. If this option is included then
+the input file (if any) is ignored.
+
 =back
 
 =head1 NOTES
diff --git a/doc/man1/gendsa.pod b/doc/man1/gendsa.pod
index 76dc9dd..180ce57 100644
--- a/doc/man1/gendsa.pod
+++ b/doc/man1/gendsa.pod
@@ -25,6 +25,7 @@ B<openssl> B<gendsa>
 [B<-rand file...>]
 [B<-writerand file>]
 [B<-engine id>]
+[B<-verbose>]
 [B<paramfile>]
 
 =head1 DESCRIPTION
@@ -71,6 +72,10 @@ to attempt to obtain a functional reference to the specified engine,
 thus initialising it if needed. The engine will then be set as the default
 for all available algorithms.
 
+=item B<-verbose>
+
+Print extra details about the operations being performed.
+
 =item B<paramfile>
 
 This option specifies the DSA parameter file to use. The parameters in this


More information about the openssl-commits mailing list