2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-dgst - perform digest operations
10 B<openssl> B<dgst>|I<digest>
21 [B<-sign> I<filename>]
22 [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
24 [B<-verify> I<filename>]
25 [B<-prverify> I<filename>]
26 [B<-signature> I<filename>]
27 [B<-sigopt> I<nm>:I<v>]
30 [B<-macopt> I<nm>:I<v>]
31 [B<-fips-fingerprint>]
32 {- $OpenSSL::safe::opt_engine_synopsis -}
33 [B<-engine_impl> I<id>]
34 {- $OpenSSL::safe::opt_r_synopsis -}
35 {- $OpenSSL::safe::opt_provider_synopsis -}
40 This command output the message digest of a supplied file or files
41 in hexadecimal, and also generates and verifies digital
42 signatures using message digests.
44 The generic name, B<openssl dgst>, may be used with an option specifying the
46 The default digest is B<sha256>.
47 A supported I<digest> name may also be used as the sub-command name.
48 To see the list of supported algorithms, use C<openssl list -digest-commands>
56 Print out a usage message.
60 Specifies name of a supported digest to be used. To see the list of
61 supported digests, use the command C<list --digest-commands>.
65 Print out the digest in two digit groups separated by colons, only relevant if
66 the B<-hex> option is given as well.
68 =item B<-d>, B<-debug>
70 Print out BIO debugging information.
74 Prints out a list of supported message digests.
78 Digest is to be output as a hex dump. This is the default case for a "normal"
79 digest as opposed to a digital signature. See NOTES below for digital
80 signatures using B<-hex>.
84 Output the digest or signature in binary form.
88 =for openssl foreign manual sha1sum(1)
90 Output the digest in the "coreutils" format, including newlines.
91 Used by programs like L<sha1sum(1)>.
93 =item B<-out> I<filename>
95 Filename to output to, or standard output by default.
97 =item B<-sign> I<filename>
99 Digitally sign the digest using the private key in "filename". Note this option
100 does not support Ed25519 or Ed448 private keys. Use the L<openssl-pkeyutl(1)>
101 command instead for this.
103 =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
105 The format of the key to sign with; the default is B<PEM>.
106 The only value with effect is B<ENGINE>; all others have become obsolete.
107 See L<openssl(1)/Format Options> for details.
109 =item B<-sigopt> I<nm>:I<v>
111 Pass options to the signature algorithm during sign or verify operations.
112 Names and values of these options are algorithm-specific.
114 =item B<-passin> I<arg>
116 The private key password source. For more information about the format of I<arg>
117 see L<openssl(1)/Pass Phrase Options>.
119 =item B<-verify> I<filename>
121 Verify the signature using the public key in "filename".
122 The output is either "Verification OK" or "Verification Failure".
124 =item B<-prverify> I<filename>
126 Verify the signature using the private key in "filename".
128 =item B<-signature> I<filename>
130 The actual signature to verify.
132 =item B<-hmac> I<key>
134 Create a hashed MAC using "key".
136 The L<openssl-mac(1)> command should be preferred to using this command line
141 Create MAC (keyed Message Authentication Code). The most popular MAC
142 algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
143 which are not based on hash, for instance B<gost-mac> algorithm,
144 supported by the B<gost> engine. MAC keys and other options should be set
145 via B<-macopt> parameter.
147 The L<openssl-mac(1)> command should be preferred to using this command line
150 =item B<-macopt> I<nm>:I<v>
152 Passes options to MAC algorithm, specified by B<-mac> key.
153 Following options are supported by both by B<HMAC> and B<gost-mac>:
157 =item B<key>:I<string>
159 Specifies MAC key as alphanumeric string (use if key contain printable
160 characters only). String length must conform to any restrictions of
161 the MAC algorithm for example exactly 32 chars for gost-mac.
163 =item B<hexkey>:I<string>
165 Specifies MAC key in hexadecimal form (two hex digits per byte).
166 Key length must conform to any restrictions of the MAC algorithm
167 for example exactly 32 chars for gost-mac.
171 The L<openssl-mac(1)> command should be preferred to using this command line
174 =item B<-fips-fingerprint>
176 Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
178 {- $OpenSSL::safe::opt_r_item -}
180 {- $OpenSSL::safe::opt_engine_item -}
181 The engine is not used for digests unless the B<-engine_impl> option is
182 used or it is configured to do so, see L<config(5)/Engine Configuration Module>.
184 =item B<-engine_impl> I<id>
186 When used with the B<-engine> option, it specifies to also use
187 engine I<id> for digest operations.
189 {- $OpenSSL::safe::opt_provider_item -}
193 File or files to digest. If no files are specified then standard input is
201 To create a hex-encoded message digest of a file:
202 openssl dgst -md5 -hex file.txt
204 To sign a file using SHA-256 with binary file output:
205 openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
207 To verify a signature:
208 openssl dgst -sha256 -verify publickey.pem \
209 -signature signature.sign \
215 The digest mechanisms that are available will depend on the options
216 used when building OpenSSL.
217 The C<openssl list -digest-commands> command can be used to list them.
219 New or agile applications should use probably use SHA-256. Other digests,
220 particularly SHA-1 and MD5, are still widely used for interoperating
221 with existing formats and protocols.
223 When signing a file, this command will automatically determine the algorithm
224 (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
225 When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
226 itself, not the related data to identify the signer and algorithm used in
227 formats such as x.509, CMS, and S/MIME.
229 A source of random numbers is required for certain signing algorithms, in
230 particular ECDSA and DSA.
232 The signing and verify options should only be used if a single file is
233 being signed or verified.
235 Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
236 or similar program to transform the hex signature into a binary signature
237 prior to verification.
239 The L<openssl-mac(1)> command is preferred over the B<-hmac>, B<-mac> and
240 B<-macopt> command line options.
248 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
249 The FIPS-related options were removed in OpenSSL 1.1.0.
251 All B<-keyform> values except B<ENGINE> have become obsolete in OpenSSL 3.0.0
256 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
258 Licensed under the Apache License 2.0 (the "License"). You may not use
259 this file except in compliance with the License. You can obtain a copy
260 in the file LICENSE in the source distribution or at
261 L<https://www.openssl.org/source/license.html>.