diff options
Diffstat (limited to 'src/lib/libcrypto/arc4random/getentropy_linux.c')
| -rw-r--r-- | src/lib/libcrypto/arc4random/getentropy_linux.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_linux.c b/src/lib/libcrypto/arc4random/getentropy_linux.c index 59bc3628a6..a84f7ad888 100644 --- a/src/lib/libcrypto/arc4random/getentropy_linux.c +++ b/src/lib/libcrypto/arc4random/getentropy_linux.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getentropy_linux.c,v 1.32 2014/07/22 01:15:58 bcook Exp $ */ | 1 | /* $OpenBSD: getentropy_linux.c,v 1.33 2014/08/16 17:21:56 bcook 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> |
| @@ -98,6 +98,8 @@ getentropy(void *buf, size_t len) | |||
| 98 | ret = getentropy_getrandom(buf, len); | 98 | ret = getentropy_getrandom(buf, len); |
| 99 | if (ret != -1) | 99 | if (ret != -1) |
| 100 | return (ret); | 100 | return (ret); |
| 101 | if (errno != ENOSYS) | ||
| 102 | return (-1); | ||
| 101 | 103 | ||
| 102 | /* | 104 | /* |
| 103 | * Try to get entropy with /dev/urandom | 105 | * Try to get entropy with /dev/urandom |
| @@ -187,23 +189,18 @@ gotdata(char *buf, size_t len) | |||
| 187 | static int | 189 | static int |
| 188 | getentropy_getrandom(void *buf, size_t len) | 190 | getentropy_getrandom(void *buf, size_t len) |
| 189 | { | 191 | { |
| 190 | #if 0 | 192 | #ifdef SYS_getrandom |
| 191 | 193 | int ret; | |
| 192 | /* Hand-definitions until the API becomes commonplace */ | ||
| 193 | #ifndef SYS__getrandom | ||
| 194 | #ifdef __LP64__ | ||
| 195 | #define SYS__getrandom 317 | ||
| 196 | #else | ||
| 197 | #define SYS__getrandom 354 | ||
| 198 | #endif | ||
| 199 | #endif | ||
| 200 | if (len > 256) | 194 | if (len > 256) |
| 201 | return (-1); | 195 | return (-1); |
| 202 | ret = syscall(SYS__getrandom, buf, len, 0); | 196 | do { |
| 197 | ret = syscall(SYS_getrandom, buf, len, 0); | ||
| 198 | } while (ret == -1 && errno == EINTR); | ||
| 199 | |||
| 203 | if (ret == len) | 200 | if (ret == len) |
| 204 | return (0); | 201 | return (0); |
| 205 | #endif | 202 | #endif |
| 206 | return -1; | 203 | return (-1); |
| 207 | } | 204 | } |
| 208 | 205 | ||
| 209 | static int | 206 | static int |
