diff options
| author | markus <> | 2002-09-05 12:51:52 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:52 +0000 |
| commit | 5514995a9d5ed91db089875adb509c7781357c0e (patch) | |
| tree | 2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/rand/rand_unix.c | |
| parent | fd9566423b542798f5c8b06e68101a9ea5bb9885 (diff) | |
| download | openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2 openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip | |
import openssl-0.9.7-beta1
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 | ||
