1DGST(1) OpenSSL DGST(1)
2
3
4
6 openssl-dgst, dgst - perform digest operations
7
9 openssl dgst [-digest] [-help] [-c] [-d] [-list] [-hex] [-binary] [-r]
10 [-out filename] [-sign filename] [-keyform arg] [-passin arg] [-verify
11 filename] [-prverify filename] [-signature filename] [-sigopt nm:v]
12 [-hmac key] [-fips-fingerprint] [-rand file...] [-engine id]
13 [-engine_impl] [file...]
14
15 openssl digest [...]
16
18 The digest functions output the message digest of a supplied file or
19 files in hexadecimal. The digest functions also generate and verify
20 digital signatures using message digests.
21
22 The generic name, dgst, may be used with an option specifying the
23 algorithm to be used. The default digest is sha256. A supported
24 digest name may also be used as the command name. To see the list of
25 supported algorithms, use the list --digest-commands command.
26
28 -help
29 Print out a usage message.
30
31 -digest
32 Specifies name of a supported digest to be used. To see the list of
33 supported digests, use the command list --digest-commands.
34
35 -c Print out the digest in two digit groups separated by colons, only
36 relevant if hex format output is used.
37
38 -d Print out BIO debugging information.
39
40 -list
41 Prints out a list of supported message digests.
42
43 -hex
44 Digest is to be output as a hex dump. This is the default case for
45 a "normal" digest as opposed to a digital signature. See NOTES
46 below for digital signatures using -hex.
47
48 -binary
49 Output the digest or signature in binary form.
50
51 -r Output the digest in the "coreutils" format, including newlines.
52 Used by programs like sha1sum.
53
54 -out filename
55 Filename to output to, or standard output by default.
56
57 -sign filename
58 Digitally sign the digest using the private key in "filename". Note
59 this option does not support Ed25519 or Ed448 private keys.
60
61 -keyform arg
62 Specifies the key format to sign digest with. The DER, PEM, P12,
63 and ENGINE formats are supported.
64
65 -sigopt nm:v
66 Pass options to the signature algorithm during sign or verify
67 operations. Names and values of these options are algorithm-
68 specific.
69
70 -passin arg
71 The private key password source. For more information about the
72 format of arg see "Pass Phrase Options" in openssl(1).
73
74 -verify filename
75 Verify the signature using the public key in "filename". The
76 output is either "Verification OK" or "Verification Failure".
77
78 -prverify filename
79 Verify the signature using the private key in "filename".
80
81 -signature filename
82 The actual signature to verify.
83
84 -hmac key
85 Create a hashed MAC using "key".
86
87 -mac alg
88 Create MAC (keyed Message Authentication Code). The most popular
89 MAC algorithm is HMAC (hash-based MAC), but there are other MAC
90 algorithms which are not based on hash, for instance gost-mac
91 algorithm, supported by ccgost engine. MAC keys and other options
92 should be set via -macopt parameter.
93
94 -macopt nm:v
95 Passes options to MAC algorithm, specified by -mac key. Following
96 options are supported by both by HMAC and gost-mac:
97
98 key:string
99 Specifies MAC key as alphanumeric string (use if key contain
100 printable characters only). String length must conform to any
101 restrictions of the MAC algorithm for example exactly 32 chars
102 for gost-mac.
103
104 hexkey:string
105 Specifies MAC key in hexadecimal form (two hex digits per
106 byte). Key length must conform to any restrictions of the MAC
107 algorithm for example exactly 32 chars for gost-mac.
108
109 -rand file...
110 A file or files containing random data used to seed the random
111 number generator. Multiple files can be specified separated by an
112 OS-dependent character. The separator is ; for MS-Windows, , for
113 OpenVMS, and : for all others.
114
115 [-writerand file]
116 Writes random data to the specified file upon exit. This can be
117 used with a subsequent -rand flag.
118
119 -fips-fingerprint
120 Compute HMAC using a specific key for certain OpenSSL-FIPS
121 operations.
122
123 -engine id
124 Use engine id for operations (including private key storage). This
125 engine is not used as source for digest algorithms, unless it is
126 also specified in the configuration file or -engine_impl is also
127 specified.
128
129 -engine_impl
130 When used with the -engine option, it specifies to also use engine
131 id for digest operations.
132
133 file...
134 File or files to digest. If no files are specified then standard
135 input is used.
136
138 To create a hex-encoded message digest of a file:
139 openssl dgst -md5 -hex file.txt
140
141 To sign a file using SHA-256 with binary file output:
142 openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
143
144 To verify a signature:
145 openssl dgst -sha256 -verify publickey.pem \
146 -signature signature.sign \
147 file.txt
148
150 The digest mechanisms that are available will depend on the options
151 used when building OpenSSL. The list digest-commands command can be
152 used to list them.
153
154 New or agile applications should use probably use SHA-256. Other
155 digests, particularly SHA-1 and MD5, are still widely used for
156 interoperating with existing formats and protocols.
157
158 When signing a file, dgst will automatically determine the algorithm
159 (RSA, ECC, etc) to use for signing based on the private key's ASN.1
160 info. When verifying signatures, it only handles the RSA, DSA, or
161 ECDSA signature itself, not the related data to identify the signer and
162 algorithm used in formats such as x.509, CMS, and S/MIME.
163
164 A source of random numbers is required for certain signing algorithms,
165 in particular ECDSA and DSA.
166
167 The signing and verify options should only be used if a single file is
168 being signed or verified.
169
170 Hex signatures cannot be verified using openssl. Instead, use "xxd -r"
171 or similar program to transform the hex signature into a binary
172 signature prior to verification.
173
175 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
176 The FIPS-related options were removed in OpenSSL 1.1.0.
177
179 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
180
181 Licensed under the OpenSSL license (the "License"). You may not use
182 this file except in compliance with the License. You can obtain a copy
183 in the file LICENSE in the source distribution or at
184 <https://www.openssl.org/source/license.html>.
185
186
187
1881.1.1k 2021-03-26 DGST(1)