Where does the entropy that cryptographic .NET libraries use for encryption come from? I know with Linux you can use
/dev/random, but does a similar pool exist within Windows?
Update: Since I wrote this post,
CryptGenRandom has been deprecated. Apparently it is now recommended to use
BCryptGenRandom from the "Cryptography Next Generation" API.
(Confusingly, it has nothing to do with bcrypt.)
Yes, Windows has something similar. It can be accessed through
With Microsoft CSPs, CryptGenRandom uses the same random number generator used by other security components. This allows numerous processes to contribute to a system-wide seed. CryptoAPI stores an intermediate random seed with every user. To form the seed for the random number generator, a calling application supplies bits it might have—for instance, mouse or keyboard timing input—that are then combined with both the stored seed and various system data and user data such as the process ID and thread ID, the system clock, the system time, the system counter, memory status, free disk clusters, the hashed user environment block. This result is used to seed the pseudorandom number generator (PRNG). In Windows Vista with Service Pack 1 (SP1) and later, an implementation of the AES counter-mode based PRNG specified in NIST Special Publication 800-90 is used.
Technically this is closer to
/dev/random, but in practice the fact that you get cryptographically random numbers rather than "pure entropy" does not matter.