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