1=pod
2
3=head1 NAME
4
5EVP_PKEY-DSA, EVP_KEYMGMT-DSA - EVP_PKEY DSA keytype and algorithm support
6
7=head1 DESCRIPTION
8
9For B<DSA> the FIPS186-4 standard specifies that the values used for FFC
10parameter generation are also required for parameter validation.
11This means that optional FFC domain parameter values for I<seed>, I<pcounter>
12and I<gindex> may need to be stored for validation purposes. For B<DSA> these
13fields are not stored in the ASN1 data so they need to be stored externally if
14validation is required.
15
16=head2 DSA parameters
17
18The B<DSA> key type supports the FFC parameters (see
19L<EVP_PKEY-FFC(7)/FFC parameters>).
20
21=head2 DSA key generation parameters
22
23The B<DSA> key type supports the FFC key generation parameters (see
24L<EVP_PKEY-FFC(7)/FFC key generation parameters>
25
26The following restrictions apply to the "pbits" field:
27
28For "fips186_4" this must be either 2048 or 3072.
29For "fips186_2" this must be 1024.
30For "group" this can be any one of 2048, 3072, 4096, 6144 or 8192.
31
32=head2 DSA key validation
33
34For DSA keys, L<EVP_PKEY_param_check(3)> behaves in the following way:
35The OpenSSL FIPS provider conforms to the rules within the FIPS186-4
36standard for FFC parameter validation. For backwards compatibility the OpenSSL
37default provider uses a much simpler check (see below) for parameter validation,
38unless the seed parameter is set.
39
40For DSA keys, L<EVP_PKEY_param_check_quick(3)> behaves in the following way:
41A simple check of L and N and partial g is performed. The default provider
42also supports validation of legacy "fips186_2" keys.
43
44For DSA keys, L<EVP_PKEY_public_check(3)>, L<EVP_PKEY_private_check(3)> and
45L<EVP_PKEY_pairwise_check(3)> the OpenSSL default and FIPS providers conform to
46the rules within SP800-56Ar3 for public, private and pairwise tests respectively.
47
48=head1 EXAMPLES
49
50An B<EVP_PKEY> context can be obtained by calling:
51
52    EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
53
54The B<DSA> domain parameters can be generated by calling:
55
56    unsigned int pbits = 2048;
57    unsigned int qbits = 256;
58    int gindex = 1;
59    OSSL_PARAM params[5];
60    EVP_PKEY *param_key = NULL;
61    EVP_PKEY_CTX *pctx = NULL;
62
63    pctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
64    EVP_PKEY_paramgen_init(pctx);
65
66    params[0] = OSSL_PARAM_construct_uint("pbits", &pbits);
67    params[1] = OSSL_PARAM_construct_uint("qbits", &qbits);
68    params[2] = OSSL_PARAM_construct_int("gindex", &gindex);
69    params[3] = OSSL_PARAM_construct_utf8_string("digest", "SHA384", 0);
70    params[4] = OSSL_PARAM_construct_end();
71    EVP_PKEY_CTX_set_params(pctx, params);
72
73    EVP_PKEY_generate(pctx, &param_key);
74    EVP_PKEY_CTX_free(pctx);
75
76    EVP_PKEY_print_params(bio_out, param_key, 0, NULL);
77
78A B<DSA> key can be generated using domain parameters by calling:
79
80    EVP_PKEY *key = NULL;
81    EVP_PKEY_CTX *gctx = NULL;
82
83    gctx = EVP_PKEY_CTX_new_from_pkey(NULL, param_key, NULL);
84    EVP_PKEY_keygen_init(gctx);
85    EVP_PKEY_generate(gctx, &key);
86    EVP_PKEY_CTX_free(gctx);
87    EVP_PKEY_print_private(bio_out, key, 0, NULL);
88
89
90=head1 CONFORMING TO
91
92The following sections of FIPS186-4:
93
94=over 4
95
96=item A.1.1.2 Generation of Probable Primes p and q Using an Approved Hash Function.
97
98=item A.2.3 Generation of canonical generator g.
99
100=item A.2.1 Unverifiable Generation of the Generator g.
101
102=back
103
104=head1 SEE ALSO
105
106L<EVP_PKEY-FFC(7)>,
107L<EVP_SIGNATURE-DSA(7)>
108L<EVP_PKEY(3)>,
109L<provider-keymgmt(7)>,
110L<EVP_KEYMGMT(3)>,
111L<OSSL_PROVIDER-default(7)>,
112L<OSSL_PROVIDER-FIPS(7)>
113
114=head1 COPYRIGHT
115
116Copyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved.
117
118Licensed under the Apache License 2.0 (the "License").  You may not use
119this file except in compliance with the License.  You can obtain a copy
120in the file LICENSE in the source distribution or at
121L<https://www.openssl.org/source/license.html>.
122
123=cut
124