I'm generating a private key on my new GPG smartcard at this very moment.

On linux, the random would be fed by the keystrokes on my keyboard, the network packets, the mouse movements etc.

How does the chip on my smartcard generate unpredictable random numbers?

  • Are you not just writing to the smart card? – McMatty Jan 9 at 21:25
  • I’m using the “generate” command from a gpg prompt. From what I understand the key is generated on the card and never reaches the computer. I may be wrong though. – aspyct Jan 9 at 21:27

Almost all - if not all - smart cards have a true random number generator (TRNG) on it. Most often the TRNG depends on thermal noise or clock drift, but other entropy sources are possible. A more technical evaluation of this can be found e.g. here ("Sources of Randomness in Digital Devices and Their Testability by Viktor Fischer"). For a longer set of options, have a look at the "hardware random number generator page on Wikipedia. Which one is implemented depends on the specific model of smart card that you are using. It may be hard to find out because commonly this kind of info is hidden in technical documentation that you may not have access to.

The entropy generated by such a TRNG are commonly whitened and / or fed into a CSPRNG before they are used by the OS, applications and / or libraries on the smart card. Usually the RNG's are validated against FIPS 140-2 or AIS31 (German BSI), possibly as part of a Common Criteria certification. The certification of the TRNG / CSPRNG is commonly mentioned in the data sheets of the specific processors and the certification may indicate the precise TRNG that is used.

In your case undoubtedly either a whitened TRNG or a CSPRNG seeded from that TRNG is used for generating two primes of half the key size for your key pair. This requires a lot of randomness. How much entropy and randomness is used depends on the implementation and possibly how much luck the implementation has on finding the primes.

Note that Linux will nowadays also use randomness on chips that support the RDRAND implementation specified by Intel and copied under their agreement by AMD for their Ryzen chips. Because not everybody trusts this kind of random source it is common to mix in entropy from other sources. Other CPU's such as VIA's Eden processors have sported other chip based solutions. Motherboards often contain a TPM chip as well, which is commonly based on a Smart Card design, and sports the same kind of hardware TRNG.

  • Pretty cool answer! Thanks, that clears it up, I’ll have a look at those links. – aspyct Feb 12 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.