dgst.pod 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. =pod
  2. =head1 NAME
  3. dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md2, md4, md5, dss1 - message digests
  4. =head1 SYNOPSIS
  5. B<openssl> B<dgst>
  6. [B<-sha|-sha1|-mdc2|-ripemd160|-sha224|-sha256|-sha384|-sha512|-md2|-md4|-md5|-dss1>]
  7. [B<-c>]
  8. [B<-d>]
  9. [B<-hex>]
  10. [B<-binary>]
  11. [B<-r>]
  12. [B<-non-fips-allow>]
  13. [B<-out filename>]
  14. [B<-sign filename>]
  15. [B<-keyform arg>]
  16. [B<-passin arg>]
  17. [B<-verify filename>]
  18. [B<-prverify filename>]
  19. [B<-signature filename>]
  20. [B<-hmac key>]
  21. [B<-non-fips-allow>]
  22. [B<-fips-fingerprint>]
  23. [B<file...>]
  24. B<openssl>
  25. [I<digest>]
  26. [B<...>]
  27. =head1 DESCRIPTION
  28. The digest functions output the message digest of a supplied file or files
  29. in hexadecimal. The digest functions also generate and verify digital
  30. signatures using message digests.
  31. =head1 OPTIONS
  32. =over 4
  33. =item B<-c>
  34. print out the digest in two digit groups separated by colons, only relevant if
  35. B<hex> format output is used.
  36. =item B<-d>
  37. print out BIO debugging information.
  38. =item B<-hex>
  39. digest is to be output as a hex dump. This is the default case for a "normal"
  40. digest as opposed to a digital signature. See NOTES below for digital
  41. signatures using B<-hex>.
  42. =item B<-binary>
  43. output the digest or signature in binary form.
  44. =item B<-r>
  45. output the digest in the "coreutils" format used by programs like B<sha1sum>.
  46. =item B<-non-fips-allow>
  47. Allow use of non FIPS digest when in FIPS mode. This has no effect when not in
  48. FIPS mode.
  49. =item B<-out filename>
  50. filename to output to, or standard output by default.
  51. =item B<-sign filename>
  52. digitally sign the digest using the private key in "filename".
  53. =item B<-keyform arg>
  54. Specifies the key format to sign digest with. The DER, PEM, P12,
  55. and ENGINE formats are supported.
  56. =item B<-engine id>
  57. Use engine B<id> for operations (including private key storage).
  58. This engine is not used as source for digest algorithms, unless it is
  59. also specified in the configuration file.
  60. =item B<-sigopt nm:v>
  61. Pass options to the signature algorithm during sign or verify operations.
  62. Names and values of these options are algorithm-specific.
  63. =item B<-passin arg>
  64. the private key password source. For more information about the format of B<arg>
  65. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
  66. =item B<-verify filename>
  67. verify the signature using the the public key in "filename".
  68. The output is either "Verification OK" or "Verification Failure".
  69. =item B<-prverify filename>
  70. verify the signature using the the private key in "filename".
  71. =item B<-signature filename>
  72. the actual signature to verify.
  73. =item B<-hmac key>
  74. create a hashed MAC using "key".
  75. =item B<-mac alg>
  76. create MAC (keyed Message Authentication Code). The most popular MAC
  77. algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
  78. which are not based on hash, for instance B<gost-mac> algorithm,
  79. supported by B<ccgost> engine. MAC keys and other options should be set
  80. via B<-macopt> parameter.
  81. =item B<-macopt nm:v>
  82. Passes options to MAC algorithm, specified by B<-mac> key.
  83. Following options are supported by both by B<HMAC> and B<gost-mac>:
  84. =over 8
  85. =item B<key:string>
  86. Specifies MAC key as alphnumeric string (use if key contain printable
  87. characters only). String length must conform to any restrictions of
  88. the MAC algorithm for example exactly 32 chars for gost-mac.
  89. =item B<hexkey:string>
  90. Specifies MAC key in hexadecimal form (two hex digits per byte).
  91. Key length must conform to any restrictions of the MAC algorithm
  92. for example exactly 32 chars for gost-mac.
  93. =back
  94. =item B<-rand file(s)>
  95. a file or files containing random data used to seed the random number
  96. generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
  97. Multiple files can be specified separated by a OS-dependent character.
  98. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
  99. all others.
  100. =item B<-non-fips-allow>
  101. enable use of non-FIPS algorithms such as MD5 even in FIPS mode.
  102. =item B<-fips-fingerprint>
  103. compute HMAC using a specific key
  104. for certain OpenSSL-FIPS operations.
  105. =item B<file...>
  106. file or files to digest. If no files are specified then standard input is
  107. used.
  108. =back
  109. =head1 EXAMPLES
  110. To create a hex-encoded message digest of a file:
  111. openssl dgst -md5 -hex file.txt
  112. To sign a file using SHA-256 with binary file output:
  113. openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
  114. To verify a signature:
  115. openssl dgst -sha256 -verify publickey.pem \
  116. -signature signature.sign \
  117. file.txt
  118. =head1 NOTES
  119. The digest of choice for all new applications is SHA1. Other digests are
  120. however still widely used.
  121. When signing a file, B<dgst> will automatically determine the algorithm
  122. (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
  123. When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
  124. itself, not the related data to identify the signer and algorithm used in
  125. formats such as x.509, CMS, and S/MIME.
  126. A source of random numbers is required for certain signing algorithms, in
  127. particular ECDSA and DSA.
  128. The signing and verify options should only be used if a single file is
  129. being signed or verified.
  130. Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
  131. or similar program to transform the hex signature into a binary signature
  132. prior to verification.
  133. =cut