dgst.pod 6.3 KB

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