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