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