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