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