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