diff options
Diffstat (limited to 'src/lib/libcrypto/arc4random/getentropy_osx.c')
| -rw-r--r-- | src/lib/libcrypto/arc4random/getentropy_osx.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_osx.c b/src/lib/libcrypto/arc4random/getentropy_osx.c index 2a5f83f3bb..26dcc824de 100644 --- a/src/lib/libcrypto/arc4random/getentropy_osx.c +++ b/src/lib/libcrypto/arc4random/getentropy_osx.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getentropy_osx.c,v 1.11 2016/09/03 15:24:09 bcook Exp $ */ | 1 | /* $OpenBSD: getentropy_osx.c,v 1.12 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> |
| @@ -82,7 +82,6 @@ | |||
| 82 | 82 | ||
| 83 | int getentropy(void *buf, size_t len); | 83 | int getentropy(void *buf, size_t len); |
| 84 | 84 | ||
| 85 | static int gotdata(char *buf, size_t len); | ||
| 86 | static int getentropy_urandom(void *buf, size_t len); | 85 | static int getentropy_urandom(void *buf, size_t len); |
| 87 | static int getentropy_fallback(void *buf, size_t len); | 86 | static int getentropy_fallback(void *buf, size_t len); |
| 88 | 87 | ||
| @@ -142,22 +141,6 @@ getentropy(void *buf, size_t len) | |||
| 142 | return (ret); | 141 | return (ret); |
| 143 | } | 142 | } |
| 144 | 143 | ||
| 145 | /* | ||
| 146 | * Basic sanity checking; wish we could do better. | ||
| 147 | */ | ||
| 148 | static int | ||
| 149 | gotdata(char *buf, size_t len) | ||
| 150 | { | ||
| 151 | char any_set = 0; | ||
| 152 | size_t i; | ||
| 153 | |||
| 154 | for (i = 0; i < len; ++i) | ||
| 155 | any_set |= buf[i]; | ||
| 156 | if (any_set == 0) | ||
| 157 | return (-1); | ||
| 158 | return (0); | ||
| 159 | } | ||
| 160 | |||
| 161 | static int | 144 | static int |
| 162 | getentropy_urandom(void *buf, size_t len) | 145 | getentropy_urandom(void *buf, size_t len) |
| 163 | { | 146 | { |
| @@ -203,10 +186,8 @@ start: | |||
| 203 | i += ret; | 186 | i += ret; |
| 204 | } | 187 | } |
| 205 | close(fd); | 188 | close(fd); |
| 206 | if (gotdata(buf, len) == 0) { | 189 | errno = save_errno; |
| 207 | errno = save_errno; | 190 | return (0); /* satisfied */ |
| 208 | return (0); /* satisfied */ | ||
| 209 | } | ||
| 210 | nodevrandom: | 191 | nodevrandom: |
| 211 | errno = EIO; | 192 | errno = EIO; |
| 212 | return (-1); | 193 | return (-1); |
| @@ -431,10 +412,6 @@ getentropy_fallback(void *buf, size_t len) | |||
| 431 | } | 412 | } |
| 432 | explicit_bzero(&ctx, sizeof ctx); | 413 | explicit_bzero(&ctx, sizeof ctx); |
| 433 | explicit_bzero(results, sizeof results); | 414 | explicit_bzero(results, sizeof results); |
| 434 | if (gotdata(buf, len) == 0) { | 415 | errno = save_errno; |
| 435 | errno = save_errno; | 416 | return (0); /* satisfied */ |
| 436 | return (0); /* satisfied */ | ||
| 437 | } | ||
| 438 | errno = EIO; | ||
| 439 | return (-1); | ||
| 440 | } | 417 | } |
