diff options
author | Adam Jackson <ajax@aspartame.nwnk.net> | 2007-11-16 19:53:11 -0500 |
---|---|---|
committer | Adam Jackson <ajax@aspartame.nwnk.net> | 2007-11-16 19:53:11 -0500 |
commit | 514ba4ca727f0b1076bc67500617722203d34daa (patch) | |
tree | 7b965e8c634361da0f6ccf4755166497d1c4d540 /os | |
parent | 20fd4783247b1b93d9675dc36768dd1ed59ba2d3 (diff) |
Bug #1612: Use a stronger PRNG.
Currently just reads from /dev/urandom, and only on Linux.
Diffstat (limited to 'os')
-rw-r--r-- | os/auth.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 */ |