openssl-dgst.pod.in 7.4 KB

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