]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/pkeyutl.1
MFV r333789: libpcap 1.9.0 (pre-release)
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / pkeyutl.1
1 .\" Automatically generated by Pod::Man 4.07 (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-03-27" "1.0.2o" "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,
139 pkeyutl \- public key algorithm utility
140 .SH "SYNOPSIS"
141 .IX Header "SYNOPSIS"
142 \&\fBopenssl\fR \fBpkeyutl\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\fR]
148 [\fB\-passin arg\fR]
149 [\fB\-peerkey file\fR]
150 [\fB\-peerform PEM|DER\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\-pkeyopt opt:value\fR]
161 [\fB\-hexdump\fR]
162 [\fB\-asn1parse\fR]
163 [\fB\-engine id\fR]
164 .SH "DESCRIPTION"
165 .IX Header "DESCRIPTION"
166 The \fBpkeyutl\fR command can be used to perform public key operations using
167 any supported algorithm.
168 .SH "COMMAND OPTIONS"
169 .IX Header "COMMAND OPTIONS"
170 .IP "\fB\-in filename\fR" 4
171 .IX Item "-in filename"
172 This specifies the input filename to read data from or standard input
173 if this option is not specified.
174 .IP "\fB\-out filename\fR" 4
175 .IX Item "-out filename"
176 specifies the output filename to write to or standard output by
177 default.
178 .IP "\fB\-inkey file\fR" 4
179 .IX Item "-inkey file"
180 the input key file, by default it should be a private key.
181 .IP "\fB\-keyform PEM|DER\fR" 4
182 .IX Item "-keyform PEM|DER"
183 the key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0
184 .IP "\fB\-passin arg\fR" 4
185 .IX Item "-passin arg"
186 the input key password source. For more information about the format of \fBarg\fR
187 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
188 .IP "\fB\-peerkey file\fR" 4
189 .IX Item "-peerkey file"
190 the peer key file, used by key derivation (agreement) operations.
191 .IP "\fB\-peerform PEM|DER\fR" 4
192 .IX Item "-peerform PEM|DER"
193 the peer key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0
194 .IP "\fB\-engine id\fR" 4
195 .IX Item "-engine id"
196 specifying an engine (by its unique \fBid\fR string) will cause \fBpkeyutl\fR
197 to attempt to obtain a functional reference to the specified engine,
198 thus initialising it if needed. The engine will then be set as the default
199 for all available algorithms.
200 .IP "\fB\-pubin\fR" 4
201 .IX Item "-pubin"
202 the input file is a public key.
203 .IP "\fB\-certin\fR" 4
204 .IX Item "-certin"
205 the input is a certificate containing a public key.
206 .IP "\fB\-rev\fR" 4
207 .IX Item "-rev"
208 reverse the order of the input buffer. This is useful for some libraries
209 (such as CryptoAPI) which represent the buffer in little endian format.
210 .IP "\fB\-sign\fR" 4
211 .IX Item "-sign"
212 sign the input data and output the signed result. This requires
213 a private key.
214 .IP "\fB\-verify\fR" 4
215 .IX Item "-verify"
216 verify the input data against the signature file and indicate if the
217 verification succeeded or failed.
218 .IP "\fB\-verifyrecover\fR" 4
219 .IX Item "-verifyrecover"
220 verify the input data and output the recovered data.
221 .IP "\fB\-encrypt\fR" 4
222 .IX Item "-encrypt"
223 encrypt the input data using a public key.
224 .IP "\fB\-decrypt\fR" 4
225 .IX Item "-decrypt"
226 decrypt the input data using a private key.
227 .IP "\fB\-derive\fR" 4
228 .IX Item "-derive"
229 derive a shared secret using the peer key.
230 .IP "\fB\-hexdump\fR" 4
231 .IX Item "-hexdump"
232 hex dump the output data.
233 .IP "\fB\-asn1parse\fR" 4
234 .IX Item "-asn1parse"
235 asn1parse the output data, this is useful when combined with the
236 \&\fB\-verifyrecover\fR option when an \s-1ASN1\s0 structure is signed.
237 .SH "NOTES"
238 .IX Header "NOTES"
239 The operations and options supported vary according to the key algorithm
240 and its implementation. The OpenSSL operations and options are indicated below.
241 .PP
242 Unless otherwise mentioned all algorithms support the \fBdigest:alg\fR option
243 which specifies the digest in use for sign, verify and verifyrecover operations.
244 The value \fBalg\fR should represent a digest name as used in the
245 \&\fIEVP_get_digestbyname()\fR function for example \fBsha1\fR.
246 This value is used only for sanity-checking the lengths of data passed in to
247 the \fBpkeyutl\fR and for creating the structures that make up the signature
248 (e.g. \fBDigestInfo\fR in \s-1RSASSA\s0 PKCS#1 v1.5 signatures).
249 In case of \s-1RSA, ECDSA\s0 and \s-1DSA\s0 signatures, this utility
250 will not perform hashing on input data but rather use the data directly as
251 input of signature algorithm. Depending on key type, signature type and mode
252 of padding, the maximum acceptable lengths of input data differ. In general,
253 with \s-1RSA\s0 the signed data can't be longer than the key modulus, in case of \s-1ECDSA\s0
254 and \s-1DSA\s0 the data shouldn't be longer than field size, otherwise it will be
255 silently truncated to field size.
256 .PP
257 In other words, if the value of digest is \fBsha1\fR the input should be 20 bytes
258 long binary encoding of \s-1SHA\-1\s0 hash function output.
259 .SH "RSA ALGORITHM"
260 .IX Header "RSA ALGORITHM"
261 The \s-1RSA\s0 algorithm supports encrypt, decrypt, sign, verify and verifyrecover
262 operations in general. Some padding modes only support some of these 
263 operations however.
264 .IP "\-\fBrsa_padding_mode:mode\fR" 4
265 .IX Item "-rsa_padding_mode:mode"
266 This sets the \s-1RSA\s0 padding mode. Acceptable values for \fBmode\fR are \fBpkcs1\fR for
267 PKCS#1 padding, \fBsslv23\fR for SSLv23 padding, \fBnone\fR for no padding, \fBoaep\fR
268 for \fB\s-1OAEP\s0\fR mode, \fBx931\fR for X9.31 mode and \fBpss\fR for \s-1PSS.\s0
269 .Sp
270 In PKCS#1 padding if the message digest is not set then the supplied data is 
271 signed or verified directly instead of using a \fBDigestInfo\fR structure. If a
272 digest is set then the a \fBDigestInfo\fR structure is used and its the length
273 must correspond to the digest type.
274 .Sp
275 For \fBoeap\fR mode only encryption and decryption is supported.
276 .Sp
277 For \fBx931\fR if the digest type is set it is used to format the block data
278 otherwise the first byte is used to specify the X9.31 digest \s-1ID.\s0 Sign,
279 verify and verifyrecover are can be performed in this mode.
280 .Sp
281 For \fBpss\fR mode only sign and verify are supported and the digest type must be
282 specified.
283 .IP "\fBrsa_pss_saltlen:len\fR" 4
284 .IX Item "rsa_pss_saltlen:len"
285 For \fBpss\fR mode only this option specifies the salt length. Two special values
286 are supported: \-1 sets the salt length to the digest length. When signing \-2
287 sets the salt length to the maximum permissible value. When verifying \-2 causes
288 the salt length to be automatically determined based on the \fB\s-1PSS\s0\fR block
289 structure.
290 .SH "DSA ALGORITHM"
291 .IX Header "DSA ALGORITHM"
292 The \s-1DSA\s0 algorithm supports signing and verification operations only. Currently
293 there are no additional options other than \fBdigest\fR. Only the \s-1SHA1\s0
294 digest can be used and this digest is assumed by default.
295 .SH "DH ALGORITHM"
296 .IX Header "DH ALGORITHM"
297 The \s-1DH\s0 algorithm only supports the derivation operation and no additional
298 options.
299 .SH "EC ALGORITHM"
300 .IX Header "EC ALGORITHM"
301 The \s-1EC\s0 algorithm supports sign, verify and derive operations. The sign and
302 verify operations use \s-1ECDSA\s0 and derive uses \s-1ECDH.\s0 Currently there are no
303 additional options other than \fBdigest\fR. Only the \s-1SHA1\s0 digest can be used and
304 this digest is assumed by default.
305 .SH "EXAMPLES"
306 .IX Header "EXAMPLES"
307 Sign some data using a private key:
308 .PP
309 .Vb 1
310 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig
311 .Ve
312 .PP
313 Recover the signed data (e.g. if an \s-1RSA\s0 key is used):
314 .PP
315 .Vb 1
316 \& openssl pkeyutl \-verifyrecover \-in sig \-inkey key.pem
317 .Ve
318 .PP
319 Verify the signature (e.g. a \s-1DSA\s0 key):
320 .PP
321 .Vb 1
322 \& openssl pkeyutl \-verify \-in file \-sigfile sig \-inkey key.pem
323 .Ve
324 .PP
325 Sign data using a message digest value (this is currently only valid for \s-1RSA\s0):
326 .PP
327 .Vb 1
328 \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig \-pkeyopt digest:sha256
329 .Ve
330 .PP
331 Derive a shared secret value:
332 .PP
333 .Vb 1
334 \& openssl pkeyutl \-derive \-inkey key.pem \-peerkey pubkey.pem \-out secret
335 .Ve
336 .SH "SEE ALSO"
337 .IX Header "SEE ALSO"
338 \&\fIgenpkey\fR\|(1), \fIpkey\fR\|(1), \fIrsautl\fR\|(1)
339 \&\fIdgst\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1)