summaryrefslogtreecommitdiff
path: root/os/auth.c
diff options
context:
space:
mode:
authorAdam Jackson <ajax@aspartame.nwnk.net>2007-11-16 19:53:11 -0500
committerAdam Jackson <ajax@aspartame.nwnk.net>2007-11-16 19:53:11 -0500
commit514ba4ca727f0b1076bc67500617722203d34daa (patch)
tree7b965e8c634361da0f6ccf4755166497d1c4d540 /os/auth.c
parent20fd4783247b1b93d9675dc36768dd1ed59ba2d3 (diff)
Bug #1612: Use a stronger PRNG.
Currently just reads from /dev/urandom, and only on Linux.
Diffstat (limited to 'os/auth.c')
-rw-r--r--os/auth.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/os/auth.c b/os/auth.c
index b2a145f89..fa3ba7924 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -325,6 +325,20 @@ GenerateAuthorization(
return -1;
}
+#ifdef HAVE_URANDOM
+
+void
+GenerateRandomData (int len, char *buf)
+{
+ int fd;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ read(fd, buf, len);
+ 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. */
@@ -362,4 +376,6 @@ GenerateRandomData (int len, char *buf)
/* XXX add getrusage, popen("ps -ale") */
}
+#endif /* HAVE_URANDOM */
+
#endif /* XCSECURITY */