Fix descriptions of credentials and verification options for various apps
[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 -}
33 [B<-engine_impl> I<id>]
34 {- $OpenSSL::safe::opt_r_synopsis -}
35 {- $OpenSSL::safe::opt_provider_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>, B<-debug>
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 =for openssl foreign manual sha1sum(1)
89
90 Output the digest in the "coreutils" format, including newlines.
91 Used by programs like L<sha1sum(1)>.
92
93 =item B<-out> I<filename>
94
95 Filename to output to, or standard output by default.
96
97 =item B<-sign> I<filename>
98
99 Digitally sign the digest using the private key in "filename". Note this option
100 does not support Ed25519 or Ed448 private keys. Use the L<openssl-pkeyutl(1)>
101 command instead for this.
102
103 =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
104
105 The format of the key to sign with; the default is B<PEM>.
106 See L<openssl(1)/Format Options> for details.
107
108 =item B<-sigopt> I<nm>:I<v>
109
110 Pass options to the signature algorithm during sign or verify operations.
111 Names and values of these options are algorithm-specific.
112
113 =item B<-passin> I<arg>
114
115 The private key password source. For more information about the format of I<arg>
116 see L<openssl(1)/Pass Phrase Options>.
117
118 =item B<-verify> I<filename>
119
120 Verify the signature using the public key in "filename".
121 The output is either "Verification OK" or "Verification Failure".
122
123 =item B<-prverify> I<filename>
124
125 Verify the signature using the private key in "filename".
126
127 =item B<-signature> I<filename>
128
129 The actual signature to verify.
130
131 =item B<-hmac> I<key>
132
133 Create a hashed MAC using "key".
134
135 The L<openssl-mac(1)> command should be preferred to using this command line
136 option.
137
138 =item B<-mac> I<alg>
139
140 Create MAC (keyed Message Authentication Code). The most popular MAC
141 algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
142 which are not based on hash, for instance B<gost-mac> algorithm,
143 supported by the B<gost> engine. MAC keys and other options should be set
144 via B<-macopt> parameter.
145
146 The L<openssl-mac(1)> command should be preferred to using this command line
147 option.
148
149 =item B<-macopt> I<nm>:I<v>
150
151 Passes options to MAC algorithm, specified by B<-mac> key.
152 Following options are supported by both by B<HMAC> and B<gost-mac>:
153
154 =over 4
155
156 =item B<key>:I<string>
157
158 Specifies MAC key as alphanumeric string (use if key contain printable
159 characters only). String length must conform to any restrictions of
160 the MAC algorithm for example exactly 32 chars for gost-mac.
161
162 =item B<hexkey>:I<string>
163
164 Specifies MAC key in hexadecimal form (two hex digits per byte).
165 Key length must conform to any restrictions of the MAC algorithm
166 for example exactly 32 chars for gost-mac.
167
168 =back
169
170 The L<openssl-mac(1)> command should be preferred to using this command line
171 option.
172
173 =item B<-fips-fingerprint>
174
175 Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
176
177 {- $OpenSSL::safe::opt_r_item -}
178
179 {- $OpenSSL::safe::opt_engine_item -}
180 The engine is not used for digests unless the B<-engine_impl> option is
181 used or it is configured to do so, see L<config(5)/Engine Configuration Module>.
182
183 =item B<-engine_impl> I<id>
184
185 When used with the B<-engine> option, it specifies to also use
186 engine I<id> for digest operations.
187
188 {- $OpenSSL::safe::opt_provider_item -}
189
190 =item I<file> ...
191
192 File or files to digest. If no files are specified then standard input is
193 used.
194
195 =back
196
197
198 =head1 EXAMPLES
199
200 To create a hex-encoded message digest of a file:
201  openssl dgst -md5 -hex file.txt
202
203 To sign a file using SHA-256 with binary file output:
204  openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
205
206 To verify a signature:
207  openssl dgst -sha256 -verify publickey.pem \
208  -signature signature.sign \
209  file.txt
210
211
212 =head1 NOTES
213
214 The digest mechanisms that are available will depend on the options
215 used when building OpenSSL.
216 The C<openssl list -digest-commands> command can be used to list them.
217
218 New or agile applications should use probably use SHA-256. Other digests,
219 particularly SHA-1 and MD5, are still widely used for interoperating
220 with existing formats and protocols.
221
222 When signing a file, this command will automatically determine the algorithm
223 (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
224 When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
225 itself, not the related data to identify the signer and algorithm used in
226 formats such as x.509, CMS, and S/MIME.
227
228 A source of random numbers is required for certain signing algorithms, in
229 particular ECDSA and DSA.
230
231 The signing and verify options should only be used if a single file is
232 being signed or verified.
233
234 Hex signatures cannot be verified using B<openssl>.  Instead, use "xxd -r"
235 or similar program to transform the hex signature into a binary signature
236 prior to verification.
237
238 The L<openssl-mac(1)> command is preferred over the B<-hmac>, B<-mac> and
239 B<-macopt> command line options.
240
241 =head1 SEE ALSO
242
243 L<openssl-mac(1)>
244
245 =head1 HISTORY
246
247 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
248 The FIPS-related options were removed in OpenSSL 1.1.0.
249
250 =head1 COPYRIGHT
251
252 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
253
254 Licensed under the Apache License 2.0 (the "License").  You may not use
255 this file except in compliance with the License.  You can obtain a copy
256 in the file LICENSE in the source distribution or at
257 L<https://www.openssl.org/source/license.html>.
258
259 =cut