tpm2_hash

Section: General Commands Manual (1)
Updated: SEPTEMBER 2017
Page Index
 

NAME

tpm2_hash(1) - Performs a hash operation with the TPM.  

SYNOPSIS

tpm2_hash [OPTIONS] FILE  

DESCRIPTION

tpm2_hash(1) - performs a hash operation on FILE and returns the results. If FILE is not specified, then data is read from stdin. If the results of the hash will be used in a signing operation that uses a restricted signing key, then the ticket returned by this command can indicate that the hash is safe to sign.  

OPTIONS

-H, -hierarchy=HIERARCHY: hierarchy to use for the ticket. Supported options are:
o for TPM_RH_OWNER
p for TPM_RH_PLATFORM
e for TPM_RH_ENDORSEMENT
n for TPM_RH_NULL
-g, -halg=HASH_ALGORITHM: The hash algorithm to use. Algorithms should follow the "formatting standards, see section"Algorithm Specifiers". Also, see section"Supported Hash Algorithms" for a list of supported hash algorithms.
-o, -outfile=OUT_FILE Optional file record of the hash result. Defaults to stdout in hex form.
-t, -ticket=TICKET_FILE Optional file record of the ticket result. Defaults to stdout in hex form.
 

COMMON OPTIONS

This collection of options are common to many programs and provide information that many users may expect.

-h, -help: Display the tools manpage. This requires the manpages to be installed or on MANPATH, See man(1) for more details.
-v, -version: Display version information for this tool, supported tctis and exit.
-V, -verbose: Increase the information that the tool prints to the console during its execution. When using this option the file and line number are printed.
-Q, -quiet: Silence normal tool output to stdout.
-Z, -enable-errata: Enable the application of errata fixups. Useful if an errata fixup needs to be applied to commands sent to the TPM. # TCTI ENVIRONMENT

This collection of environment variables that may be used to configure the various TCTI modules available.

The values passed through these variables can be overridden on a per-command basis using the available command line options, see the TCTI_OPTIONS section.

The variables respected depend on how the software was configured.

TPM2TOOLS_TCTI_NAME: Select the TCTI used for communication with the next component down the TSS stack. In most configurations this will be the TPM but it could be a simulator or proxy. The current known TCTIs are:
tabrmd - The new resource manager, called tabrmd (https://github.com/01org/tpm2-abrmd).
socket - Typically used with the old resource manager, or talking directly to a simulator.
device - Used when talking directly to a TPM device file.
TPM2TOOLS_DEVICE_FILE: When using the device TCTI, specify the TPM device file. The default is "/dev/tpm0".

Note: Using the tpm directly requires the users to ensure that concurrent access does not occur and that they manage the tpm resources. These tasks are usually managed by a resource manager. Linux 4.12 and greater supports an in kernel resource manager at "/dev/tpmrm", typically "/dev/tpmrm0".

TPM2TOOLS_SOCKET_ADDRESS: When using the socket TCTI, specify the domain name or IP address used. The default is 127.0.0.1.
TPM2TOOLS_SOCKET_PORT: When using the socket TCTI, specify the port number used. The default is 2321.
 

TCTI OPTIONS

This collection of options are used to configure the varous TCTI modules available. They override any environment variables.

-T, -tcti=TCTI_NAME[:TCTI_OPTIONS]: Select the TCTI used for communication with the next component down the TSS stack. In most configurations this will be the resource manager: tabrmd (https://github.com/01org/tpm2-abrmd) Optionally, tcti specific options can appended to TCTI_NAME by appending a : to TCTI_NAME.
For the device TCTI, the TPM device file for use by the device TCTI can be specified. The default is /dev/tpm0. Example: -T device:/dev/tpm0
For the socket TCTI, the domain name or IP address and port number used by the socket can be specified. The default are 127.0.0.1 and 2321. Example: -T socket:127.0.0.1:2321
For the abrmd TCTI, it takes no options. Example: -T abrmd
 

Supported Hash Algorithms

Supported hash algorithms are:

0x4 or sha1 for TPM_ALG_SHA1 (default)
0xB or sha256 for TPM_ALG_SHA256
0xC or sha384 for TPM_ALG_SHA384
0xD or sha512 for TPM_ALG_SHA512
0x12 or sm3_256 for TPM_ALG_SM3_256

NOTE: Your TPM may not support all algorithms.  

Algorithm Specfiers

Options that take algorithms support "nice-names". Nice names, like sha1 can be used in place of the raw hex for sha1: 0x4. The nice names are converted by stripping the leading TPM_ALG_ from the Algorithm Name field and converting it to lower case. For instance TPM_ALG_SHA3_256 becomes sha3_256.

The algorithms can be found at: <https://trustedcomputinggroup.org/wp-content/uploads/TCG_Algorithm_Registry_Rev_1.24.pdf>  

EXAMPLES

Hash a file with sha1 hash algorithm and save the hash and ticket to a file:


tpm2_hash -H e -g sha1 -o hash.bin -t ticket.bin data.txt

 

RETURNS

0 on success or 1 on failure.  

BUGS

Github Issues (https://github.com/01org/tpm2-tools/issues)  

HELP

See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
COMMON OPTIONS
TCTI OPTIONS
Supported Hash Algorithms
Algorithm Specfiers
EXAMPLES
RETURNS
BUGS
HELP