openssl-dgst.pod.in 7.3 KB

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