Cleanup cert config files for tests
[openssl.git] / test / recipes / 15-test_gendsa.t
1 #! /usr/bin/env perl
2 # Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
3 #
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
8
9
10 use strict;
11 use warnings;
12
13 use File::Spec;
14 use OpenSSL::Test qw/:DEFAULT srctop_file/;
15 use OpenSSL::Test::Utils;
16
17 setup("test_gendsa");
18
19 plan skip_all => "This test is unsupported in a no-dsa build"
20     if disabled("dsa");
21
22 plan tests => 8;
23
24 ok(run(app([ 'openssl', 'genpkey', '-genparam',
25              '-algorithm', 'DSA',
26              '-pkeyopt', 'gindex:1',
27              '-pkeyopt', 'type:fips186_4',
28              '-text'])),
29    "genpkey DSA params fips186_4 with verifiable g");
30
31 ok(run(app([ 'openssl', 'genpkey', '-genparam',
32              '-algorithm', 'DSA',
33              '-pkeyopt', 'type:fips186_4',
34              '-text'])),
35    "genpkey DSA params fips186_4 with unverifiable g");
36
37 ok(run(app([ 'openssl', 'genpkey', '-genparam',
38              '-algorithm', 'DSA',
39              '-pkeyopt', 'type:fips186_2',
40              '-text'])),
41    "genpkey DSA params fips186_2");
42
43 ok(!run(app([ 'openssl', 'genpkey', '-algorithm', 'DSA',
44              '-pkeyopt', 'type:group',
45              '-text'])),
46    "genpkey DSA does not support groups");
47
48 ok(run(app([ 'openssl', 'genpkey', '-genparam',
49              '-algorithm', 'DSA',
50              '-pkeyopt', 'gindex:1',
51              '-pkeyopt', 'type:fips186_4',
52              '-out', 'dsagen.pem'])),
53    "genpkey DSA params fips186_4 PEM");
54
55 ok(run(app([ 'openssl', 'genpkey', '-genparam',
56              '-algorithm', 'DSA',
57              '-pkeyopt', 'gindex:1',
58              '-pkeyopt', 'pbits:2048',
59              '-pkeyopt', 'qbits:256',
60              '-pkeyopt', 'type:fips186_4',
61              '-outform', 'DER',
62              '-out', 'dsagen.der'])),
63    "genpkey DSA params fips186_4 DER");
64
65 # The seed and counter should be the ones generated from the param generation
66 # Just put some dummy ones in to show it works.
67 ok(run(app([ 'openssl', 'genpkey',
68              '-paramfile', 'dsagen.der',
69              '-pkeyopt', 'gindex:1',
70              '-pkeyopt', 'hexseed:0102030405060708090A0B0C0D0E0F1011121314',
71              '-pkeyopt', 'pcounter:25',
72              '-text'])),
73    "genpkey DSA fips186_4 with DER params");
74
75 ok(!run(app([ 'openssl', 'genpkey',
76               '-algorithm', 'DSA'])),
77    "genpkey DSA with no params should fail");