From: Guus Sliepen Date: Sun, 25 May 2014 19:14:34 +0000 (+0200) Subject: Re-add accidentily removed randomize() from crypto.c. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=b1c340b62be086515b951572bf8ffac0acd6c78f;p=meshlink Re-add accidentily removed randomize() from crypto.c. --- 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