summaryrefslogtreecommitdiff
path: root/xio.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-04 09:58:23 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-06-04 09:59:09 +0200
commit0f1f8ccf43e1296725cfbef482d19c90b15af98c (patch)
treeabf85cfed8766641119736cceca61f0f8cd7d1fc /xio.c
parent9a1b2fbdc9f319aaf57a79f8e6ce7d5e6a3ecaa6 (diff)
rnd: break out prng from xutils
We only need it in curvetun, this makes it easier to maintain. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'xio.c')
-rw-r--r--xio.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/xio.c b/xio.c
index 991ff7f..da17206 100644
--- a/xio.c
+++ b/xio.c
@@ -158,51 +158,6 @@ ssize_t write_exact(int fd, void *buf, size_t len, int mayexit)
return num;
}
-static int fd_rnd = -1;
-
-static void randombytes(unsigned char *x, unsigned long long xlen)
-{
- int ret;
-
- if (fd_rnd == -1) {
- for (;;) {
- fd_rnd = open("/dev/urandom", O_RDONLY);
- if (fd_rnd != -1)
- break;
- sleep(1);
- }
- }
-
- while (xlen > 0) {
- if (xlen < 1048576)
- ret = xlen;
- else
- ret = 1048576;
-
- ret = read(fd_rnd, x, ret);
- if (ret < 1) {
- sleep(1);
- continue;
- }
-
- x += ret;
- xlen -= ret;
- }
-}
-
-/* Note: it's not really secure, but the name only suggests it's better to use
- * than rand(3) when transferring bytes over the network in non-security
- * critical structure members. secrand() is only used to fill up salts actually.
- */
-int secrand(void)
-{
- int ret;
-
- randombytes((void *) &ret, sizeof(ret));
-
- return ret;
-}
-
static char const *priov[] = {
[LOG_EMERG] = "EMERG:",
[LOG_ALERT] = "ALERT:",