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