Add info about the header and footer lines used in PEM formats
[openssl.git] / doc / man / pkcs8.pod
1 =pod
2
3 =head1 NAME
4
5 pkcs8 - PKCS#8 format private key conversion tool
6
7 =head1 SYNOPSIS
8
9 B<openssl> B<pkcs8>
10 [B<-topk8>]
11 [B<-inform PEM|DER>]
12 [B<-outform PEM|DER>]
13 [B<-in filename>]
14 [B<-out filename>]
15 [B<-noiter>]
16 [B<-nocrypt>]
17 [B<-nooct>]
18 [B<-v2 alg>]
19
20 =head1 DESCRIPTION
21
22 The B<pkcs8> command processes private keys in PKCS#8 format. It can handle
23 both unencrypted PKCS#8 PrivateKeyInfo format and EncryptedPrivateKeyInfo
24 format with a variety of PKCS#5 (v1.5 and v2.0) and PKCS#12 algorithms.
25
26 =head1 COMMAND OPTIONS
27
28 =over 4
29
30 =item B<-topk8>
31
32 Normally a PKCS#8 private key is expected on input and a traditional format
33 private key will be written. With the B<-topk8> option the situation is
34 reversed: it reads a traditional format private key and writes a PKCS#8
35 format key.
36
37 =item B<-inform DER|PEM>
38
39 This specifies the input format. If a PKCS#8 format key is expected on input
40 then either a B<DER> or B<PEM> encoded version of a PKCS#8 key will be
41 expected. Otherwise the B<DER> or B<PEM> format of the traditional format
42 private key is used.
43
44 =item B<-outform DER|PEM>
45
46 This specifies the output format, the options have the same meaning as the 
47 B<-inform> option.
48
49 =item B<-in filename>
50
51 This specifies the input filename to read a key from or standard input if this
52 option is not specified. If the key is encrypted a pass phrase will be
53 prompted for.
54
55 =item B<-out filename>
56
57 This specifies the output filename to write a key to or standard output by
58 default. If any encryption options are set then a pass phrase will be
59 prompted for. The output filename should B<not> be the same as the input
60 filename.
61
62 =item B<-nocrypt>
63
64 PKCS#8 keys generated or input are normally PKCS#8 EncryptedPrivateKeyInfo
65 structures using an appropriate password based encryption algorithm. With
66 this option an unencrypted PrivateKeyInfo structure is expected or output.
67 This option does not encrypt private keys at all and should only be used
68 when absolutely necessary. Certain software such as some versions of Java
69 code signing software used unencrypted private keys.
70
71 =item B<-nooct>
72
73 This option generates private keys in a broken format that some software
74 uses. Specifically the private key should be enclosed in a OCTET STRING
75 but some software just includes the structure itself without the
76 surrounding OCTET STRING.
77
78 =item B<-v2 alg>
79
80 This option enables the use of PKCS#5 v2.0 algorithms. Normally PKCS#8
81 private keys are encrypted with the password based encryption algorithm
82 called B<pbeWithMD5AndDES-CBC> this uses 56 bit DES encryption but it
83 was the strongest encryption algorithm supported in PKCS#5 v1.5. Using 
84 the B<-v2> option PKCS#5 v2.0 algorithms are used which can use any
85 encryption algorithm such as 168 bit triple DES or 128 bit RC2 however
86 not many implementations support PKCS#5 v2.0 yet. If you are just using
87 private keys with OpenSSL then this doesn't matter.
88
89 The B<alg> argument is the encryption algorithm to use, valid values include
90 B<des>, B<des3> and B<rc2>. It is recommended that B<des3> is used.
91
92 =back
93
94 =head1 NOTES
95
96 The encrypted form of a PEM encode PKCS#8 files uses the following
97 headers and footers:
98
99  -----BEGIN ENCRYPTED PRIVATE KEY-----
100  -----END ENCRYPTED PRIVATE KEY-----
101
102 The unencrypted form uses:
103
104  -----BEGIN PRIVATE KEY-----
105  -----END PRIVATE KEY-----
106
107 Private keys encrypted using PKCS#5 v2.0 algorithms and high iteration
108 counts are more secure that those encrypted using the traditional
109 SSLeay compatible formats. So if additional security is considered
110 important the keys should be converted.
111
112 The default encryption is only 56 bits because this is the encryption
113 that most current implementations of PKCS#8 will support.
114
115 Some software may use PKCS#12 password based encryption algorithms
116 with PKCS#8 format private keys: these are handled automatically
117 but there is no option to produce them.
118
119 It is possible to write out DER encoded encrypted private keys in
120 PKCS#8 format because the encryption details are included at an ASN1
121 level whereas the traditional format includes them at a PEM level.
122
123 =head1 EXAMPLES
124
125 Convert a private from traditional to PKCS#5 v2.0 format using triple
126 DES:
127
128  openssl pkcs8 -in key.pem -topk8 -v2 des3 -out enckey.pem
129
130 Convert a private key to PKCS#8 using a PKCS#5 1.5 compatible algorithm
131 (DES):
132
133  openssl pkcs8 -in key.pem -topk8 -out enckey.pem
134
135 Read a DER unencrypted PKCS#8 format private key:
136
137  openssl pkcs8 -inform DER -nocrypt -in key.der -out key.pem
138
139 Convert a private key from any PKCS#8 format to traditional format:
140
141  openssl pkcs8 -in pk8.pem -out key.pem
142
143 =head1 STANDARDS
144
145 Test vectors from this implementation were posted to the pkcs-tng mailing
146 list using triple DES, DES and RC2 with high iteration counts, several
147 people confirmed that they could decrypt the private keys produced and
148 Therefore it can be assumed that the PKCS#5 v2.0 implementation is
149 reasonably accurate at least as far as these algorithms are concerned.
150
151 =head1 BUGS
152
153 It isn't possible to produce keys encrypted using PKCS#5 v1.5 algorithms
154 other than B<pbeWithMD5AndDES-CBC> using this utility.
155
156 There should be an option that prints out the encryption algorithm
157 in use and other details such as the iteration count.
158
159 PKCS#8 using triple DES and PKCS#5 v2.0 should be the default private
160 key format for OpenSSL: for compatability several of the utilities use
161 the old format at present.
162
163 =head1 SEE ALSO
164
165 dsa(1), rsa(1), genrsa(1), gendsa(1)
166
167 =cut