Debian Codegraph @

upstream/debian-trixie/man1/openssl-genpkey.1ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "OPENSSL-GENPKEY 1SSL"
58 .TH OPENSSL-GENPKEY 1SSL 2026-04-07 3.5.6 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 openssl\-genpkey \- generate a private key or key pair
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 \&\fBopenssl\fR \fBgenpkey\fR
68 [\fB\-help\fR]
69 [\fB\-out\fR \fIfilename\fR]
70 [\fB\-outpubkey\fR \fIfilename\fR]
71 [\fB\-outform\fR \fBDER\fR|\fBPEM\fR]
72 [\fB\-verbose\fR]
73 [\fB\-quiet\fR]
74 [\fB\-pass\fR \fIarg\fR]
75 [\fB\-\fR\f(BIcipher\fR]
76 [\fB\-paramfile\fR \fIfile\fR]
77 [\fB\-algorithm\fR \fIalg\fR]
78 [\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR]
79 [\fB\-genparam\fR]
80 [\fB\-text\fR]
81 [\fB\-rand\fR \fIfiles\fR]
82 [\fB\-writerand\fR \fIfile\fR]
83 [\fB\-engine\fR \fIid\fR]
84 .PP
85 [\fB\-provider\fR \fIname\fR]
86 [\fB\-provider\-path\fR \fIpath\fR]
87 [\fB\-provparam\fR \fI[name:]key=value\fR]
88 [\fB\-propquery\fR \fIpropq\fR]
89 [\fB\-config\fR \fIconfigfile\fR]
90 .SH DESCRIPTION
91 .IX Header "DESCRIPTION"
92 This command generates a private key or key pair.
93 .SH OPTIONS
94 .IX Header "OPTIONS"
95 .IP \fB\-help\fR 4
96 .IX Item "-help"
97 Print out a usage message.
98 .IP "\fB\-out\fR \fIfilename\fR" 4
99 .IX Item "-out filename"
100 Output the private key to the specified file. If this argument is not
101 specified then standard output is used.
102 .IP "\fB\-outpubkey\fR \fIfilename\fR" 4
103 .IX Item "-outpubkey filename"
104 Output the public key to the specified file. If this argument is not
105 specified then the public key is not output.
106 .IP "\fB\-outform\fR \fBDER\fR|\fBPEM\fR" 4
107 .IX Item "-outform DER|PEM"
108 The output format, except when \fB\-genparam\fR is given; the default is \fBPEM\fR.
109 See \fBopenssl\-format\-options\fR\|(1) for details.
110 .Sp
111 When \fB\-genparam\fR is given, \fB\-outform\fR is ignored.
112 .IP \fB\-verbose\fR 4
113 .IX Item "-verbose"
114 Output "status dots" while generating keys.
115 .IP \fB\-quiet\fR 4
116 .IX Item "-quiet"
117 Do not output "status dots" while generating keys.
118 .IP "\fB\-pass\fR \fIarg\fR" 4
119 .IX Item "-pass arg"
120 The output file password source. For more information about the format of \fIarg\fR
121 see \fBopenssl\-passphrase\-options\fR\|(1).
122 .IP \fB\-\fR\f(BIcipher\fR 4
123 .IX Item "-cipher"
124 This option encrypts the private key with the supplied cipher. Any algorithm
125 name accepted by \fBEVP_get_cipherbyname()\fR is acceptable such as \fBdes3\fR.
126 .IP "\fB\-algorithm\fR \fIalg\fR" 4
127 .IX Item "-algorithm alg"
128 Public key algorithm to use such as RSA, DSA, DH or DHX. If used this option must
129 precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
130 are mutually exclusive. Engines or providers may add algorithms in addition to
131 the standard built-in ones.
132 .Sp
133 Valid built-in algorithm names for private key generation are RSA, RSA-PSS, EC,
134 X25519, X448, ED25519, ED448, ML-DSA and ML-KEM.
135 .Sp
136 Valid built-in algorithm names for parameter generation (see the \fB\-genparam\fR
137 option) are DH, DSA and EC.
138 .Sp
139 Note that the algorithm name X9.42 DH may be used as a synonym for DHX keys and
140 PKCS#3 refers to DH Keys. Some options are not shared between DH and DHX keys.
141 .IP "\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR" 4
142 .IX Item "-pkeyopt opt:value"
143 Set the public key algorithm option \fIopt\fR to \fIvalue\fR. The precise set of
144 options supported depends on the public key algorithm used and its
145 implementation. See "KEY GENERATION OPTIONS" and
146 "PARAMETER GENERATION OPTIONS" below for more details.
147 .Sp
148 To list the possible \fIopt\fR values for an algorithm use:
149 \&\fBopenssl\fR \fBgenpkey\fR \-algorithm XXX \-help
150 .IP \fB\-genparam\fR 4
151 .IX Item "-genparam"
152 Generate a set of parameters instead of a private key. If used this option must
153 precede any \fB\-algorithm\fR, \fB\-paramfile\fR or \fB\-pkeyopt\fR options.
154 .IP "\fB\-paramfile\fR \fIfilename\fR" 4
155 .IX Item "-paramfile filename"
156 Some public key algorithms generate a private key based on a set of parameters.
157 They can be supplied using this option. If this option is used the public key
158 algorithm used is determined by the parameters. If used this option must
159 precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
160 are mutually exclusive.
161 .IP \fB\-text\fR 4
162 .IX Item "-text"
163 Print an (unencrypted) text representation of private and public keys and
164 parameters along with the PEM or DER structure.
165 .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
166 .IX Item "-rand files, -writerand file"
167 See "Random State Options" in \fBopenssl\fR\|(1) for details.
168 .IP "\fB\-engine\fR \fIid\fR" 4
169 .IX Item "-engine id"
170 See "Engine Options" in \fBopenssl\fR\|(1).
171 This option is deprecated.
172 .IP "\fB\-provider\fR \fIname\fR" 4
173 .IX Item "-provider name"
174 .PD 0
175 .IP "\fB\-provider\-path\fR \fIpath\fR" 4
176 .IX Item "-provider-path path"
177 .IP "\fB\-provparam\fR \fI[name:]key=value\fR" 4
178 .IX Item "-provparam [name:]key=value"
179 .IP "\fB\-propquery\fR \fIpropq\fR" 4
180 .IX Item "-propquery propq"
181 .PD
182 See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
183 .IP "\fB\-config\fR \fIconfigfile\fR" 4
184 .IX Item "-config configfile"
185 See "Configuration Option" in \fBopenssl\fR\|(1).
186 .SH "KEY GENERATION OPTIONS"
187 .IX Header "KEY GENERATION OPTIONS"
188 The options supported by each algorithm and indeed each implementation of an
189 algorithm can vary. The options for the OpenSSL implementations are detailed
190 below. There are no key generation options defined for the X25519, X448, ED25519
191 or ED448 algorithms.
192 .SS "RSA Key Generation Options"
193 .IX Subsection "RSA Key Generation Options"
194 .IP \fBrsa_keygen_bits:numbits\fR 4
195 .IX Item "rsa_keygen_bits:numbits"
196 The number of bits in the generated key. If not specified 2048 is used.
197 .IP \fBrsa_keygen_primes:numprimes\fR 4
198 .IX Item "rsa_keygen_primes:numprimes"
199 The number of primes in the generated key. If not specified 2 is used.
200 .IP \fBrsa_keygen_pubexp:value\fR 4
201 .IX Item "rsa_keygen_pubexp:value"
202 The RSA public exponent value. This can be a large decimal or
203 hexadecimal value if preceded by \f(CW\*(C`0x\*(C'\fR. Default value is 65537.
204 .SS "RSA-PSS Key Generation Options"
205 .IX Subsection "RSA-PSS Key Generation Options"
206 Note: by default an \fBRSA-PSS\fR key has no parameter restrictions.
207 .IP "\fBrsa_keygen_bits\fR:\fInumbits\fR, \fBrsa_keygen_primes\fR:\fInumprimes\fR, \fBrsa_keygen_pubexp\fR:\fIvalue\fR" 4
208 .IX Item "rsa_keygen_bits:numbits, rsa_keygen_primes:numprimes, rsa_keygen_pubexp:value"
209 These options have the same meaning as the \fBRSA\fR algorithm.
210 .IP \fBrsa_pss_keygen_md\fR:\fIdigest\fR 4
211 .IX Item "rsa_pss_keygen_md:digest"
212 If set the key is restricted and can only use \fIdigest\fR for signing.
213 .IP \fBrsa_pss_keygen_mgf1_md\fR:\fIdigest\fR 4
214 .IX Item "rsa_pss_keygen_mgf1_md:digest"
215 If set the key is restricted and can only use \fIdigest\fR as it's MGF1
216 parameter.
217 .IP \fBrsa_pss_keygen_saltlen\fR:\fIlen\fR 4
218 .IX Item "rsa_pss_keygen_saltlen:len"
219 If set the key is restricted and \fIlen\fR specifies the minimum salt length.
220 .SS "EC Key Generation Options"
221 .IX Subsection "EC Key Generation Options"
222 The EC key generation options can also be used for parameter generation.
223 .IP \fBec_paramgen_curve\fR:\fIcurve\fR 4
224 .IX Item "ec_paramgen_curve:curve"
225 The EC curve to use. OpenSSL supports NIST curve names such as "P\-256".
226 .IP \fBec_param_enc\fR:\fIencoding\fR 4
227 .IX Item "ec_param_enc:encoding"
228 The encoding to use for parameters. The \fIencoding\fR parameter must be either
229 \&\fBnamed_curve\fR or \fBexplicit\fR. The default value is \fBnamed_curve\fR.
230 .SS "ML-DSA Key Generation Options"
231 .IX Subsection "ML-DSA Key Generation Options"
232 .IP \fBhexseed\fR:\fIseed\fR 4
233 .IX Item "hexseed:seed"
234 This specifies the optional ML-DSA \fIseed\fR in hexadecimal form. The seed is 32
235 bytes, giving 64 hexadecimal digits.
236 When generated from an explicit seed the key is completely determined by the
237 seed value.
238 If other users can see the command-line arguments of the running process, this
239 option may compromise the secret key, it is best avoided, tests-aside.
240 .Sp
241 See \fBEVP_PKEY\-ML\-DSA\fR\|(7) for more detail.
242 .SS "ML-KEM Key Generation Options"
243 .IX Subsection "ML-KEM Key Generation Options"
244 .IP \fBhexseed\fR:\fIseed\fR 4
245 .IX Item "hexseed:seed"
246 This specifies the optional ML-KEM \fIseed\fR in hexadecimal form. The seed is 64
247 bytes, giving 128 hexadecimal digits.
248 When generated from an explicit seed the key is completely determined by the
249 seed value.
250 If other users can see the command-line arguments of the running process, this
251 option may compromise the secret key, it is best avoided, tests-aside.
252 .Sp
253 See \fBEVP_PKEY\-ML\-KEM\fR\|(7) for more detail.
254 .SS "DH Key Generation Options"
255 .IX Subsection "DH Key Generation Options"
256 .IP \fBgroup\fR:\fIname\fR 4
257 .IX Item "group:name"
258 The \fBparamfile\fR option is not required if a named group is used here.
259 See the "DH Parameter Generation Options" section below.
260 .SH "PARAMETER GENERATION OPTIONS"
261 .IX Header "PARAMETER GENERATION OPTIONS"
262 The options supported by each algorithm and indeed each implementation of an
263 algorithm can vary. The options for the OpenSSL implementations are detailed
264 below.
265 .SS "DSA Parameter Generation Options"
266 .IX Subsection "DSA Parameter Generation Options"
267 .IP \fBdsa_paramgen_bits\fR:\fInumbits\fR 4
268 .IX Item "dsa_paramgen_bits:numbits"
269 The number of bits in the generated prime. If not specified 2048 is used.
270 .IP \fBdsa_paramgen_q_bits\fR:\fInumbits\fR 4
271 .IX Item "dsa_paramgen_q_bits:numbits"
272 .PD 0
273 .IP \fBqbits\fR:\fInumbits\fR 4
274 .IX Item "qbits:numbits"
275 .PD
276 The number of bits in the q parameter. Must be one of 160, 224 or 256. If not
277 specified 224 is used.
278 .IP \fBdsa_paramgen_md\fR:\fIdigest\fR 4
279 .IX Item "dsa_paramgen_md:digest"
280 .PD 0
281 .IP \fBdigest\fR:\fIdigest\fR 4
282 .IX Item "digest:digest"
283 .PD
284 The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR
285 or \fBsha256\fR. If set, then the number of bits in \fBq\fR will match the output size
286 of the specified digest and the \fBdsa_paramgen_q_bits\fR parameter will be
287 ignored. If not set, then a digest will be used that gives an output matching
288 the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it 224
289 or \fBsha256\fR if it is 256.
290 .IP \fBproperties\fR:\fIquery\fR 4
291 .IX Item "properties:query"
292 The \fIdigest\fR property \fIquery\fR string to use when fetching a digest from a provider.
293 .IP \fBtype\fR:\fItype\fR 4
294 .IX Item "type:type"
295 The type of generation to use. Set this to 1 to use legacy FIPS186\-2 parameter
296 generation. The default of 0 uses FIPS186\-4 parameter generation.
297 .IP \fBgindex\fR:\fIindex\fR 4
298 .IX Item "gindex:index"
299 The index to use for canonical generation and verification of the generator g.
300 Set this to a positive value ranging from 0..255 to use this mode. Larger values
301 will only use the bottom byte.
302 This \fIindex\fR must then be reused during key validation to verify the value of g.
303 If this value is not set then g is not verifiable. The default value is \-1.
304 .IP \fBhexseed\fR:\fIseed\fR 4
305 .IX Item "hexseed:seed"
306 The seed \fIseed\fR data to use instead of generating a random seed internally.
307 This should be used for testing purposes only. This will either produced fixed
308 values for the generated parameters OR it will fail if the seed did not
309 generate valid primes.
310 .SS "DH Parameter Generation Options"
311 .IX Subsection "DH Parameter Generation Options"
312 For most use cases it is recommended to use the \fBgroup\fR option rather than
313 the \fBtype\fR options. Note that the \fBgroup\fR option is not used by default if
314 no parameter generation options are specified.
315 .IP \fBgroup\fR:\fIname\fR 4
316 .IX Item "group:name"
317 .PD 0
318 .IP \fBdh_param\fR:\fIname\fR 4
319 .IX Item "dh_param:name"
320 .PD
321 Use a named DH group to select constant values for the DH parameters.
322 All other options will be ignored if this value is set.
323 .Sp
324 Valid values that are associated with the \fBalgorithm\fR of \fB"DH"\fR are:
325 "ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144", "ffdhe8192",
326 "modp_1536", "modp_2048", "modp_3072", "modp_4096", "modp_6144", "modp_8192".
327 .Sp
328 Valid values that are associated with the \fBalgorithm\fR of \fB"DHX"\fR are the
329 RFC5114 names "dh_1024_160", "dh_2048_224", "dh_2048_256".
330 .IP \fBdh_rfc5114\fR:\fInum\fR 4
331 .IX Item "dh_rfc5114:num"
332 If this option is set, then the appropriate RFC5114 parameters are used
333 instead of generating new parameters. The value \fInum\fR can be one of
334 1, 2 or 3 that are equivalent to using the option \fBgroup\fR with one of
335 "dh_1024_160", "dh_2048_224" or "dh_2048_256".
336 All other options will be ignored if this value is set.
337 .IP \fBpbits\fR:\fInumbits\fR 4
338 .IX Item "pbits:numbits"
339 .PD 0
340 .IP \fBdh_paramgen_prime_len\fR:\fInumbits\fR 4
341 .IX Item "dh_paramgen_prime_len:numbits"
342 .PD
343 The number of bits in the prime parameter \fIp\fR. The default is 2048.
344 .IP \fBqbits\fR:\fInumbits\fR 4
345 .IX Item "qbits:numbits"
346 .PD 0
347 .IP \fBdh_paramgen_subprime_len\fR:\fInumbits\fR 4
348 .IX Item "dh_paramgen_subprime_len:numbits"
349 .PD
350 The number of bits in the sub prime parameter \fIq\fR. The default is 224.
351 Only relevant if used in conjunction with the \fBdh_paramgen_type\fR option to
352 generate DHX parameters.
353 .IP \fBsafeprime-generator\fR:\fIvalue\fR 4
354 .IX Item "safeprime-generator:value"
355 .PD 0
356 .IP \fBdh_paramgen_generator\fR:\fIvalue\fR 4
357 .IX Item "dh_paramgen_generator:value"
358 .PD
359 The value to use for the generator \fIg\fR. The default is 2.
360 The \fBalgorithm\fR option must be \fB"DH"\fR for this parameter to be used.
361 .IP \fBtype\fR:\fIstring\fR 4
362 .IX Item "type:string"
363 The type name of DH parameters to generate. Valid values are:
364 .RS 4
365 .IP """generator""" 4
366 .IX Item """generator"""
367 Use a safe prime generator with the option \fBsafeprime_generator\fR
368 The \fBalgorithm\fR option must be \fB"DH"\fR.
369 .IP """fips186_4""" 4
370 .IX Item """fips186_4"""
371 FIPS186\-4 parameter generation.
372 The \fBalgorithm\fR option must be \fB"DHX"\fR.
373 .IP """fips186_2""" 4
374 .IX Item """fips186_2"""
375 FIPS186\-4 parameter generation.
376 The \fBalgorithm\fR option must be \fB"DHX"\fR.
377 .IP """group""" 4
378 .IX Item """group"""
379 Can be used with the option \fBpbits\fR to select one of
380 "ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144" or "ffdhe8192".
381 The \fBalgorithm\fR option must be \fB"DH"\fR.
382 .IP """default""" 4
383 .IX Item """default"""
384 Selects a default type based on the \fBalgorithm\fR. This is used by the
385 OpenSSL default provider to set the type for backwards compatibility.
386 If \fBalgorithm\fR is \fB"DH"\fR then \fB"generator"\fR is used.
387 If \fBalgorithm\fR is \fB"DHX"\fR then \fB"fips186_2"\fR is used.
388 .RE
389 .RS 4
390 .RE
391 .IP \fBdh_paramgen_type\fR:\fIvalue\fR 4
392 .IX Item "dh_paramgen_type:value"
393 The type of DH parameters to generate. Valid values are 0, 1, 2 or 3
394 which correspond to setting the option \fBtype\fR to
395 "generator", "fips186_2", "fips186_4" or "group".
396 .IP \fBdigest\fR:\fIdigest\fR 4
397 .IX Item "digest:digest"
398 The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR
399 or \fBsha256\fR. If set, then the number of bits in \fBqbits\fR will match the output
400 size of the specified digest and the \fBqbits\fR parameter will be
401 ignored. If not set, then a digest will be used that gives an output matching
402 the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it is
403 224 or \fBsha256\fR if it is 256.
404 This is only used by "fips186_4" and "fips186_2" key generation.
405 .IP \fBproperties\fR:\fIquery\fR 4
406 .IX Item "properties:query"
407 The \fIdigest\fR property \fIquery\fR string to use when fetching a digest from a provider.
408 This is only used by "fips186_4" and "fips186_2" key generation.
409 .IP \fBgindex\fR:\fIindex\fR 4
410 .IX Item "gindex:index"
411 The index to use for canonical generation and verification of the generator g.
412 Set this to a positive value ranging from 0..255 to use this mode. Larger values
413 will only use the bottom byte.
414 This \fIindex\fR must then be reused during key validation to verify the value of g.
415 If this value is not set then g is not verifiable. The default value is \-1.
416 This is only used by "fips186_4" and "fips186_2" key generation.
417 .IP \fBhexseed\fR:\fIseed\fR 4
418 .IX Item "hexseed:seed"
419 The seed \fIseed\fR data to use instead of generating a random seed internally.
420 This should be used for testing purposes only. This will either produced fixed
421 values for the generated parameters OR it will fail if the seed did not
422 generate valid primes.
423 This is only used by "fips186_4" and "fips186_2" key generation.
424 .SS "EC Parameter Generation Options"
425 .IX Subsection "EC Parameter Generation Options"
426 The EC parameter generation options are the same as for key generation. See
427 "EC Key Generation Options" above.
428 .SH NOTES
429 .IX Header "NOTES"
430 The use of the genpkey program is encouraged over the algorithm specific
431 utilities because additional algorithm options and ENGINE provided algorithms
432 can be used.
433 .SH EXAMPLES
434 .IX Header "EXAMPLES"
435 Generate an RSA private key using default parameters:
436 .PP
437 .Vb 1
438 \& openssl genpkey \-algorithm RSA \-out key.pem
439 .Ve
440 .PP
441 Encrypt output private key using 128 bit AES and the passphrase "hello":
442 .PP
443 .Vb 1
444 \& openssl genpkey \-algorithm RSA \-out key.pem \-aes\-128\-cbc \-pass pass:hello
445 .Ve
446 .PP
447 Generate a 2048 bit RSA key using 3 as the public exponent:
448 .PP
449 .Vb 2
450 \& openssl genpkey \-algorithm RSA \-out key.pem \e
451 \& \-pkeyopt rsa_keygen_bits:2048 \-pkeyopt rsa_keygen_pubexp:3
452 .Ve
453 .PP
454 Generate 2048 bit DSA parameters that can be validated: The output values for
455 gindex and seed are required for key validation purposes and are not saved to
456 the output pem file).
457 .PP
458 .Vb 2
459 \& openssl genpkey \-genparam \-algorithm DSA \-out dsap.pem \-pkeyopt pbits:2048 \e
460 \& \-pkeyopt qbits:224 \-pkeyopt digest:SHA256 \-pkeyopt gindex:1 \-text
461 .Ve
462 .PP
463 Generate DSA key from parameters:
464 .PP
465 .Vb 1
466 \& openssl genpkey \-paramfile dsap.pem \-out dsakey.pem
467 .Ve
468 .PP
469 Generate 4096 bit DH Key using safe prime group ffdhe4096:
470 .PP
471 .Vb 1
472 \& openssl genpkey \-algorithm DH \-out dhkey.pem \-pkeyopt group:ffdhe4096
473 .Ve
474 .PP
475 Generate 2048 bit X9.42 DH key with 256 bit subgroup using RFC5114 group3:
476 .PP
477 .Vb 1
478 \& openssl genpkey \-algorithm DHX \-out dhkey.pem \-pkeyopt dh_rfc5114:3
479 .Ve
480 .PP
481 Generate a DH key using a DH parameters file:
482 .PP
483 .Vb 1
484 \& openssl genpkey \-paramfile dhp.pem \-out dhkey.pem
485 .Ve
486 .PP
487 Output DH parameters for safe prime group ffdhe2048:
488 .PP
489 .Vb 1
490 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \-pkeyopt group:ffdhe2048
491 .Ve
492 .PP
493 Output 2048 bit X9.42 DH parameters with 224 bit subgroup using RFC5114 group2:
494 .PP
495 .Vb 1
496 \& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-pkeyopt dh_rfc5114:2
497 .Ve
498 .PP
499 Output 2048 bit X9.42 DH parameters with 224 bit subgroup using FIP186\-4 keygen:
500 .PP
501 .Vb 3
502 \& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-text \e
503 \& \-pkeyopt pbits:2048 \-pkeyopt qbits:224 \-pkeyopt digest:SHA256 \e
504 \& \-pkeyopt gindex:1 \-pkeyopt dh_paramgen_type:2
505 .Ve
506 .PP
507 Output 1024 bit X9.42 DH parameters with 160 bit subgroup using FIP186\-2 keygen:
508 .PP
509 .Vb 3
510 \& openssl genpkey \-genparam \-algorithm DHX \-out dhp.pem \-text \e
511 \& \-pkeyopt pbits:1024 \-pkeyopt qbits:160 \-pkeyopt digest:SHA1 \e
512 \& \-pkeyopt gindex:1 \-pkeyopt dh_paramgen_type:1
513 .Ve
514 .PP
515 Output 2048 bit DH parameters:
516 .PP
517 .Vb 2
518 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \e
519 \& \-pkeyopt dh_paramgen_prime_len:2048
520 .Ve
521 .PP
522 Output 2048 bit DH parameters using a generator:
523 .PP
524 .Vb 3
525 \& openssl genpkey \-genparam \-algorithm DH \-out dhpx.pem \e
526 \& \-pkeyopt dh_paramgen_prime_len:2048 \e
527 \& \-pkeyopt dh_paramgen_type:1
528 .Ve
529 .PP
530 Generate EC parameters:
531 .PP
532 .Vb 3
533 \& openssl genpkey \-genparam \-algorithm EC \-out ecp.pem \e
534 \& \-pkeyopt ec_paramgen_curve:secp384r1 \e
535 \& \-pkeyopt ec_param_enc:named_curve
536 .Ve
537 .PP
538 Generate EC key from parameters:
539 .PP
540 .Vb 1
541 \& openssl genpkey \-paramfile ecp.pem \-out eckey.pem
542 .Ve
543 .PP
544 Generate EC key directly:
545 .PP
546 .Vb 3
547 \& openssl genpkey \-algorithm EC \-out eckey.pem \e
548 \& \-pkeyopt ec_paramgen_curve:P\-384 \e
549 \& \-pkeyopt ec_param_enc:named_curve
550 .Ve
551 .PP
552 Generate an X25519 private key:
553 .PP
554 .Vb 1
555 \& openssl genpkey \-algorithm X25519 \-out xkey.pem
556 .Ve
557 .PP
558 Generate an ED448 private key:
559 .PP
560 .Vb 1
561 \& openssl genpkey \-algorithm ED448 \-out xkey.pem
562 .Ve
563 .PP
564 Generate an ML\-DSA\-65 private key:
565 .PP
566 .Vb 1
567 \& openssl genpkey \-algorithm ML\-DSA\-65 \-out ml\-dsa\-key.pem
568 .Ve
569 .PP
570 Generate an ML\-KEM\-768 private key:
571 .PP
572 .Vb 1
573 \& openssl genpkey \-algorithm ML\-KEM\-768 \-out ml\-kem\-key.pem
574 .Ve
575 .SH HISTORY
576 .IX Header "HISTORY"
577 The ability to use NIST curve names, and to generate an EC key directly,
578 were added in OpenSSL 1.0.2.
579 The ability to generate X25519 keys was added in OpenSSL 1.1.0.
580 The ability to generate X448, ED25519 and ED448 keys was added in OpenSSL 1.1.1.
581 .PP
582 The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
583 .PP
584 Support for \fBML-DSA\fR and \fBML-KEM\fR was added in OpenSSL 3.5.
585 .SH COPYRIGHT
586 .IX Header "COPYRIGHT"
587 Copyright 2006\-2025 The OpenSSL Project Authors. All Rights Reserved.
588 .PP
589 Licensed under the Apache License 2.0 (the "License"). You may not use
590 this file except in compliance with the License. You can obtain a copy
591 in the file LICENSE in the source distribution or at
592 <https://www.openssl.org/source/license.html>.