aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2015-01-21 06:14:24 -0600
committerBrent Cook <busterb@gmail.com>2015-01-21 06:14:24 -0600
commita2233651277a50955cdc4c7810da7a12e4e33551 (patch)
tree5d48e874577eb6f0c955bfa6ddfdae04d13af406
parentec81c28219b3d3234ddf0af12d0579efa1a3d2a6 (diff)
downloadportable-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.ac9
-rw-r--r--crypto/Makefile.am18
-rw-r--r--crypto/compat/arc4random.h3
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])
60AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) 63AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd])
61AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) 64AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux])
62AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) 65AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux])
66AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd])
63AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) 67AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
64AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) 68AM_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
216AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], 220AM_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
219AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ 226AC_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
74if HOST_FREEBSD 74if HOST_FREEBSD
75libcompat_la_SOURCES += compat/getentropy_freebsd.c 75libcompat_la_SOURCES += compat/getentropy_freebsd.c
76endif 76endif
77if HOST_HPUX
78libcompat_la_SOURCES += compat/getentropy_hpux.c
79endif
77if HOST_LINUX 80if HOST_LINUX
78libcompat_la_SOURCES += compat/getentropy_linux.c 81libcompat_la_SOURCES += compat/getentropy_linux.c
79endif 82endif
83if HOST_NETBSD
84libcompat_la_SOURCES += compat/getentropy_netbsd.c
85endif
80if HOST_DARWIN 86if HOST_DARWIN
81libcompat_la_SOURCES += compat/getentropy_osx.c 87libcompat_la_SOURCES += compat/getentropy_osx.c
82endif 88endif
@@ -86,9 +92,6 @@ endif
86if HOST_WIN 92if HOST_WIN
87libcompat_la_SOURCES += compat/getentropy_win.c 93libcompat_la_SOURCES += compat/getentropy_win.c
88endif 94endif
89if HOST_HPUX
90libcompat_la_SOURCES += compat/getentropy_hpux.c
91endif
92endif 95endif
93 96
94endif 97endif
@@ -97,22 +100,23 @@ if !HAVE_ISSETUGID
97if HOST_LINUX 100if HOST_LINUX
98libcompat_la_SOURCES += compat/issetugid_linux.c 101libcompat_la_SOURCES += compat/issetugid_linux.c
99endif 102endif
100if HOST_WIN
101libcompat_la_SOURCES += compat/issetugid_win.c
102endif
103if HOST_HPUX 103if HOST_HPUX
104libcompat_la_SOURCES += compat/issetugid_hpux.c 104libcompat_la_SOURCES += compat/issetugid_hpux.c
105endif 105endif
106if HOST_WIN
107libcompat_la_SOURCES += compat/issetugid_win.c
108endif
106endif 109endif
107 110
108noinst_HEADERS = 111noinst_HEADERS =
109noinst_HEADERS += compat/arc4random.h 112noinst_HEADERS += compat/arc4random.h
110noinst_HEADERS += compat/arc4random_freebsd.h 113noinst_HEADERS += compat/arc4random_freebsd.h
114noinst_HEADERS += compat/arc4random_hpux.h
111noinst_HEADERS += compat/arc4random_linux.h 115noinst_HEADERS += compat/arc4random_linux.h
116noinst_HEADERS += compat/arc4random_netbsd.h
112noinst_HEADERS += compat/arc4random_osx.h 117noinst_HEADERS += compat/arc4random_osx.h
113noinst_HEADERS += compat/arc4random_solaris.h 118noinst_HEADERS += compat/arc4random_solaris.h
114noinst_HEADERS += compat/arc4random_win.h 119noinst_HEADERS += compat/arc4random_win.h
115noinst_HEADERS += compat/arc4random_hpux.h
116noinst_HEADERS += compat/chacha_private.h 120noinst_HEADERS += compat/chacha_private.h
117 121
118libcrypto_la_SOURCES = 122libcrypto_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