openssl-dgst.1ossl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OPENSSL-DGST 1ossl"
  136. .TH OPENSSL-DGST 1ossl "2025-06-29" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. openssl\-dgst \- perform digest operations
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. \&\fBopenssl\fR \fBdgst\fR|\fIdigest\fR
  146. [\fB\-\f(BIdigest\fB\fR]
  147. [\fB\-list\fR]
  148. [\fB\-help\fR]
  149. [\fB\-c\fR]
  150. [\fB\-d\fR]
  151. [\fB\-debug\fR]
  152. [\fB\-hex\fR]
  153. [\fB\-binary\fR]
  154. [\fB\-xoflen\fR \fIlength\fR]
  155. [\fB\-r\fR]
  156. [\fB\-out\fR \fIfilename\fR]
  157. [\fB\-sign\fR \fIfilename\fR|\fIuri\fR]
  158. [\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR]
  159. [\fB\-passin\fR \fIarg\fR]
  160. [\fB\-verify\fR \fIfilename\fR]
  161. [\fB\-prverify\fR \fIfilename\fR]
  162. [\fB\-signature\fR \fIfilename\fR]
  163. [\fB\-sigopt\fR \fInm\fR:\fIv\fR]
  164. [\fB\-hmac\fR \fIkey\fR]
  165. [\fB\-mac\fR \fIalg\fR]
  166. [\fB\-macopt\fR \fInm\fR:\fIv\fR]
  167. [\fB\-fips\-fingerprint\fR]
  168. [\fB\-engine\fR \fIid\fR]
  169. [\fB\-engine_impl\fR \fIid\fR]
  170. [\fB\-rand\fR \fIfiles\fR]
  171. [\fB\-writerand\fR \fIfile\fR]
  172. [\fB\-provider\fR \fIname\fR]
  173. [\fB\-provider\-path\fR \fIpath\fR]
  174. [\fB\-propquery\fR \fIpropq\fR]
  175. [\fIfile\fR ...]
  176. .SH "DESCRIPTION"
  177. .IX Header "DESCRIPTION"
  178. This command output the message digest of a supplied file or files
  179. in hexadecimal, and also generates and verifies digital
  180. signatures using message digests.
  181. .PP
  182. The generic name, \fBopenssl dgst\fR, may be used with an option specifying the
  183. algorithm to be used.
  184. The default digest is \fBsha256\fR.
  185. A supported \fIdigest\fR name may also be used as the sub-command name.
  186. To see the list of supported algorithms, use \f(CW\*(C`openssl list \-digest\-algorithms\*(C'\fR
  187. .SH "OPTIONS"
  188. .IX Header "OPTIONS"
  189. .IP "\fB\-help\fR" 4
  190. .IX Item "-help"
  191. Print out a usage message.
  192. .IP "\fB\-\f(BIdigest\fB\fR" 4
  193. .IX Item "-digest"
  194. Specifies name of a supported digest to be used. See option \fB\-list\fR below :
  195. .IP "\fB\-list\fR" 4
  196. .IX Item "-list"
  197. Prints out a list of supported message digests.
  198. .IP "\fB\-c\fR" 4
  199. .IX Item "-c"
  200. Print out the digest in two digit groups separated by colons, only relevant if
  201. the \fB\-hex\fR option is given as well.
  202. .IP "\fB\-d\fR, \fB\-debug\fR" 4
  203. .IX Item "-d, -debug"
  204. Print out \s-1BIO\s0 debugging information.
  205. .IP "\fB\-hex\fR" 4
  206. .IX Item "-hex"
  207. Digest is to be output as a hex dump. This is the default case for a \*(L"normal\*(R"
  208. digest as opposed to a digital signature. See \s-1NOTES\s0 below for digital
  209. signatures using \fB\-hex\fR.
  210. .IP "\fB\-binary\fR" 4
  211. .IX Item "-binary"
  212. Output the digest or signature in binary form.
  213. .IP "\fB\-xoflen\fR \fIlength\fR" 4
  214. .IX Item "-xoflen length"
  215. Set the output length for \s-1XOF\s0 algorithms, such as \fBshake128\fR and \fBshake256\fR.
  216. This option is not supported for signing operations.
  217. .Sp
  218. For OpenSSL providers it is recommended to set this value for shake algorithms,
  219. since the default values are set to only supply half of the maximum security
  220. strength.
  221. .Sp
  222. For backwards compatibility reasons the default xoflen length for \fBshake128\fR is
  223. 16 (bytes) which results in a security strength of only 64 bits. To ensure the
  224. maximum security strength of 128 bits, the xoflen should be set to at least 32.
  225. .Sp
  226. For backwards compatibility reasons the default xoflen length for \fBshake256\fR is
  227. 32 (bytes) which results in a security strength of only 128 bits. To ensure the
  228. maximum security strength of 256 bits, the xoflen should be set to at least 64.
  229. .IP "\fB\-r\fR" 4
  230. .IX Item "-r"
  231. Output the digest in the \*(L"coreutils\*(R" format, including newlines.
  232. Used by programs like \fBsha1sum\fR\|(1).
  233. .IP "\fB\-out\fR \fIfilename\fR" 4
  234. .IX Item "-out filename"
  235. Filename to output to, or standard output by default.
  236. .IP "\fB\-sign\fR \fIfilename\fR|\fIuri\fR" 4
  237. .IX Item "-sign filename|uri"
  238. Digitally sign the digest using the given private key. Note this option
  239. does not support Ed25519 or Ed448 private keys. Use the \fBopenssl\-pkeyutl\fR\|(1)
  240. command instead for this.
  241. .IP "\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR" 4
  242. .IX Item "-keyform DER|PEM|P12|ENGINE"
  243. The format of the key to sign with; unspecified by default.
  244. See \fBopenssl\-format\-options\fR\|(1) for details.
  245. .IP "\fB\-sigopt\fR \fInm\fR:\fIv\fR" 4
  246. .IX Item "-sigopt nm:v"
  247. Pass options to the signature algorithm during sign or verify operations.
  248. Names and values of these options are algorithm-specific and documented
  249. in \*(L"Signature parameters\*(R" in \fBprovider\-signature\fR\|(7).
  250. .IP "\fB\-passin\fR \fIarg\fR" 4
  251. .IX Item "-passin arg"
  252. The private key password source. For more information about the format of \fIarg\fR
  253. see \fBopenssl\-passphrase\-options\fR\|(1).
  254. .IP "\fB\-verify\fR \fIfilename\fR" 4
  255. .IX Item "-verify filename"
  256. Verify the signature using the public key in \*(L"filename\*(R".
  257. The output is either \*(L"Verified \s-1OK\*(R"\s0 or \*(L"Verification Failure\*(R".
  258. .IP "\fB\-prverify\fR \fIfilename\fR" 4
  259. .IX Item "-prverify filename"
  260. Verify the signature using the private key in \*(L"filename\*(R".
  261. .IP "\fB\-signature\fR \fIfilename\fR" 4
  262. .IX Item "-signature filename"
  263. The actual signature to verify.
  264. .IP "\fB\-hmac\fR \fIkey\fR" 4
  265. .IX Item "-hmac key"
  266. Create a hashed \s-1MAC\s0 using \*(L"key\*(R".
  267. .Sp
  268. The \fBopenssl\-mac\fR\|(1) command should be preferred to using this command line
  269. option.
  270. .IP "\fB\-mac\fR \fIalg\fR" 4
  271. .IX Item "-mac alg"
  272. Create \s-1MAC\s0 (keyed Message Authentication Code). The most popular \s-1MAC\s0
  273. algorithm is \s-1HMAC\s0 (hash-based \s-1MAC\s0), but there are other \s-1MAC\s0 algorithms
  274. which are not based on hash, for instance \fBgost-mac\fR algorithm,
  275. supported by the \fBgost\fR engine. \s-1MAC\s0 keys and other options should be set
  276. via \fB\-macopt\fR parameter.
  277. .Sp
  278. The \fBopenssl\-mac\fR\|(1) command should be preferred to using this command line
  279. option.
  280. .IP "\fB\-macopt\fR \fInm\fR:\fIv\fR" 4
  281. .IX Item "-macopt nm:v"
  282. Passes options to \s-1MAC\s0 algorithm, specified by \fB\-mac\fR key.
  283. Following options are supported by both by \fB\s-1HMAC\s0\fR and \fBgost-mac\fR:
  284. .RS 4
  285. .IP "\fBkey\fR:\fIstring\fR" 4
  286. .IX Item "key:string"
  287. Specifies \s-1MAC\s0 key as alphanumeric string (use if key contain printable
  288. characters only). String length must conform to any restrictions of
  289. the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac.
  290. .IP "\fBhexkey\fR:\fIstring\fR" 4
  291. .IX Item "hexkey:string"
  292. Specifies \s-1MAC\s0 key in hexadecimal form (two hex digits per byte).
  293. Key length must conform to any restrictions of the \s-1MAC\s0 algorithm
  294. for example exactly 32 chars for gost-mac.
  295. .RE
  296. .RS 4
  297. .Sp
  298. The \fBopenssl\-mac\fR\|(1) command should be preferred to using this command line
  299. option.
  300. .RE
  301. .IP "\fB\-fips\-fingerprint\fR" 4
  302. .IX Item "-fips-fingerprint"
  303. Compute \s-1HMAC\s0 using a specific key for certain OpenSSL-FIPS operations.
  304. .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
  305. .IX Item "-rand files, -writerand file"
  306. See \*(L"Random State Options\*(R" in \fBopenssl\fR\|(1) for details.
  307. .IP "\fB\-engine\fR \fIid\fR" 4
  308. .IX Item "-engine id"
  309. See \*(L"Engine Options\*(R" in \fBopenssl\fR\|(1).
  310. This option is deprecated.
  311. .Sp
  312. The engine is not used for digests unless the \fB\-engine_impl\fR option is
  313. used or it is configured to do so, see \*(L"Engine Configuration Module\*(R" in \fBconfig\fR\|(5).
  314. .IP "\fB\-engine_impl\fR \fIid\fR" 4
  315. .IX Item "-engine_impl id"
  316. When used with the \fB\-engine\fR option, it specifies to also use
  317. engine \fIid\fR for digest operations.
  318. .IP "\fB\-provider\fR \fIname\fR" 4
  319. .IX Item "-provider name"
  320. .PD 0
  321. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  322. .IX Item "-provider-path path"
  323. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  324. .IX Item "-propquery propq"
  325. .PD
  326. See \*(L"Provider Options\*(R" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  327. .IP "\fIfile\fR ..." 4
  328. .IX Item "file ..."
  329. File or files to digest. If no files are specified then standard input is
  330. used.
  331. .SH "EXAMPLES"
  332. .IX Header "EXAMPLES"
  333. To create a hex-encoded message digest of a file:
  334. .PP
  335. .Vb 3
  336. \& openssl dgst \-md5 \-hex file.txt
  337. \& or
  338. \& openssl md5 file.txt
  339. .Ve
  340. .PP
  341. To sign a file using \s-1SHA\-256\s0 with binary file output:
  342. .PP
  343. .Vb 3
  344. \& openssl dgst \-sha256 \-sign privatekey.pem \-out signature.sign file.txt
  345. \& or
  346. \& openssl sha256 \-sign privatekey.pem \-out signature.sign file.txt
  347. .Ve
  348. .PP
  349. To verify a signature:
  350. .PP
  351. .Vb 3
  352. \& openssl dgst \-sha256 \-verify publickey.pem \e
  353. \& \-signature signature.sign \e
  354. \& file.txt
  355. .Ve
  356. .SH "NOTES"
  357. .IX Header "NOTES"
  358. The digest mechanisms that are available will depend on the options
  359. used when building OpenSSL.
  360. The \f(CW\*(C`openssl list \-digest\-algorithms\*(C'\fR command can be used to list them.
  361. .PP
  362. New or agile applications should use probably use \s-1SHA\-256.\s0 Other digests,
  363. particularly \s-1SHA\-1\s0 and \s-1MD5,\s0 are still widely used for interoperating
  364. with existing formats and protocols.
  365. .PP
  366. When signing a file, this command will automatically determine the algorithm
  367. (\s-1RSA, ECC,\s0 etc) to use for signing based on the private key's \s-1ASN.1\s0 info.
  368. When verifying signatures, it only handles the \s-1RSA, DSA,\s0 or \s-1ECDSA\s0 signature
  369. itself, not the related data to identify the signer and algorithm used in
  370. formats such as x.509, \s-1CMS,\s0 and S/MIME.
  371. .PP
  372. A source of random numbers is required for certain signing algorithms, in
  373. particular \s-1ECDSA\s0 and \s-1DSA.\s0
  374. .PP
  375. The signing and verify options should only be used if a single file is
  376. being signed or verified.
  377. .PP
  378. Hex signatures cannot be verified using \fBopenssl\fR. Instead, use \*(L"xxd \-r\*(R"
  379. or similar program to transform the hex signature into a binary signature
  380. prior to verification.
  381. .PP
  382. The \fBopenssl\-mac\fR\|(1) command is preferred over the \fB\-hmac\fR, \fB\-mac\fR and
  383. \&\fB\-macopt\fR command line options.
  384. .SH "SEE ALSO"
  385. .IX Header "SEE ALSO"
  386. \&\fBopenssl\-mac\fR\|(1)
  387. .SH "HISTORY"
  388. .IX Header "HISTORY"
  389. The default digest was changed from \s-1MD5\s0 to \s-1SHA256\s0 in OpenSSL 1.1.0.
  390. The FIPS-related options were removed in OpenSSL 1.1.0.
  391. .PP
  392. The \fB\-engine\fR and \fB\-engine_impl\fR options were deprecated in OpenSSL 3.0.
  393. .SH "COPYRIGHT"
  394. .IX Header "COPYRIGHT"
  395. Copyright 2000\-2024 The OpenSSL Project Authors. All Rights Reserved.
  396. .PP
  397. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  398. this file except in compliance with the License. You can obtain a copy
  399. in the file \s-1LICENSE\s0 in the source distribution or at
  400. <https://www.openssl.org/source/license.html>.