14 Commits

Author SHA1 Message Date
Nick Mathewson
9f560bfa11 Use "_WIN32", not WIN32: it's standard and we don't need to fake it
This patch was automatically generated with perl.

Based on a patch by Peter Rosin.
2011-05-25 20:03:15 -04:00
Nick Mathewson
9f5bf66396 Merge remote branch 'origin/patches-2.0' 2011-02-08 22:24:51 -05:00
Nick Mathewson
f736198086 Fix a type error in our (unused) arc4random_stir() 2011-02-08 22:24:06 -05:00
Kevin Bowling
ded0a0907b Add evconfig-private to remaining files 2011-01-07 00:41:37 -07:00
Nick Mathewson
9c8db0f804 Fix all warnings in the main codebase flagged by -Wsigned-compare
Remember, the code
   int is_less_than(int a, unsigned b) {
      return a < b;
   }
is buggy, since the C integer promotion rules basically turn it into
   int is_less_than(int a, unsigned b) {
      return ((unsigned)a) < b;
   }
and we really want something closer to
   int is_less_than(int a, unsigned b) {
      return a < 0 || ((unsigned)a) < b;
   }
.

Suggested by an example from Ralph Castain
2010-09-23 22:45:55 -04:00
Nick Mathewson
c44de06c76 Numerous opensolaris compilation fixes
For future note, opensolaris doesn't have sys/sysctl.h, doesn't like
comparing iov_buf to a chain_space_ptr without a cast, and is (predictably)
unforgiving of dumb syntax errors.

Also, we had accidentally broken the devpoll backend test in configure.in
2010-05-08 19:34:09 -04:00
Nick Mathewson
90d4225137 Fix some crazy macro mistakes in arc4random.c 2010-05-08 15:31:54 -04:00
Nick Mathewson
20fda296c5 Try /proc on Linux as entropy fallback; use sysctl as last resort
It turns out that the happy fun Linux kernel is deprecating sysctl,
and using sysctl to fetch entropy will spew messages in the kernel
logs.  Let's not do that.  Instead, let's call sysctl for our
entropy only when all other means fail.

Additionally, let's add another means, and try
/proc/sys/kernel/random/uuid if /dev/urandom fails.
2010-05-03 13:00:00 -04:00
Nick Mathewson
a47a4b7e7e Fix a couple of bugs in the BSD sysctl arc4seed logic
Of course, FreeBSD has its own arc4random() implementation, so this should
never actually be needed.  Still, it's good to paint the underside of the
wagon.
2010-04-23 16:08:09 -04:00
Nick Mathewson
71fc3eb08b Seed the RNG using sysctl() as well as /dev/urandom
William Ahern points out that if the user has chrooted, they might not
have a working /dev/urandom.  Linux and many of the BSDs, however,
define a sysctl interface to their kernel random number generators.

This patch takes a belt-and-suspenders approach and tries to do use the
sysctl _and_ the /dev/urandom approach if both are present.  When using
the sysctl approach, it tries to bulletproof itself by checking to make
sure that the buffers are actually set by the sysctl calls.
2010-04-23 15:46:04 -04:00
Nick Mathewson
98edb891f8 Fix arc4random compilation on MSVC. 2010-02-25 17:14:41 -05:00
Nick Mathewson
ff2a134d6e Fix getpid() usage on Windows
On Windows, getpid() is _getpid(), and requires that we first include
<process.h>.  arc4random.c previously didn't know that.

Actually, I question whether arc4random needs to do its getpid() tricks
on Windows.  They exist only so that we remember to re-seed the ARC4
cipher whenever we fork... but Windows has no fork(), so I think we're
in the clear.
2010-02-18 00:54:44 -05:00
Nick Mathewson
4ec8fea68e Make RNG work when we have arc4random() but not arc4random_buf() 2010-02-13 00:11:44 -05:00
Nick Mathewson
d4de062efc Add an arc4random implementation for use by evdns
Previously, evdns was at the mercy of the user for providing a good
entropy source; without one, it would be vulnerable to various
active attacks.

This patch adds a port of OpenBSD's arc4random() calls to Libevent
[port by Chris Davis], and wraps it up a little bit so we can use it
more safely.
2010-02-11 12:53:32 -05:00