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