]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/pkeyutl.1
MFC: r340705, r340708
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / pkeyutl.1
1 .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "PKEYUTL 1"
132 .TH PKEYUTL 1 "2018-11-20" "1.1.1a" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 openssl\-pkeyutl, pkeyutl \- public key algorithm utility
139 .SH "SYNOPSIS"
140 .IX Header "SYNOPSIS"
141 \&\fBopenssl\fR \fBpkeyutl\fR
142 [\fB\-help\fR]
143 [\fB\-in file\fR]
144 [\fB\-out file\fR]
145 [\fB\-sigfile file\fR]
146 [\fB\-inkey file\fR]
147 [\fB\-keyform PEM|DER|ENGINE\fR]
148 [\fB\-passin arg\fR]
149 [\fB\-peerkey file\fR]
150 [\fB\-peerform PEM|DER|ENGINE\fR]
151 [\fB\-pubin\fR]
152 [\fB\-certin\fR]
153 [\fB\-rev\fR]
154 [\fB\-sign\fR]
155 [\fB\-verify\fR]
156 [\fB\-verifyrecover\fR]
157 [\fB\-encrypt\fR]
158 [\fB\-decrypt\fR]
159 [\fB\-derive\fR]
160 [\fB\-kdf algorithm\fR]
161 [\fB\-kdflen length\fR]
162 [\fB\-pkeyopt opt:value\fR]
163 [\fB\-hexdump\fR]
164 [\fB\-asn1parse\fR]
165 [\fB\-rand file...\fR]
166 [\fB\-writerand file\fR]
167 [\fB\-engine id\fR]
168 [\fB\-engine_impl\fR]
169 .SH "DESCRIPTION"
170 .IX Header "DESCRIPTION"
171 The \fBpkeyutl\fR command can be used to perform low level public key operations
172 using any supported algorithm.
173 .SH "OPTIONS"
174 .IX Header "OPTIONS"
175 .IP "\fB\-help\fR" 4
176 .IX Item "-help"
177 Print out a usage message.
178 .IP "\fB\-in filename\fR" 4
179 .IX Item "-in filename"
180 This specifies the input filename to read data from or standard input
181 if this option is not specified.
182 .IP "\fB\-out filename\fR" 4
183 .IX Item "-out filename"
184 Specifies the output filename to write to or standard output by
185 default.
186 .IP "\fB\-sigfile file\fR" 4
187 .IX Item "-sigfile file"
188 Signature file, required for \fBverify\fR operations only
189 .IP "\fB\-inkey file\fR" 4
190 .IX Item "-inkey file"
191 The input key file, by default it should be a private key.
192 .IP "\fB\-keyform PEM|DER|ENGINE\fR" 4
193 .IX Item "-keyform PEM|DER|ENGINE"
194 The key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0 Default is \s-1PEM.\s0
195 .IP "\fB\-passin arg\fR" 4
196 .IX Item "-passin arg"
197 The input key password source. For more information about the format of \fBarg\fR
198 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
199 .IP "\fB\-peerkey file\fR" 4
200 .IX Item "-peerkey file"
201 The peer key file, used by key derivation (agreement) operations.
202 .IP "\fB\-peerform PEM|DER|ENGINE\fR" 4
203 .IX Item "-peerform PEM|DER|ENGINE"
204 The peer key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0 Default is \s-1PEM.\s0
205 .IP "\fB\-pubin\fR" 4
206 .IX Item "-pubin"
207 The input file is a public key.
208 .IP "\fB\-certin\fR" 4
209 .IX Item "-certin"
210 The input is a certificate containing a public key.
211 .IP "\fB\-rev\fR" 4
212 .IX Item "-rev"
213 Reverse the order of the input buffer. This is useful for some libraries
214 (such as CryptoAPI) which represent the buffer in little endian format.
215 .IP "\fB\-sign\fR" 4
216 .IX Item "-sign"
217 Sign the input data (which must be a hash) and output the signed result. This
218 requires a private key.
219 .IP "\fB\-verify\fR" 4
220 .IX Item "-verify"
221 Verify the input data (which must be a hash) against the signature file and
222 indicate if the verification succeeded or failed.
223 .IP "\fB\-verifyrecover\fR" 4
224 .IX Item "-verifyrecover"
225 Verify the input data (which must be a hash) and output the recovered data.
226 .IP "\fB\-encrypt\fR" 4
227 .IX Item "-encrypt"
228 Encrypt the input data using a public key.
229 .IP "\fB\-decrypt\fR" 4
230 .IX Item "-decrypt"
231 Decrypt the input data using a private key.
232 .IP "\fB\-derive\fR" 4
233 .IX Item "-derive"
234 Derive a shared secret using the peer key.
235 .IP "\fB\-kdf algorithm\fR" 4
236 .IX Item "-kdf algorithm"
237 Use key derivation function \fBalgorithm\fR.  The supported algorithms are
238 at present \fB\s-1TLS1\-PRF\s0\fR and \fB\s-1HKDF\s0\fR.
239 Note: additional parameters and the \s-1KDF\s0 output length will normally have to be
240 set for this to work.
241 See \fIEVP_PKEY_CTX_set_hkdf_md\fR\|(3) and \fIEVP_PKEY_CTX_set_tls1_prf_md\fR\|(3)
242 for the supported string parameters of each algorithm.
243 .IP "\fB\-kdflen length\fR" 4
244 .IX Item "-kdflen length"
245 Set the output length for \s-1KDF.\s0
246 .IP "\fB\-pkeyopt opt:value\fR" 4
247 .IX Item "-pkeyopt opt:value"
248 Public key options specified as opt:value. See \s-1NOTES\s0 below for more details.
249 .IP "\fB\-hexdump\fR" 4
250 .IX Item "-hexdump"
251 hex dump the output data.
252 .IP "\fB\-asn1parse\fR" 4
253 .IX Item "-asn1parse"
254 Parse the \s-1ASN.1\s0 output data, this is useful when combined with the
255 \&\fB\-verifyrecover\fR option when an \s-1ASN1\s0 structure is signed.
256 .IP "\fB\-rand file...\fR" 4
257 .IX Item "-rand file..."
258 A file or files containing random data used to seed the random number
259 generator.
260 Multiple files can be specified separated by an OS-dependent character.
261 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
262 all others.
263 .IP "[\fB\-writerand file\fR]" 4
264 .IX Item "[-writerand file]"
265 Writes random data to the specified \fIfile\fR upon exit.
266 This can be used with a subsequent \fB\-rand\fR flag.
267 .IP "\fB\-engine id\fR" 4
268 .IX Item "-engine id"
269 Specifying an engine (by its unique \fBid\fR string) will cause \fBpkeyutl\fR
270 to attempt to obtain a functional reference to the specified engine,
271 thus initialising it if needed. The engine will then be set as the default
272 for all available algorithms.
273 .IP "\fB\-engine_impl\fR" 4
274 .IX Item "-engine_impl"
275 When used with the \fB\-engine\fR option, it specifies to also use
276 engine \fBid\fR for crypto operations.
277 .SH "NOTES"
278 .IX Header "NOTES"
279 The operations and options supported vary according to the key algorithm
280 and its implementation. The OpenSSL operations and options are indicated below.
281 .PP
282 Unless otherwise mentioned all algorithms support the \fBdigest:alg\fR option
283 which specifies the digest in use for sign, verify and verifyrecover operations.
284 The value \fBalg\fR should represent a digest name as used in the
285 \&\fIEVP_get_digestbyname()\fR function for example \fBsha1\fR. This value is not used to
286 hash the input data. It is used (by some algorithms) for sanity-checking the
287 lengths of data passed in to the \fBpkeyutl\fR and for creating the structures that
288 make up the signature (e.g. \fBDigestInfo\fR in \s-1RSASSA\s0 PKCS#1 v1.5 signatures).
289 .PP
290 This utility does not hash the input data but rather it will use the data
291 directly as input to the signature algorithm. Depending on the key type,
292 signature type, and mode of padding, the maximum acceptable lengths of input
293 data differ. The signed data can't be longer than the key modulus with \s-1RSA.\s0 In
294 case of \s-1ECDSA\s0 and \s-1DSA\s0 the data shouldn't be longer than the field
295 size, otherwise it will be silently truncated to the field size. In any event
296 the input size must not be larger than the largest supported digest size.
297 .PP
298 In other words, if the value of digest is \fBsha1\fR the input should be the 20
299 bytes long binary encoding of the \s-1SHA\-1\s0 hash function output.
300 .PP
301 The Ed25519 and Ed448 signature algorithms are not supported by this utility.
302 They accept non-hashed input, but this utility can only be used to sign hashed
303 input.
304 .SH "RSA ALGORITHM"
305 .IX Header "RSA ALGORITHM"
306 The \s-1RSA\s0 algorithm generally supports the encrypt, decrypt, sign,
307 verify and verifyrecover operations. However, some padding modes
308 support only a subset of these operations. The following additional
309 \&\fBpkeyopt\fR values are supported:
310 .IP "\fBrsa_padding_mode:mode\fR" 4
311 .IX Item "rsa_padding_mode:mode"
312 This sets the \s-1RSA\s0 padding mode. Acceptable values for \fBmode\fR are \fBpkcs1\fR for
313 PKCS#1 padding, \fBsslv23\fR for SSLv23 padding, \fBnone\fR for no padding, \fBoaep\fR
314 for \fB\s-1OAEP\s0\fR mode, \fBx931\fR for X9.31 mode and \fBpss\fR for \s-1PSS.\s0
315 .Sp
316 In PKCS#1 padding if the message digest is not set then the supplied data is
317 signed or verified directly instead of using a \fBDigestInfo\fR structure. If a
318 digest is set then the a \fBDigestInfo\fR structure is used and its the length
319 must correspond to the digest type.
320 .Sp
321 For \fBoaep\fR mode only encryption and decryption is supported.
322 .Sp
323 For \fBx931\fR if the digest type is set it is used to format the block data
324 otherwise the first byte is used to specify the X9.31 digest \s-1ID.\s0 Sign,
325 verify and verifyrecover are can be performed in this mode.
326 .Sp
327 For \fBpss\fR mode only sign and verify are supported and the digest type must be
328 specified.
329 .IP "\fBrsa_pss_saltlen:len\fR" 4
330 .IX Item "rsa_pss_saltlen:len"
331 For \fBpss\fR mode only this option specifies the salt length. Three special
332 values are supported: \*(L"digest\*(R" sets the salt length to the digest length,
333 \&\*(L"max\*(R" sets the salt length to the maximum permissible value. When verifying
334 \&\*(L"auto\*(R" causes the salt length to be automatically determined based on the
335 \&\fB\s-1PSS\s0\fR block structure.
336 .IP "\fBrsa_mgf1_md:digest\fR" 4
337 .IX Item "rsa_mgf1_md:digest"
338 For \s-1PSS\s0 and \s-1OAEP\s0 padding sets the \s-1MGF1\s0 digest. If the \s-1MGF1\s0 digest is not
339 explicitly set in \s-1PSS\s0 mode then the signing digest is used.
340 .SH "RSA-PSS ALGORITHM"
341 .IX Header "RSA-PSS ALGORITHM"
342 The RSA-PSS algorithm is a restricted version of the \s-1RSA\s0 algorithm which only
343 supports the sign and verify operations with \s-1PSS\s0 padding. The following
344 additional \fBpkeyopt\fR values are supported:
345 .IP "\fBrsa_padding_mode:mode\fR, \fBrsa_pss_saltlen:len\fR, \fBrsa_mgf1_md:digest\fR" 4
346 .IX Item "rsa_padding_mode:mode, rsa_pss_saltlen:len, rsa_mgf1_md:digest"
347 These have the same meaning as the \fB\s-1RSA\s0\fR algorithm with some additional
348 restrictions. The padding mode can only be set to \fBpss\fR which is the
349 default value.
350 .Sp
351 If the key has parameter restrictions than the digest, \s-1MGF1\s0
352 digest and salt length are set to the values specified in the parameters.
353 The digest and \s-1MG\s0 cannot be changed and the salt length cannot be set to a
354 value less than the minimum restriction.
355 .SH "DSA ALGORITHM"
356 .IX Header "DSA ALGORITHM"
357 The \s-1DSA\s0 algorithm supports signing and verification operations only. Currently
358 there are no additional options other than \fBdigest\fR. Only the \s-1SHA1\s0
359 digest can be used and this digest is assumed by default.
360 .SH "DH ALGORITHM"
361 .IX Header "DH ALGORITHM"
362 The \s-1DH\s0 algorithm only supports the derivation operation and no additional
363 options.
364 .SH "EC ALGORITHM"
365 .IX Header "EC ALGORITHM"
366 The \s-1EC\s0 algorithm supports sign, verify and derive operations. The sign and
367 verify operations use \s-1ECDSA\s0 and derive uses \s-1ECDH.\s0 Currently there are no
368 additional options other than \fBdigest\fR. Only the \s-1SHA1\s0 digest can be used and
369 this digest is assumed by default.
370 .SH "X25519 and X448 ALGORITHMS"
371 .IX Header "X25519 and X448 ALGORITHMS"
372 The X25519 and X448 algorithms support key derivation only. Currently there are
373 no additional options.
374 .SH "EXAMPLES"
375 .IX Header "EXAMPLES"
376 Sign some data using a private key:
377 .PP
378 .Vb 1
379 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig
380 .Ve
381 .PP
382 Recover the signed data (e.g. if an \s-1RSA\s0 key is used):
383 .PP
384 .Vb 1
385 \& openssl pkeyutl \-verifyrecover \-in sig \-inkey key.pem
386 .Ve
387 .PP
388 Verify the signature (e.g. a \s-1DSA\s0 key):
389 .PP
390 .Vb 1
391 \& openssl pkeyutl \-verify \-in file \-sigfile sig \-inkey key.pem
392 .Ve
393 .PP
394 Sign data using a message digest value (this is currently only valid for \s-1RSA\s0):
395 .PP
396 .Vb 1
397 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig \-pkeyopt digest:sha256
398 .Ve
399 .PP
400 Derive a shared secret value:
401 .PP
402 .Vb 1
403 \& openssl pkeyutl \-derive \-inkey key.pem \-peerkey pubkey.pem \-out secret
404 .Ve
405 .PP
406 Hexdump 48 bytes of \s-1TLS1 PRF\s0 using digest \fB\s-1SHA256\s0\fR and shared secret and
407 seed consisting of the single byte 0xFF:
408 .PP
409 .Vb 2
410 \& openssl pkeyutl \-kdf TLS1\-PRF \-kdflen 48 \-pkeyopt md:SHA256 \e
411 \&    \-pkeyopt hexsecret:ff \-pkeyopt hexseed:ff \-hexdump
412 .Ve
413 .SH "SEE ALSO"
414 .IX Header "SEE ALSO"
415 \&\fIgenpkey\fR\|(1), \fIpkey\fR\|(1), \fIrsautl\fR\|(1)
416 \&\fIdgst\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1),
417 \&\fIEVP_PKEY_CTX_set_hkdf_md\fR\|(3), \fIEVP_PKEY_CTX_set_tls1_prf_md\fR\|(3)
418 .SH "COPYRIGHT"
419 .IX Header "COPYRIGHT"
420 Copyright 2006\-2018 The OpenSSL Project Authors. All Rights Reserved.
421 .PP
422 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
423 this file except in compliance with the License.  You can obtain a copy
424 in the file \s-1LICENSE\s0 in the source distribution or at
425 <https://www.openssl.org/source/license.html>.