From b1c340b62be086515b951572bf8ffac0acd6c78f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 25 May 2014 21:14:34 +0200 Subject: [PATCH] Re-add accidentily removed randomize() from crypto.c. --- src/crypto.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/crypto.c b/src/crypto.c index 2e2fa538..e3797f8d 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -41,6 +41,20 @@ void crypto_exit(void) { close(random_fd); } +void randomize(void *out, size_t outlen) { + while(outlen) { + size_t len = read(random_fd, out, outlen); + if(len <= 0) { + if(errno == EAGAIN || errno == EINTR) + continue; + fprintf(stderr, "Could not read random numbers: %s\n", strerror(errno)); + abort(); + } + out += len; + outlen -= len; + } +} + #else #include -- 2.39.5