summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/crypto/getentropy_linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcrypto/crypto/getentropy_linux.c')
-rw-r--r--lib/libcrypto/crypto/getentropy_linux.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libcrypto/crypto/getentropy_linux.c b/lib/libcrypto/crypto/getentropy_linux.c
index 78d0d786a65..a7f5991201b 100644
--- a/lib/libcrypto/crypto/getentropy_linux.c
+++ b/lib/libcrypto/crypto/getentropy_linux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getentropy_linux.c,v 1.14 2014/06/26 13:48:11 deraadt Exp $ */
+/* $OpenBSD: getentropy_linux.c,v 1.15 2014/07/08 08:33:43 deraadt Exp $ */
/*
* Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@@ -288,7 +288,7 @@ static int
getentropy_fallback(void *buf, size_t len)
{
uint8_t results[SHA512_DIGEST_LENGTH];
- int save_errno = errno, e, m, pgs = getpagesize(), repeat;
+ int save_errno = errno, e, m, pgs = getpagesize(), repeat = 0;
static int cnt;
struct timespec ts;
struct timeval tv;
@@ -296,13 +296,20 @@ getentropy_fallback(void *buf, size_t len)
sigset_t sigset;
struct stat st;
SHA512_CTX ctx;
+ static pid_t lastpid;
pid_t pid;
size_t i, ii;
char *p;
+ pid = getpid();
+ if (lastpid == getpid())
+ repeat = REPEAT - 1;
+ else
+ lastpid = pid;
+
for (i = 0; i < len; ) {
SHA512_Init(&ctx);
- for (repeat = 0; repeat < REPEAT; repeat++) {
+ for (; repeat < REPEAT; repeat++) {
HX((e = gettimeofday(&tv, NULL)) == -1, tv);
if (e != -1) {