15
$\begingroup$

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?

$\endgroup$
16
$\begingroup$

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 CryptGenRandom.

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/urandom than /dev/random, but in practice the fact that you get cryptographically random numbers rather than "pure entropy" does not matter.

$\endgroup$
  • 1
    $\begingroup$ off-topic comment: where do you people read up such advanced things? $\endgroup$ – Spandan Sep 2 '16 at 13:07
  • 1
    $\begingroup$ @Spandan, I gave the link or what do you mean? $\endgroup$ – otus Sep 2 '16 at 13:20

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.