6 dgst - perform digest operations
24 [B<-prverify filename>]
25 [B<-signature filename>]
28 [B<-fips-fingerprint>]
34 B<openssl> I<digest> [B<...>]
38 The digest functions output the message digest of a supplied file or files
39 in hexadecimal. The digest functions also generate and verify digital
40 signatures using message digests.
42 The generic name, B<dgst>, may be used with an option specifying the
44 The default digest is I<sha256>.
45 A supported I<digest> name may also be used as the command name.
46 To see the list of supported algorithms, use the I<list --digest-commands>
55 Print out a usage message.
59 Specifies name of a supported digest to be used. To see the list of
60 supported digests, use the command I<list --digest-commands>.
64 Print out the digest in two digit groups separated by colons, only relevant if
65 B<hex> format output is used.
69 Print out BIO debugging information.
73 Prints out a list of supported message digests.
77 Digest is to be output as a hex dump. This is the default case for a "normal"
78 digest as opposed to a digital signature. See NOTES below for digital
79 signatures using B<-hex>.
83 Output the digest or signature in binary form.
87 Output the digest in the "coreutils" format, including newlines.
88 Used by programs like B<sha1sum>.
90 =item B<-out filename>
92 Filename to output to, or standard output by default.
94 =item B<-sign filename>
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 B<pkeyutl> command
100 =item B<-keyform arg>
102 Specifies the key format to sign digest with. The DER, PEM, P12,
103 and ENGINE formats are supported.
105 =item B<-sigopt nm:v>
107 Pass options to the signature algorithm during sign or verify operations.
108 Names and values of these options are algorithm-specific.
112 The private key password source. For more information about the format of B<arg>
113 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
115 =item B<-verify filename>
117 Verify the signature using the public key in "filename".
118 The output is either "Verification OK" or "Verification Failure".
120 =item B<-prverify filename>
122 Verify the signature using the private key in "filename".
124 =item B<-signature filename>
126 The actual signature to verify.
130 Create a hashed MAC using "key".
134 Create MAC (keyed Message Authentication Code). The most popular MAC
135 algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
136 which are not based on hash, for instance B<gost-mac> algorithm,
137 supported by B<ccgost> engine. MAC keys and other options should be set
138 via B<-macopt> parameter.
140 =item B<-macopt nm:v>
142 Passes options to MAC algorithm, specified by B<-mac> key.
143 Following options are supported by both by B<HMAC> and B<gost-mac>:
149 Specifies MAC key as alphanumeric string (use if key contain printable
150 characters only). String length must conform to any restrictions of
151 the MAC algorithm for example exactly 32 chars for gost-mac.
153 =item B<hexkey:string>
155 Specifies MAC key in hexadecimal form (two hex digits per byte).
156 Key length must conform to any restrictions of the MAC algorithm
157 for example exactly 32 chars for gost-mac.
161 =item B<-rand file...>
163 A file or files containing random data used to seed the random number
165 Multiple files can be specified separated by an OS-dependent character.
166 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
169 =item [B<-writerand file>]
171 Writes random data to the specified I<file> upon exit.
172 This can be used with a subsequent B<-rand> flag.
174 =item B<-fips-fingerprint>
176 Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
180 Use engine B<id> for operations (including private key storage).
181 This engine is not used as source for digest algorithms, unless it is
182 also specified in the configuration file or B<-engine_impl> is also
185 =item B<-engine_impl>
187 When used with the B<-engine> option, it specifies to also use
188 engine B<id> for digest operations.
192 File or files to digest. If no files are specified then standard input is
200 To create a hex-encoded message digest of a file:
201 openssl dgst -md5 -hex file.txt
203 To sign a file using SHA-256 with binary file output:
204 openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
206 To verify a signature:
207 openssl dgst -sha256 -verify publickey.pem \
208 -signature signature.sign \
214 The digest mechanisms that are available will depend on the options
215 used when building OpenSSL.
216 The B<list digest-commands> command can be used to list them.
218 New or agile applications should use probably use SHA-256. Other digests,
219 particularly SHA-1 and MD5, are still widely used for interoperating
220 with existing formats and protocols.
222 When signing a file, B<dgst> will automatically determine the algorithm
223 (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
224 When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
225 itself, not the related data to identify the signer and algorithm used in
226 formats such as x.509, CMS, and S/MIME.
228 A source of random numbers is required for certain signing algorithms, in
229 particular ECDSA and DSA.
231 The signing and verify options should only be used if a single file is
232 being signed or verified.
234 Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
235 or similar program to transform the hex signature into a binary signature
236 prior to verification.
240 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
241 The FIPS-related options were removed in OpenSSL 1.1.0.
245 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
247 Licensed under the OpenSSL license (the "License"). You may not use
248 this file except in compliance with the License. You can obtain a copy
249 in the file LICENSE in the source distribution or at
250 L<https://www.openssl.org/source/license.html>.