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