Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Does WSL provide decent entropy? (e.g. for generating ssh keys) #1789

Closed
evancox10 opened this issue Mar 19, 2017 · 3 comments
Closed
Labels

Comments

@evancox10
Copy link

While recognizing the complexities inherent in this topic, I wanted to know if we could get some guidance on what to expect from the entropy sources / random number generators in WSL (/dev/random, /dev/urandom, and the getentropy/getrandom sys calls). Is it mixing in user-generated entropy from the environment? Using hardware-assisted RNG from a CPU (when available)? Or instead, is it doing something boneheaded like seeding the entropy pool with the current time or PID? Or worse, a hard-coded seed?

An example use case would be generating ssh keys. I would like to know whether or not I can expect the randomness used to generate the keys as "good enough" for every day usage. ie No state-level actors or APT malware.

Currently there is no /proc/sys/kernel/random/entropy_avail to check for entropy, but I see in #1092 that a fix is inbound for some parts of /proc/sys/kernel/random, so maybe that will include a working implementation of entropy_avail.

Any implementation details that could be shared would be appreciated too. Thanks!

@fpqc
Copy link

fpqc commented Mar 20, 2017

@evancox10 /dev/random does not use entropy_avail in userspace in Linux. The Linux kernel blocks when entropy_avail is zero, not the userspace. Pretty sure that in WSL, /dev/random sits on top of the NT Kernel's version of /dev/random (KsecDD).

From Wikipedia:
In Windows NT, similar functionality is delivered by ksecdd.sys, but reading the special file \Device\KsecDD does not work as in UNIX. The documented methods to generate cryptographically random bytes are CryptGenRandom and RtlGenRandom.

@benhillis
Copy link
Member

benhillis commented Mar 20, 2017

@evancox10 - Great question. We use the BCryptGenRandom API in our driver to generate random bytes for the getrandom syscall as well as /dev/random and /dev/urandom.

@evancox10
Copy link
Author

Thanks @benhillis, that answers my question!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants