Initial import from FreeBSD RELENG_4:
[dragonfly.git] / secure / usr.bin / openssl / man / pkcs8.1
CommitLineData
984263bc
MD
1.\" Automatically generated by Pod::Man version 1.15
2.\" Wed Feb 19 16:49:35 2003
3.\"
4.\" Standard preamble:
5.\" ======================================================================
6.de Sh \" Subsection heading
7.br
8.if t .Sp
9.ne 5
10.PP
11\fB\\$1\fR
12.PP
13..
14.de Sp \" Vertical space (when we can't use .PP)
15.if t .sp .5v
16.if n .sp
17..
18.de Ip \" List item
19.br
20.ie \\n(.$>=3 .ne \\$3
21.el .ne 3
22.IP "\\$1" \\$2
23..
24.de Vb \" Begin verbatim text
25.ft CW
26.nf
27.ne \\$1
28..
29.de Ve \" End verbatim text
30.ft R
31
32.fi
33..
34.\" Set up some character translations and predefined strings. \*(-- will
35.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36.\" double quote, and \*(R" will give a right double quote. | will give a
37.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used
38.\" to do unbreakable dashes and therefore won't be available. \*(C` and
39.\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40.tr \(*W-|\(bv\*(Tr
41.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42.ie n \{\
43. ds -- \(*W-
44. ds PI pi
45. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
47. ds L" ""
48. ds R" ""
49. ds C` ""
50. ds C' ""
51'br\}
52.el\{\
53. ds -- \|\(em\|
54. ds PI \(*p
55. ds L" ``
56. ds R" ''
57'br\}
58.\"
59.\" If the F register is turned on, we'll generate index entries on stderr
60.\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61.\" index entries marked with X<> in POD. Of course, you'll have to process
62.\" the output yourself in some meaningful fashion.
63.if \nF \{\
64. de IX
65. tm Index:\\$1\t\\n%\t"\\$2"
66..
67. nr % 0
68. rr F
69.\}
70.\"
71.\" For nroff, turn off justification. Always turn off hyphenation; it
72.\" makes way too many mistakes in technical documents.
73.hy 0
74.if n .na
75.\"
76.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77.\" Fear. Run. Save yourself. No user-serviceable parts.
78.bd B 3
79. \" fudge factors for nroff and troff
80.if n \{\
81. ds #H 0
82. ds #V .8m
83. ds #F .3m
84. ds #[ \f1
85. ds #] \fP
86.\}
87.if t \{\
88. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89. ds #V .6m
90. ds #F 0
91. ds #[ \&
92. ds #] \&
93.\}
94. \" simple accents for nroff and troff
95.if n \{\
96. ds ' \&
97. ds ` \&
98. ds ^ \&
99. ds , \&
100. ds ~ ~
101. ds /
102.\}
103.if t \{\
104. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110.\}
111. \" troff and (daisy-wheel) nroff accents
112.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119.ds ae a\h'-(\w'a'u*4/10)'e
120.ds Ae A\h'-(\w'A'u*4/10)'E
121. \" corrections for vroff
122.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124. \" for low resolution devices (crt and lpr)
125.if \n(.H>23 .if \n(.V>19 \
126\{\
127. ds : e
128. ds 8 ss
129. ds o a
130. ds d- d\h'-1'\(ga
131. ds D- D\h'-1'\(hy
132. ds th \o'bp'
133. ds Th \o'LP'
134. ds ae ae
135. ds Ae AE
136.\}
137.rm #[ #] #H #V #F C
138.\" ======================================================================
139.\"
140.IX Title "PKCS8 1"
141.TH PKCS8 1 "0.9.7a" "2003-02-19" "OpenSSL"
142.UC
143.SH "NAME"
144pkcs8 \- PKCS#8 format private key conversion tool
145.SH "SYNOPSIS"
146.IX Header "SYNOPSIS"
147\&\fBopenssl\fR \fBpkcs8\fR
148[\fB\-topk8\fR]
149[\fB\-inform PEM|DER\fR]
150[\fB\-outform PEM|DER\fR]
151[\fB\-in filename\fR]
152[\fB\-passin arg\fR]
153[\fB\-out filename\fR]
154[\fB\-passout arg\fR]
155[\fB\-noiter\fR]
156[\fB\-nocrypt\fR]
157[\fB\-nooct\fR]
158[\fB\-embed\fR]
159[\fB\-nsdb\fR]
160[\fB\-v2 alg\fR]
161[\fB\-v1 alg\fR]
162[\fB\-engine id\fR]
163.SH "DESCRIPTION"
164.IX Header "DESCRIPTION"
165The \fBpkcs8\fR command processes private keys in PKCS#8 format. It can handle
166both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo
167format with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms.
168.SH "COMMAND OPTIONS"
169.IX Header "COMMAND OPTIONS"
170.Ip "\fB\-topk8\fR" 4
171.IX Item "-topk8"
172Normally a PKCS#8 private key is expected on input and a traditional format
173private key will be written. With the \fB\-topk8\fR option the situation is
174reversed: it reads a traditional format private key and writes a PKCS#8
175format key.
176.Ip "\fB\-inform DER|PEM\fR" 4
177.IX Item "-inform DER|PEM"
178This specifies the input format. If a PKCS#8 format key is expected on input
179then either a \fB\s-1DER\s0\fR or \fB\s-1PEM\s0\fR encoded version of a PKCS#8 key will be
180expected. Otherwise the \fB\s-1DER\s0\fR or \fB\s-1PEM\s0\fR format of the traditional format
181private key is used.
182.Ip "\fB\-outform DER|PEM\fR" 4
183.IX Item "-outform DER|PEM"
184This specifies the output format, the options have the same meaning as the
185\&\fB\-inform\fR option.
186.Ip "\fB\-in filename\fR" 4
187.IX Item "-in filename"
188This specifies the input filename to read a key from or standard input if this
189option is not specified. If the key is encrypted a pass phrase will be
190prompted for.
191.Ip "\fB\-passin arg\fR" 4
192.IX Item "-passin arg"
193the input file password source. For more information about the format of \fBarg\fR
194see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in openssl(1).
195.Ip "\fB\-out filename\fR" 4
196.IX Item "-out filename"
197This specifies the output filename to write a key to or standard output by
198default. If any encryption options are set then a pass phrase will be
199prompted for. The output filename should \fBnot\fR be the same as the input
200filename.
201.Ip "\fB\-passout arg\fR" 4
202.IX Item "-passout arg"
203the output file password source. For more information about the format of \fBarg\fR
204see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in openssl(1).
205.Ip "\fB\-nocrypt\fR" 4
206.IX Item "-nocrypt"
207PKCS#8 keys generated or input are normally PKCS#8 EncryptedPrivateKeyInfo
208structures using an appropriate password based encryption algorithm. With
209this option an unencrypted PrivateKeyInfo structure is expected or output.
210This option does not encrypt private keys at all and should only be used
211when absolutely necessary. Certain software such as some versions of Java
212code signing software used unencrypted private keys.
213.Ip "\fB\-nooct\fR" 4
214.IX Item "-nooct"
215This option generates \s-1RSA\s0 private keys in a broken format that some software
216uses. Specifically the private key should be enclosed in a \s-1OCTET\s0 \s-1STRING\s0
217but some software just includes the structure itself without the
218surrounding \s-1OCTET\s0 \s-1STRING\s0.
219.Ip "\fB\-embed\fR" 4
220.IX Item "-embed"
221This option generates \s-1DSA\s0 keys in a broken format. The \s-1DSA\s0 parameters are
222embedded inside the PrivateKey structure. In this form the \s-1OCTET\s0 \s-1STRING\s0
223contains an \s-1ASN1\s0 \s-1SEQUENCE\s0 consisting of two structures: a \s-1SEQUENCE\s0 containing
224the parameters and an \s-1ASN1\s0 \s-1INTEGER\s0 containing the private key.
225.Ip "\fB\-nsdb\fR" 4
226.IX Item "-nsdb"
227This option generates \s-1DSA\s0 keys in a broken format compatible with Netscape
228private key databases. The PrivateKey contains a \s-1SEQUENCE\s0 consisting of
229the public and private keys respectively.
230.Ip "\fB\-v2 alg\fR" 4
231.IX Item "-v2 alg"
232This option enables the use of PKCS#5 v2.0 algorithms. Normally PKCS#8
233private keys are encrypted with the password based encryption algorithm
234called \fBpbeWithMD5AndDES-CBC\fR this uses 56 bit \s-1DES\s0 encryption but it
235was the strongest encryption algorithm supported in PKCS#5 v1.5. Using
236the \fB\-v2\fR option PKCS#5 v2.0 algorithms are used which can use any
237encryption algorithm such as 168 bit triple \s-1DES\s0 or 128 bit \s-1RC2\s0 however
238not many implementations support PKCS#5 v2.0 yet. If you are just using
239private keys with OpenSSL then this doesn't matter.
240.Sp
241The \fBalg\fR argument is the encryption algorithm to use, valid values include
242\&\fBdes\fR, \fBdes3\fR and \fBrc2\fR. It is recommended that \fBdes3\fR is used.
243.Ip "\fB\-v1 alg\fR" 4
244.IX Item "-v1 alg"
245This option specifies a PKCS#5 v1.5 or PKCS#12 algorithm to use. A complete
246list of possible algorithms is included below.
247.Ip "\fB\-engine id\fR" 4
248.IX Item "-engine id"
249specifying an engine (by it's unique \fBid\fR string) will cause \fBreq\fR
250to attempt to obtain a functional reference to the specified engine,
251thus initialising it if needed. The engine will then be set as the default
252for all available algorithms.
253.SH "NOTES"
254.IX Header "NOTES"
255The encrypted form of a \s-1PEM\s0 encode PKCS#8 files uses the following
256headers and footers:
257.PP
258.Vb 2
259\& -----BEGIN ENCRYPTED PRIVATE KEY-----
260\& -----END ENCRYPTED PRIVATE KEY-----
261.Ve
262The unencrypted form uses:
263.PP
264.Vb 2
265\& -----BEGIN PRIVATE KEY-----
266\& -----END PRIVATE KEY-----
267.Ve
268Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration
269counts are more secure that those encrypted using the traditional
270SSLeay compatible formats. So if additional security is considered
271important the keys should be converted.
272.PP
273The default encryption is only 56 bits because this is the encryption
274that most current implementations of PKCS#8 will support.
275.PP
276Some software may use PKCS#12 password based encryption algorithms
277with PKCS#8 format private keys: these are handled automatically
278but there is no option to produce them.
279.PP
280It is possible to write out \s-1DER\s0 encoded encrypted private keys in
281PKCS#8 format because the encryption details are included at an \s-1ASN1\s0
282level whereas the traditional format includes them at a \s-1PEM\s0 level.
283.SH "PKCS#5 v1.5 and PKCS#12 algorithms."
284.IX Header "PKCS#5 v1.5 and PKCS#12 algorithms."
285Various algorithms can be used with the \fB\-v1\fR command line option,
286including PKCS#5 v1.5 and PKCS#12. These are described in more detail
287below.
288.Ip "\fB\s-1PBE-MD2\-DES\s0 \s-1PBE-MD5\-DES\s0\fR" 4
289.IX Item "PBE-MD2-DES PBE-MD5-DES"
290These algorithms were included in the original PKCS#5 v1.5 specification.
291They only offer 56 bits of protection since they both use \s-1DES\s0.
292.Ip "\fB\s-1PBE-SHA1\-RC2\-64\s0 \s-1PBE-MD2\-RC2\-64\s0 \s-1PBE-MD5\-RC2\-64\s0 \s-1PBE-SHA1\-DES\s0\fR" 4
293.IX Item "PBE-SHA1-RC2-64 PBE-MD2-RC2-64 PBE-MD5-RC2-64 PBE-SHA1-DES"
294These algorithms are not mentioned in the original PKCS#5 v1.5 specification
295but they use the same key derivation algorithm and are supported by some
296software. They are mentioned in PKCS#5 v2.0. They use either 64 bit \s-1RC2\s0 or
29756 bit \s-1DES\s0.
298.Ip "\fB\s-1PBE-SHA1\-RC4\-128\s0 \s-1PBE-SHA1\-RC4\-40\s0 \s-1PBE-SHA1\-3DES\s0 \s-1PBE-SHA1\-2DES\s0 \s-1PBE-SHA1\-RC2\-128\s0 \s-1PBE-SHA1\-RC2\-40\s0\fR" 4
299.IX Item "PBE-SHA1-RC4-128 PBE-SHA1-RC4-40 PBE-SHA1-3DES PBE-SHA1-2DES PBE-SHA1-RC2-128 PBE-SHA1-RC2-40"
300These algorithms use the PKCS#12 password based encryption algorithm and
301allow strong encryption algorithms like triple \s-1DES\s0 or 128 bit \s-1RC2\s0 to be used.
302.SH "EXAMPLES"
303.IX Header "EXAMPLES"
304Convert a private from traditional to PKCS#5 v2.0 format using triple
305\&\s-1DES:\s0
306.PP
307.Vb 1
308\& openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem
309.Ve
310Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm
311(\s-1DES\s0):
312.PP
313.Vb 1
314\& openssl pkcs8 -in key.pem -topk8 -out enckey.pem
315.Ve
316Convert a private key to PKCS#8 using a PKCS#12 compatible algorithm
317(3DES):
318.PP
319.Vb 1
320\& openssl pkcs8 -in key.pem -topk8 -out enckey.pem -v1 PBE-SHA1-3DES
321.Ve
322Read a \s-1DER\s0 unencrypted PKCS#8 format private key:
323.PP
324.Vb 1
325\& openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem
326.Ve
327Convert a private key from any PKCS#8 format to traditional format:
328.PP
329.Vb 1
330\& openssl pkcs8 -in pk8.pem -out key.pem
331.Ve
332.SH "STANDARDS"
333.IX Header "STANDARDS"
334Test vectors from this PKCS#5 v2.0 implementation were posted to the
335pkcs-tng mailing list using triple \s-1DES\s0, \s-1DES\s0 and \s-1RC2\s0 with high iteration
336counts, several people confirmed that they could decrypt the private
337keys produced and Therefore it can be assumed that the PKCS#5 v2.0
338implementation is reasonably accurate at least as far as these
339algorithms are concerned.
340.PP
341The format of PKCS#8 \s-1DSA\s0 (and other) private keys is not well documented:
342it is hidden away in PKCS#11 v2.01, section 11.9. OpenSSL's default \s-1DSA\s0
343PKCS#8 private key format complies with this standard.
344.SH "BUGS"
345.IX Header "BUGS"
346There should be an option that prints out the encryption algorithm
347in use and other details such as the iteration count.
348.PP
349PKCS#8 using triple \s-1DES\s0 and PKCS#5 v2.0 should be the default private
350key format for OpenSSL: for compatibility several of the utilities use
351the old format at present.
352.SH "SEE ALSO"
353.IX Header "SEE ALSO"
354dsa(1), rsa(1), genrsa(1),
355gendsa(1)