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