2
0

openssl-dgst.pod.in 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-dgst - perform digest operations
  5. =head1 SYNOPSIS
  6. B<openssl> B<dgst>|I<digest>
  7. [B<-I<digest>>]
  8. [B<-list>]
  9. [B<-help>]
  10. [B<-c>]
  11. [B<-d>]
  12. [B<-debug>]
  13. [B<-hex>]
  14. [B<-binary>]
  15. [B<-xoflen> I<length>]
  16. [B<-r>]
  17. [B<-out> I<filename>]
  18. [B<-sign> I<filename>|I<uri>]
  19. [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
  20. [B<-passin> I<arg>]
  21. [B<-verify> I<filename>]
  22. [B<-prverify> I<filename>]
  23. [B<-signature> I<filename>]
  24. [B<-sigopt> I<nm>:I<v>]
  25. [B<-hmac> I<key>]
  26. [B<-mac> I<alg>]
  27. [B<-macopt> I<nm>:I<v>]
  28. [B<-fips-fingerprint>]
  29. {- $OpenSSL::safe::opt_engine_synopsis -}{- output_off() if $disabled{"deprecated-3.0"}; ""
  30. -}[B<-engine_impl> I<id>]{-
  31. output_on() if $disabled{"deprecated-3.0"}; "" -}
  32. {- $OpenSSL::safe::opt_r_synopsis -}
  33. {- $OpenSSL::safe::opt_provider_synopsis -}
  34. [I<file> ...]
  35. =head1 DESCRIPTION
  36. This command output the message digest of a supplied file or files
  37. in hexadecimal, and also generates and verifies digital
  38. signatures using message digests.
  39. The generic name, B<openssl dgst>, may be used with an option specifying the
  40. algorithm to be used.
  41. The default digest is B<sha256>.
  42. A supported I<digest> name may also be used as the sub-command name.
  43. To see the list of supported algorithms, use C<openssl list -digest-algorithms>
  44. =head1 OPTIONS
  45. =over 4
  46. =item B<-help>
  47. Print out a usage message.
  48. =item B<-I<digest>>
  49. Specifies name of a supported digest to be used. See option B<-list> below :
  50. =item B<-list>
  51. Prints out a list of supported message digests.
  52. =item B<-c>
  53. Print out the digest in two digit groups separated by colons, only relevant if
  54. the B<-hex> option is given as well.
  55. =item B<-d>, B<-debug>
  56. Print out BIO debugging information.
  57. =item B<-hex>
  58. Digest is to be output as a hex dump. This is the default case for a "normal"
  59. digest as opposed to a digital signature. See NOTES below for digital
  60. signatures using B<-hex>.
  61. =item B<-binary>
  62. Output the digest or signature in binary form.
  63. =item B<-xoflen> I<length>
  64. Set the output length for XOF algorithms, such as B<shake128> and B<shake256>.
  65. This option is not supported for signing operations.
  66. For OpenSSL providers it is recommended to set this value for shake algorithms,
  67. since the default values are set to only supply half of the maximum security
  68. strength.
  69. For backwards compatibility reasons the default xoflen length for B<shake128> is
  70. 16 (bytes) which results in a security strength of only 64 bits. To ensure the
  71. maximum security strength of 128 bits, the xoflen should be set to at least 32.
  72. For backwards compatibility reasons the default xoflen length for B<shake256> is
  73. 32 (bytes) which results in a security strength of only 128 bits. To ensure the
  74. maximum security strength of 256 bits, the xoflen should be set to at least 64.
  75. =item B<-r>
  76. =for openssl foreign manual sha1sum(1)
  77. Output the digest in the "coreutils" format, including newlines.
  78. Used by programs like L<sha1sum(1)>.
  79. =item B<-out> I<filename>
  80. Filename to output to, or standard output by default.
  81. =item B<-sign> I<filename>|I<uri>
  82. Digitally sign the digest using the given private key. Note this option
  83. does not support Ed25519 or Ed448 private keys. Use the L<openssl-pkeyutl(1)>
  84. command instead for this.
  85. =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
  86. The format of the key to sign with; unspecified by default.
  87. See L<openssl-format-options(1)> for details.
  88. =item B<-sigopt> I<nm>:I<v>
  89. Pass options to the signature algorithm during sign or verify operations.
  90. Names and values of these options are algorithm-specific.
  91. =item B<-passin> I<arg>
  92. The private key password source. For more information about the format of I<arg>
  93. see L<openssl-passphrase-options(1)>.
  94. =item B<-verify> I<filename>
  95. Verify the signature using the public key in "filename".
  96. The output is either "Verified OK" or "Verification Failure".
  97. =item B<-prverify> I<filename>
  98. Verify the signature using the private key in "filename".
  99. =item B<-signature> I<filename>
  100. The actual signature to verify.
  101. =item B<-hmac> I<key>
  102. Create a hashed MAC using "key".
  103. The L<openssl-mac(1)> command should be preferred to using this command line
  104. option.
  105. =item B<-mac> I<alg>
  106. Create MAC (keyed Message Authentication Code). The most popular MAC
  107. algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
  108. which are not based on hash, for instance B<gost-mac> algorithm,
  109. supported by the B<gost> engine. MAC keys and other options should be set
  110. via B<-macopt> parameter.
  111. The L<openssl-mac(1)> command should be preferred to using this command line
  112. option.
  113. =item B<-macopt> I<nm>:I<v>
  114. Passes options to MAC algorithm, specified by B<-mac> key.
  115. Following options are supported by both by B<HMAC> and B<gost-mac>:
  116. =over 4
  117. =item B<key>:I<string>
  118. Specifies MAC key as alphanumeric string (use if key contain printable
  119. characters only). String length must conform to any restrictions of
  120. the MAC algorithm for example exactly 32 chars for gost-mac.
  121. =item B<hexkey>:I<string>
  122. Specifies MAC key in hexadecimal form (two hex digits per byte).
  123. Key length must conform to any restrictions of the MAC algorithm
  124. for example exactly 32 chars for gost-mac.
  125. =back
  126. The L<openssl-mac(1)> command should be preferred to using this command line
  127. option.
  128. =item B<-fips-fingerprint>
  129. Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
  130. {- $OpenSSL::safe::opt_r_item -}
  131. {- $OpenSSL::safe::opt_engine_item -}
  132. {- output_off() if $disabled{"deprecated-3.0"}; "" -}
  133. The engine is not used for digests unless the B<-engine_impl> option is
  134. used or it is configured to do so, see L<config(5)/Engine Configuration Module>.
  135. =item B<-engine_impl> I<id>
  136. When used with the B<-engine> option, it specifies to also use
  137. engine I<id> for digest operations.
  138. {- output_on() if $disabled{"deprecated-3.0"}; "" -}
  139. {- $OpenSSL::safe::opt_provider_item -}
  140. =item I<file> ...
  141. File or files to digest. If no files are specified then standard input is
  142. used.
  143. =back
  144. =head1 EXAMPLES
  145. To create a hex-encoded message digest of a file:
  146. openssl dgst -md5 -hex file.txt
  147. or
  148. openssl md5 file.txt
  149. To sign a file using SHA-256 with binary file output:
  150. openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
  151. or
  152. openssl sha256 -sign privatekey.pem -out signature.sign file.txt
  153. To verify a signature:
  154. openssl dgst -sha256 -verify publickey.pem \
  155. -signature signature.sign \
  156. file.txt
  157. =head1 NOTES
  158. The digest mechanisms that are available will depend on the options
  159. used when building OpenSSL.
  160. The C<openssl list -digest-algorithms> command can be used to list them.
  161. New or agile applications should use probably use SHA-256. Other digests,
  162. particularly SHA-1 and MD5, are still widely used for interoperating
  163. with existing formats and protocols.
  164. When signing a file, this command will automatically determine the algorithm
  165. (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
  166. When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
  167. itself, not the related data to identify the signer and algorithm used in
  168. formats such as x.509, CMS, and S/MIME.
  169. A source of random numbers is required for certain signing algorithms, in
  170. particular ECDSA and DSA.
  171. The signing and verify options should only be used if a single file is
  172. being signed or verified.
  173. Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
  174. or similar program to transform the hex signature into a binary signature
  175. prior to verification.
  176. The L<openssl-mac(1)> command is preferred over the B<-hmac>, B<-mac> and
  177. B<-macopt> command line options.
  178. =head1 SEE ALSO
  179. L<openssl-mac(1)>
  180. =head1 HISTORY
  181. The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
  182. The FIPS-related options were removed in OpenSSL 1.1.0.
  183. The B<-engine> and B<-engine_impl> options were deprecated in OpenSSL 3.0.
  184. =head1 COPYRIGHT
  185. Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
  186. Licensed under the Apache License 2.0 (the "License"). You may not use
  187. this file except in compliance with the License. You can obtain a copy
  188. in the file LICENSE in the source distribution or at
  189. L<https://www.openssl.org/source/license.html>.
  190. =cut