tpm2_getrandom man page

tpm2_getrandom(1) — Retrieves random bytes from the TPM.


tpm2_getrandom [Options] SIZE


tpm2_getrandom(1) - Returns the next SIZE octets from the random number generator. The SIZE parameter is expected as the only argument to the tool.


Common Options

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

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.

Tcti Options

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


Generate a random 20 bytes and output the binary data to a file:

tpm2_getrandom -o random.out 20

Generate a random 8 bytes and output the hex formated data to stdout:

tpm2_getrandom 8


0 on success or 1 on failure.


Github Issues (


See the Mailing List (


SEPTEMBER 2017 tpm2-tools General Commands Manual