Fix typo
[oweals/openssl.git] / doc / apps / dgst.pod
1 =pod
2
3 =head1 NAME
4
5 dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md4, md5 - message digests
6
7 =head1 SYNOPSIS
8
9 B<openssl> B<dgst> 
10 [B<-sha|-sha1|-mdc2|-ripemd160|-sha224|-sha256|-sha384|-sha512|-md4|-md5>]
11 [B<-c>]
12 [B<-d>]
13 [B<-hex>]
14 [B<-binary>]
15 [B<-r>]
16 [B<-non-fips-allow>]
17 [B<-out filename>]
18 [B<-sign filename>]
19 [B<-keyform arg>]
20 [B<-passin arg>]
21 [B<-verify filename>]
22 [B<-prverify filename>]
23 [B<-signature filename>]
24 [B<-hmac key>]
25 [B<-non-fips-allow>]
26 [B<-fips-fingerprint>]
27 [B<file...>]
28
29 B<openssl>
30 [I<digest>]
31 [B<...>]
32
33 =head1 DESCRIPTION
34
35 The digest functions output the message digest of a supplied file or files
36 in hexadecimal.  The digest functions also generate and verify digital
37 signatures using message digests.
38
39 The generic name, B<dgst>, may be used with an option specifying the
40 algorithm to be used.
41 The default digest is I<sha256>.
42 The digest name may also be used as the command name.
43 To see the list of supported algorithms, use the <Ilist --digest-commands>
44 command.
45
46 =head1 OPTIONS
47
48 =over 4
49
50 =item B<-c>
51
52 print out the digest in two digit groups separated by colons, only relevant if
53 B<hex> format output is used.
54
55 =item B<-d>
56
57 print out BIO debugging information.
58
59 =item B<-hex>
60
61 digest is to be output as a hex dump. This is the default case for a "normal"
62 digest as opposed to a digital signature.  See NOTES below for digital
63 signatures using B<-hex>.
64
65 =item B<-binary>
66
67 output the digest or signature in binary form.
68
69 =item B<-r>
70
71 output the digest in the "coreutils" format used by programs like B<sha1sum>.
72
73 =item B<-non-fips-allow>
74
75 Allow use of non FIPS digest when in FIPS mode.  This has no effect when not in
76 FIPS mode.
77
78 =item B<-out filename>
79
80 filename to output to, or standard output by default.
81
82 =item B<-sign filename>
83
84 digitally sign the digest using the private key in "filename".
85
86 =item B<-keyform arg>
87
88 Specifies the key format to sign digest with. The DER, PEM, P12,
89 and ENGINE formats are supported.
90
91 =item B<-engine id>
92
93 Use engine B<id> for operations (including private key storage).
94 This engine is not used as source for digest algorithms, unless it is
95 also specified in the configuration file.
96
97 =item B<-sigopt nm:v>
98
99 Pass options to the signature algorithm during sign or verify operations.
100 Names and values of these options are algorithm-specific.
101
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 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  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 8
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(s)>
155
156 a file or files containing random data used to seed the random number
157 generator, or an EGD socket (see L<RAND_egd(3)>).
158 Multiple files can be specified separated by a OS-dependent character.
159 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
160 all others. 
161
162 =item B<-non-fips-allow>
163
164 enable use of non-FIPS algorithms such as MD5 even in FIPS mode.
165
166 =item B<-fips-fingerprint>
167
168 compute HMAC using a specific key
169 for certain OpenSSL-FIPS operations.
170
171 =item B<file...>
172
173 file or files to digest. If no files are specified then standard input is
174 used.
175
176 =back
177
178
179 =head1 EXAMPLES
180
181 To create a hex-encoded message digest of a file:
182  openssl dgst -md5 -hex file.txt
183
184 To sign a file using SHA-256 with binary file output:
185  openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
186
187 To verify a signature:
188  openssl dgst -sha256 -verify publickey.pem \
189  -signature signature.sign \
190  file.txt
191
192
193 =head1 NOTES
194
195 The digest mechanisms that are available will depend on the options
196 used when building OpenSSL.
197 The B<list digest-commands> command can be used to list them.
198
199 New or agile applications should use probably use SHA-256. Other digests,
200 particularly SHA-1 and MD5, are still widely used for interoperating
201 with existing formats and protocols.
202
203 When signing a file, B<dgst> will automatically determine the algorithm
204 (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
205 When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
206 itself, not the related data to identify the signer and algorithm used in
207 formats such as x.509, CMS, and S/MIME.
208
209 A source of random numbers is required for certain signing algorithms, in
210 particular ECDSA and DSA.
211
212 The signing and verify options should only be used if a single file is
213 being signed or verified.
214
215 Hex signatures cannot be verified using B<openssl>.  Instead, use "xxd -r"
216 or similar program to transform the hex signature into a binary signature
217 prior to verification.
218
219 =head1 HISTORY
220
221 The default digest was changed from MD5 to SHA256 in Openssl 1.1.
222
223 =cut