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