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