Update man3/verify documentation, error text
[openssl.git] / doc / man1 / openssl-dgst.pod.in
1 =pod
2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
3
4 =head1 NAME
5
6 openssl-dgst - perform digest operations
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<dgst>|I<digest>
11 [B<-I<digest>>]
12 [B<-help>]
13 [B<-c>]
14 [B<-d>]
15 [B<-list>]
16 [B<-hex>]
17 [B<-binary>]
18 [B<-r>]
19 [B<-out> I<filename>]
20 [B<-sign> I<filename>]
21 [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
22 [B<-passin> I<arg>]
23 [B<-verify> I<filename>]
24 [B<-prverify> I<filename>]
25 [B<-signature> I<filename>]
26 [B<-sigopt> I<nm>:I<v>]
27 [B<-hmac> I<key>]
28 [B<-fips-fingerprint>]
29 [B<-engine> I<id>]
30 [B<-engine_impl> I<id>]
31 {- $OpenSSL::safe::opt_engine_synopsis -}
32 {- $OpenSSL::safe::opt_r_synopsis -}
33 [I<file> ...]
34
35 =head1 DESCRIPTION
36
37 This command output the message digest of a supplied file or files
38 in hexadecimal, and also generates and verifies digital
39 signatures using message digests.
40
41 The generic name, B<openssl dgst>, may be used with an option specifying the
42 algorithm to be used.
43 The default digest is B<sha256>.
44 A supported I<digest> name may also be used as the sub-command name.
45 To see the list of supported algorithms, use C<openssl list -digest-commands>
46
47 =head1 OPTIONS
48
49 =over 4
50
51 =item B<-help>
52
53 Print out a usage message.
54
55 =item B<-I<digest>>
56
57 Specifies name of a supported digest to be used. To see the list of
58 supported digests, use the command C<list --digest-commands>.
59
60 =item B<-c>
61
62 Print out the digest in two digit groups separated by colons, only relevant if
63 the B<-hex> option is given as well.
64
65 =item B<-d>
66
67 Print out BIO debugging information.
68
69 =item B<-list>
70
71 Prints out a list of supported message digests.
72
73 =item B<-hex>
74
75 Digest is to be output as a hex dump. This is the default case for a "normal"
76 digest as opposed to a digital signature.  See NOTES below for digital
77 signatures using B<-hex>.
78
79 =item B<-binary>
80
81 Output the digest or signature in binary form.
82
83 =item B<-r>
84
85 =for openssl foreign manual sha1sum(1)
86
87 Output the digest in the "coreutils" format, including newlines.
88 Used by programs like L<sha1sum(1)>.
89
90 =item B<-out> I<filename>
91
92 Filename to output to, or standard output by default.
93
94 =item B<-sign> I<filename>
95
96 Digitally sign the digest using the private key in "filename". Note this option
97 does not support Ed25519 or Ed448 private keys. Use the L<openssl-pkeyutl(1)>
98 command instead for this.
99
100 =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
101
102 The format of the key to sign with; the default is B<PEM>.
103 See L<openssl(1)/Format Options> for details.
104
105 =item B<-sigopt> I<nm>:I<v>
106
107 Pass options to the signature algorithm during sign or verify operations.
108 Names and values of these options are algorithm-specific.
109
110 =item B<-passin> I<arg>
111
112 The private key password source. For more information about the format of I<arg>
113 see L<openssl(1)/Pass Phrase Options>.
114
115 =item B<-verify> I<filename>
116
117 Verify the signature using the public key in "filename".
118 The output is either "Verification OK" or "Verification Failure".
119
120 =item B<-prverify> I<filename>
121
122 Verify the signature using the private key in "filename".
123
124 =item B<-signature> I<filename>
125
126 The actual signature to verify.
127
128 =item B<-hmac> I<key>
129
130 Create a hashed MAC using "key".
131
132 The L<openssl-mac(1)> command should be preferred to using this command line
133 option.
134
135 =item B<-mac> I<alg>
136
137 Create MAC (keyed Message Authentication Code). The most popular MAC
138 algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
139 which are not based on hash, for instance B<gost-mac> algorithm,
140 supported by the B<gost> engine. MAC keys and other options should be set
141 via B<-macopt> parameter.
142
143 The L<openssl-mac(1)> command should be preferred to using this command line
144 option.
145
146 =item B<-macopt> I<nm>:I<v>
147
148 Passes options to MAC algorithm, specified by B<-mac> key.
149 Following options are supported by both by B<HMAC> and B<gost-mac>:
150
151 =over 4
152
153 =item B<key>:I<string>
154
155 Specifies MAC key as alphanumeric string (use if key contain printable
156 characters only). String length must conform to any restrictions of
157 the MAC algorithm for example exactly 32 chars for gost-mac.
158
159 =item B<hexkey>:I<string>
160
161 Specifies MAC key in hexadecimal form (two hex digits per byte).
162 Key length must conform to any restrictions of the MAC algorithm
163 for example exactly 32 chars for gost-mac.
164
165 =back
166
167 The L<openssl-mac(1)> command should be preferred to using this command line
168 option.
169
170 =item B<-fips-fingerprint>
171
172 Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
173
174 {- $OpenSSL::safe::opt_r_item -}
175
176 {- $OpenSSL::safe::opt_engine_item -}
177 The engine is not used for digests unless the B<-engine_impl> option is
178 used or it is configured to do so, see L<config(5)/Engine Configuration Module>.
179
180 =item B<-engine_impl>
181
182 When used with the B<-engine> option, it specifies to also use
183 engine I<id> for digest operations.
184
185 =item I<file> ...
186
187 File or files to digest. If no files are specified then standard input is
188 used.
189
190 =back
191
192
193 =head1 EXAMPLES
194
195 To create a hex-encoded message digest of a file:
196  openssl dgst -md5 -hex file.txt
197
198 To sign a file using SHA-256 with binary file output:
199  openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
200
201 To verify a signature:
202  openssl dgst -sha256 -verify publickey.pem \
203  -signature signature.sign \
204  file.txt
205
206
207 =head1 NOTES
208
209 The digest mechanisms that are available will depend on the options
210 used when building OpenSSL.
211 The C<openssl list -digest-commands> command can be used to list them.
212
213 New or agile applications should use probably use SHA-256. Other digests,
214 particularly SHA-1 and MD5, are still widely used for interoperating
215 with existing formats and protocols.
216
217 When signing a file, this command will automatically determine the algorithm
218 (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
219 When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
220 itself, not the related data to identify the signer and algorithm used in
221 formats such as x.509, CMS, and S/MIME.
222
223 A source of random numbers is required for certain signing algorithms, in
224 particular ECDSA and DSA.
225
226 The signing and verify options should only be used if a single file is
227 being signed or verified.
228
229 Hex signatures cannot be verified using B<openssl>.  Instead, use "xxd -r"
230 or similar program to transform the hex signature into a binary signature
231 prior to verification.
232
233 The L<openssl-mac(1)> command is preferred over the B<-hmac>, B<-mac> and
234 B<-macopt> command line options.
235
236 =head1 SEE ALSO
237
238 L<openssl-mac(1)>
239
240 =head1 HISTORY
241
242 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
243 The FIPS-related options were removed in OpenSSL 1.1.0.
244
245 =head1 COPYRIGHT
246
247 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
248
249 Licensed under the Apache License 2.0 (the "License").  You may not use
250 this file except in compliance with the License.  You can obtain a copy
251 in the file LICENSE in the source distribution or at
252 L<https://www.openssl.org/source/license.html>.
253
254 =cut