diff options
author | bcook <> | 2014-08-16 18:42:41 +0000 |
---|---|---|
committer | bcook <> | 2014-08-16 18:42:41 +0000 |
commit | 98469e1608c075636fa47a174471eb83ad35c83d (patch) | |
tree | 5d18873b2926eb23b22006998396cb6b00e2315b | |
parent | dd0ff50cd5d30db59d9069a9e0b516c03c456e8e (diff) | |
download | openbsd-98469e1608c075636fa47a174471eb83ad35c83d.tar.gz openbsd-98469e1608c075636fa47a174471eb83ad35c83d.tar.bz2 openbsd-98469e1608c075636fa47a174471eb83ad35c83d.zip |
only build the getrandom path if SYS_getrandom is defined.
like the sysctl path
-rw-r--r-- | src/lib/libcrypto/arc4random/getentropy_linux.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/crypto/getentropy_linux.c | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/libcrypto/arc4random/getentropy_linux.c b/src/lib/libcrypto/arc4random/getentropy_linux.c index a84f7ad888..76d724af14 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.33 2014/08/16 17:21:56 bcook Exp $ */ | 1 | /* $OpenBSD: getentropy_linux.c,v 1.34 2014/08/16 18:42:41 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> |
@@ -74,7 +74,9 @@ | |||
74 | int getentropy(void *buf, size_t len); | 74 | int getentropy(void *buf, size_t len); |
75 | 75 | ||
76 | static int gotdata(char *buf, size_t len); | 76 | static int gotdata(char *buf, size_t len); |
77 | #ifdef SYS_getrandom | ||
77 | static int getentropy_getrandom(void *buf, size_t len); | 78 | static int getentropy_getrandom(void *buf, size_t len); |
79 | #endif | ||
78 | static int getentropy_urandom(void *buf, size_t len); | 80 | static int getentropy_urandom(void *buf, size_t len); |
79 | #ifdef SYS__sysctl | 81 | #ifdef SYS__sysctl |
80 | static int getentropy_sysctl(void *buf, size_t len); | 82 | static int getentropy_sysctl(void *buf, size_t len); |
@@ -92,6 +94,7 @@ getentropy(void *buf, size_t len) | |||
92 | return -1; | 94 | return -1; |
93 | } | 95 | } |
94 | 96 | ||
97 | #ifdef SYS_getrandom | ||
95 | /* | 98 | /* |
96 | * Try descriptor-less getrandom() | 99 | * Try descriptor-less getrandom() |
97 | */ | 100 | */ |
@@ -100,6 +103,7 @@ getentropy(void *buf, size_t len) | |||
100 | return (ret); | 103 | return (ret); |
101 | if (errno != ENOSYS) | 104 | if (errno != ENOSYS) |
102 | return (-1); | 105 | return (-1); |
106 | #endif | ||
103 | 107 | ||
104 | /* | 108 | /* |
105 | * Try to get entropy with /dev/urandom | 109 | * Try to get entropy with /dev/urandom |
@@ -186,10 +190,10 @@ gotdata(char *buf, size_t len) | |||
186 | return 0; | 190 | return 0; |
187 | } | 191 | } |
188 | 192 | ||
193 | #ifdef SYS_getrandom | ||
189 | static int | 194 | static int |
190 | getentropy_getrandom(void *buf, size_t len) | 195 | getentropy_getrandom(void *buf, size_t len) |
191 | { | 196 | { |
192 | #ifdef SYS_getrandom | ||
193 | int ret; | 197 | int ret; |
194 | if (len > 256) | 198 | if (len > 256) |
195 | return (-1); | 199 | return (-1); |
@@ -199,9 +203,9 @@ getentropy_getrandom(void *buf, size_t len) | |||
199 | 203 | ||
200 | if (ret == len) | 204 | if (ret == len) |
201 | return (0); | 205 | return (0); |
202 | #endif | ||
203 | return (-1); | 206 | return (-1); |
204 | } | 207 | } |
208 | #endif | ||
205 | 209 | ||
206 | static int | 210 | static int |
207 | getentropy_urandom(void *buf, size_t len) | 211 | getentropy_urandom(void *buf, size_t len) |
diff --git a/src/lib/libcrypto/crypto/getentropy_linux.c b/src/lib/libcrypto/crypto/getentropy_linux.c index a84f7ad888..76d724af14 100644 --- a/src/lib/libcrypto/crypto/getentropy_linux.c +++ b/src/lib/libcrypto/crypto/getentropy_linux.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: getentropy_linux.c,v 1.33 2014/08/16 17:21:56 bcook Exp $ */ | 1 | /* $OpenBSD: getentropy_linux.c,v 1.34 2014/08/16 18:42:41 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> |
@@ -74,7 +74,9 @@ | |||
74 | int getentropy(void *buf, size_t len); | 74 | int getentropy(void *buf, size_t len); |
75 | 75 | ||
76 | static int gotdata(char *buf, size_t len); | 76 | static int gotdata(char *buf, size_t len); |
77 | #ifdef SYS_getrandom | ||
77 | static int getentropy_getrandom(void *buf, size_t len); | 78 | static int getentropy_getrandom(void *buf, size_t len); |
79 | #endif | ||
78 | static int getentropy_urandom(void *buf, size_t len); | 80 | static int getentropy_urandom(void *buf, size_t len); |
79 | #ifdef SYS__sysctl | 81 | #ifdef SYS__sysctl |
80 | static int getentropy_sysctl(void *buf, size_t len); | 82 | static int getentropy_sysctl(void *buf, size_t len); |
@@ -92,6 +94,7 @@ getentropy(void *buf, size_t len) | |||
92 | return -1; | 94 | return -1; |
93 | } | 95 | } |
94 | 96 | ||
97 | #ifdef SYS_getrandom | ||
95 | /* | 98 | /* |
96 | * Try descriptor-less getrandom() | 99 | * Try descriptor-less getrandom() |
97 | */ | 100 | */ |
@@ -100,6 +103,7 @@ getentropy(void *buf, size_t len) | |||
100 | return (ret); | 103 | return (ret); |
101 | if (errno != ENOSYS) | 104 | if (errno != ENOSYS) |
102 | return (-1); | 105 | return (-1); |
106 | #endif | ||
103 | 107 | ||
104 | /* | 108 | /* |
105 | * Try to get entropy with /dev/urandom | 109 | * Try to get entropy with /dev/urandom |
@@ -186,10 +190,10 @@ gotdata(char *buf, size_t len) | |||
186 | return 0; | 190 | return 0; |
187 | } | 191 | } |
188 | 192 | ||
193 | #ifdef SYS_getrandom | ||
189 | static int | 194 | static int |
190 | getentropy_getrandom(void *buf, size_t len) | 195 | getentropy_getrandom(void *buf, size_t len) |
191 | { | 196 | { |
192 | #ifdef SYS_getrandom | ||
193 | int ret; | 197 | int ret; |
194 | if (len > 256) | 198 | if (len > 256) |
195 | return (-1); | 199 | return (-1); |
@@ -199,9 +203,9 @@ getentropy_getrandom(void *buf, size_t len) | |||
199 | 203 | ||
200 | if (ret == len) | 204 | if (ret == len) |
201 | return (0); | 205 | return (0); |
202 | #endif | ||
203 | return (-1); | 206 | return (-1); |
204 | } | 207 | } |
208 | #endif | ||
205 | 209 | ||
206 | static int | 210 | static int |
207 | getentropy_urandom(void *buf, size_t len) | 211 | getentropy_urandom(void *buf, size_t len) |