openssl-dgst.pod.in 6.7 KB

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