GH628: Add -help to all apps docs.
[openssl.git] / doc / apps / pkeyutl.pod
1 =pod
2
3 =head1 NAME
4
5 pkeyutl - public key algorithm utility
6
7 =head1 SYNOPSIS
8
9 B<openssl> B<pkeyutl>
10 [B<-help>]
11 [B<-in file>]
12 [B<-out file>]
13 [B<-sigfile file>]
14 [B<-inkey file>]
15 [B<-keyform PEM|DER|ENGINE>]
16 [B<-passin arg>]
17 [B<-peerkey file>]
18 [B<-peerform PEM|DER|ENGINE>]
19 [B<-pubin>]
20 [B<-certin>]
21 [B<-rev>]
22 [B<-sign>]
23 [B<-verify>]
24 [B<-verifyrecover>]
25 [B<-encrypt>]
26 [B<-decrypt>]
27 [B<-derive>]
28 [B<-pkeyopt opt:value>]
29 [B<-hexdump>]
30 [B<-asn1parse>]
31 [B<-engine id>]
32
33 =head1 DESCRIPTION
34
35 The B<pkeyutl> command can be used to perform public key operations using
36 any supported algorithm.
37
38 =head1 COMMAND OPTIONS
39
40 =over 4
41
42 =item B<-help>
43
44 Print out a usage message.
45
46 =item B<-in filename>
47
48 This specifies the input filename to read data from or standard input
49 if this option is not specified.
50
51 =item B<-out filename>
52
53 specifies the output filename to write to or standard output by
54 default.
55
56 =item B<-inkey file>
57
58 the input key file, by default it should be a private key.
59
60 =item B<-keyform PEM|DER|ENGINE>
61
62 the key format PEM, DER or ENGINE.
63
64 =item B<-passin arg>
65
66 the input key password source. For more information about the format of B<arg>
67 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
68
69
70 =item B<-peerkey file>
71
72 the peer key file, used by key derivation (agreement) operations.
73
74 =item B<-peerform PEM|DER|ENGINE>
75
76 the peer key format PEM, DER or ENGINE.
77
78 =item B<-engine id>
79
80 specifying an engine (by its unique B<id> string) will cause B<pkeyutl>
81 to attempt to obtain a functional reference to the specified engine,
82 thus initialising it if needed. The engine will then be set as the default
83 for all available algorithms.
84
85
86 =item B<-pubin>
87
88 the input file is a public key. 
89
90 =item B<-certin>
91
92 the input is a certificate containing a public key. 
93
94 =item B<-rev>
95
96 reverse the order of the input buffer. This is useful for some libraries
97 (such as CryptoAPI) which represent the buffer in little endian format.
98
99 =item B<-sign>
100
101 sign the input data and output the signed result. This requires
102 a private key.
103
104 =item B<-verify>
105
106 verify the input data against the signature file and indicate if the
107 verification succeeded or failed.
108
109 =item B<-verifyrecover>
110
111 verify the input data and output the recovered data.
112
113 =item B<-encrypt>
114
115 encrypt the input data using a public key.
116
117 =item B<-decrypt>
118
119 decrypt the input data using a private key.
120
121 =item B<-derive>
122
123 derive a shared secret using the peer key.
124
125 =item B<-hexdump>
126
127 hex dump the output data.
128
129 =item B<-asn1parse>
130
131 asn1parse the output data, this is useful when combined with the
132 B<-verifyrecover> option when an ASN1 structure is signed.
133
134 =back
135
136 =head1 NOTES
137
138 The operations and options supported vary according to the key algorithm
139 and its implementation. The OpenSSL operations and options are indicated below.
140
141 Unless otherwise mentioned all algorithms support the B<digest:alg> option
142 which specifies the digest in use for sign, verify and verifyrecover operations.
143 The value B<alg> should represent a digest name as used in the
144 EVP_get_digestbyname() function for example B<sha1>.
145 This value is used only for sanity-checking the lengths of data passed in to
146 the B<pkeyutl> and for creating the structures that make up the signature
147 (e.g. B<DigestInfo> in RSASSA PKCS#1 v1.5 signatures).
148 In case of RSA, ECDSA and DSA signatures, this utility
149 will not perform hashing on input data but rather use the data directly as
150 input of signature algorithm. Depending on key type, signature type and mode
151 of padding, the maximum acceptable lengths of input data differ. In general,
152 with RSA the signed data can't be longer than the key modulus, in case of ECDSA
153 and DSA the data shouldn't be longer than field size, otherwise it will be
154 silently truncated to field size.
155
156 In other words, if the value of digest is B<sha1> the input should be 20 bytes
157 long binary encoding of SHA-1 hash function output.
158
159 =head1 RSA ALGORITHM
160
161 The RSA algorithm generally supports the encrypt, decrypt, sign,
162 verify and verifyrecover operations. However, some padding modes
163 support only a subset of these operations. The following additional
164 B<pkeyopt> values are supported:
165
166 =over 4
167
168 =item B<rsa_padding_mode:mode>
169
170 This sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for
171 PKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep>
172 for B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS.
173
174 In PKCS#1 padding if the message digest is not set then the supplied data is 
175 signed or verified directly instead of using a B<DigestInfo> structure. If a
176 digest is set then the a B<DigestInfo> structure is used and its the length
177 must correspond to the digest type.
178
179 For B<oaep> mode only encryption and decryption is supported.
180
181 For B<x931> if the digest type is set it is used to format the block data
182 otherwise the first byte is used to specify the X9.31 digest ID. Sign,
183 verify and verifyrecover are can be performed in this mode.
184
185 For B<pss> mode only sign and verify are supported and the digest type must be
186 specified.
187
188 =item B<rsa_pss_saltlen:len>
189
190 For B<pss> mode only this option specifies the salt length. Two special values
191 are supported: -1 sets the salt length to the digest length. When signing -2
192 sets the salt length to the maximum permissible value. When verifying -2 causes
193 the salt length to be automatically determined based on the B<PSS> block
194 structure.
195
196 =back
197
198 =head1 DSA ALGORITHM
199
200 The DSA algorithm supports signing and verification operations only. Currently
201 there are no additional options other than B<digest>. Only the SHA1
202 digest can be used and this digest is assumed by default.
203
204 =head1 DH ALGORITHM
205
206 The DH algorithm only supports the derivation operation and no additional
207 options.
208
209 =head1 EC ALGORITHM
210
211 The EC algorithm supports sign, verify and derive operations. The sign and
212 verify operations use ECDSA and derive uses ECDH. Currently there are no
213 additional options other than B<digest>. Only the SHA1 digest can be used and
214 this digest is assumed by default.
215
216 =head1 EXAMPLES
217
218 Sign some data using a private key:
219
220  openssl pkeyutl -sign -in file -inkey key.pem -out sig
221
222 Recover the signed data (e.g. if an RSA key is used):
223
224  openssl pkeyutl -verifyrecover -in sig -inkey key.pem
225
226 Verify the signature (e.g. a DSA key):
227
228  openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem
229
230 Sign data using a message digest value (this is currently only valid for RSA):
231
232  openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256
233
234 Derive a shared secret value:
235
236  openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret
237
238 =head1 SEE ALSO
239
240 L<genpkey(1)>, L<pkey(1)>, L<rsautl(1)>
241 L<dgst(1)>, L<rsa(1)>, L<genrsa(1)>