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_hpux.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_hpux.c')
| -rw-r--r-- | src/lib/libcrypto/arc4random/getentropy_hpux.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_hpux.c b/src/lib/libcrypto/arc4random/getentropy_hpux.c index 3ae6a6aa42..7208aa44c4 100644 --- a/src/lib/libcrypto/arc4random/getentropy_hpux.c +++ b/src/lib/libcrypto/arc4random/getentropy_hpux.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getentropy_hpux.c,v 1.5 2016/08/07 03:27:21 tb Exp $ */ | 1 | /* $OpenBSD: getentropy_hpux.c,v 1.6 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> |
| @@ -64,7 +64,6 @@ | |||
| 64 | 64 | ||
| 65 | int getentropy(void *buf, size_t len); | 65 | int getentropy(void *buf, size_t len); |
| 66 | 66 | ||
| 67 | static int gotdata(char *buf, size_t len); | ||
| 68 | static int getentropy_urandom(void *buf, size_t len, const char *path, | 67 | static int getentropy_urandom(void *buf, size_t len, const char *path, |
| 69 | int devfscheck); | 68 | int devfscheck); |
| 70 | static int getentropy_fallback(void *buf, size_t len); | 69 | static int getentropy_fallback(void *buf, size_t len); |
| @@ -122,22 +121,6 @@ getentropy(void *buf, size_t len) | |||
| 122 | return (ret); | 121 | return (ret); |
| 123 | } | 122 | } |
| 124 | 123 | ||
| 125 | /* | ||
| 126 | * Basic sanity checking; wish we could do better. | ||
| 127 | */ | ||
| 128 | static int | ||
| 129 | gotdata(char *buf, size_t len) | ||
| 130 | { | ||
| 131 | char any_set = 0; | ||
| 132 | size_t i; | ||
| 133 | |||
| 134 | for (i = 0; i < len; ++i) | ||
| 135 | any_set |= buf[i]; | ||
| 136 | if (any_set == 0) | ||
| 137 | return (-1); | ||
| 138 | return (0); | ||
| 139 | } | ||
| 140 | |||
| 141 | static int | 124 | static int |
| 142 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) | 125 | getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck) |
| 143 | { | 126 | { |
| @@ -183,10 +166,8 @@ start: | |||
| 183 | i += ret; | 166 | i += ret; |
| 184 | } | 167 | } |
| 185 | close(fd); | 168 | close(fd); |
| 186 | if (gotdata(buf, len) == 0) { | 169 | errno = save_errno; |
| 187 | errno = save_errno; | 170 | return (0); /* satisfied */ |
| 188 | return (0); /* satisfied */ | ||
| 189 | } | ||
| 190 | nodevrandom: | 171 | nodevrandom: |
| 191 | errno = EIO; | 172 | errno = EIO; |
| 192 | return (-1); | 173 | return (-1); |
| @@ -410,10 +391,6 @@ getentropy_fallback(void *buf, size_t len) | |||
| 410 | } | 391 | } |
| 411 | explicit_bzero(&ctx, sizeof ctx); | 392 | explicit_bzero(&ctx, sizeof ctx); |
| 412 | explicit_bzero(results, sizeof results); | 393 | explicit_bzero(results, sizeof results); |
| 413 | if (gotdata(buf, len) == 0) { | 394 | errno = save_errno; |
| 414 | errno = save_errno; | 395 | return (0); /* satisfied */ |
| 415 | return (0); /* satisfied */ | ||
| 416 | } | ||
| 417 | errno = EIO; | ||
| 418 | return (-1); | ||
| 419 | } | 396 | } |
