1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
% tpm2_hash(1) tpm2-tools | General Commands Manual
# NAME
**tpm2_hash**(1) - Performs a hash operation with the TPM.
# SYNOPSIS
**tpm2_hash** [*OPTIONS*] [*ARGUMENT* OR *STDIN*]
# DESCRIPTION
**tpm2_hash**(1) - Performs a hash operation on file and returns the results.
If argument 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.
Output defaults to *stdout* and binary format unless otherwise specified via
**-o** and **--hex** options respectively.
# OPTIONS
* **-C**, **\--hierarchy**=_OBJECT_:
Hierarchy to use for the ticket. Defaults to **o**, **TPM_RH_OWNER**, when
no value has been specified.
Supported options are:
* **o** for **TPM_RH_OWNER**
* **p** for **TPM_RH_PLATFORM**
* **e** for **TPM_RH_ENDORSEMENT**
* **n** for **TPM_RH_NULL**
* **-g**, **\--hash-algorithm**=_ALGORITHM_:
The hashing algorithm for the digest operation.
* **\--hex**
Convert the output hmac to hex format without a leading "0x".
* **-o**, **\--output**=_FILE_ or _STDOUT_:
Optional file to save 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.
* **ARGUMENT** or **STDIN** the command line argument specifies the _FILE_ to
hash.
## References
[context object format](common/ctxobj.md) details the methods for specifying
_OBJECT_.
[authorization formatting](common/alg.md) details the methods for specifying the
_ALGORITHM_.
[common options](common/options.md) collection of common options that provide
information many users may expect.
[common tcti options](common/tcti.md) collection of options used to configure
the various known TCTI modules.
# EXAMPLES
## Hash a file with sha1 hash algorithm and save the hash and ticket to a file
```bash
tpm2_hash -C e -g sha1 -o hash.bin -t ticket.bin data.txt
```
[returns](common/returns.md)
[footer](common/footer.md)
|