]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Added tests and updated help
authorAleksey Sanin <aleksey@aleksey.com>
Mon, 20 Mar 2023 15:26:50 +0000 (11:26 -0400)
committerPauli <pauli@openssl.org>
Thu, 23 Mar 2023 00:09:17 +0000 (11:09 +1100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19898)

apps/dsaparam.c
test/recipes/15-test_gendsa.t

index adeeb095a0caec370e07d4f042d9bcb699e40d71..ca98fe58c454650773a73c49b720a03378bc108d 100644 (file)
@@ -32,7 +32,7 @@ typedef enum OPTION_choice {
 } OPTION_CHOICE;
 
 const OPTIONS dsaparam_options[] = {
-    {OPT_HELP_STR, 1, '-', "Usage: %s [options] [numbits]\n"},
+    {OPT_HELP_STR, 1, '-', "Usage: %s [options] [numbits] [numqbits]\n"},
 
     OPT_SECTION("General"),
     {"help", OPT_HELP, '-', "Display this summary"},
@@ -57,8 +57,8 @@ const OPTIONS dsaparam_options[] = {
     OPT_PROV_OPTIONS,
 
     OPT_PARAMETERS(),
-    {"numbits", 0, 0, "Number of bits if generating parameters (optional)"},
-    {"numqbits", 0, 0, "Number of bits in the subprime parameter q if generating parameters (optional)"},
+    {"numbits", 0, 0, "Number of bits if generating parameters or key (optional)"},
+    {"numqbits", 0, 0, "Number of bits in the subprime parameter q if generating parameters or key (optional)"},
     {NULL}
 };
 
@@ -249,4 +249,3 @@ int dsaparam_main(int argc, char **argv)
     release_engine(e);
     return ret;
 }
-
index 00423ce12fa9a89a781fbf78b2b7fc96ba56e997..b4bb9b29ca9e913faad057626feda0565b2f75a4 100644 (file)
@@ -28,7 +28,7 @@ my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
 
 plan tests =>
     ($no_fips ? 0 : 2)          # FIPS related tests
-    + 13;
+    + 18;
 
 ok(run(app([ 'openssl', 'genpkey', '-genparam',
              '-algorithm', 'DSA',
@@ -115,6 +115,43 @@ ok(!run(app(["openssl", "gendsa",
              'dsagen.pem', "-verbose"])),
    "gendsa with extra parameter (at end) should fail");
 
+# test key generation with dsaparam tool
+ok(run(app([ 'openssl', 'dsaparam',
+             '-genkey',
+             '-text',
+             '1024',
+             ])),
+   "dsaparam -genkey DSA 1024 with default qbits");
+
+ok(run(app([ 'openssl', 'dsaparam',
+             '-genkey',
+             '-text',
+             '2048',
+             ])),
+   "dsaparam -genkey DSA 2048 with default qbits");
+
+ok(run(app([ 'openssl', 'dsaparam',
+             '-genkey',
+             '-text',
+             '1024', '160',
+             ])),
+   "dsaparam -genkey DSA 1024 with 160 qbits");
+
+ok(run(app([ 'openssl', 'dsaparam',
+             '-genkey',
+             '-text',
+             '2048', '224',
+             ])),
+   "dsaparam -genkey DSA 2048 with 224 qbits");
+
+ok(run(app([ 'openssl', 'dsaparam',
+             '-genkey',
+             '-text',
+             '2048', '256',
+             ])),
+   "dsaparam -genkey DSA 2048 with 256 qbits");
+# genkey test for 3072 bits keys were removed to speed up the tests
+
 unless ($no_fips) {
     my $provconf = srctop_file("test", "fips-and-base.cnf");
     my $provpath = bldtop_dir("providers");