Smart Card - Entropy during on-board public key generation I know that some (advanced) smart cards or tokens allow generating key pair directly on the device, but I wonder how the card can gather entropy during the process. Any idea ?
In short, they retrieve the entropy directly from a source on the chip.

From Wikipedia:


  In computing, a hardware random number generator (TRNG, True Random Number Generator) is an apparatus that generates random numbers from a physical process, rather than a computer program. Such devices are often based on microscopic phenomena that generate low-level, statistically random "noise" signals, such as thermal noise, the photoelectric effect, and other quantum phenomena


All reasonably secure smart cards contain a hardware source of entropy. In that way they are not dependable on entropy from the outside. This is of course highly important for smart cards as they should consider any outside information as possibly tainted.

Often these sources of random entropy are post-processed by some form of whitening. And often they are fed into a Deterministic Random Number Generator before the data is used by an application or send to the outside world. On less secure cards this is often a LSFR, but on higher-end cards NIST modes such as CTR_DRBG are used. This is therefore somewhat similar to how RD_RAND operates on modern Intel CPU's.

Beware to check if on card key generation is actually certified in the field for the particular smart card. Even if the key generation is supported, it may not contain enough protection against side channel attacks in the field. In that case you should only use the on board key generation within a secure environment. This is particularly true for RSA key pair generation.

Just like all the other parts of a smart card processor, the entropy source as well as the post processing can come under attack. Furthermore there have been (many) mistakes in the implementation of random generation in smart cards. Some of these can be contributed to the sometimes extreme limitation of resources on smart cards chips (over-optimization).