 The problem of how to safely generate truly random keys is difficult, and has been addressed in many ways by various cryptographic systems.There is a RFC on generating randomness (RFC 4086, "Randomness Requirements for Security").Some operating systems include tools for "collecting" entropy from the timing of unpredictable operations such as disk drive head movements.