diff options
Diffstat (limited to 'src/lib/libcrypto/rand/rand_unix.c')
-rw-r--r-- | src/lib/libcrypto/rand/rand_unix.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c index 0b29235130..5a78009e9a 100644 --- a/src/lib/libcrypto/rand/rand_unix.c +++ b/src/lib/libcrypto/rand/rand_unix.c | |||
@@ -122,43 +122,6 @@ | |||
122 | #include <unistd.h> | 122 | #include <unistd.h> |
123 | #include <time.h> | 123 | #include <time.h> |
124 | 124 | ||
125 | #ifdef __OpenBSD__ | ||
126 | #undef DEVRANDOM | ||
127 | #define DEVRANDOM "/dev/arandom" | ||
128 | int RAND_poll(void) | ||
129 | { | ||
130 | unsigned long l; | ||
131 | pid_t curr_pid = getpid(); | ||
132 | FILE *fh; | ||
133 | |||
134 | /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD | ||
135 | * have this. Use /dev/urandom if you can as /dev/random may block | ||
136 | * if it runs out of random entries. */ | ||
137 | |||
138 | if ((fh = fopen(DEVRANDOM, "r")) != NULL) | ||
139 | { | ||
140 | unsigned char tmpbuf[ENTROPY_NEEDED]; | ||
141 | int n; | ||
142 | |||
143 | setvbuf(fh, NULL, _IONBF, 0); | ||
144 | n=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh); | ||
145 | fclose(fh); | ||
146 | RAND_add(tmpbuf,sizeof tmpbuf,n); | ||
147 | memset(tmpbuf,0,n); | ||
148 | } | ||
149 | |||
150 | /* put in some default random data, we need more than just this */ | ||
151 | l=curr_pid; | ||
152 | RAND_add(&l,sizeof(l),0); | ||
153 | l=getuid(); | ||
154 | RAND_add(&l,sizeof(l),0); | ||
155 | |||
156 | l=time(NULL); | ||
157 | RAND_add(&l,sizeof(l),0); | ||
158 | |||
159 | return 1; | ||
160 | } | ||
161 | #else | ||
162 | int RAND_poll(void) | 125 | int RAND_poll(void) |
163 | { | 126 | { |
164 | unsigned long l; | 127 | unsigned long l; |
@@ -271,4 +234,3 @@ int RAND_poll(void) | |||
271 | } | 234 | } |
272 | 235 | ||
273 | #endif | 236 | #endif |
274 | #endif | ||