Update docs with algorithm options.
[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<-in file>]
11 [B<-out file>]
12 [B<-sigfile file>]
13 [B<-inkey file>]
14 [B<-keyform PEM|DER>]
15 [B<-peerkey file>]
16 [B<-peerform PEM|DER>]
17 [B<-pubin>]
18 [B<-certin>]
19 [B<-rev>]
20 [B<-sign>]
21 [B<-verify>]
22 [B<-verifyrecover>]
23 [B<-encrypt>]
24 [B<-decrypt>]
25 [B<-derive>]
26 [B<-pkeyopt opt:value>]
27 [B<-hexdump>]
28 [B<-asn1parse>]
29
30 =head1 DESCRIPTION
31
32 The B<pkeyutl> command can be used to perform public key operations using
33 any supported algorithm.
34
35 =head1 COMMAND OPTIONS
36
37 =over 4
38
39 =item B<-in filename>
40
41 This specifies the input filename to read data from or standard input
42 if this option is not specified.
43
44 =item B<-out filename>
45
46 specifies the output filename to write to or standard output by
47 default.
48
49 =item B<-inkey file>
50
51 the input key file, by default it should be a private key.
52
53 =item B<-keyform PEM|DER>
54
55 the key format PEM or DER.
56
57 =item B<-peerkey file>
58
59 the peer key file, used by key derivation (agreement) operations.
60
61 =item B<-peerform PEM|DER>
62
63 the peer key format PEM or DER.
64
65 =item B<-pubin>
66
67 the input file is a public key. 
68
69 =item B<-certin>
70
71 the input is a certificate containing a public key. 
72
73 =item B<-rev>
74
75 reverse the order of the input buffer. This is useful for some libraries
76 (such as CryptoAPI) which represent the buffer in little endian format.
77
78 =item B<-sign>
79
80 sign the input data and output the signed result. This requires
81 a private key.
82
83 =item B<-verify>
84
85 verify the input data against the signature file and indicate if the
86 verification succeeded or failed.
87
88 =item B<-verifyrecover>
89
90 verify the input data and output the recovered data.
91
92 =item B<-encrypt>
93
94 encrypt the input data using a public key.
95
96 =item B<-decrypt>
97
98 decrypt the input data using a private key.
99
100 =item B<-derive>
101
102 derive a shared secret using the peer key.
103
104 =item B<-hexdump>
105
106 hex dump the output data.
107
108 =item B<-asn1parse>
109
110 asn1parse the output data, this is useful when combined with the
111 B<-verifyrecover> option when an ASN1 structure is signed.
112
113 =back
114
115 =head1 NOTES
116
117 The operations and options supported vary according to the key algorithm
118 and its implementation. The OpenSSL operations and options are indicated below.
119
120 Unless otherwise mentioned all algorithms support the B<digest:alg> option
121 which specifies the digest in use for sign, verify and verifyrecover operations.
122 The value B<alg> should represent a digest name as used in the
123 EVP_get_digestbyname() function for example B<sha1>.
124
125 =head1 RSA ALGORITHM
126
127 The RSA algorithm supports encrypt, decrypt, sign, verify and verifyrecover
128 operations in general. Some padding modes only support some of these 
129 operations however.
130
131 =over 4
132
133 =item -B<rsa_padding_mode:mode>
134
135 This sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for
136 PKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep>
137 for B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS.
138
139 In PKCS#1 padding if the message digest is not set then the supplied data is 
140 signed or verified directly instead of using a B<DigestInfo> structure. If a
141 digest is set then the a B<DigestInfo> structure is used and its the length
142 must correspond to the digest type.
143
144 For B<oeap> mode only encryption and decryption is supported.
145
146 For B<x931> if the digest type is set it is used to format the block data
147 otherwise the first byte is used to specify the X9.31 digest ID. Sign,
148 verify and verifyrecover are can be performed in this mode.
149
150 For B<pss> mode only sign and verify are supported and the digest type must be
151 specified.
152
153 =item B<rsa_pss_saltlen:len>
154
155 For B<pss> mode only this option specifies the salt length. Two special
156 values are supported: -1 sets the salt length to the digest length. When
157 signing -2 sets the salt length to the maximum permissible value. When
158 verifying -2 causes the salt length to be automatically determined based
159 on the B<PSS> block structure.
160
161 =back
162
163 =head1 DSA ALGORITHM
164
165 The DSA algorithm supports signing and verification operations only. Currently
166 there are no additional options other than B<digest>. Only the SHA1
167 digest can be used and this digest is assumed by default.
168
169 =head1 DH ALGORITHM
170
171 The DH algorithm only supports the derivation operation and no additional
172 options.
173
174 =head1 EC ALGORITHM
175
176 The EC algorithm supports sign, verify and derive operations. The sign and
177 verify operations use ECDSA and derive uses ECDH. Currently there are no
178 additional options other than B<digest>. Only the SHA1 digest can be used and
179 this digest is assumed by default.
180
181 =head1 EXAMPLES
182
183 Sign some data using a private key:
184
185  openssl pkeyutl -sign -in file -inkey key.pem -out sig
186
187 Recover the signed data (e.g. if an RSA key is used):
188
189  openssl pkeyutl -verifyrecover -in sig -inkey key.pem
190
191 Verify the signature (e.g. a DSA key):
192
193  openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem
194
195 Sign data using a message digest value (this is currently only valid for RSA):
196
197  openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256
198
199 Derive a shared secret value:
200
201  openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret
202
203 =head1 SEE ALSO
204
205 L<genpkey(1)|genpkey(1)>, L<pkey(1)|pkey(1)>, L<rsautl(1)|rsautl(1)>
206 L<dgst(1)|dgst(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)>