summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rand/rand_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rand/rand_unix.c')
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c
index a776e52243..fa2bab57c6 100644
--- a/src/lib/libcrypto/rand/rand_unix.c
+++ b/src/lib/libcrypto/rand/rand_unix.c
@@ -115,7 +115,7 @@
115#include <openssl/rand.h> 115#include <openssl/rand.h>
116#include "rand_lcl.h" 116#include "rand_lcl.h"
117 117
118#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS)) 118#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2))
119 119
120#include <sys/types.h> 120#include <sys/types.h>
121#include <sys/time.h> 121#include <sys/time.h>
@@ -124,6 +124,24 @@
124#include <unistd.h> 124#include <unistd.h>
125#include <time.h> 125#include <time.h>
126 126
127#ifdef __OpenBSD__
128int RAND_poll(void)
129{
130 u_int32_t rnd = 0, i;
131 unsigned char buf[ENTROPY_NEEDED];
132
133 for (i = 0; i < sizeof(buf); i++) {
134 if (i % 4 == 0)
135 rnd = arc4random();
136 buf[i] = rnd;
137 rnd >>= 8;
138 }
139 RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
140 memset(buf, 0, sizeof(buf));
141
142 return 1;
143}
144#else
127int RAND_poll(void) 145int RAND_poll(void)
128{ 146{
129 unsigned long l; 147 unsigned long l;
@@ -215,7 +233,7 @@ int RAND_poll(void)
215 if (n > 0) 233 if (n > 0)
216 { 234 {
217 RAND_add(tmpbuf,sizeof tmpbuf,n); 235 RAND_add(tmpbuf,sizeof tmpbuf,n);
218 OPENSSL_cleanse(tmpbuf,n); 236 memset(tmpbuf,0,n);
219 } 237 }
220#endif 238#endif
221 239
@@ -236,10 +254,4 @@ int RAND_poll(void)
236} 254}
237 255
238#endif 256#endif
239
240#if defined(OPENSSL_SYS_VXWORKS)
241int RAND_poll(void)
242{
243 return 0;
244}
245#endif 257#endif