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