diff options
| author | markus <> | 2004-04-07 20:42:12 +0000 |
|---|---|---|
| committer | markus <> | 2004-04-07 20:42:12 +0000 |
| commit | 00b426069b0dfa8f0d9b87308646e9684f45c515 (patch) | |
| tree | 2eb0df944a8ed229c1d2a165679566e87ce34575 /src/lib/libcrypto/rand | |
| parent | fd84abe5019daf5a6869e1d12702e3e11b7a81bc (diff) | |
| download | openbsd-00b426069b0dfa8f0d9b87308646e9684f45c515.tar.gz openbsd-00b426069b0dfa8f0d9b87308646e9684f45c515.tar.bz2 openbsd-00b426069b0dfa8f0d9b87308646e9684f45c515.zip | |
import openssl-0.9.7d
Diffstat (limited to 'src/lib/libcrypto/rand')
| -rw-r--r-- | src/lib/libcrypto/rand/rand_egd.c | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_unix.c | 19 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_win.c | 2 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c index 1f168221e3..6f742900a0 100644 --- a/src/lib/libcrypto/rand/rand_egd.c +++ b/src/lib/libcrypto/rand/rand_egd.c | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | 56 | ||
| 57 | #include <openssl/e_os2.h> | 57 | #include <openssl/e_os2.h> |
| 58 | #include <openssl/rand.h> | 58 | #include <openssl/rand.h> |
| 59 | #include <openssl/buffer.h> | ||
| 59 | 60 | ||
| 60 | /* | 61 | /* |
| 61 | * Query the EGD <URL: http://www.lothar.com/tech/crypto/>. | 62 | * Query the EGD <URL: http://www.lothar.com/tech/crypto/>. |
| @@ -145,7 +146,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) | |||
| 145 | addr.sun_family = AF_UNIX; | 146 | addr.sun_family = AF_UNIX; |
| 146 | if (strlen(path) >= sizeof(addr.sun_path)) | 147 | if (strlen(path) >= sizeof(addr.sun_path)) |
| 147 | return (-1); | 148 | return (-1); |
| 148 | strcpy(addr.sun_path,path); | 149 | BUF_strlcpy(addr.sun_path,path,sizeof addr.sun_path); |
| 149 | len = offsetof(struct sockaddr_un, sun_path) + strlen(path); | 150 | len = offsetof(struct sockaddr_un, sun_path) + strlen(path); |
| 150 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 151 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
| 151 | if (fd == -1) return (-1); | 152 | if (fd == -1) return (-1); |
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c index a776e52243..0599719dd1 100644 --- a/src/lib/libcrypto/rand/rand_unix.c +++ b/src/lib/libcrypto/rand/rand_unix.c | |||
| @@ -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__ | ||
| 128 | int 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 | ||
| 127 | int RAND_poll(void) | 145 | int RAND_poll(void) |
| 128 | { | 146 | { |
| 129 | unsigned long l; | 147 | unsigned long l; |
| @@ -236,6 +254,7 @@ int RAND_poll(void) | |||
| 236 | } | 254 | } |
| 237 | 255 | ||
| 238 | #endif | 256 | #endif |
| 257 | #endif | ||
| 239 | 258 | ||
| 240 | #if defined(OPENSSL_SYS_VXWORKS) | 259 | #if defined(OPENSSL_SYS_VXWORKS) |
| 241 | int RAND_poll(void) | 260 | int RAND_poll(void) |
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c index 263068d256..3584842224 100644 --- a/src/lib/libcrypto/rand/rand_win.c +++ b/src/lib/libcrypto/rand/rand_win.c | |||
| @@ -646,7 +646,7 @@ static void readtimer(void) | |||
| 646 | * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V. | 646 | * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V. |
| 647 | * | 647 | * |
| 648 | * Code adapted from | 648 | * Code adapted from |
| 649 | * <URL:http://www.microsoft.com/kb/developr/win_dk/q97193.htm>; | 649 | * <URL:http://support.microsoft.com/default.aspx?scid=kb;[LN];97193>; |
| 650 | * the original copyright message is: | 650 | * the original copyright message is: |
| 651 | * | 651 | * |
| 652 | * (C) Copyright Microsoft Corp. 1993. All rights reserved. | 652 | * (C) Copyright Microsoft Corp. 1993. All rights reserved. |
