Random Number Generator (TPM2)
1. IntroductionAmong other features, Trusted Platform Modules (TPM) comes with a True Random Number Generator (TRNG) that can be used for various applications including cryptographic purposes. This RNG module serves as the source for randomness for the TPM 2.0 Chip. A RNG module in TPM2 will typically contain the following -
An entropy source and collector
State Register
A mixing func.
There can be two types of calls to the TPMβs Random Number Generator, Internal call and External Call. RNG is capable to provide enough randomness for all the internal calls made. As well as, RNG is capable of providing 32 octets of randomness as per the specification to an external call. Another thing to note here is, each call made to the RNG produces a new value irrespective of the type of call. 1.1 The source of RandomnessThe source of entropy in the TPM is the entropy collector. As the name suggests, entropy collector collects entropy from entropy sources and also removes bias. A TPM2.0 has at least one internal source of entropy. These sources can include noise, clock variations, air movement amongst other events. As depicted in Fig 1.1 the entropy collector provides input to the State Register. 1.2 Stages involved Various algorithms and process supported by TPM calls RNG for unpredictable numbers, which is actually obtained from βRNG Protected Capabilityβ. The βDeterministic Random Bit Generator (DRBG) Protected Capabilityβ obtains entropy from βEntropy Protected Capabilityβ. Along with Entropy Protected Capability, TPM2_StirRandom() can also gather entropy from other entropy sources within the same TPM. 2. Random Numbers via TPM2 ToolsIf one needs to use TPMβs RNG for other external applications, then TPM2 Tools Command Line tools can be a great option. TPM2 Tools Command : tpm2_getrandom - - hex 16 - - hex : Converts output to hexadecimal 16 : Size in bytes Now, if one wants to have additional randomness, TPM2 Tools provides a convenient utility for this purpose called tpm2_stirrandom. To inject entropy via TPM2_StirRandom() to βEntropy Protected Capabilityβ , we can use some file or use stdin. TPM2 Tools Command : echo -n βsome_random_dataβ | tpm2_stirrandom Note : 128 bytes can only be injected using stdin at once through stirrandom() 3. ConclusionThe TPM2 provides in a sense True Random Numbers for use. These unpredictable numbers are coming from a dedicated hardware, hence can be trusted to be given as input to Crypto Algorithms amongst other applications. TPM2 also uses this for its internal use, and TCG claims it to be as secure as the strongest algorithm that TPM supports. Also, using the RNG is pretty straight forward via TPM2 Tools. #Tutorials


Comments
Start the Conversation
Indeed, I myself have used the TPM 1.2 code to poke around attestation. To be honest, it was the quickest way to get attestation running for TPM 1.2 after Trousers with the benefit of having more concise code. Ken Goldman would you β¦more
Now that I think about it, I did have one issue with the IBM TSS stack and it was about policies. To run the included scripts and demos I had to create TPM policies for authorization. And I remember there was some difficulty with that, what are the expect β¦more
1. The package includes all the sample policies in the ../utils/policies directory. It's possible that one is missing, but we test widely. Could you have customized the installation β¦more
Ken Goldman my experience is from 2017 and lots has changed since then in the IBM TSS.
Our experience might be interesting β¦more
For the (previous) listing question, I suggest adding the IBM TSS's tools on the https://tpm.dev/tpm_tools.html page. My experience is that developers start with these tools to (bash) script their application quickly, then convert to β¦more
I'm sure that it was intentional, but I found it a nuisance having to get two packages and worry about compatibility.
Dropping by to say that all TPM Tools, Stacks and Applications now reside under single section at the webpage - TPM Software. Can be checked at this link: