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