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