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