dgst.pod 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. =pod
  2. =head1 NAME
  3. openssl-dgst,
  4. dgst - perform digest operations
  5. =head1 SYNOPSIS
  6. B<openssl dgst>
  7. [B<-I<digest>>]
  8. [B<-help>]
  9. [B<-c>]
  10. [B<-d>]
  11. [B<-list>]
  12. [B<-hex>]
  13. [B<-binary>]
  14. [B<-r>]
  15. [B<-out filename>]
  16. [B<-sign filename>]
  17. [B<-keyform arg>]
  18. [B<-passin arg>]
  19. [B<-verify filename>]
  20. [B<-prverify filename>]
  21. [B<-signature filename>]
  22. [B<-sigopt nm:v>]
  23. [B<-hmac key>]
  24. [B<-fips-fingerprint>]
  25. [B<-rand file...>]
  26. [B<-engine id>]
  27. [B<-engine_impl>]
  28. [B<file...>]
  29. B<openssl> I<digest> [B<...>]
  30. =head1 DESCRIPTION
  31. The digest functions output the message digest of a supplied file or files
  32. in hexadecimal. The digest functions also generate and verify digital
  33. signatures using message digests.
  34. The generic name, B<dgst>, may be used with an option specifying the
  35. algorithm to be used.
  36. The default digest is I<sha256>.
  37. A supported I<digest> name may also be used as the command name.
  38. To see the list of supported algorithms, use the I<list --digest-commands>
  39. command.
  40. =head1 OPTIONS
  41. =over 4
  42. =item B<-help>
  43. Print out a usage message.
  44. =item B<-I<digest>>
  45. Specifies name of a supported digest to be used. To see the list of
  46. supported digests, use the command I<list --digest-commands>.
  47. =item B<-c>
  48. Print out the digest in two digit groups separated by colons, only relevant if
  49. B<hex> format output is used.
  50. =item B<-d>
  51. Print out BIO debugging information.
  52. =item B<-list>
  53. Prints out a list of supported message digests.
  54. =item B<-hex>
  55. Digest is to be output as a hex dump. This is the default case for a "normal"
  56. digest as opposed to a digital signature. See NOTES below for digital
  57. signatures using B<-hex>.
  58. =item B<-binary>
  59. Output the digest or signature in binary form.
  60. =item B<-r>
  61. Output the digest in the "coreutils" format, including newlines.
  62. Used by programs like B<sha1sum>.
  63. =item B<-out filename>
  64. Filename to output to, or standard output by default.
  65. =item B<-sign filename>
  66. Digitally sign the digest using the private key in "filename". Note this option
  67. does not support Ed25519 or Ed448 private keys.
  68. =item B<-keyform arg>
  69. Specifies the key format to sign digest with. The DER, PEM, P12,
  70. and ENGINE formats are supported.
  71. =item B<-sigopt nm:v>
  72. Pass options to the signature algorithm during sign or verify operations.
  73. Names and values of these options are algorithm-specific.
  74. =item B<-passin arg>
  75. The private key password source. For more information about the format of B<arg>
  76. see L<openssl(1)/Pass Phrase Options>.
  77. =item B<-verify filename>
  78. Verify the signature using the public key in "filename".
  79. The output is either "Verification OK" or "Verification Failure".
  80. =item B<-prverify filename>
  81. Verify the signature using the private key in "filename".
  82. =item B<-signature filename>
  83. The actual signature to verify.
  84. =item B<-hmac key>
  85. Create a hashed MAC using "key".
  86. =item B<-mac alg>
  87. Create MAC (keyed Message Authentication Code). The most popular MAC
  88. algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
  89. which are not based on hash, for instance B<gost-mac> algorithm,
  90. supported by B<ccgost> engine. MAC keys and other options should be set
  91. via B<-macopt> parameter.
  92. =item B<-macopt nm:v>
  93. Passes options to MAC algorithm, specified by B<-mac> key.
  94. Following options are supported by both by B<HMAC> and B<gost-mac>:
  95. =over 4
  96. =item B<key:string>
  97. Specifies MAC key as alphanumeric string (use if key contain printable
  98. characters only). String length must conform to any restrictions of
  99. the MAC algorithm for example exactly 32 chars for gost-mac.
  100. =item B<hexkey:string>
  101. Specifies MAC key in hexadecimal form (two hex digits per byte).
  102. Key length must conform to any restrictions of the MAC algorithm
  103. for example exactly 32 chars for gost-mac.
  104. =back
  105. =item B<-rand file...>
  106. A file or files containing random data used to seed the random number
  107. generator.
  108. Multiple files can be specified separated by an OS-dependent character.
  109. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
  110. all others.
  111. =item [B<-writerand file>]
  112. Writes random data to the specified I<file> upon exit.
  113. This can be used with a subsequent B<-rand> flag.
  114. =item B<-fips-fingerprint>
  115. Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
  116. =item B<-engine id>
  117. Use engine B<id> for operations (including private key storage).
  118. This engine is not used as source for digest algorithms, unless it is
  119. also specified in the configuration file or B<-engine_impl> is also
  120. specified.
  121. =item B<-engine_impl>
  122. When used with the B<-engine> option, it specifies to also use
  123. engine B<id> for digest operations.
  124. =item B<file...>
  125. File or files to digest. If no files are specified then standard input is
  126. used.
  127. =back
  128. =head1 EXAMPLES
  129. To create a hex-encoded message digest of a file:
  130. openssl dgst -md5 -hex file.txt
  131. To sign a file using SHA-256 with binary file output:
  132. openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
  133. To verify a signature:
  134. openssl dgst -sha256 -verify publickey.pem \
  135. -signature signature.sign \
  136. file.txt
  137. =head1 NOTES
  138. The digest mechanisms that are available will depend on the options
  139. used when building OpenSSL.
  140. The B<list digest-commands> command can be used to list them.
  141. New or agile applications should use probably use SHA-256. Other digests,
  142. particularly SHA-1 and MD5, are still widely used for interoperating
  143. with existing formats and protocols.
  144. When signing a file, B<dgst> will automatically determine the algorithm
  145. (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
  146. When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
  147. itself, not the related data to identify the signer and algorithm used in
  148. formats such as x.509, CMS, and S/MIME.
  149. A source of random numbers is required for certain signing algorithms, in
  150. particular ECDSA and DSA.
  151. The signing and verify options should only be used if a single file is
  152. being signed or verified.
  153. Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
  154. or similar program to transform the hex signature into a binary signature
  155. prior to verification.
  156. =head1 HISTORY
  157. The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
  158. The FIPS-related options were removed in OpenSSL 1.1.0.
  159. =head1 COPYRIGHT
  160. Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
  161. Licensed under the OpenSSL license (the "License"). You may not use
  162. this file except in compliance with the License. You can obtain a copy
  163. in the file LICENSE in the source distribution or at
  164. L<https://www.openssl.org/source/license.html>.
  165. =cut