]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/genpkey.1
OpenSSL: Merge OpenSSL 1.1.1o
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / genpkey.1
1 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "GENPKEY 1"
136 .TH GENPKEY 1 "2022-05-03" "1.1.1o" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 openssl\-genpkey, genpkey \- generate a private key
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 \&\fBopenssl\fR \fBgenpkey\fR
146 [\fB\-help\fR]
147 [\fB\-out filename\fR]
148 [\fB\-outform PEM|DER\fR]
149 [\fB\-pass arg\fR]
150 [\fB\-\f(BIcipher\fB\fR]
151 [\fB\-engine id\fR]
152 [\fB\-paramfile file\fR]
153 [\fB\-algorithm alg\fR]
154 [\fB\-pkeyopt opt:value\fR]
155 [\fB\-genparam\fR]
156 [\fB\-text\fR]
157 .SH "DESCRIPTION"
158 .IX Header "DESCRIPTION"
159 The \fBgenpkey\fR command generates a private key.
160 .SH "OPTIONS"
161 .IX Header "OPTIONS"
162 .IP "\fB\-help\fR" 4
163 .IX Item "-help"
164 Print out a usage message.
165 .IP "\fB\-out filename\fR" 4
166 .IX Item "-out filename"
167 Output the key to the specified file. If this argument is not specified then
168 standard output is used.
169 .IP "\fB\-outform DER|PEM\fR" 4
170 .IX Item "-outform DER|PEM"
171 This specifies the output format \s-1DER\s0 or \s-1PEM.\s0 The default format is \s-1PEM.\s0
172 .IP "\fB\-pass arg\fR" 4
173 .IX Item "-pass arg"
174 The output file password source. For more information about the format of \fBarg\fR
175 see \*(L"Pass Phrase Options\*(R" in \fBopenssl\fR\|(1).
176 .IP "\fB\-\f(BIcipher\fB\fR" 4
177 .IX Item "-cipher"
178 This option encrypts the private key with the supplied cipher. Any algorithm
179 name accepted by \fBEVP_get_cipherbyname()\fR is acceptable such as \fBdes3\fR.
180 .IP "\fB\-engine id\fR" 4
181 .IX Item "-engine id"
182 Specifying an engine (by its unique \fBid\fR string) will cause \fBgenpkey\fR
183 to attempt to obtain a functional reference to the specified engine,
184 thus initialising it if needed. The engine will then be set as the default
185 for all available algorithms. If used this option should precede all other
186 options.
187 .IP "\fB\-algorithm alg\fR" 4
188 .IX Item "-algorithm alg"
189 Public key algorithm to use such as \s-1RSA, DSA\s0 or \s-1DH.\s0 If used this option must
190 precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
191 are mutually exclusive. Engines may add algorithms in addition to the standard
192 built-in ones.
193 .Sp
194 Valid built-in algorithm names for private key generation are \s-1RSA,\s0 RSA-PSS, \s-1EC,
195 X25519, X448, ED25519\s0 and \s-1ED448.\s0
196 .Sp
197 Valid built-in algorithm names for parameter generation (see the \fB\-genparam\fR
198 option) are \s-1DH, DSA\s0 and \s-1EC.\s0
199 .Sp
200 Note that the algorithm name X9.42 \s-1DH\s0 may be used as a synonym for the \s-1DH\s0
201 algorithm. These are identical and do not indicate the type of parameters that
202 will be generated. Use the \fBdh_paramgen_type\fR option to indicate whether PKCS#3
203 or X9.42 \s-1DH\s0 parameters are required. See \*(L"\s-1DH\s0 Parameter Generation Options\*(R"
204 below for more details.
205 .IP "\fB\-pkeyopt opt:value\fR" 4
206 .IX Item "-pkeyopt opt:value"
207 Set the public key algorithm option \fBopt\fR to \fBvalue\fR. The precise set of
208 options supported depends on the public key algorithm used and its
209 implementation. See \*(L"\s-1KEY GENERATION OPTIONS\*(R"\s0 and
210 \&\*(L"\s-1PARAMETER GENERATION OPTIONS\*(R"\s0 below for more details.
211 .IP "\fB\-genparam\fR" 4
212 .IX Item "-genparam"
213 Generate a set of parameters instead of a private key. If used this option must
214 precede any \fB\-algorithm\fR, \fB\-paramfile\fR or \fB\-pkeyopt\fR options.
215 .IP "\fB\-paramfile filename\fR" 4
216 .IX Item "-paramfile filename"
217 Some public key algorithms generate a private key based on a set of parameters.
218 They can be supplied using this option. If this option is used the public key
219 algorithm used is determined by the parameters. If used this option must
220 precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
221 are mutually exclusive.
222 .IP "\fB\-text\fR" 4
223 .IX Item "-text"
224 Print an (unencrypted) text representation of private and public keys and
225 parameters along with the \s-1PEM\s0 or \s-1DER\s0 structure.
226 .SH "KEY GENERATION OPTIONS"
227 .IX Header "KEY GENERATION OPTIONS"
228 The options supported by each algorithm and indeed each implementation of an
229 algorithm can vary. The options for the OpenSSL implementations are detailed
230 below. There are no key generation options defined for the X25519, X448, \s-1ED25519\s0
231 or \s-1ED448\s0 algorithms.
232 .SS "\s-1RSA\s0 Key Generation Options"
233 .IX Subsection "RSA Key Generation Options"
234 .IP "\fBrsa_keygen_bits:numbits\fR" 4
235 .IX Item "rsa_keygen_bits:numbits"
236 The number of bits in the generated key. If not specified 2048 is used.
237 .IP "\fBrsa_keygen_primes:numprimes\fR" 4
238 .IX Item "rsa_keygen_primes:numprimes"
239 The number of primes in the generated key. If not specified 2 is used.
240 .IP "\fBrsa_keygen_pubexp:value\fR" 4
241 .IX Item "rsa_keygen_pubexp:value"
242 The \s-1RSA\s0 public exponent value. This can be a large decimal or
243 hexadecimal value if preceded by \fB0x\fR. Default value is 65537.
244 .SS "RSA-PSS Key Generation Options"
245 .IX Subsection "RSA-PSS Key Generation Options"
246 Note: by default an \fBRSA-PSS\fR key has no parameter restrictions.
247 .IP "\fBrsa_keygen_bits:numbits\fR, \fBrsa_keygen_primes:numprimes\fR,  \fBrsa_keygen_pubexp:value\fR" 4
248 .IX Item "rsa_keygen_bits:numbits, rsa_keygen_primes:numprimes, rsa_keygen_pubexp:value"
249 These options have the same meaning as the \fB\s-1RSA\s0\fR algorithm.
250 .IP "\fBrsa_pss_keygen_md:digest\fR" 4
251 .IX Item "rsa_pss_keygen_md:digest"
252 If set the key is restricted and can only use \fBdigest\fR for signing.
253 .IP "\fBrsa_pss_keygen_mgf1_md:digest\fR" 4
254 .IX Item "rsa_pss_keygen_mgf1_md:digest"
255 If set the key is restricted and can only use \fBdigest\fR as it's \s-1MGF1\s0
256 parameter.
257 .IP "\fBrsa_pss_keygen_saltlen:len\fR" 4
258 .IX Item "rsa_pss_keygen_saltlen:len"
259 If set the key is restricted and \fBlen\fR specifies the minimum salt length.
260 .SS "\s-1EC\s0 Key Generation Options"
261 .IX Subsection "EC Key Generation Options"
262 The \s-1EC\s0 key generation options can also be used for parameter generation.
263 .IP "\fBec_paramgen_curve:curve\fR" 4
264 .IX Item "ec_paramgen_curve:curve"
265 The \s-1EC\s0 curve to use. OpenSSL supports \s-1NIST\s0 curve names such as \*(L"P\-256\*(R".
266 .IP "\fBec_param_enc:encoding\fR" 4
267 .IX Item "ec_param_enc:encoding"
268 The encoding to use for parameters. The \*(L"encoding\*(R" parameter must be either
269 \&\*(L"named_curve\*(R" or \*(L"explicit\*(R". The default value is \*(L"named_curve\*(R".
270 .SH "PARAMETER GENERATION OPTIONS"
271 .IX Header "PARAMETER GENERATION OPTIONS"
272 The options supported by each algorithm and indeed each implementation of an
273 algorithm can vary. The options for the OpenSSL implementations are detailed
274 below.
275 .SS "\s-1DSA\s0 Parameter Generation Options"
276 .IX Subsection "DSA Parameter Generation Options"
277 .IP "\fBdsa_paramgen_bits:numbits\fR" 4
278 .IX Item "dsa_paramgen_bits:numbits"
279 The number of bits in the generated prime. If not specified 2048 is used.
280 .IP "\fBdsa_paramgen_q_bits:numbits\fR" 4
281 .IX Item "dsa_paramgen_q_bits:numbits"
282 The number of bits in the q parameter. Must be one of 160, 224 or 256. If not
283 specified 224 is used.
284 .IP "\fBdsa_paramgen_md:digest\fR" 4
285 .IX Item "dsa_paramgen_md:digest"
286 The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR
287 or \fBsha256\fR. If set, then the number of bits in \fBq\fR will match the output size
288 of the specified digest and the \fBdsa_paramgen_q_bits\fR parameter will be
289 ignored. If not set, then a digest will be used that gives an output matching
290 the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it 224
291 or \fBsha256\fR if it is 256.
292 .SS "\s-1DH\s0 Parameter Generation Options"
293 .IX Subsection "DH Parameter Generation Options"
294 .IP "\fBdh_paramgen_prime_len:numbits\fR" 4
295 .IX Item "dh_paramgen_prime_len:numbits"
296 The number of bits in the prime parameter \fBp\fR. The default is 2048.
297 .IP "\fBdh_paramgen_subprime_len:numbits\fR" 4
298 .IX Item "dh_paramgen_subprime_len:numbits"
299 The number of bits in the sub prime parameter \fBq\fR. The default is 256 if the
300 prime is at least 2048 bits long or 160 otherwise. Only relevant if used in
301 conjunction with the \fBdh_paramgen_type\fR option to generate X9.42 \s-1DH\s0 parameters.
302 .IP "\fBdh_paramgen_generator:value\fR" 4
303 .IX Item "dh_paramgen_generator:value"
304 The value to use for the generator \fBg\fR. The default is 2.
305 .IP "\fBdh_paramgen_type:value\fR" 4
306 .IX Item "dh_paramgen_type:value"
307 The type of \s-1DH\s0 parameters to generate. Use 0 for PKCS#3 \s-1DH\s0 and 1 for X9.42 \s-1DH.\s0
308 The default is 0.
309 .IP "\fBdh_rfc5114:num\fR" 4
310 .IX Item "dh_rfc5114:num"
311 If this option is set, then the appropriate \s-1RFC5114\s0 parameters are used
312 instead of generating new parameters. The value \fBnum\fR can take the
313 values 1, 2 or 3 corresponding to \s-1RFC5114 DH\s0 parameters consisting of
314 1024 bit group with 160 bit subgroup, 2048 bit group with 224 bit subgroup
315 and 2048 bit group with 256 bit subgroup as mentioned in \s-1RFC5114\s0 sections
316 2.1, 2.2 and 2.3 respectively. If present this overrides all other \s-1DH\s0 parameter
317 options.
318 .SS "\s-1EC\s0 Parameter Generation Options"
319 .IX Subsection "EC Parameter Generation Options"
320 The \s-1EC\s0 parameter generation options are the same as for key generation. See
321 \&\*(L"\s-1EC\s0 Key Generation Options\*(R" above.
322 .SH "NOTES"
323 .IX Header "NOTES"
324 The use of the genpkey program is encouraged over the algorithm specific
325 utilities because additional algorithm options and \s-1ENGINE\s0 provided algorithms
326 can be used.
327 .SH "EXAMPLES"
328 .IX Header "EXAMPLES"
329 Generate an \s-1RSA\s0 private key using default parameters:
330 .PP
331 .Vb 1
332 \& openssl genpkey \-algorithm RSA \-out key.pem
333 .Ve
334 .PP
335 Encrypt output private key using 128 bit \s-1AES\s0 and the passphrase \*(L"hello\*(R":
336 .PP
337 .Vb 1
338 \& openssl genpkey \-algorithm RSA \-out key.pem \-aes\-128\-cbc \-pass pass:hello
339 .Ve
340 .PP
341 Generate a 2048 bit \s-1RSA\s0 key using 3 as the public exponent:
342 .PP
343 .Vb 2
344 \& openssl genpkey \-algorithm RSA \-out key.pem \e
345 \&     \-pkeyopt rsa_keygen_bits:2048 \-pkeyopt rsa_keygen_pubexp:3
346 .Ve
347 .PP
348 Generate 2048 bit \s-1DSA\s0 parameters:
349 .PP
350 .Vb 2
351 \& openssl genpkey \-genparam \-algorithm DSA \-out dsap.pem \e
352 \&     \-pkeyopt dsa_paramgen_bits:2048
353 .Ve
354 .PP
355 Generate \s-1DSA\s0 key from parameters:
356 .PP
357 .Vb 1
358 \& openssl genpkey \-paramfile dsap.pem \-out dsakey.pem
359 .Ve
360 .PP
361 Generate 2048 bit \s-1DH\s0 parameters:
362 .PP
363 .Vb 2
364 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \e
365 \&     \-pkeyopt dh_paramgen_prime_len:2048
366 .Ve
367 .PP
368 Generate 2048 bit X9.42 \s-1DH\s0 parameters:
369 .PP
370 .Vb 3
371 \& openssl genpkey \-genparam \-algorithm DH \-out dhpx.pem \e
372 \&     \-pkeyopt dh_paramgen_prime_len:2048 \e
373 \&     \-pkeyopt dh_paramgen_type:1
374 .Ve
375 .PP
376 Output \s-1RFC5114 2048\s0 bit \s-1DH\s0 parameters with 224 bit subgroup:
377 .PP
378 .Vb 1
379 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \-pkeyopt dh_rfc5114:2
380 .Ve
381 .PP
382 Generate \s-1DH\s0 key from parameters:
383 .PP
384 .Vb 1
385 \& openssl genpkey \-paramfile dhp.pem \-out dhkey.pem
386 .Ve
387 .PP
388 Generate \s-1EC\s0 parameters:
389 .PP
390 .Vb 3
391 \& openssl genpkey \-genparam \-algorithm EC \-out ecp.pem \e
392 \&        \-pkeyopt ec_paramgen_curve:secp384r1 \e
393 \&        \-pkeyopt ec_param_enc:named_curve
394 .Ve
395 .PP
396 Generate \s-1EC\s0 key from parameters:
397 .PP
398 .Vb 1
399 \& openssl genpkey \-paramfile ecp.pem \-out eckey.pem
400 .Ve
401 .PP
402 Generate \s-1EC\s0 key directly:
403 .PP
404 .Vb 3
405 \& openssl genpkey \-algorithm EC \-out eckey.pem \e
406 \&        \-pkeyopt ec_paramgen_curve:P\-384 \e
407 \&        \-pkeyopt ec_param_enc:named_curve
408 .Ve
409 .PP
410 Generate an X25519 private key:
411 .PP
412 .Vb 1
413 \& openssl genpkey \-algorithm X25519 \-out xkey.pem
414 .Ve
415 .PP
416 Generate an \s-1ED448\s0 private key:
417 .PP
418 .Vb 1
419 \& openssl genpkey \-algorithm ED448 \-out xkey.pem
420 .Ve
421 .SH "HISTORY"
422 .IX Header "HISTORY"
423 The ability to use \s-1NIST\s0 curve names, and to generate an \s-1EC\s0 key directly,
424 were added in OpenSSL 1.0.2.
425 The ability to generate X25519 keys was added in OpenSSL 1.1.0.
426 The ability to generate X448, \s-1ED25519\s0 and \s-1ED448\s0 keys was added in OpenSSL 1.1.1.
427 .SH "COPYRIGHT"
428 .IX Header "COPYRIGHT"
429 Copyright 2006\-2021 The OpenSSL Project Authors. All Rights Reserved.
430 .PP
431 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
432 this file except in compliance with the License.  You can obtain a copy
433 in the file \s-1LICENSE\s0 in the source distribution or at
434 <https://www.openssl.org/source/license.html>.