summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-09-10 05:38:05 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-09-10 05:38:05 +0000
commit5028a28dde0e046ce22fc782e3590bc4d03d36ec (patch)
tree6ca41c2e69c6a31d987f2d9ecef89a9cd78463ed
parent48ac92e8ee739d7a7fc8a9e9c5d9bbf0ca615f4d (diff)
use one call to arc4random_buf() instead of lots of arc4random()
-rw-r--r--lib/libssl/src/crypto/rand/rand_unix.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/libssl/src/crypto/rand/rand_unix.c b/lib/libssl/src/crypto/rand/rand_unix.c
index 6c2be5cb966..964d25833cd 100644
--- a/lib/libssl/src/crypto/rand/rand_unix.c
+++ b/lib/libssl/src/crypto/rand/rand_unix.c
@@ -136,16 +136,10 @@
#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);
+ arc4random_buf(buf, sizeof(buf));
+ RAND_add(buf, sizeof(buf), sizeof(buf));
memset(buf, 0, sizeof(buf));
return 1;