]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/pkcs8.1
OpenSSL: Merge OpenSSL 1.1.1o
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / pkcs8.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 "PKCS8 1"
136 .TH PKCS8 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\-pkcs8, pkcs8 \- PKCS#8 format private key conversion tool
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 \&\fBopenssl\fR \fBpkcs8\fR
146 [\fB\-help\fR]
147 [\fB\-topk8\fR]
148 [\fB\-inform PEM|DER\fR]
149 [\fB\-outform PEM|DER\fR]
150 [\fB\-in filename\fR]
151 [\fB\-passin arg\fR]
152 [\fB\-out filename\fR]
153 [\fB\-passout arg\fR]
154 [\fB\-iter count\fR]
155 [\fB\-noiter\fR]
156 [\fB\-rand file...\fR]
157 [\fB\-writerand file\fR]
158 [\fB\-nocrypt\fR]
159 [\fB\-traditional\fR]
160 [\fB\-v2 alg\fR]
161 [\fB\-v2prf alg\fR]
162 [\fB\-v1 alg\fR]
163 [\fB\-engine id\fR]
164 [\fB\-scrypt\fR]
165 [\fB\-scrypt_N N\fR]
166 [\fB\-scrypt_r r\fR]
167 [\fB\-scrypt_p p\fR]
168 .SH "DESCRIPTION"
169 .IX Header "DESCRIPTION"
170 The \fBpkcs8\fR command processes private keys in PKCS#8 format. It can handle
171 both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo
172 format with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms.
173 .SH "OPTIONS"
174 .IX Header "OPTIONS"
175 .IP "\fB\-help\fR" 4
176 .IX Item "-help"
177 Print out a usage message.
178 .IP "\fB\-topk8\fR" 4
179 .IX Item "-topk8"
180 Normally a PKCS#8 private key is expected on input and a private key will be
181 written to the output file. With the \fB\-topk8\fR option the situation is
182 reversed: it reads a private key and writes a PKCS#8 format key.
183 .IP "\fB\-inform DER|PEM\fR" 4
184 .IX Item "-inform DER|PEM"
185 This specifies the input format: see \*(L"\s-1KEY FORMATS\*(R"\s0 for more details. The default
186 format is \s-1PEM.\s0
187 .IP "\fB\-outform DER|PEM\fR" 4
188 .IX Item "-outform DER|PEM"
189 This specifies the output format: see \*(L"\s-1KEY FORMATS\*(R"\s0 for more details. The default
190 format is \s-1PEM.\s0
191 .IP "\fB\-traditional\fR" 4
192 .IX Item "-traditional"
193 When this option is present and \fB\-topk8\fR is not a traditional format private
194 key is written.
195 .IP "\fB\-in filename\fR" 4
196 .IX Item "-in filename"
197 This specifies the input filename to read a key from or standard input if this
198 option is not specified. If the key is encrypted a pass phrase will be
199 prompted for.
200 .IP "\fB\-passin arg\fR" 4
201 .IX Item "-passin arg"
202 The input file password source. For more information about the format of \fBarg\fR
203 see \*(L"Pass Phrase Options\*(R" in \fBopenssl\fR\|(1).
204 .IP "\fB\-out filename\fR" 4
205 .IX Item "-out filename"
206 This specifies the output filename to write a key to or standard output by
207 default. If any encryption options are set then a pass phrase will be
208 prompted for. The output filename should \fBnot\fR be the same as the input
209 filename.
210 .IP "\fB\-passout arg\fR" 4
211 .IX Item "-passout arg"
212 The output file password source. For more information about the format of \fBarg\fR
213 see \*(L"Pass Phrase Options\*(R" in \fBopenssl\fR\|(1).
214 .IP "\fB\-iter count\fR" 4
215 .IX Item "-iter count"
216 When creating new PKCS#8 containers, use a given number of iterations on
217 the password in deriving the encryption key for the PKCS#8 output.
218 High values increase the time required to brute-force a PKCS#8 container.
219 .IP "\fB\-nocrypt\fR" 4
220 .IX Item "-nocrypt"
221 PKCS#8 keys generated or input are normally PKCS#8 EncryptedPrivateKeyInfo
222 structures using an appropriate password based encryption algorithm. With
223 this option an unencrypted PrivateKeyInfo structure is expected or output.
224 This option does not encrypt private keys at all and should only be used
225 when absolutely necessary. Certain software such as some versions of Java
226 code signing software used unencrypted private keys.
227 .IP "\fB\-rand file...\fR" 4
228 .IX Item "-rand file..."
229 A file or files containing random data used to seed the random number
230 generator.
231 Multiple files can be specified separated by an OS-dependent character.
232 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
233 all others.
234 .IP "[\fB\-writerand file\fR]" 4
235 .IX Item "[-writerand file]"
236 Writes random data to the specified \fIfile\fR upon exit.
237 This can be used with a subsequent \fB\-rand\fR flag.
238 .IP "\fB\-v2 alg\fR" 4
239 .IX Item "-v2 alg"
240 This option sets the PKCS#5 v2.0 algorithm.
241 .Sp
242 The \fBalg\fR argument is the encryption algorithm to use, valid values include
243 \&\fBaes128\fR, \fBaes256\fR and \fBdes3\fR. If this option isn't specified then \fBaes256\fR
244 is used.
245 .IP "\fB\-v2prf alg\fR" 4
246 .IX Item "-v2prf alg"
247 This option sets the \s-1PRF\s0 algorithm to use with PKCS#5 v2.0. A typical value
248 value would be \fBhmacWithSHA256\fR. If this option isn't set then the default
249 for the cipher is used or \fBhmacWithSHA256\fR if there is no default.
250 .Sp
251 Some implementations may not support custom \s-1PRF\s0 algorithms and may require
252 the \fBhmacWithSHA1\fR option to work.
253 .IP "\fB\-v1 alg\fR" 4
254 .IX Item "-v1 alg"
255 This option indicates a PKCS#5 v1.5 or PKCS#12 algorithm should be used.  Some
256 older implementations may not support PKCS#5 v2.0 and may require this option.
257 If not specified PKCS#5 v2.0 form is used.
258 .IP "\fB\-engine id\fR" 4
259 .IX Item "-engine id"
260 Specifying an engine (by its unique \fBid\fR string) will cause \fBpkcs8\fR
261 to attempt to obtain a functional reference to the specified engine,
262 thus initialising it if needed. The engine will then be set as the default
263 for all available algorithms.
264 .IP "\fB\-scrypt\fR" 4
265 .IX Item "-scrypt"
266 Uses the \fBscrypt\fR algorithm for private key encryption using default
267 parameters: currently N=16384, r=8 and p=1 and \s-1AES\s0 in \s-1CBC\s0 mode with a 256 bit
268 key. These parameters can be modified using the \fB\-scrypt_N\fR, \fB\-scrypt_r\fR,
269 \&\fB\-scrypt_p\fR and \fB\-v2\fR options.
270 .IP "\fB\-scrypt_N N\fR \fB\-scrypt_r r\fR \fB\-scrypt_p p\fR" 4
271 .IX Item "-scrypt_N N -scrypt_r r -scrypt_p p"
272 Sets the scrypt \fBN\fR, \fBr\fR or \fBp\fR parameters.
273 .SH "KEY FORMATS"
274 .IX Header "KEY FORMATS"
275 Various different formats are used by the pkcs8 utility. These are detailed
276 below.
277 .PP
278 If a key is being converted from PKCS#8 form (i.e. the \fB\-topk8\fR option is
279 not used) then the input file must be in PKCS#8 format. An encrypted
280 key is expected unless \fB\-nocrypt\fR is included.
281 .PP
282 If \fB\-topk8\fR is not used and \fB\s-1PEM\s0\fR mode is set the output file will be an
283 unencrypted private key in PKCS#8 format. If the \fB\-traditional\fR option is
284 used then a traditional format private key is written instead.
285 .PP
286 If \fB\-topk8\fR is not used and \fB\s-1DER\s0\fR mode is set the output file will be an
287 unencrypted private key in traditional \s-1DER\s0 format.
288 .PP
289 If \fB\-topk8\fR is used then any supported private key can be used for the input
290 file in a format specified by \fB\-inform\fR. The output file will be encrypted
291 PKCS#8 format using the specified encryption parameters unless \fB\-nocrypt\fR
292 is included.
293 .SH "NOTES"
294 .IX Header "NOTES"
295 By default, when converting a key to PKCS#8 format, PKCS#5 v2.0 using 256 bit
296 \&\s-1AES\s0 with \s-1HMAC\s0 and \s-1SHA256\s0 is used.
297 .PP
298 Some older implementations do not support PKCS#5 v2.0 format and require
299 the older PKCS#5 v1.5 form instead, possibly also requiring insecure weak
300 encryption algorithms such as 56 bit \s-1DES.\s0
301 .PP
302 The encrypted form of a \s-1PEM\s0 encode PKCS#8 files uses the following
303 headers and footers:
304 .PP
305 .Vb 2
306 \& \-\-\-\-\-BEGIN ENCRYPTED PRIVATE KEY\-\-\-\-\-
307 \& \-\-\-\-\-END ENCRYPTED PRIVATE KEY\-\-\-\-\-
308 .Ve
309 .PP
310 The unencrypted form uses:
311 .PP
312 .Vb 2
313 \& \-\-\-\-\-BEGIN PRIVATE KEY\-\-\-\-\-
314 \& \-\-\-\-\-END PRIVATE KEY\-\-\-\-\-
315 .Ve
316 .PP
317 Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration
318 counts are more secure that those encrypted using the traditional
319 SSLeay compatible formats. So if additional security is considered
320 important the keys should be converted.
321 .PP
322 It is possible to write out \s-1DER\s0 encoded encrypted private keys in
323 PKCS#8 format because the encryption details are included at an \s-1ASN1\s0
324 level whereas the traditional format includes them at a \s-1PEM\s0 level.
325 .SH "PKCS#5 v1.5 and PKCS#12 algorithms."
326 .IX Header "PKCS#5 v1.5 and PKCS#12 algorithms."
327 Various algorithms can be used with the \fB\-v1\fR command line option,
328 including PKCS#5 v1.5 and PKCS#12. These are described in more detail
329 below.
330 .IP "\fB\s-1PBE\-MD2\-DES PBE\-MD5\-DES\s0\fR" 4
331 .IX Item "PBE-MD2-DES PBE-MD5-DES"
332 These algorithms were included in the original PKCS#5 v1.5 specification.
333 They only offer 56 bits of protection since they both use \s-1DES.\s0
334 .IP "\fB\s-1PBE\-SHA1\-RC2\-64\s0\fR, \fB\s-1PBE\-MD2\-RC2\-64\s0\fR, \fB\s-1PBE\-MD5\-RC2\-64\s0\fR, \fB\s-1PBE\-SHA1\-DES\s0\fR" 4
335 .IX Item "PBE-SHA1-RC2-64, PBE-MD2-RC2-64, PBE-MD5-RC2-64, PBE-SHA1-DES"
336 These algorithms are not mentioned in the original PKCS#5 v1.5 specification
337 but they use the same key derivation algorithm and are supported by some
338 software. They are mentioned in PKCS#5 v2.0. They use either 64 bit \s-1RC2\s0 or
339 56 bit \s-1DES.\s0
340 .IP "\fB\s-1PBE\-SHA1\-RC4\-128\s0\fR, \fB\s-1PBE\-SHA1\-RC4\-40\s0\fR, \fB\s-1PBE\-SHA1\-3DES\s0\fR, \fB\s-1PBE\-SHA1\-2DES\s0\fR, \fB\s-1PBE\-SHA1\-RC2\-128\s0\fR, \fB\s-1PBE\-SHA1\-RC2\-40\s0\fR" 4
341 .IX Item "PBE-SHA1-RC4-128, PBE-SHA1-RC4-40, PBE-SHA1-3DES, PBE-SHA1-2DES, PBE-SHA1-RC2-128, PBE-SHA1-RC2-40"
342 These algorithms use the PKCS#12 password based encryption algorithm and
343 allow strong encryption algorithms like triple \s-1DES\s0 or 128 bit \s-1RC2\s0 to be used.
344 .SH "EXAMPLES"
345 .IX Header "EXAMPLES"
346 Convert a private key to PKCS#8 format using default parameters (\s-1AES\s0 with
347 256 bit key and \fBhmacWithSHA256\fR):
348 .PP
349 .Vb 1
350 \& openssl pkcs8 \-in key.pem \-topk8 \-out enckey.pem
351 .Ve
352 .PP
353 Convert a private key to PKCS#8 unencrypted format:
354 .PP
355 .Vb 1
356 \& openssl pkcs8 \-in key.pem \-topk8 \-nocrypt \-out enckey.pem
357 .Ve
358 .PP
359 Convert a private key to PKCS#5 v2.0 format using triple \s-1DES:\s0
360 .PP
361 .Vb 1
362 \& openssl pkcs8 \-in key.pem \-topk8 \-v2 des3 \-out enckey.pem
363 .Ve
364 .PP
365 Convert a private key to PKCS#5 v2.0 format using \s-1AES\s0 with 256 bits in \s-1CBC\s0
366 mode and \fBhmacWithSHA512\fR \s-1PRF:\s0
367 .PP
368 .Vb 1
369 \& openssl pkcs8 \-in key.pem \-topk8 \-v2 aes\-256\-cbc \-v2prf hmacWithSHA512 \-out enckey.pem
370 .Ve
371 .PP
372 Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm
373 (\s-1DES\s0):
374 .PP
375 .Vb 1
376 \& openssl pkcs8 \-in key.pem \-topk8 \-v1 PBE\-MD5\-DES \-out enckey.pem
377 .Ve
378 .PP
379 Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm
380 (3DES):
381 .PP
382 .Vb 1
383 \& openssl pkcs8 \-in key.pem \-topk8 \-out enckey.pem \-v1 PBE\-SHA1\-3DES
384 .Ve
385 .PP
386 Read a \s-1DER\s0 unencrypted PKCS#8 format private key:
387 .PP
388 .Vb 1
389 \& openssl pkcs8 \-inform DER \-nocrypt \-in key.der \-out key.pem
390 .Ve
391 .PP
392 Convert a private key from any PKCS#8 encrypted format to traditional format:
393 .PP
394 .Vb 1
395 \& openssl pkcs8 \-in pk8.pem \-traditional \-out key.pem
396 .Ve
397 .PP
398 Convert a private key to PKCS#8 format, encrypting with \s-1AES\-256\s0 and with
399 one million iterations of the password:
400 .PP
401 .Vb 1
402 \& openssl pkcs8 \-in key.pem \-topk8 \-v2 aes\-256\-cbc \-iter 1000000 \-out pk8.pem
403 .Ve
404 .SH "STANDARDS"
405 .IX Header "STANDARDS"
406 Test vectors from this PKCS#5 v2.0 implementation were posted to the
407 pkcs-tng mailing list using triple \s-1DES, DES\s0 and \s-1RC2\s0 with high iteration
408 counts, several people confirmed that they could decrypt the private
409 keys produced and therefore, it can be assumed that the PKCS#5 v2.0
410 implementation is reasonably accurate at least as far as these
411 algorithms are concerned.
412 .PP
413 The format of PKCS#8 \s-1DSA\s0 (and other) private keys is not well documented:
414 it is hidden away in PKCS#11 v2.01, section 11.9. OpenSSL's default \s-1DSA\s0
415 PKCS#8 private key format complies with this standard.
416 .SH "BUGS"
417 .IX Header "BUGS"
418 There should be an option that prints out the encryption algorithm
419 in use and other details such as the iteration count.
420 .SH "SEE ALSO"
421 .IX Header "SEE ALSO"
422 \&\fBdsa\fR\|(1), \fBrsa\fR\|(1), \fBgenrsa\fR\|(1),
423 \&\fBgendsa\fR\|(1)
424 .SH "HISTORY"
425 .IX Header "HISTORY"
426 The \fB\-iter\fR option was added in OpenSSL 1.1.0.
427 .SH "COPYRIGHT"
428 .IX Header "COPYRIGHT"
429 Copyright 2000\-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>.