diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/arc4random/getentropy_linux.c | 13 | ||||
| -rw-r--r-- | src/lib/libcrypto/crypto/getentropy_linux.c | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_linux.c b/src/lib/libcrypto/arc4random/getentropy_linux.c index 78d0d786a6..a7f5991201 100644 --- a/src/lib/libcrypto/arc4random/getentropy_linux.c +++ b/src/lib/libcrypto/arc4random/getentropy_linux.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getentropy_linux.c,v 1.14 2014/06/26 13:48:11 deraadt Exp $ */ | 1 | /* $OpenBSD: getentropy_linux.c,v 1.15 2014/07/08 08:33:43 deraadt Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> |
| @@ -288,7 +288,7 @@ static int | |||
| 288 | getentropy_fallback(void *buf, size_t len) | 288 | getentropy_fallback(void *buf, size_t len) |
| 289 | { | 289 | { |
| 290 | uint8_t results[SHA512_DIGEST_LENGTH]; | 290 | uint8_t results[SHA512_DIGEST_LENGTH]; |
| 291 | int save_errno = errno, e, m, pgs = getpagesize(), repeat; | 291 | int save_errno = errno, e, m, pgs = getpagesize(), repeat = 0; |
| 292 | static int cnt; | 292 | static int cnt; |
| 293 | struct timespec ts; | 293 | struct timespec ts; |
| 294 | struct timeval tv; | 294 | struct timeval tv; |
| @@ -296,13 +296,20 @@ getentropy_fallback(void *buf, size_t len) | |||
| 296 | sigset_t sigset; | 296 | sigset_t sigset; |
| 297 | struct stat st; | 297 | struct stat st; |
| 298 | SHA512_CTX ctx; | 298 | SHA512_CTX ctx; |
| 299 | static pid_t lastpid; | ||
| 299 | pid_t pid; | 300 | pid_t pid; |
| 300 | size_t i, ii; | 301 | size_t i, ii; |
| 301 | char *p; | 302 | char *p; |
| 302 | 303 | ||
| 304 | pid = getpid(); | ||
| 305 | if (lastpid == getpid()) | ||
| 306 | repeat = REPEAT - 1; | ||
| 307 | else | ||
| 308 | lastpid = pid; | ||
| 309 | |||
| 303 | for (i = 0; i < len; ) { | 310 | for (i = 0; i < len; ) { |
| 304 | SHA512_Init(&ctx); | 311 | SHA512_Init(&ctx); |
| 305 | for (repeat = 0; repeat < REPEAT; repeat++) { | 312 | for (; repeat < REPEAT; repeat++) { |
| 306 | 313 | ||
| 307 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | 314 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); |
| 308 | if (e != -1) { | 315 | if (e != -1) { |
diff --git a/src/lib/libcrypto/crypto/getentropy_linux.c b/src/lib/libcrypto/crypto/getentropy_linux.c index 78d0d786a6..a7f5991201 100644 --- a/src/lib/libcrypto/crypto/getentropy_linux.c +++ b/src/lib/libcrypto/crypto/getentropy_linux.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getentropy_linux.c,v 1.14 2014/06/26 13:48:11 deraadt Exp $ */ | 1 | /* $OpenBSD: getentropy_linux.c,v 1.15 2014/07/08 08:33:43 deraadt Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> |
| @@ -288,7 +288,7 @@ static int | |||
| 288 | getentropy_fallback(void *buf, size_t len) | 288 | getentropy_fallback(void *buf, size_t len) |
| 289 | { | 289 | { |
| 290 | uint8_t results[SHA512_DIGEST_LENGTH]; | 290 | uint8_t results[SHA512_DIGEST_LENGTH]; |
| 291 | int save_errno = errno, e, m, pgs = getpagesize(), repeat; | 291 | int save_errno = errno, e, m, pgs = getpagesize(), repeat = 0; |
| 292 | static int cnt; | 292 | static int cnt; |
| 293 | struct timespec ts; | 293 | struct timespec ts; |
| 294 | struct timeval tv; | 294 | struct timeval tv; |
| @@ -296,13 +296,20 @@ getentropy_fallback(void *buf, size_t len) | |||
| 296 | sigset_t sigset; | 296 | sigset_t sigset; |
| 297 | struct stat st; | 297 | struct stat st; |
| 298 | SHA512_CTX ctx; | 298 | SHA512_CTX ctx; |
| 299 | static pid_t lastpid; | ||
| 299 | pid_t pid; | 300 | pid_t pid; |
| 300 | size_t i, ii; | 301 | size_t i, ii; |
| 301 | char *p; | 302 | char *p; |
| 302 | 303 | ||
| 304 | pid = getpid(); | ||
| 305 | if (lastpid == getpid()) | ||
| 306 | repeat = REPEAT - 1; | ||
| 307 | else | ||
| 308 | lastpid = pid; | ||
| 309 | |||
| 303 | for (i = 0; i < len; ) { | 310 | for (i = 0; i < len; ) { |
| 304 | SHA512_Init(&ctx); | 311 | SHA512_Init(&ctx); |
| 305 | for (repeat = 0; repeat < REPEAT; repeat++) { | 312 | for (; repeat < REPEAT; repeat++) { |
| 306 | 313 | ||
| 307 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); | 314 | HX((e = gettimeofday(&tv, NULL)) == -1, tv); |
| 308 | if (e != -1) { | 315 | if (e != -1) { |
