]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/genpkey.1
Merge OpenSSL 1.0.2s.
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / genpkey.1
1 .\" Automatically generated by Pod::Man 4.10 (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 .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 "2019-05-28" "1.0.2s" "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,
143 genpkey \- generate a private key
144 .SH "SYNOPSIS"
145 .IX Header "SYNOPSIS"
146 \&\fBopenssl\fR \fBgenpkey\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\-out filename\fR" 4
163 .IX Item "-out filename"
164 the output filename. If this argument is not specified then standard output is
165 used.
166 .IP "\fB\-outform DER|PEM\fR" 4
167 .IX Item "-outform DER|PEM"
168 This specifies the output format \s-1DER\s0 or \s-1PEM.\s0 The default format is \s-1PEM.\s0
169 .IP "\fB\-pass arg\fR" 4
170 .IX Item "-pass arg"
171 The output file password source. For more information about the format of \fBarg\fR
172 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fBopenssl\fR\|(1).
173 .IP "\fB\-\f(BIcipher\fB\fR" 4
174 .IX Item "-cipher"
175 This option encrypts the private key with the supplied cipher. Any algorithm
176 name accepted by \fBEVP_get_cipherbyname()\fR is acceptable such as \fBdes3\fR.
177 .IP "\fB\-engine id\fR" 4
178 .IX Item "-engine id"
179 Specifying an engine (by its unique \fBid\fR string) will cause \fBgenpkey\fR
180 to attempt to obtain a functional reference to the specified engine,
181 thus initialising it if needed. The engine will then be set as the default
182 for all available algorithms. If used this option should precede all other
183 options.
184 .IP "\fB\-algorithm alg\fR" 4
185 .IX Item "-algorithm alg"
186 Public key algorithm to use such as \s-1RSA, DSA\s0 or \s-1DH.\s0 If used this option must
187 precede any \fB\-pkeyopt\fR options. The options \fB\-paramfile\fR and \fB\-algorithm\fR
188 are mutually exclusive. Engines may add algorithms in addition to the standard
189 built-in ones.
190 .Sp
191 Valid built-in algorithm names for private key generation are \s-1RSA\s0 and \s-1EC.\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 and \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 algorith and indeed each implementation of an
225 algorithm can vary. The options for the OpenSSL implementations are detailed
226 below.
227 .SS "\s-1RSA\s0 Key Generation Options"
228 .IX Subsection "RSA Key Generation Options"
229 .IP "\fBrsa_keygen_bits:numbits\fR" 4
230 .IX Item "rsa_keygen_bits:numbits"
231 The number of bits in the generated key. If not specified 2048 is used.
232 .IP "\fBrsa_keygen_pubexp:value\fR" 4
233 .IX Item "rsa_keygen_pubexp:value"
234 The \s-1RSA\s0 public exponent value. This can be a large decimal or
235 hexadecimal value if preceded by \fB0x\fR. Default value is 65537.
236 .SS "\s-1EC\s0 Key Generation Options"
237 .IX Subsection "EC Key Generation Options"
238 The \s-1EC\s0 key generation options can also be used for parameter generation.
239 .IP "\fBec_paramgen_curve:curve\fR" 4
240 .IX Item "ec_paramgen_curve:curve"
241 The \s-1EC\s0 curve to use. OpenSSL supports \s-1NIST\s0 curve names such as \*(L"P\-256\*(R".
242 .IP "\fBec_param_enc:encoding\fR" 4
243 .IX Item "ec_param_enc:encoding"
244 The encoding to use for parameters. The \*(L"encoding\*(R" parameter must be either
245 \&\*(L"named_curve\*(R" or \*(L"explicit\*(R". The default value is \*(L"named_curve\*(R".
246 .SH "PARAMETER GENERATION OPTIONS"
247 .IX Header "PARAMETER GENERATION OPTIONS"
248 The options supported by each algorithm and indeed each implementation of an
249 algorithm can vary. The options for the OpenSSL implementations are detailed
250 below.
251 .SS "\s-1DSA\s0 Parameter Generation Options"
252 .IX Subsection "DSA Parameter Generation Options"
253 .IP "\fBdsa_paramgen_bits:numbits\fR" 4
254 .IX Item "dsa_paramgen_bits:numbits"
255 The number of bits in the generated prime. If not specified 2048 is used.
256 .IP "\fBdsa_paramgen_q_bits:numbits\fR" 4
257 .IX Item "dsa_paramgen_q_bits:numbits"
258 The number of bits in the q parameter. Must be one of 160, 224 or 256. If not
259 specified 224 is used.
260 .IP "\fBdsa_paramgen_md:digest\fR" 4
261 .IX Item "dsa_paramgen_md:digest"
262 The digest to use during parameter generation. Must be one of \fBsha1\fR, \fBsha224\fR
263 or \fBsha256\fR. If set, then the number of bits in \fBq\fR will match the output size
264 of the specified digest and the \fBdsa_paramgen_q_bits\fR parameter will be
265 ignored. If not set, then a digest will be used that gives an output matching
266 the number of bits in \fBq\fR, i.e. \fBsha1\fR if q length is 160, \fBsha224\fR if it 224
267 or \fBsha256\fR if it is 256.
268 .SS "\s-1DH\s0 Parameter Generation Options"
269 .IX Subsection "DH Parameter Generation Options"
270 .IP "\fBdh_paramgen_prime_len:numbits\fR" 4
271 .IX Item "dh_paramgen_prime_len:numbits"
272 The number of bits in the prime parameter \fBp\fR. The default is 2048.
273 .IP "\fBdh_paramgen_subprime_len:numbits\fR" 4
274 .IX Item "dh_paramgen_subprime_len:numbits"
275 The number of bits in the sub prime parameter \fBq\fR. The default is 256 if the
276 prime is at least 2048 bits long or 160 otherwise. Only relevant if used in
277 conjunction with the \fBdh_paramgen_type\fR option to generate X9.42 \s-1DH\s0 parameters.
278 .IP "\fBdh_paramgen_generator:value\fR" 4
279 .IX Item "dh_paramgen_generator:value"
280 The value to use for the generator \fBg\fR. The default is 2.
281 .IP "\fBdh_paramgen_type:value\fR" 4
282 .IX Item "dh_paramgen_type:value"
283 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
284 The default is 0.
285 .IP "\fBdh_rfc5114:num\fR" 4
286 .IX Item "dh_rfc5114:num"
287 If this option is set, then the appropriate \s-1RFC5114\s0 parameters are used
288 instead of generating new parameters. The value \fBnum\fR can take the
289 values 1, 2 or 3 corresponding to \s-1RFC5114 DH\s0 parameters consisting of
290 1024 bit group with 160 bit subgroup, 2048 bit group with 224 bit subgroup
291 and 2048 bit group with 256 bit subgroup as mentioned in \s-1RFC5114\s0 sections
292 2.1, 2.2 and 2.3 respectively. If present this overrides all other \s-1DH\s0 parameter
293 options.
294 .SS "\s-1EC\s0 Parameter Generation Options"
295 .IX Subsection "EC Parameter Generation Options"
296 The \s-1EC\s0 parameter generation options are the same as for key generation. See
297 \&\*(L"\s-1EC\s0 Key Generation Options\*(R" above.
298 .SH "GOST2001 KEY GENERATION AND PARAMETER OPTIONS"
299 .IX Header "GOST2001 KEY GENERATION AND PARAMETER OPTIONS"
300 Gost 2001 support is not enabled by default. To enable this algorithm,
301 one should load the ccgost engine in the OpenSSL configuration file.
302 See \s-1README\s0.gost file in the engines/ccgost directiry of the source
303 distribution for more details.
304 .PP
305 Use of a parameter file for the \s-1GOST R 34.10\s0 algorithm is optional.
306 Parameters can be specified during key generation directly as well as
307 during generation of parameter file.
308 .IP "\fBparamset:name\fR" 4
309 .IX Item "paramset:name"
310 Specifies \s-1GOST R 34.10\-2001\s0 parameter set according to \s-1RFC 4357.\s0
311 Parameter set can be specified using abbreviated name, object short name or
312 numeric \s-1OID.\s0 Following parameter sets are supported:
313 .Sp
314 .Vb 7
315 \&  paramset   OID               Usage
316 \&  A          1.2.643.2.2.35.1  Signature
317 \&  B          1.2.643.2.2.35.2  Signature
318 \&  C          1.2.643.2.2.35.3  Signature
319 \&  XA         1.2.643.2.2.36.0  Key exchange
320 \&  XB         1.2.643.2.2.36.1  Key exchange
321 \&  test       1.2.643.2.2.35.0  Test purposes
322 .Ve
323 .SH "NOTES"
324 .IX Header "NOTES"
325 The use of the genpkey program is encouraged over the algorithm specific
326 utilities because additional algorithm options and \s-1ENGINE\s0 provided algorithms
327 can be used.
328 .SH "EXAMPLES"
329 .IX Header "EXAMPLES"
330 Generate an \s-1RSA\s0 private key using default parameters:
331 .PP
332 .Vb 1
333 \& openssl genpkey \-algorithm RSA \-out key.pem
334 .Ve
335 .PP
336 Encrypt output private key using 128 bit \s-1AES\s0 and the passphrase \*(L"hello\*(R":
337 .PP
338 .Vb 1
339 \& openssl genpkey \-algorithm RSA \-out key.pem \-aes\-128\-cbc \-pass pass:hello
340 .Ve
341 .PP
342 Generate a 2048 bit \s-1RSA\s0 key using 3 as the public exponent:
343 .PP
344 .Vb 2
345 \& openssl genpkey \-algorithm RSA \-out key.pem \-pkeyopt rsa_keygen_bits:2048 \e
346 \&                                                \-pkeyopt rsa_keygen_pubexp:3
347 .Ve
348 .PP
349 Generate 2048 bit \s-1DSA\s0 parameters:
350 .PP
351 .Vb 2
352 \& openssl genpkey \-genparam \-algorithm DSA \-out dsap.pem \e
353 \&                                                \-pkeyopt dsa_paramgen_bits:2048
354 .Ve
355 .PP
356 Generate \s-1DSA\s0 key from parameters:
357 .PP
358 .Vb 1
359 \& openssl genpkey \-paramfile dsap.pem \-out dsakey.pem
360 .Ve
361 .PP
362 Generate 2048 bit \s-1DH\s0 parameters:
363 .PP
364 .Vb 2
365 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \e
366 \&                                        \-pkeyopt dh_paramgen_prime_len:2048
367 .Ve
368 .PP
369 Generate 2048 bit X9.42 \s-1DH\s0 parameters:
370 .PP
371 .Vb 3
372 \& openssl genpkey \-genparam \-algorithm DH \-out dhpx.pem \e
373 \&                                        \-pkeyopt dh_paramgen_prime_len:2048 \e
374 \&                                        \-pkeyopt dh_paramgen_type:1
375 .Ve
376 .PP
377 Output \s-1RFC5114 2048\s0 bit \s-1DH\s0 parameters with 224 bit subgroup:
378 .PP
379 .Vb 1
380 \& openssl genpkey \-genparam \-algorithm DH \-out dhp.pem \-pkeyopt dh_rfc5114:2
381 .Ve
382 .PP
383 Generate \s-1DH\s0 key from parameters:
384 .PP
385 .Vb 1
386 \& openssl genpkey \-paramfile dhp.pem \-out dhkey.pem
387 .Ve
388 .PP
389 Generate \s-1EC\s0 key directly:
390 .PP
391 .Vb 3
392 \& openssl genpkey \-algorithm EC \-out eckey.pem \e
393 \&        \-pkeyopt ec_paramgen_curve:P\-384 \e
394 \&        \-pkeyopt ec_param_enc:named_curve
395 .Ve
396 .SH "HISTORY"
397 .IX Header "HISTORY"
398 The ability to use \s-1NIST\s0 curve names, and to generate an \s-1EC\s0 key directly,
399 were added in OpenSSL 1.0.2.