diff options
author | Brent Cook <busterb@gmail.com> | 2015-01-21 06:14:24 -0600 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2015-01-21 06:14:24 -0600 |
commit | a2233651277a50955cdc4c7810da7a12e4e33551 (patch) | |
tree | 5d48e874577eb6f0c955bfa6ddfdae04d13af406 | |
parent | ec81c28219b3d3234ddf0af12d0579efa1a3d2a6 (diff) | |
download | portable-a2233651277a50955cdc4c7810da7a12e4e33551.tar.gz portable-a2233651277a50955cdc4c7810da7a12e4e33551.tar.bz2 portable-a2233651277a50955cdc4c7810da7a12e4e33551.zip |
add NetBSD shims for arc4random
The current NetBSD release, 6.1.5, fails to reseed arc4random fork. Work
around it by providing arc4random/getentropy shims. Revisit when NetBSD
7 is available.
-rw-r--r-- | configure.ac | 9 | ||||
-rw-r--r-- | crypto/Makefile.am | 18 | ||||
-rw-r--r-- | crypto/compat/arc4random.h | 3 |
3 files changed, 22 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index 54209da..d8e5338 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -32,6 +32,9 @@ case $host_os in | |||
32 | HOST_ABI=elf | 32 | HOST_ABI=elf |
33 | CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE" | 33 | CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE" |
34 | ;; | 34 | ;; |
35 | *netbsd*) | ||
36 | HOST_OS=netbsd | ||
37 | ;; | ||
35 | *openbsd*) | 38 | *openbsd*) |
36 | HOST_ABI=elf | 39 | HOST_ABI=elf |
37 | AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) | 40 | AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) |
@@ -60,6 +63,7 @@ AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) | |||
60 | AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) | 63 | AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) |
61 | AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) | 64 | AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) |
62 | AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) | 65 | AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) |
66 | AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd]) | ||
63 | AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) | 67 | AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) |
64 | AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) | 68 | AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) |
65 | 69 | ||
@@ -214,7 +218,10 @@ AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" | |||
214 | 218 | ||
215 | # overrides for arc4random_buf implementations with known issues | 219 | # overrides for arc4random_buf implementations with known issues |
216 | AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], | 220 | AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], |
217 | [test "x$HOST_OS" != xdarwin -a "x$HOST_OS" != xfreebsd -a "x$ac_cv_func_arc4random_buf" = xyes]) | 221 | [test "x$HOST_OS" != xdarwin \ |
222 | -a "x$HOST_OS" != xfreebsd \ | ||
223 | -a "x$HOST_OS" != xnetbsd \ | ||
224 | -a "x$ac_cv_func_arc4random_buf" = xyes]) | ||
218 | 225 | ||
219 | AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ | 226 | AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ |
220 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | 227 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 9f5311a..10dd63d 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am | |||
@@ -74,9 +74,15 @@ if !HAVE_GETENTROPY | |||
74 | if HOST_FREEBSD | 74 | if HOST_FREEBSD |
75 | libcompat_la_SOURCES += compat/getentropy_freebsd.c | 75 | libcompat_la_SOURCES += compat/getentropy_freebsd.c |
76 | endif | 76 | endif |
77 | if HOST_HPUX | ||
78 | libcompat_la_SOURCES += compat/getentropy_hpux.c | ||
79 | endif | ||
77 | if HOST_LINUX | 80 | if HOST_LINUX |
78 | libcompat_la_SOURCES += compat/getentropy_linux.c | 81 | libcompat_la_SOURCES += compat/getentropy_linux.c |
79 | endif | 82 | endif |
83 | if HOST_NETBSD | ||
84 | libcompat_la_SOURCES += compat/getentropy_netbsd.c | ||
85 | endif | ||
80 | if HOST_DARWIN | 86 | if HOST_DARWIN |
81 | libcompat_la_SOURCES += compat/getentropy_osx.c | 87 | libcompat_la_SOURCES += compat/getentropy_osx.c |
82 | endif | 88 | endif |
@@ -86,9 +92,6 @@ endif | |||
86 | if HOST_WIN | 92 | if HOST_WIN |
87 | libcompat_la_SOURCES += compat/getentropy_win.c | 93 | libcompat_la_SOURCES += compat/getentropy_win.c |
88 | endif | 94 | endif |
89 | if HOST_HPUX | ||
90 | libcompat_la_SOURCES += compat/getentropy_hpux.c | ||
91 | endif | ||
92 | endif | 95 | endif |
93 | 96 | ||
94 | endif | 97 | endif |
@@ -97,22 +100,23 @@ if !HAVE_ISSETUGID | |||
97 | if HOST_LINUX | 100 | if HOST_LINUX |
98 | libcompat_la_SOURCES += compat/issetugid_linux.c | 101 | libcompat_la_SOURCES += compat/issetugid_linux.c |
99 | endif | 102 | endif |
100 | if HOST_WIN | ||
101 | libcompat_la_SOURCES += compat/issetugid_win.c | ||
102 | endif | ||
103 | if HOST_HPUX | 103 | if HOST_HPUX |
104 | libcompat_la_SOURCES += compat/issetugid_hpux.c | 104 | libcompat_la_SOURCES += compat/issetugid_hpux.c |
105 | endif | 105 | endif |
106 | if HOST_WIN | ||
107 | libcompat_la_SOURCES += compat/issetugid_win.c | ||
108 | endif | ||
106 | endif | 109 | endif |
107 | 110 | ||
108 | noinst_HEADERS = | 111 | noinst_HEADERS = |
109 | noinst_HEADERS += compat/arc4random.h | 112 | noinst_HEADERS += compat/arc4random.h |
110 | noinst_HEADERS += compat/arc4random_freebsd.h | 113 | noinst_HEADERS += compat/arc4random_freebsd.h |
114 | noinst_HEADERS += compat/arc4random_hpux.h | ||
111 | noinst_HEADERS += compat/arc4random_linux.h | 115 | noinst_HEADERS += compat/arc4random_linux.h |
116 | noinst_HEADERS += compat/arc4random_netbsd.h | ||
112 | noinst_HEADERS += compat/arc4random_osx.h | 117 | noinst_HEADERS += compat/arc4random_osx.h |
113 | noinst_HEADERS += compat/arc4random_solaris.h | 118 | noinst_HEADERS += compat/arc4random_solaris.h |
114 | noinst_HEADERS += compat/arc4random_win.h | 119 | noinst_HEADERS += compat/arc4random_win.h |
115 | noinst_HEADERS += compat/arc4random_hpux.h | ||
116 | noinst_HEADERS += compat/chacha_private.h | 120 | noinst_HEADERS += compat/chacha_private.h |
117 | 121 | ||
118 | libcrypto_la_SOURCES = | 122 | libcrypto_la_SOURCES = |
diff --git a/crypto/compat/arc4random.h b/crypto/compat/arc4random.h index ed812ba..ce1bbea 100644 --- a/crypto/compat/arc4random.h +++ b/crypto/compat/arc4random.h | |||
@@ -12,6 +12,9 @@ | |||
12 | #elif defined(__linux__) | 12 | #elif defined(__linux__) |
13 | #include "arc4random_linux.h" | 13 | #include "arc4random_linux.h" |
14 | 14 | ||
15 | #elif defined(__NetBSD__) | ||
16 | #include "arc4random_netbsd.h" | ||
17 | |||
15 | #elif defined(__APPLE__) | 18 | #elif defined(__APPLE__) |
16 | #include "arc4random_osx.h" | 19 | #include "arc4random_osx.h" |
17 | 20 | ||