I recently had a bug where I didn't properly handle when the entropy on my linux server got too low and a read of /dev/urandom returned less than the number of bytes expected.
How can I recreate this with a test? Is there a way to lower the entropy on a system or to reliably empty /dev/urandom?
I'd like to be able to have a regression test that will verify my fix. I'm using Ubuntu 12.04.
According to random(4) man page,
You should read a lot of bytes from
/dev/random
(without anyu
) if you want it to block. (How many is hardware and system dependent).So you cannot "exaust"
/dev/urandom
, sinceI believe you should use
/dev/random
which indeed can be exhausted, by blocking. But you should not read more than about 256 bits from it.