summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm <>2008-09-10 05:38:04 +0000
committerdjm <>2008-09-10 05:38:04 +0000
commitb558ff83b6fe99a196d1c89185e7e9785b6b0bf6 (patch)
tree2b0539e8f6811f935f6ea8365461a18b29e7c319
parent0abc698722622c8941475565889452000fe9f149 (diff)
downloadopenbsd-b558ff83b6fe99a196d1c89185e7e9785b6b0bf6.tar.gz
openbsd-b558ff83b6fe99a196d1c89185e7e9785b6b0bf6.tar.bz2
openbsd-b558ff83b6fe99a196d1c89185e7e9785b6b0bf6.zip
use one call to arc4random_buf() instead of lots of arc4random()
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c10
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_unix.c10
2 files changed, 4 insertions, 16 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;
diff --git a/src/lib/libssl/src/crypto/rand/rand_unix.c b/src/lib/libssl/src/crypto/rand/rand_unix.c
index 6c2be5cb96..964d25833c 100644
--- a/src/lib/libssl/src/crypto/rand/rand_unix.c
+++ b/src/lib/libssl/src/crypto/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;