]> git.pond.sub.org Git - empserver/commit
Fix PRNG seeding to resist guessing
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 29 Dec 2012 14:06:29 +0000 (15:06 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:55:21 +0000 (06:55 +0200)
commit9102ecce547c357802578ef437aae466ea88dc1d
treec0b35ea238d238236e83204ef56121fca767c6ff
parent39c26f4238f26671537659450038e12fc35a528c
Fix PRNG seeding to resist guessing

We seed it with value of time().  It's the traditional way, but it
provides only a few bits of effective entropy when an attacker has a
rough idea when the program started.

Instead, seed with a kernel random number.  If we can't get one, fall
back to a hash of gettimeofday() and getpid().  This should happen
only on old systems or Windows.  Far worse than a kernel random
number, but far better than using time().

Note that fairland used to seed with time() + getpid() until commit
331aac2a (v4.2.20) dropped the getpid(), claiming it didn't improve
the randomness.  Perhaps it didn't under Windows then, but it
certainly did elsewhere, so it was a regression.
include/chance.h
src/lib/gen/chance.c
src/server/main.c
src/util/fairland.c