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