diff options
| author | deraadt <> | 2018-11-20 08:04:28 +0000 |
|---|---|---|
| committer | deraadt <> | 2018-11-20 08:04:28 +0000 |
| commit | 1c9e20cbc776ff1a1ba01d20a3d7ae740718e16e (patch) | |
| tree | f0a99bac9b58c33006d9c873c65b2281fb8d7a03 /src/lib/libcrypto/arc4random/getentropy_solaris.c | |
| parent | 2aceb79bcea2b521506207ee08481893378cd518 (diff) | |
| download | openbsd-1c9e20cbc776ff1a1ba01d20a3d7ae740718e16e.tar.gz openbsd-1c9e20cbc776ff1a1ba01d20a3d7ae740718e16e.tar.bz2 openbsd-1c9e20cbc776ff1a1ba01d20a3d7ae740718e16e.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 'src/lib/libcrypto/arc4random/getentropy_solaris.c')
| -rw-r--r-- | src/lib/libcrypto/arc4random/getentropy_solaris.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_solaris.c b/src/lib/libcrypto/arc4random/getentropy_solaris.c index f0fcdcf28b..b80c84de9e 100644 --- a/src/lib/libcrypto/arc4random/getentropy_solaris.c +++ b/src/lib/libcrypto/arc4random/getentropy_solaris.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getentropy_solaris.c,v 1.12 2016/08/07 03:27:21 tb Exp $ */ | 1 | /* $OpenBSD: getentropy_solaris.c,v 1.13 2018/11/20 08:04:28 deraadt Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> | 4 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> |
| @@ -68,7 +68,6 @@ | |||
| 68 | 68 | ||
| 69 | int getentropy(void *buf, size_t len); | 69 | int getentropy(void *buf, size_t len); |
| 70 | 70 | ||
| 71 | static int gotdata(char *buf, size_t len); | ||
| 72 | static int getentropy_urandom(void *buf, size_t len, const char *path, | 71 | static int getentropy_urandom(void *buf, size_t len, const char *path, |
| 73 | int devfscheck); | 72 | int devfscheck); |
| 74 | static int getentropy_fallback(void *buf, size_t len); | 73 | static int getentropy_fallback(void *buf, size_t len); |
| @@ -148,22 +147,6 @@ getentropy(void *buf, size_t len) | |||
| 148 | return (ret); | 147 | return (ret); |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | /* | ||
| 152 | * Basic sanity checking; wish we could do better. | ||
| 153 | */ | ||
| 154 | static int | ||
| 155 | gotdata(char *buf, size_t len) | ||
| 156 | { | ||
| 157 | char any_set = 0; | ||
| 158 | size_t i; | ||
| 159 | |||
| 160 | for (i = 0; i < len; ++i) | ||
| 161 | any_set |= buf[i]; | ||
| 162 | if (any_set == 0) | ||
| 163 | return (-1); | ||
| 164 | return (0); | ||
| 165 | } | ||
| 166 | |||
| 167 | static int | 150 | static int |
| 168 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) | 151 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) |
| 169 | { | 152 | { |
| @@ -210,10 +193,8 @@ start: | |||
| 210 | i += ret; | 193 | i += ret; |
| 211 | } | 194 | } |
| 212 | close(fd); | 195 | close(fd); |
| 213 | if (gotdata(buf, len) == 0) { | 196 | errno = save_errno; |
| 214 | errno = save_errno; | 197 | return (0); /* satisfied */ |
| 215 | return (0); /* satisfied */ | ||
| 216 | } | ||
| 217 | nodevrandom: | 198 | nodevrandom: |
| 218 | errno = EIO; | 199 | errno = EIO; |
| 219 | return (-1); | 200 | return (-1); |
| @@ -436,10 +417,6 @@ getentropy_fallback(void *buf, size_t len) | |||
| 436 | } | 417 | } |
| 437 | explicit_bzero(&ctx, sizeof ctx); | 418 | explicit_bzero(&ctx, sizeof ctx); |
| 438 | explicit_bzero(results, sizeof results); | 419 | explicit_bzero(results, sizeof results); |
| 439 | if (gotdata(buf, len) == 0) { | 420 | errno = save_errno; |
| 440 | errno = save_errno; | 421 | return (0); /* satisfied */ |
| 441 | return (0); /* satisfied */ | ||
| 442 | } | ||
| 443 | errno = EIO; | ||
| 444 | return (-1); | ||
| 445 | } | 422 | } |
