Re: Why does reading from /dev/urandom deplete entropy so much?

Matt Mackall
2007-12-05T21:28:36Z

On Tue, Dec 04, 2007 at 07:17:58PM +0100, Eric Dumazet wrote:
> Alan Cox a ?crit :
> >>No matter what you consider as being better, changing a 12 years old and
> >>widely used userspace interface like /dev/urandom is simply not an
> >>option.
> >>
> >
> >Fixing it to be more efficient in its use of entropy and also fixing the
> >fact its not actually a good random number source would be worth looking
> >at however.
> >
> Yes, since current behavior on network irq is very pessimistic.

No, it's very optimistic. The network should not be trusted.

The distinction between /dev/random and /dev/urandom boils down to one
word: paranoia. If you are not paranoid enough to mistrust your
network, then /dev/random IS NOT FOR YOU. Use /dev/urandom. Do not
send patches to make /dev/random less paranoid, kthxbye.

> If you have some trafic, (ie more than HZ/2 interrupts per second),
> then add_timer_randomness() feeds
> some entropy but gives no credit (calling credit_entropy_store() with
> nbits=0)
>
> This is because we take into account only the jiffies difference, and
> not the get_cycles() that should give
> us more entropy on most plaforms.

If we cannot measure a difference, we should nonetheless assume there
is one?

> In this patch, I suggest that we feed only one u32 word of entropy,
> combination of the previous distinct
> words (with some of them being constant or so), so that the nbits
> estimation is less pessimistic, but also to
> avoid injecting false entropy.

Umm.. no, that's not how it works at all.

Also, for future reference, patches for /dev/random go through me, not
through Dave.

--
Mathematics is the supreme nostalgia of our time.