2 # Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
14 use OpenSSL::Test qw/:DEFAULT srctop_file/;
15 use OpenSSL::Test::Utils;
19 plan skip_all => "This test is unsupported in a no-dsa build"
24 ok(run(app([ 'openssl', 'genpkey', '-genparam',
26 '-pkeyopt', 'gindex:1',
27 '-pkeyopt', 'type:fips186_4',
29 "genpkey DSA params fips186_4 with verifiable g");
31 ok(run(app([ 'openssl', 'genpkey', '-genparam',
33 '-pkeyopt', 'type:fips186_4',
35 "genpkey DSA params fips186_4 with unverifiable g");
37 ok(run(app([ 'openssl', 'genpkey', '-genparam',
39 '-pkeyopt', 'type:fips186_2',
41 "genpkey DSA params fips186_2");
43 ok(run(app([ 'openssl', 'genpkey', '-genparam',
45 '-pkeyopt', 'type:fips186_2',
46 '-pkeyopt', 'dsa_paramgen_bits:1024',
47 '-out', 'dsagen.legacy.pem'])),
48 "genpkey DSA params fips186_2 PEM");
50 ok(!run(app([ 'openssl', 'genpkey', '-algorithm', 'DSA',
51 '-pkeyopt', 'type:group',
53 "genpkey DSA does not support groups");
55 ok(run(app([ 'openssl', 'genpkey', '-genparam',
57 '-pkeyopt', 'gindex:1',
58 '-pkeyopt', 'type:fips186_4',
59 '-out', 'dsagen.pem'])),
60 "genpkey DSA params fips186_4 PEM");
62 ok(run(app([ 'openssl', 'genpkey', '-genparam',
64 '-pkeyopt', 'gindex:1',
65 '-pkeyopt', 'pbits:2048',
66 '-pkeyopt', 'qbits:256',
67 '-pkeyopt', 'type:fips186_4',
69 '-out', 'dsagen.der'])),
70 "genpkey DSA params fips186_4 DER");
72 ok(run(app([ 'openssl', 'genpkey',
73 '-paramfile', 'dsagen.legacy.pem',
74 '-pkeyopt', 'type:fips186_2',
76 "genpkey DSA fips186_2 with PEM params");
78 # The seed and counter should be the ones generated from the param generation
79 # Just put some dummy ones in to show it works.
80 ok(run(app([ 'openssl', 'genpkey',
81 '-paramfile', 'dsagen.der',
82 '-pkeyopt', 'gindex:1',
83 '-pkeyopt', 'hexseed:0102030405060708090A0B0C0D0E0F1011121314',
84 '-pkeyopt', 'pcounter:25',
86 "genpkey DSA fips186_4 with DER params");
88 ok(!run(app([ 'openssl', 'genpkey',
89 '-algorithm', 'DSA'])),
90 "genpkey DSA with no params should fail");