lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, 17 Jan 2010 19:12:20 +0000
David Given <dg@cowlark.com> wrote:

> On 17/01/10 13:06, Rob Kendrick wrote:
> > On Sun, 17 Jan 2010 12:55:56 +0000
> > startx <startx@plentyfact.org> wrote:
> [...]
> >> i assume by "unsafe" you mean "unreliable", meaning that if there
> >> is not enought entropy it will block? thats the nature
> >> of /dev/random , if you want non-blocking entropy /dev/urandom is
> >> what you need.
> > 
> > No, it won't block.  It's PRNG that is occasionally reseeded by
> > people writing to it.
> 
> For clarity:
> 
> On Linux, /dev/random will return truly random values from the entropy
> pool. If the entropy pool is empty, it *will* block.
> 
> /dev/urandom is a variant of /dev/random that, when the entropy pool
> is empty, will return fake random numbers generated with a PRNG. As
> such it is not suitable for crypto purposes.

Although /dev/urandom is periodically (and quite often on busy systems)
reseeded from /dev/random.   You can witness this effect by examining
the contents of /proc/sys/kernel/random/entropy_avail while reading
large amounts of data from urandom.

It's also worth noting that many operating systems (like OS X)
essentially symlink urandom to random.

> By default, Linux's entropy pool size is 4096 bits. Processes will
> only get woken up when at least 64 bits of entropy are available.
> There's a warning in the documentation that /dev/random is suitable
> for reading very small quantities of data only, such as crypto key
> seeds (not crypto keys themselves!), and that unless you really know
> what you're doing /dev/urandom is almost certainly the one you want.

B.