apps/pkey.c: Re-order help output and option documentation
[openssl.git] / doc / man1 / openssl-pkey.pod.in
1 =pod
2
3 =begin comment
4 {- join("\n", @autowarntext) -}
5
6 =end comment
7
8 =head1 NAME
9
10 openssl-pkey - public or private key processing command
11
12 =head1 SYNOPSIS
13
14 B<openssl> B<pkey>
15 [B<-help>]
16 {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
17 [B<-check>]
18 [B<-pubcheck>]
19 [B<-in> I<filename>|I<uri>]
20 [B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
21 [B<-passin> I<arg>]
22 [B<-pubin>]
23 [B<-out> I<filename>]
24 [B<-outform> B<DER>|B<PEM>]
25 [B<-I<cipher>>]
26 [B<-passout> I<arg>]
27 [B<-traditional>]
28 [B<-pubout>]
29 [B<-noout>]
30 [B<-text_pub>]
31 [B<-text>]
32 [B<-ec_conv_form> I<arg>]
33 [B<-ec_param_enc> I<arg>]
34
35 =for openssl ifdef engine
36
37 =head1 DESCRIPTION
38
39 This command processes public or private keys. They can be
40 converted between various forms and their components printed.
41
42 =head1 OPTIONS
43
44 =head2 General options
45
46 =over 4
47
48 =item B<-help>
49
50 Print out a usage message.
51
52 {- $OpenSSL::safe::opt_engine_item -}
53
54 {- $OpenSSL::safe::opt_provider_item -}
55
56 =item B<-check>
57
58 This option checks the consistency of a key pair for both public and private
59 components.
60
61 =item B<-pubcheck>
62
63 This option checks the correctness of either a public key
64 or the public component of a key pair.
65
66 =back
67
68 =head2 Input options
69
70 =over 4
71
72 =item B<-in> I<filename>|I<uri>
73
74 This specifies the input to read a key from
75 or standard input if this option is not specified.
76 If the key is encrypted and B<-passin> is not given
77 a pass phrase will be prompted for.
78
79 =item B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
80
81 The key input format; the default is B<PEM>.
82 The only value with effect is B<ENGINE>; all others have become obsolete.
83 See L<openssl-format-options(1)> for details.
84
85 =item B<-passin> I<arg>
86
87 The password source for the key input.
88
89 For more information about the format of B<arg>
90 see L<openssl-passphrase-options(1)>.
91
92 =item B<-pubin>
93
94 By default a private key is read from the input file: with this
95 option a public key is read instead.
96
97 =back
98
99 =head2 Output options
100
101 =over 4
102
103 =item B<-out> I<filename>
104
105 This specifies the output filename to write a key to
106 or standard output if this option is not specified.
107 If any encryption option is set but no B<-passout> is given
108 then a pass phrase will be prompted for.
109 The output filename should B<not> be the same as the input filename.
110
111 =item B<-outform> B<DER>|B<PEM>
112
113 The key output format; the default is B<PEM>.
114 See L<openssl-format-options(1)> for details.
115
116 =item B<-I<cipher>>
117
118 These options encrypt the private key with the supplied cipher. Any algorithm
119 name accepted by EVP_get_cipherbyname() is acceptable such as B<aes128>.
120
121 =item B<-passout> I<arg>
122
123 The password source for the output file.
124 The -passout option is not supported for DER output.
125
126 For more information about the format of B<arg>
127 see L<openssl-passphrase-options(1)>.
128
129 =item B<-traditional>
130
131 Normally a private key is written using standard format: this is PKCS#8 form
132 with the appropriate encryption algorithm (if any). If the B<-traditional>
133 option is specified then the older "traditional" format is used instead.
134
135 =item B<-pubout>
136
137 By default the encoded private key is output:
138 with this option the encoded public key will be output instead.
139 This option is automatically set if the input is a public key.
140
141 =item B<-noout>
142
143 Do not output the encoded version of the key.
144
145 =item B<-text>
146
147 Output the various public or private key components in
148 plain text (possibly in addition to the encoded version).
149
150 =item B<-text_pub>
151
152 Output in text form the public key components (also for private keys).
153
154 =item B<-ec_conv_form> I<arg>
155
156 This option only applies to elliptic-curve based keys.
157
158 This specifies how the points on the elliptic curve are converted
159 into octet strings. Possible values are: B<compressed> (the default
160 value), B<uncompressed> and B<hybrid>. For more information regarding
161 the point conversion forms please read the X9.62 standard.
162 B<Note> Due to patent issues the B<compressed> option is disabled
163 by default for binary curves and can be enabled by defining
164 the preprocessor macro B<OPENSSL_EC_BIN_PT_COMP> at compile time.
165
166 =item B<-ec_param_enc> I<arg>
167
168 This option only applies to elliptic curve based public and private keys.
169
170 This specifies how the elliptic curve parameters are encoded.
171 Possible value are: B<named_curve>, i.e. the ec parameters are
172 specified by an OID, or B<explicit> where the ec parameters are
173 explicitly given (see RFC 3279 for the definition of the
174 EC parameters structures). The default value is B<named_curve>.
175 B<Note> the B<implicitlyCA> alternative, as specified in RFC 3279,
176 is currently not implemented in OpenSSL.
177
178 =back
179
180 =head1 EXAMPLES
181
182 To remove the pass phrase on a private key:
183
184  openssl pkey -in key.pem -out keyout.pem
185
186 To encrypt a private key using triple DES:
187
188  openssl pkey -in key.pem -des3 -out keyout.pem
189
190 To convert a private key from PEM to DER format:
191
192  openssl pkey -in key.pem -outform DER -out keyout.der
193
194 To print out the components of a private key to standard output:
195
196  openssl pkey -in key.pem -text -noout
197
198 To print out the public components of a private key to standard output:
199
200  openssl pkey -in key.pem -text_pub -noout
201
202 To just output the public part of a private key:
203
204  openssl pkey -in key.pem -pubout -out pubkey.pem
205
206 To change the EC parameters encoding to B<explicit>:
207
208  openssl pkey -in key.pem -ec_param_enc explicit -out keyout.pem
209
210 To change the EC point conversion form to B<compressed>:
211
212  openssl pkey -in key.pem -ec_conv_form compressed -out keyout.pem
213
214 =head1 SEE ALSO
215
216 L<openssl(1)>,
217 L<openssl-genpkey(1)>,
218 L<openssl-rsa(1)>,
219 L<openssl-pkcs8(1)>,
220 L<openssl-dsa(1)>,
221 L<openssl-genrsa(1)>,
222 L<openssl-gendsa(1)>
223
224 =head1 HISTORY
225
226 The B<-engine> option was deprecated in OpenSSL 3.0.
227
228 =head1 COPYRIGHT
229
230 Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
231
232 Licensed under the Apache License 2.0 (the "License").  You may not use
233 this file except in compliance with the License.  You can obtain a copy
234 in the file LICENSE in the source distribution or at
235 L<https://www.openssl.org/source/license.html>.
236
237 =cut