Yes, but that's how you're getting randomness anyway. In Linux and most other operating systems, the exact time in nanoseconds that a key is pressed is recorded and injected into the entropy pool. This pool is used to seed the CSPRNG that powers /dev/urandom
and other cryptographic random APIs.
The similar /dev/random
character device is what we describe as blocking. It assumes that all used cryptographic functions are broken (a worst-case scenario) and so will only output randomness when it thinks it has "collected" enough entropy. When you type keys, the operating system uses that as a source of entropy and increases the entropy estimate, causing /dev/random
to unblock. This speeds up the entropy collection by programs using that device. Now that doesn't mean that the program sare doing the right thing. They should have just used /dev/urandom
which does not block and is still quite cryptographically secure. You should take a look at https://www.2uo.de/myths-about-urandom.
A related document on best practices for randomness generation is BCP 106.
/dev/urandom
than will ever be needed. At best, it does nothing. At worst, they mix that input with/dev/urandom
themselves in a way that reduces the overally quality of the entropy. – Stephen Touset Feb 26 '19 at 23:48The Linux kernel uses only the arrival times of events to estimate their entropy. It does that by interpolating polynomials of those arrival times, to calculate “how surprising” the actual arrival time was, according to the model.
Those events can be any events that the kernel as some expectation for how quickly they should happen, not just keyboard and mouse. It's a nebulous answer, because I don't even know half the stuff that goes on in my computer. The harddrive is acting much less chaotically if the init is serialized. – Ed Grimm Feb 27 '19 at 04:27Exported interfaces ---- input
. Note also that calculating "how surprising" is only done via the input subsystem and for disk reads, not for interrupts which don't affect the entropy estimate. – forest Feb 27 '19 at 04:30