1 .\" $NetBSD: libcrypto.pl,v 1.3 2007/11/27 22:16:03 christos Exp $
3 .\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05)
6 .\" ========================================================================
7 .de Sh \" Subsection heading
15 .de Sp \" Vertical space (when we can't use .PP)
19 .de Vb \" Begin verbatim text
24 .de Ve \" End verbatim text
28 .\" Set up some character translations and predefined strings. \*(-- will
29 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
30 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
31 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
32 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
33 .\" nothing in troff, for use with C<>.
35 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
39 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
40 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
53 .\" Escape single quotes in literal strings from groff's Unicode transform.
57 .\" If the F register is turned on, we'll generate index entries on stderr for
58 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
59 .\" entries marked with X<> in POD. Of course, you'll have to process the
60 .\" output yourself in some meaningful fashion.
63 . tm Index:\\$1\t\\n%\t"\\$2"
73 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
74 .\" Fear. Run. Save yourself. No user-serviceable parts.
75 . \" fudge factors for nroff and troff
84 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
90 . \" simple accents for nroff and troff
100 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
101 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
102 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
103 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
104 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
105 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
107 . \" troff and (daisy-wheel) nroff accents
108 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
109 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
110 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
111 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
112 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
113 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
114 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
115 .ds ae a\h'-(\w'a'u*4/10)'e
116 .ds Ae A\h'-(\w'A'u*4/10)'E
117 . \" corrections for vroff
118 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
119 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
120 . \" for low resolution devices (crt and lpr)
121 .if \n(.H>23 .if \n(.V>19 \
134 .\" ========================================================================
136 .IX Title "PKEYUTL 1"
137 .TH PKEYUTL 1 "2009-04-15" "1.1.0-dev" "OpenSSL"
138 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
139 .\" way too many mistakes in technical documents.
143 pkeyutl \- public key algorithm utility
147 .IX Header "SYNOPSIS"
148 \&\fBopenssl\fR \fBpkeyutl\fR
151 [\fB\-sigfile file\fR]
153 [\fB\-keyform PEM|DER\fR]
155 [\fB\-peerkey file\fR]
156 [\fB\-peerform PEM|DER\fR]
162 [\fB\-verifyrecover\fR]
166 [\fB\-pkeyopt opt:value\fR]
171 .IX Header "DESCRIPTION"
172 The \fBpkeyutl\fR command can be used to perform public key operations using
173 any supported algorithm.
174 .SH "COMMAND OPTIONS"
175 .IX Header "COMMAND OPTIONS"
176 .IP "\fB\-in filename\fR" 4
177 .IX Item "-in filename"
178 This specifies the input filename to read data from or standard input
179 if this option is not specified.
180 .IP "\fB\-out filename\fR" 4
181 .IX Item "-out filename"
182 specifies the output filename to write to or standard output by
184 .IP "\fB\-inkey file\fR" 4
185 .IX Item "-inkey file"
186 the input key file, by default it should be a private key.
187 .IP "\fB\-keyform PEM|DER\fR" 4
188 .IX Item "-keyform PEM|DER"
189 the key format \s-1PEM\s0, \s-1DER\s0 or \s-1ENGINE\s0.
190 .IP "\fB\-passin arg\fR" 4
191 .IX Item "-passin arg"
192 the input key password source. For more information about the format of \fBarg\fR
193 see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
194 .IP "\fB\-peerkey file\fR" 4
195 .IX Item "-peerkey file"
196 the peer key file, used by key derivation (agreement) operations.
197 .IP "\fB\-peerform PEM|DER\fR" 4
198 .IX Item "-peerform PEM|DER"
199 the peer key format \s-1PEM\s0, \s-1DER\s0 or \s-1ENGINE\s0.
200 .IP "\fB\-engine id\fR" 4
201 .IX Item "-engine id"
202 specifying an engine (by its unique \fBid\fR string) will cause \fBpkeyutl\fR
203 to attempt to obtain a functional reference to the specified engine,
204 thus initialising it if needed. The engine will then be set as the default
205 for all available algorithms.
206 .IP "\fB\-pubin\fR" 4
208 the input file is a public key.
209 .IP "\fB\-certin\fR" 4
211 the input is a certificate containing a public key.
214 reverse the order of the input buffer. This is useful for some libraries
215 (such as CryptoAPI) which represent the buffer in little endian format.
218 sign the input data and output the signed result. This requires
220 .IP "\fB\-verify\fR" 4
222 verify the input data against the signature file and indicate if the
223 verification succeeded or failed.
224 .IP "\fB\-verifyrecover\fR" 4
225 .IX Item "-verifyrecover"
226 verify the input data and output the recovered data.
227 .IP "\fB\-encrypt\fR" 4
229 encrypt the input data using a public key.
230 .IP "\fB\-decrypt\fR" 4
232 decrypt the input data using a private key.
233 .IP "\fB\-derive\fR" 4
235 derive a shared secret using the peer key.
236 .IP "\fB\-hexdump\fR" 4
238 hex dump the output data.
239 .IP "\fB\-asn1parse\fR" 4
240 .IX Item "-asn1parse"
241 asn1parse the output data, this is useful when combined with the
242 \&\fB\-verifyrecover\fR option when an \s-1ASN1\s0 structure is signed.
245 The operations and options supported vary according to the key algorithm
246 and its implementation. The OpenSSL operations and options are indicated below.
248 Unless otherwise mentioned all algorithms support the \fBdigest:alg\fR option
249 which specifies the digest in use for sign, verify and verifyrecover operations.
250 The value \fBalg\fR should represent a digest name as used in the
251 \&\fIEVP_get_digestbyname()\fR function for example \fBsha1\fR.
253 .IX Header "RSA ALGORITHM"
254 The \s-1RSA\s0 algorithm supports encrypt, decrypt, sign, verify and verifyrecover
255 operations in general. Some padding modes only support some of these
257 .IP "\-\fBrsa_padding_mode:mode\fR" 4
258 .IX Item "-rsa_padding_mode:mode"
259 This sets the \s-1RSA\s0 padding mode. Acceptable values for \fBmode\fR are \fBpkcs1\fR for
260 PKCS#1 padding, \fBsslv23\fR for SSLv23 padding, \fBnone\fR for no padding, \fBoaep\fR
261 for \fB\s-1OAEP\s0\fR mode, \fBx931\fR for X9.31 mode and \fBpss\fR for \s-1PSS\s0.
263 In PKCS#1 padding if the message digest is not set then the supplied data is
264 signed or verified directly instead of using a \fBDigestInfo\fR structure. If a
265 digest is set then the a \fBDigestInfo\fR structure is used and its the length
266 must correspond to the digest type.
268 For \fBoeap\fR mode only encryption and decryption is supported.
270 For \fBx931\fR if the digest type is set it is used to format the block data
271 otherwise the first byte is used to specify the X9.31 digest \s-1ID\s0. Sign,
272 verify and verifyrecover are can be performed in this mode.
274 For \fBpss\fR mode only sign and verify are supported and the digest type must be
276 .IP "\fBrsa_pss_saltlen:len\fR" 4
277 .IX Item "rsa_pss_saltlen:len"
278 For \fBpss\fR mode only this option specifies the salt length. Two special values
279 are supported: \-1 sets the salt length to the digest length. When signing \-2
280 sets the salt length to the maximum permissible value. When verifying \-2 causes
281 the salt length to be automatically determined based on the \fB\s-1PSS\s0\fR block
284 .IX Header "DSA ALGORITHM"
285 The \s-1DSA\s0 algorithm supports signing and verification operations only. Currently
286 there are no additional options other than \fBdigest\fR. Only the \s-1SHA1\s0
287 digest can be used and this digest is assumed by default.
289 .IX Header "DH ALGORITHM"
290 The \s-1DH\s0 algorithm only supports the derivation operation and no additional
293 .IX Header "EC ALGORITHM"
294 The \s-1EC\s0 algorithm supports sign, verify and derive operations. The sign and
295 verify operations use \s-1ECDSA\s0 and derive uses \s-1ECDH\s0. Currently there are no
296 additional options other than \fBdigest\fR. Only the \s-1SHA1\s0 digest can be used and
297 this digest is assumed by default.
299 .IX Header "EXAMPLES"
300 Sign some data using a private key:
303 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig
306 Recover the signed data (e.g. if an \s-1RSA\s0 key is used):
309 \& openssl pkeyutl \-verifyrecover \-in sig \-inkey key.pem
312 Verify the signature (e.g. a \s-1DSA\s0 key):
315 \& openssl pkeyutl \-verify \-in file \-sigfile sig \-inkey key.pem
318 Sign data using a message digest value (this is currently only valid for \s-1RSA\s0):
321 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig \-pkeyopt digest:sha256
324 Derive a shared secret value:
327 \& openssl pkeyutl \-derive \-inkey key.pem \-peerkey pubkey.pem \-out secret
330 .IX Header "SEE ALSO"
331 \&\fIgenpkey\fR\|(1), \fIpkey\fR\|(1), \fIopenssl_rsautl\fR\|(1)
332 \&\fIopenssl_dgst\fR\|(1), \fIopenssl_rsa\fR\|(1), \fIopenssl_genrsa\fR\|(1)