DOC: Extend EVP_PKEY-DSA(7) / EVP_PKEY_DH(7) with FFC information
[openssl.git] / doc / man7 / EVP_PKEY-DSA.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_PKEY-DSA, EVP_KEYMGMT-DSA, EVP_PKEY-DH, EVP_KEYMGMT-DH
6 - EVP_PKEY DSA and DH keytype and algorithm support
7
8 =head1 DESCRIPTION
9
10 The B<DSA> and B<DH> keytypes are implemented in OpenSSL's default and FIPS
11 providers.
12 The implementations support the basic DSA and DH keys, containing the public
13 and private keys I<pub> and I<priv> as well as the three main domain parameters
14 I<p>, I<q> and I<g>.
15
16 Finite field cryptography (FFC) is a method of implementing discrete logarithm
17 cryptography using finite field mathematics. DSA is an example of FFC and
18 Diffie-Hellman key establishment algorithms specified in SP800-56A can also be
19 implemented as FFC.
20
21 For B<DH> FFC key agreement, two classes of domain parameters can be used:
22 "safe" domain parameters that are associated with approved named safe-prime
23 groups, and a class of "FIPS 186-type" domain parameters. FIPS 186-type domain
24 parameters should only be used for backward compatibility with existing
25 applications that cannot be upgraded to use the approved safe-prime groups.
26
27 For B<DSA> (and B<DH> that is not a named group) the FIPS186-4 standard
28 specifies that the values used for FFC parameter generation are also required
29 for parameter validation.
30 This means that optional FFC domain parameter values for I<seed>, I<pcounter>
31 and I<gindex> may need to be stored for validation purposes.
32 For B<DH> the I<seed> and I<pcounter> can be stored in ASN1 data
33 (but the I<gindex> is not). For B<DSA> however, these fields are not stored in
34 the ASN1 data so they need to be stored externally if validation is required.
35
36 =head2 Common DH parameters
37
38 =over 4
39
40 =item "group" (B<OSSL_PKEY_PARAM_FFC_GROUP>) <UTF8 string>
41
42 A string that associates a B<DH> named safe prime group with known values for
43 I<p>, I<q> and I<g>.
44
45 The following values can be used by the default and OpenSSL's FIPS providers:
46 "ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144", "ffdhe8192",
47 "modp_2048", "modp_3072", "modp_4096", "modp_6144", "modp_8192".
48
49 The following additional values can also be used by the default provider:
50 "modp_1536", "dh_1024_160", "dh_2048_224", "dh_2048_256".
51
52 DH named groups can be easily validated since the parameters are well known.
53 For protocols that only transfer I<p> and I<g> the value of I<q> can also be
54 retrieved.
55
56 =item "safeprime-generator" (B<OSSL_PKEY_PARAM_FFC_GENERATOR>) <integer>
57
58 Used for DH generation of safe primes using the old generator code.
59 It is recommended to use a named safe prime group instead, if domain parameter
60 validation is required. The default value is 2.
61
62 These are not named safe prime groups so setting this value for the OpenSSL FIPS
63 provider will instead choose a named safe prime group based on the size of I<p>.
64
65 =back
66
67 =head2 Common DSA & DH parameters
68
69 In addition to the common parameters that all keytypes should support (see
70 L<provider-keymgmt(7)/Common parameters>), the B<DSA> and B<DH> keytype
71 implementations support the following.
72
73 =over 4
74
75 =item "pub" (B<OSSL_PKEY_PARAM_PUB_KEY>) <unsigned integer>
76
77 The public key value.
78
79 =item "priv" (B<OSSL_PKEY_PARAM_PRIV_KEY>) <unsigned integer>
80
81 The private key value.
82
83 =item "p" (B<OSSL_PKEY_PARAM_FFC_P>) <unsigned integer>
84
85 A DSA or Diffie-Hellman prime "p" value.
86
87 =item "q" (B<OSSL_PKEY_PARAM_FFC_Q>) <unsigned integer>
88
89 A DSA or Diffie-Hellman prime "q" value.
90
91 =item "g" (B<OSSL_PKEY_PARAM_FFC_G>) <unsigned integer>
92
93 A DSA or Diffie-Hellman generator "g" value.
94
95 =item "seed" (B<OSSL_PKEY_PARAM_FFC_SEED>) <octet string>
96
97 An optional domain parameter I<seed> value used during generation and validation
98 of I<p>, I<q> and canonical I<g>.
99 For validation this needs to set the I<seed> that was produced during generation.
100
101 =item "gindex" (B<OSSL_PKEY_PARAM_FFC_GINDEX>) <integer>
102
103 Sets the index to use for canonical generation and verification of the generator
104 I<g>.
105 Set this to a positive value from 0..FF to use this mode. This I<gindex> can
106 then be reused during key validation to verify the value of I<g>. If this value
107 is not set or is -1 then unverifiable generation of the generator I<g> will be
108 used.
109
110 =item "pcounter" (B<OSSL_PKEY_PARAM_FFC_PCOUNTER>) <integer>
111
112 An optional domain parameter I<counter> value that is output during generation
113 of I<p>. This value must be saved if domain parameter validation is required.
114
115 =item "hindex" (B<OSSL_PKEY_PARAM_FFC_H>) <integer>
116
117 For unverifiable generation of the generator I<g> this value is output during 
118 generation of I<g>. Its value is the first integer larger than one that
119 satisfies g = h^j mod p (where g != 1 and "j" is the cofactor).
120
121 =item "j" (B<OSSL_PKEY_PARAM_FFC_COFACTOR>) <unsigned integer>
122
123 An optional informational cofactor parameter that should equal (p - 1) / q.
124
125 =back
126
127
128 =head2 DSA / DH key generation (FFC) parameters
129
130 The following Key Generation types are available for the built-in FFC algorithms:
131
132 =over 4
133
134 =item "type" (B<OSSL_PKEY_PARAM_FFC_TYPE>) <utf8_string>
135
136 Sets the type of parameter generation. For DH Valid values are:
137
138 =over 4
139
140 =item "fips186_4"
141
142 The current standard. This is the default value.
143
144 =item "default"
145
146 This is an alias to use the latest implemented standard.
147 It is currently set to "fips186_4".
148
149 =item "group"
150
151 This specifies that a named safe prime name will be chosen using the "pbits"
152 type.
153
154 =item "fips186_2"
155
156 The old standard that should only be used for legacy purposes.
157
158 =item "generator"
159
160 A safe prime generator. See the "safeprime-generator" type.
161
162 =back
163
164 For DSA valid values are one of "default", "fips186_4" or "fips186_2" as
165 described above.
166
167 =item "pbits" (B<OSSL_PKEY_PARAM_FFC_PBITS>) <unsigned integer>
168
169 Sets the size (in bits) of the prime 'p'.
170
171 For "fips186_4" this must be 2048 for DH, and either of 2048 or 3072 for DSA.
172 For "fips186_2" this must be 1024.
173 For "group" this can be any one of 2048, 3072, 4096, 6144 or 8192.
174
175 =item "qbits" (B<OSSL_PKEY_PARAM_FFC_QBITS>) <unsigned integer>
176
177 Sets the size (in bits) of the prime 'q'.
178
179 For "fips186_4" this can be either 224 or 256.
180 For "fips186_2" this has a size of 160.
181
182 =item "digest" (B<OSSL_PKEY_PARAM_FFC_DIGEST>)  <utf8_string>
183
184 Sets the Digest algorithm to be used as part of the Key Generation Function
185 associated with the given Key Generation I<ctx>.
186 This must also be set for key validation.
187
188 =item "properties" (B<OSSL_PKEY_PARAM_FFC_DIGEST_PROPS>) <utf8_string>
189
190 Sets properties to be used upon look up of the implementation for the selected
191 Digest algorithm for the Key Generation Function associated with the given key
192 generation I<ctx>. This may also be set for key validation.
193
194 =item "seed" (B<OSSL_PKEY_PARAM_FFC_SEED>) <octet string>
195
196 For "fips186_4" or "fips186_2" generation this sets the I<seed> data to use
197 instead of generating a random seed internally. This should be used for
198 testing purposes only. This will either produce fixed values for the generated
199 parameters OR it will fail if the seed did not generate valid primes.
200
201 =item "group" (B<OSSL_PKEY_PARAM_FFC_GROUP>) <UTF8 string>
202
203 =item "safeprime-generator" (B<OSSL_PKEY_PARAM_FFC_GENERATOR>) <integer>
204
205 =item "gindex" (B<OSSL_PKEY_PARAM_FFC_GINDEX>) <integer>
206
207 =item "pcounter" (B<OSSL_PKEY_PARAM_FFC_PCOUNTER>) <integer>
208
209 =item "hindex" (B<OSSL_PKEY_PARAM_FFC_H>) <integer>
210
211 These types are described above.
212
213 =back
214
215
216 =head1 CONFORMING TO
217
218 =over 4
219
220 =item RFC 7919 (TLS ffdhe named safe prime groups)
221
222 =item RFC 3526 (IKE modp named safe prime groups)
223
224 =item RFC 5114 (Additional DH named groups for dh_1024_160", "dh_2048_224"
225           and "dh_2048_256").
226
227 =back
228
229 The following sections of SP800-56Ar3:
230
231 =over 4
232
233 =item 5.5.1.1 FFC Domain Parameter Selection/Generation
234
235 =item Appendix D: FFC Safe-prime Groups
236
237 =back
238
239 The following sections of FIPS 186-4:
240
241 =over 4
242
243 =item A.1.1.2 Generation of Probable Primes p and q Using an Approved Hash Function.
244
245 =item A.2.3 Generation of canonical generator g.
246
247 =item A.2.1 Unverifiable Generation of the Generator g.
248
249 =back
250
251 =head1 SEE ALSO
252
253 L<EVP_KEYMGMT(3)>, L<EVP_PKEY(3)>, L<provider-keymgmt(7)>,
254 L<OSSL_PROVIDER-default(7)>, L<OSSL_PROVIDER-FIPS(7)>,
255 L<EVP_SIGNATURE-DSA(7)>, L<EVP_KEYEXCH-DH(7)>
256
257 =head1 COPYRIGHT
258
259 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
260
261 Licensed under the Apache License 2.0 (the "License").  You may not use
262 this file except in compliance with the License.  You can obtain a copy
263 in the file LICENSE in the source distribution or at
264 L<https://www.openssl.org/source/license.html>.
265
266 =cut