diff options
author | Richard Levitte <levitte@openssl.org> | 2003-12-27 16:02:22 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2003-12-27 16:02:22 +0000 |
commit | de02ec27673108e4b1e92883171ee8c3092a6e54 (patch) | |
tree | 22bcc9426273ba547b174032d97eb626456289bb /crypto/rand/rand_unix.c | |
parent | 112341031bb60c4e75c105bc879493e42a9f406a (diff) |
Check if a random "file" is really a device file, and treat it
specially if it is.
Add a few OpenBSD-specific cases.
This is part of a large change submitted by Markus Friedl <markus@openbsd.org>
Diffstat (limited to 'crypto/rand/rand_unix.c')
-rw-r--r-- | crypto/rand/rand_unix.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index 8b4c483312..ef80201212 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -125,6 +125,24 @@ #include <unistd.h> #include <time.h> +#ifdef __OpenBSD__ +int RAND_poll(void) +{ + u_int32_t rnd = 0, i; + unsigned char buf[ENTROPY_NEEDED]; + + for (i = 0; i < sizeof(buf); i++) { + if (i % 4 == 0) + rnd = arc4random(); + buf[i] = rnd; + rnd >>= 8; + } + RAND_add(buf, sizeof(buf), ENTROPY_NEEDED); + memset(buf, 0, sizeof(buf)); + + return 1; +} +#else int RAND_poll(void) { unsigned long l; @@ -237,6 +255,7 @@ int RAND_poll(void) } #endif +#endif #if defined(OPENSSL_SYS_VXWORKS) int RAND_poll(void) |