summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rand/rand_unix.c
diff options
context:
space:
mode:
authordjm <>2008-09-10 05:38:04 +0000
committerdjm <>2008-09-10 05:38:04 +0000
commitd50f00e267227a7cafc0e756ed0ae98528cb08cf (patch)
tree2b0539e8f6811f935f6ea8365461a18b29e7c319 /src/lib/libcrypto/rand/rand_unix.c
parent24a8f04e0c97392ab5faa79717baf6aa530e14e8 (diff)
downloadopenbsd-d50f00e267227a7cafc0e756ed0ae98528cb08cf.tar.gz
openbsd-d50f00e267227a7cafc0e756ed0ae98528cb08cf.tar.bz2
openbsd-d50f00e267227a7cafc0e756ed0ae98528cb08cf.zip
use one call to arc4random_buf() instead of lots of arc4random()
Diffstat (limited to 'src/lib/libcrypto/rand/rand_unix.c')
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c
index 6c2be5cb96..964d25833c 100644
--- a/src/lib/libcrypto/rand/rand_unix.c
+++ b/src/lib/libcrypto/rand/rand_unix.c
@@ -136,16 +136,10 @@
136#ifdef __OpenBSD__ 136#ifdef __OpenBSD__
137int RAND_poll(void) 137int RAND_poll(void)
138{ 138{
139 u_int32_t rnd = 0, i;
140 unsigned char buf[ENTROPY_NEEDED]; 139 unsigned char buf[ENTROPY_NEEDED];
141 140
142 for (i = 0; i < sizeof(buf); i++) { 141 arc4random_buf(buf, sizeof(buf));
143 if (i % 4 == 0) 142 RAND_add(buf, sizeof(buf), sizeof(buf));
144 rnd = arc4random();
145 buf[i] = rnd;
146 rnd >>= 8;
147 }
148 RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
149 memset(buf, 0, sizeof(buf)); 143 memset(buf, 0, sizeof(buf));
150 144
151 return 1; 145 return 1;