1 .\" $NetBSD: openssl_dgst.1,v 1.14 2015/06/12 17:01:14 christos Exp $
3 .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
6 .\" ========================================================================
7 .de Sp \" Vertical space (when we can't use .PP)
11 .de Vb \" Begin verbatim text
16 .de Ve \" End verbatim text
20 .\" Set up some character translations and predefined strings. \*(-- will
21 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
22 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
23 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
24 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
25 .\" nothing in troff, for use with C<>.
27 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
31 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
32 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
47 .\" Escape single quotes in literal strings from groff's Unicode transform.
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
53 .\" entries marked with X<> in POD. Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
56 .\" Avoid warning from groff about undefined register 'F'.
60 .if \n(.g .if rF .nr rF 1
61 .if (\n(rF:(\n(.g==0)) \{
64 . tm Index:\\$1\t\\n%\t"\\$2"
74 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
75 .\" Fear. Run. Save yourself. No user-serviceable parts.
76 . \" fudge factors for nroff and troff
85 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
91 . \" simple accents for nroff and troff
101 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
102 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
103 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
104 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
105 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
106 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
108 . \" troff and (daisy-wheel) nroff accents
109 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
110 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
111 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
112 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
113 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
114 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
115 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
116 .ds ae a\h'-(\w'a'u*4/10)'e
117 .ds Ae A\h'-(\w'A'u*4/10)'E
118 . \" corrections for vroff
119 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
120 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
121 . \" for low resolution devices (crt and lpr)
122 .if \n(.H>23 .if \n(.V>19 \
135 .\" ========================================================================
138 .TH DGST 1 "2015-01-13" "1.0.1n" "OpenSSL"
139 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
140 .\" way too many mistakes in technical documents.
144 dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md2, md4, md5, dss1 \- message digests
148 .IX Header "SYNOPSIS"
149 \&\fBopenssl\fR \fBdgst\fR
150 [\fB\-sha|\-sha1|\-mdc2|\-ripemd160|\-sha224|\-sha256|\-sha384|\-sha512|\-md2|\-md4|\-md5|\-dss1\fR]
157 [\fB\-non\-fips\-allow\fR]
158 [\fB\-out filename\fR]
159 [\fB\-sign filename\fR]
160 [\fB\-keyform arg\fR]
162 [\fB\-verify filename\fR]
163 [\fB\-prverify filename\fR]
164 [\fB\-signature filename\fR]
166 [\fB\-non\-fips\-allow\fR]
167 [\fB\-fips\-fingerprint\fR]
174 .IX Header "DESCRIPTION"
175 The digest functions output the message digest of a supplied file or files
176 in hexadecimal. The digest functions also generate and verify digital
177 signatures using message digests.
182 print out the digest in two digit groups separated by colons, only relevant if
183 \&\fBhex\fR format output is used.
186 print out \s-1BIO\s0 debugging information.
189 digest is to be output as a hex dump. This is the default case for a \*(L"normal\*(R"
190 digest as opposed to a digital signature. See \s-1NOTES\s0 below for digital
191 signatures using \fB\-hex\fR.
192 .IP "\fB\-binary\fR" 4
194 output the digest or signature in binary form.
197 output the digest in the \*(L"coreutils\*(R" format used by programs like \fBsha1sum\fR.
198 .IP "\fB\-hmac arg\fR" 4
200 set the \s-1HMAC\s0 key to \*(L"arg\*(R".
201 .IP "\fB\-non\-fips\-allow\fR" 4
202 .IX Item "-non-fips-allow"
203 Allow use of non \s-1FIPS\s0 digest when in \s-1FIPS\s0 mode. This has no effect when not in
205 .IP "\fB\-out filename\fR" 4
206 .IX Item "-out filename"
207 filename to output to, or standard output by default.
208 .IP "\fB\-sign filename\fR" 4
209 .IX Item "-sign filename"
210 digitally sign the digest using the private key in \*(L"filename\*(R".
211 .IP "\fB\-keyform arg\fR" 4
212 .IX Item "-keyform arg"
213 Specifies the key format to sign digest with. The \s-1DER, PEM, P12,\s0
214 and \s-1ENGINE\s0 formats are supported.
215 .IP "\fB\-engine id\fR" 4
216 .IX Item "-engine id"
217 Use engine \fBid\fR for operations (including private key storage).
218 This engine is not used as source for digest algorithms, unless it is
219 also specified in the configuration file.
220 .IP "\fB\-sigopt nm:v\fR" 4
221 .IX Item "-sigopt nm:v"
222 Pass options to the signature algorithm during sign or verify operations.
223 Names and values of these options are algorithm-specific.
224 .IP "\fB\-passin arg\fR" 4
225 .IX Item "-passin arg"
226 the private key password source. For more information about the format of \fBarg\fR
227 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
228 .IP "\fB\-verify filename\fR" 4
229 .IX Item "-verify filename"
230 verify the signature using the the public key in \*(L"filename\*(R".
231 The output is either \*(L"Verification \s-1OK\*(R"\s0 or \*(L"Verification Failure\*(R".
232 .IP "\fB\-prverify filename\fR" 4
233 .IX Item "-prverify filename"
234 verify the signature using the the private key in \*(L"filename\*(R".
235 .IP "\fB\-signature filename\fR" 4
236 .IX Item "-signature filename"
237 the actual signature to verify.
238 .IP "\fB\-hmac key\fR" 4
240 create a hashed \s-1MAC\s0 using \*(L"key\*(R".
241 .IP "\fB\-mac alg\fR" 4
243 create \s-1MAC \s0(keyed Message Authentication Code). The most popular \s-1MAC\s0
244 algorithm is \s-1HMAC \s0(hash-based \s-1MAC\s0), but there are other \s-1MAC\s0 algorithms
245 which are not based on hash, for instance \fBgost-mac\fR algorithm,
246 supported by \fBccgost\fR engine. \s-1MAC\s0 keys and other options should be set
247 via \fB\-macopt\fR parameter.
248 .IP "\fB\-macopt nm:v\fR" 4
249 .IX Item "-macopt nm:v"
250 Passes options to \s-1MAC\s0 algorithm, specified by \fB\-mac\fR key.
251 Following options are supported by both by \fB\s-1HMAC\s0\fR and \fBgost-mac\fR:
253 .IP "\fBkey:string\fR" 8
254 .IX Item "key:string"
255 Specifies \s-1MAC\s0 key as alphnumeric string (use if key contain printable
256 characters only). String length must conform to any restrictions of
257 the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac.
258 .IP "\fBhexkey:string\fR" 8
259 .IX Item "hexkey:string"
260 Specifies \s-1MAC\s0 key in hexadecimal form (two hex digits per byte).
261 Key length must conform to any restrictions of the \s-1MAC\s0 algorithm
262 for example exactly 32 chars for gost-mac.
266 .IP "\fB\-rand file(s)\fR" 4
267 .IX Item "-rand file(s)"
268 a file or files containing random data used to seed the random number
269 generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)).
270 Multiple files can be specified separated by a OS-dependent character.
271 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
273 .IP "\fB\-non\-fips\-allow\fR" 4
274 .IX Item "-non-fips-allow"
275 enable use of non-FIPS algorithms such as \s-1MD5\s0 even in \s-1FIPS\s0 mode.
276 .IP "\fB\-fips\-fingerprint\fR" 4
277 .IX Item "-fips-fingerprint"
278 compute \s-1HMAC\s0 using a specific key
279 for certain OpenSSL-FIPS operations.
280 .IP "\fBfile...\fR" 4
282 file or files to digest. If no files are specified then standard input is
285 .IX Header "EXAMPLES"
286 To create a hex-encoded message digest of a file:
287 openssl dgst \-md5 \-hex file.txt
289 To sign a file using \s-1SHA\-256\s0 with binary file output:
290 openssl dgst \-sha256 \-sign privatekey.pem \-out signature.sign file.txt
292 To verify a signature:
293 openssl dgst \-sha256 \-verify publickey.pem \e
294 \-signature signature.sign \e
298 The digest of choice for all new applications is \s-1SHA1.\s0 Other digests are
299 however still widely used.
301 When signing a file, \fBdgst\fR will automatically determine the algorithm
302 (\s-1RSA, ECC,\s0 etc) to use for signing based on the private key's \s-1ASN.1\s0 info.
303 When verifying signatures, it only handles the \s-1RSA, DSA,\s0 or \s-1ECDSA\s0 signature
304 itself, not the related data to identify the signer and algorithm used in
305 formats such as x.509, \s-1CMS,\s0 and S/MIME.
307 A source of random numbers is required for certain signing algorithms, in
308 particular \s-1ECDSA\s0 and \s-1DSA.\s0
310 The signing and verify options should only be used if a single file is
311 being signed or verified.
313 Hex signatures cannot be verified using \fBopenssl\fR. Instead, use \*(L"xxd \-r\*(R"
314 or similar program to transform the hex signature into a binary signature
315 prior to verification.