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