xref: /freebsd/secure/usr.bin/openssl/man/openssl-dgst.1 (revision ba3c1f5972d7b90feb6e6da47905ff2757e0fe57)
Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "OPENSSL-DGST 1"
OPENSSL-DGST 1 "2023-06-02" "3.0.9" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
openssl-dgst - perform digest operations
"SYNOPSIS"
Header "SYNOPSIS" \fBopenssl dgst|digest [-\f(BIdigest] [-list] [-help] [-c] [-d] [-debug] [-hex] [-binary] [-xoflen length] [-r] [-out filename] [-sign filename|uri] [-keyform \s-1DER\s0|\s-1PEM\s0|P12|\s-1ENGINE\s0] [-passin arg] [-verify filename] [-prverify filename] [-signature filename] [-sigopt nm:v] [-hmac key] [-mac alg] [-macopt nm:v] [-fips-fingerprint] [-engine id] [-engine_impl id] [-rand files] [-writerand file] [-provider name] [-provider-path path] [-propquery propq] [file ...]
"DESCRIPTION"
Header "DESCRIPTION" This command output the message digest of a supplied file or files in hexadecimal, and also generates and verifies digital signatures using message digests.

The generic name, openssl dgst, may be used with an option specifying the algorithm to be used. The default digest is sha256. A supported digest name may also be used as the sub-command name. To see the list of supported algorithms, use \*(C`openssl list -digest-algorithms\*(C'

"OPTIONS"
Header "OPTIONS"
"-help" 4
Item "-help" Print out a usage message.
"-\f(BIdigest" 4
Item "-digest" Specifies name of a supported digest to be used. See option -list below :
"-list" 4
Item "-list" Prints out a list of supported message digests.
"-c" 4
Item "-c" Print out the digest in two digit groups separated by colons, only relevant if the -hex option is given as well.
"-d, -debug" 4
Item "-d, -debug" Print out \s-1BIO\s0 debugging information.
"-hex" 4
Item "-hex" Digest is to be output as a hex dump. This is the default case for a \*(L"normal\*(R" digest as opposed to a digital signature. See \s-1NOTES\s0 below for digital signatures using -hex.
"-binary" 4
Item "-binary" Output the digest or signature in binary form.
"-xoflen length" 4
Item "-xoflen length" Set the output length for \s-1XOF\s0 algorithms, such as shake128 and shake256. This option is not supported for signing operations. .Sp For OpenSSL providers it is recommended to set this value for shake algorithms, since the default values are set to only supply half of the maximum security strength. .Sp For backwards compatibility reasons the default xoflen length for shake128 is 16 (bytes) which results in a security strength of only 64 bits. To ensure the maximum security strength of 128 bits, the xoflen should be set to at least 32. .Sp For backwards compatibility reasons the default xoflen length for shake256 is 32 (bytes) which results in a security strength of only 128 bits. To ensure the maximum security strength of 256 bits, the xoflen should be set to at least 64.
"-r" 4
Item "-r" Output the digest in the \*(L"coreutils\*(R" format, including newlines. Used by programs like sha1sum\|(1).
"-out filename" 4
Item "-out filename" Filename to output to, or standard output by default.
"-sign filename|uri" 4
Item "-sign filename|uri" Digitally sign the digest using the given private key. Note this option does not support Ed25519 or Ed448 private keys. Use the openssl-pkeyutl\|(1) command instead for this.
"-keyform \s-1DER\s0|\s-1PEM\s0|P12|\s-1ENGINE\s0" 4
Item "-keyform DER|PEM|P12|ENGINE" The format of the key to sign with; unspecified by default. See openssl-format-options\|(1) for details.
"-sigopt nm:v" 4
Item "-sigopt nm:v" Pass options to the signature algorithm during sign or verify operations. Names and values of these options are algorithm-specific.
"-passin arg" 4
Item "-passin arg" The private key password source. For more information about the format of arg see openssl-passphrase-options\|(1).
"-verify filename" 4
Item "-verify filename" Verify the signature using the public key in \*(L"filename\*(R". The output is either \*(L"Verified \s-1OK\*(R"\s0 or \*(L"Verification Failure\*(R".
"-prverify filename" 4
Item "-prverify filename" Verify the signature using the private key in \*(L"filename\*(R".
"-signature filename" 4
Item "-signature filename" The actual signature to verify.
"-hmac key" 4
Item "-hmac key" Create a hashed \s-1MAC\s0 using \*(L"key\*(R". .Sp The openssl-mac\|(1) command should be preferred to using this command line option.
"-mac alg" 4
Item "-mac alg" Create \s-1MAC\s0 (keyed Message Authentication Code). The most popular \s-1MAC\s0 algorithm is \s-1HMAC\s0 (hash-based \s-1MAC\s0), but there are other \s-1MAC\s0 algorithms which are not based on hash, for instance gost-mac algorithm, supported by the gost engine. \s-1MAC\s0 keys and other options should be set via -macopt parameter. .Sp The openssl-mac\|(1) command should be preferred to using this command line option.
"-macopt nm:v" 4
Item "-macopt nm:v" Passes options to \s-1MAC\s0 algorithm, specified by -mac key. Following options are supported by both by \s-1HMAC\s0 and gost-mac:

"key:string" 4
Item "key:string" Specifies \s-1MAC\s0 key as alphanumeric string (use if key contain printable characters only). String length must conform to any restrictions of the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac.
"hexkey:string" 4
Item "hexkey:string" Specifies \s-1MAC\s0 key in hexadecimal form (two hex digits per byte). Key length must conform to any restrictions of the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac.

.Sp The openssl-mac\|(1) command should be preferred to using this command line option.

"-fips-fingerprint" 4
Item "-fips-fingerprint" Compute \s-1HMAC\s0 using a specific key for certain OpenSSL-FIPS operations.
"-rand files, -writerand file" 4
Item "-rand files, -writerand file" See \*(L"Random State Options\*(R" in openssl\|(1) for details.
"-engine id" 4
Item "-engine id" See \*(L"Engine Options\*(R" in openssl\|(1). This option is deprecated. .Sp The engine is not used for digests unless the -engine_impl option is used or it is configured to do so, see \*(L"Engine Configuration Module\*(R" in config\|(5).
"-engine_impl id" 4
Item "-engine_impl id" When used with the -engine option, it specifies to also use engine id for digest operations.
"-provider name" 4
Item "-provider name"

0

"-provider-path path" 4
Item "-provider-path path"
"-propquery propq" 4
Item "-propquery propq"

See \*(L"Provider Options\*(R" in openssl\|(1), provider\|(7), and property\|(7).

"file ..." 4
Item "file ..." File or files to digest. If no files are specified then standard input is used.
"EXAMPLES"
Header "EXAMPLES" To create a hex-encoded message digest of a file:

.Vb 3 openssl dgst -md5 -hex file.txt or openssl md5 file.txt .Ve

To sign a file using \s-1SHA-256\s0 with binary file output:

.Vb 3 openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt or openssl sha256 -sign privatekey.pem -out signature.sign file.txt .Ve

To verify a signature:

.Vb 3 openssl dgst -sha256 -verify publickey.pem \e -signature signature.sign \e file.txt .Ve

"NOTES"
Header "NOTES" The digest mechanisms that are available will depend on the options used when building OpenSSL. The \*(C`openssl list -digest-algorithms\*(C' command can be used to list them.

New or agile applications should use probably use \s-1SHA-256.\s0 Other digests, particularly \s-1SHA-1\s0 and \s-1MD5,\s0 are still widely used for interoperating with existing formats and protocols.

When signing a file, this command will automatically determine the algorithm (\s-1RSA, ECC,\s0 etc) to use for signing based on the private key's \s-1ASN.1\s0 info. When verifying signatures, it only handles the \s-1RSA, DSA,\s0 or \s-1ECDSA\s0 signature itself, not the related data to identify the signer and algorithm used in formats such as x.509, \s-1CMS,\s0 and S/MIME.

A source of random numbers is required for certain signing algorithms, in particular \s-1ECDSA\s0 and \s-1DSA.\s0

The signing and verify options should only be used if a single file is being signed or verified.

Hex signatures cannot be verified using openssl. Instead, use \*(L"xxd -r\*(R" or similar program to transform the hex signature into a binary signature prior to verification.

The openssl-mac\|(1) command is preferred over the -hmac, -mac and \fB-macopt command line options.

"SEE ALSO"
Header "SEE ALSO" \fBopenssl-mac\|(1)
"HISTORY"
Header "HISTORY" The default digest was changed from \s-1MD5\s0 to \s-1SHA256\s0 in OpenSSL 1.1.0. The FIPS-related options were removed in OpenSSL 1.1.0.

The -engine and -engine_impl options were deprecated in OpenSSL 3.0.

"COPYRIGHT"
Header "COPYRIGHT" Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.