]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssl/doc/apps/dgst.pod
MFV r329793, r329795:
[FreeBSD/FreeBSD.git] / crypto / openssl / doc / apps / dgst.pod
1 =pod
2
3 =head1 NAME
4
5 openssl-dgst,
6 dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md2, md4, md5, dss1 - message digests
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<dgst> 
11 [B<-sha|-sha1|-mdc2|-ripemd160|-sha224|-sha256|-sha384|-sha512|-md2|-md4|-md5|-dss1>]
12 [B<-c>]
13 [B<-d>]
14 [B<-hex>]
15 [B<-binary>]
16 [B<-r>]
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<-non-fips-allow>
68
69 Allow use of non FIPS digest when in FIPS mode.  This has no effect when not in
70 FIPS mode.
71
72 =item B<-out filename>
73
74 filename to output to, or standard output by default.
75
76 =item B<-sign filename>
77
78 digitally sign the digest using the private key in "filename".
79
80 =item B<-keyform arg>
81
82 Specifies the key format to sign digest with. The DER, PEM, P12,
83 and ENGINE formats are supported.
84
85 =item B<-engine id>
86
87 Use engine B<id> for operations (including private key storage).
88 This engine is not used as source for digest algorithms, unless it is
89 also specified in the configuration file.
90
91 =item B<-sigopt nm:v>
92
93 Pass options to the signature algorithm during sign or verify operations.
94 Names and values of these options are algorithm-specific.
95
96
97 =item B<-passin arg>
98
99 the private key password source. For more information about the format of B<arg>
100 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
101
102 =item B<-verify filename>
103
104 verify the signature using the public key in "filename".
105 The output is either "Verification OK" or "Verification Failure".
106
107 =item B<-prverify filename>
108
109 verify the signature using the private key in "filename".
110
111 =item B<-signature filename>
112
113 the actual signature to verify.
114
115 =item B<-hmac key>
116
117 create a hashed MAC using "key".
118
119 =item B<-mac alg>
120
121 create MAC (keyed Message Authentication Code). The most popular MAC
122 algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
123 which are not based on hash, for instance B<gost-mac> algorithm,
124 supported by B<ccgost> engine. MAC keys and other options should be set
125 via B<-macopt> parameter.
126
127 =item B<-macopt nm:v>
128
129 Passes options to MAC algorithm, specified by B<-mac> key.
130 Following options are supported by both by B<HMAC> and B<gost-mac>:
131
132 =over 8
133
134 =item B<key:string>
135
136 Specifies MAC key as alphnumeric string (use if key contain printable
137 characters only). String length must conform to any restrictions of
138 the MAC algorithm for example exactly 32 chars for gost-mac.
139
140 =item B<hexkey:string>
141
142 Specifies MAC key in hexadecimal form (two hex digits per byte).
143 Key length must conform to any restrictions of the MAC algorithm
144 for example exactly 32 chars for gost-mac.
145
146 =back
147
148 =item B<-rand file(s)>
149
150 a file or files containing random data used to seed the random number
151 generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
152 Multiple files can be specified separated by a OS-dependent character.
153 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
154 all others. 
155
156 =item B<-non-fips-allow>
157
158 enable use of non-FIPS algorithms such as MD5 even in FIPS mode.
159
160 =item B<-fips-fingerprint>
161
162 compute HMAC using a specific key
163 for certain OpenSSL-FIPS operations.
164
165 =item B<file...>
166
167 file or files to digest. If no files are specified then standard input is
168 used.
169
170 =back
171
172
173 =head1 EXAMPLES
174
175 To create a hex-encoded message digest of a file:
176  openssl dgst -md5 -hex file.txt
177
178 To sign a file using SHA-256 with binary file output:
179  openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
180
181 To verify a signature:
182  openssl dgst -sha256 -verify publickey.pem \
183  -signature signature.sign \
184  file.txt
185
186
187 =head1 NOTES
188
189 The digest of choice for all new applications is SHA1. Other digests are
190 however still widely used.
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
209 =cut