diff options
author | 2018-11-20 08:04:28 +0000 | |
---|---|---|
committer | 2018-11-20 08:04:28 +0000 | |
commit | 03b209d2bddddd6fe333a3c8aabf014de1b406ec (patch) | |
tree | 17ef4ab45aa5c24460dff15779bf96695e35a49f /lib/libcrypto/arc4random/getentropy_solaris.c | |
parent | Fix when ber_free_elements is called with a NULL-value. (diff) | |
download | wireguard-openbsd-03b209d2bddddd6fe333a3c8aabf014de1b406ec.tar.xz wireguard-openbsd-03b209d2bddddd6fe333a3c8aabf014de1b406ec.zip |
Saw a mention somewhere a while back that the gotdata() function in
here could creates non-uniformity since very short fetches of 0 would
be excluded. blocks of 0 are just as random as any other data, including
blocks of 4 4 4.. This is a misguided attempt to identify errors from the
entropy churn/gather code doesn't make sense, errors don't happen.
ok bcook
Diffstat (limited to 'lib/libcrypto/arc4random/getentropy_solaris.c')
-rw-r--r-- | lib/libcrypto/arc4random/getentropy_solaris.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/lib/libcrypto/arc4random/getentropy_solaris.c b/lib/libcrypto/arc4random/getentropy_solaris.c index f0fcdcf28b2..b80c84de9e5 100644 --- a/lib/libcrypto/arc4random/getentropy_solaris.c +++ b/lib/libcrypto/arc4random/getentropy_solaris.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getentropy_solaris.c,v 1.12 2016/08/07 03:27:21 tb Exp $ */ +/* $OpenBSD: getentropy_solaris.c,v 1.13 2018/11/20 08:04:28 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> @@ -68,7 +68,6 @@ int getentropy(void *buf, size_t len); -static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck); static int getentropy_fallback(void *buf, size_t len); @@ -148,22 +147,6 @@ getentropy(void *buf, size_t len) return (ret); } -/* - * Basic sanity checking; wish we could do better. - */ -static int -gotdata(char *buf, size_t len) -{ - char any_set = 0; - size_t i; - - for (i = 0; i < len; ++i) - any_set |= buf[i]; - if (any_set == 0) - return (-1); - return (0); -} - static int getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) { @@ -210,10 +193,8 @@ start: i += ret; } close(fd); - if (gotdata(buf, len) == 0) { - errno = save_errno; - return (0); /* satisfied */ - } + errno = save_errno; + return (0); /* satisfied */ nodevrandom: errno = EIO; return (-1); @@ -436,10 +417,6 @@ getentropy_fallback(void *buf, size_t len) } explicit_bzero(&ctx, sizeof ctx); explicit_bzero(results, sizeof results); - if (gotdata(buf, len) == 0) { - errno = save_errno; - return (0); /* satisfied */ - } - errno = EIO; - return (-1); + errno = save_errno; + return (0); /* satisfied */ } |