Everyone has urandom

If you don't have urandom, please just add a fallback to /dev/random,
rather than building our own random generator.
This commit is contained in:
Daniel Stone 2008-07-17 21:39:46 +03:00
parent 446fe9eecd
commit 711720650c
2 changed files with 0 additions and 56 deletions

View File

@ -176,19 +176,6 @@ dnl has it in libc), or if libdl is needed to get it.
AC_CHECK_FUNC([dlopen], [],
AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
case $host_os in
linux*|darwin*)
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
freebsd*|netbsd*|openbsd*|dragonfly*)
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
solaris*)
# Solaris 8 with patches, or Solaris 9 or later have /dev/urandom
if test -r /dev/urandom ; then
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom])
fi ;;
*) ;;
esac
dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \

View File

@ -314,8 +314,6 @@ GenerateAuthorization(
return -1;
}
#ifdef HAVE_URANDOM
void
GenerateRandomData (int len, char *buf)
{
@ -326,45 +324,4 @@ GenerateRandomData (int len, char *buf)
close(fd);
}
#else /* !HAVE_URANDOM */
/* A random number generator that is more unpredictable
than that shipped with some systems.
This code is taken from the C standard. */
static unsigned long int next = 1;
static int
xdm_rand(void)
{
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % 32768;
}
static void
xdm_srand(unsigned int seed)
{
next = seed;
}
void
GenerateRandomData (int len, char *buf)
{
static int seed;
int value;
int i;
seed += GetTimeInMillis();
xdm_srand (seed);
for (i = 0; i < len; i++)
{
value = xdm_rand ();
buf[i] ^= (value & 0xff00) >> 8;
}
/* XXX add getrusage, popen("ps -ale") */
}
#endif /* HAVE_URANDOM */
#endif /* XCSECURITY */