diff options
| author | Brent Cook <busterb@gmail.com> | 2015-05-02 01:40:33 -0500 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2015-05-23 19:27:57 -0500 |
| commit | 769d58e4946b35976c4da2ab54c56f6430a45d89 (patch) | |
| tree | 5ff27229f208de7077c9e8f9894c32a1ef8f6f1f | |
| parent | d3771a41cb106c945e0f538073d0a6e7b35d145b (diff) | |
| download | portable-769d58e4946b35976c4da2ab54c56f6430a45d89.tar.gz portable-769d58e4946b35976c4da2ab54c56f6430a45d89.tar.bz2 portable-769d58e4946b35976c4da2ab54c56f6430a45d89.zip | |
further refactoring, working libtls-standalone
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | crypto/Makefile.am | 44 | ||||
| -rw-r--r-- | libtls-standalone/Makefile.am | 2 | ||||
| -rw-r--r-- | libtls-standalone/VERSION | 2 | ||||
| -rw-r--r-- | libtls-standalone/app/Makefile.am | 6 | ||||
| -rw-r--r-- | libtls-standalone/app/test.c | 6 | ||||
| -rw-r--r-- | libtls-standalone/compat/Makefile.am | 45 | ||||
| -rw-r--r-- | libtls-standalone/configure.ac | 246 | ||||
| -rw-r--r-- | libtls-standalone/include/Makefile.am | 28 | ||||
| -rw-r--r-- | libtls-standalone/include/string.h | 49 | ||||
| -rw-r--r-- | libtls-standalone/src/Makefile.am | 6 | ||||
| -rwxr-xr-x | update.sh | 48 |
12 files changed, 172 insertions, 316 deletions
| @@ -122,7 +122,11 @@ include/openssl/*.he | |||
| 122 | /libtls-standalone/include/*.h | 122 | /libtls-standalone/include/*.h |
| 123 | /libtls-standalone/src/*.c | 123 | /libtls-standalone/src/*.c |
| 124 | /libtls-standalone/src/*.h | 124 | /libtls-standalone/src/*.h |
| 125 | /libtls-standalone/src/compat | 125 | /libtls-standalone/src |
| 126 | /libtls-standalone/compat | ||
| 127 | !/libtls-standalone/compat/Makefile.am | ||
| 128 | /libtls-standalone/VERSION | ||
| 129 | /libtls-standalone/m4 | ||
| 126 | 130 | ||
| 127 | openbsd/ | 131 | openbsd/ |
| 128 | 132 | ||
diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 757197f..ad26168 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am | |||
| @@ -65,49 +65,7 @@ if !HAVE_TIMINGSAFE_BCMP | |||
| 65 | libcompat_la_SOURCES += compat/timingsafe_bcmp.c | 65 | libcompat_la_SOURCES += compat/timingsafe_bcmp.c |
| 66 | endif | 66 | endif |
| 67 | 67 | ||
| 68 | if !HAVE_ARC4RANDOM_BUF | 68 | include Makefile.am.arc4random |
| 69 | libcompat_la_SOURCES += compat/arc4random.c | ||
| 70 | |||
| 71 | if !HAVE_GETENTROPY | ||
| 72 | if HOST_AIX | ||
| 73 | libcompat_la_SOURCES += compat/getentropy_aix.c | ||
| 74 | endif | ||
| 75 | if HOST_FREEBSD | ||
| 76 | libcompat_la_SOURCES += compat/getentropy_freebsd.c | ||
| 77 | endif | ||
| 78 | if HOST_HPUX | ||
| 79 | libcompat_la_SOURCES += compat/getentropy_hpux.c | ||
| 80 | endif | ||
| 81 | if HOST_LINUX | ||
| 82 | libcompat_la_SOURCES += compat/getentropy_linux.c | ||
| 83 | endif | ||
| 84 | if HOST_NETBSD | ||
| 85 | libcompat_la_SOURCES += compat/getentropy_netbsd.c | ||
| 86 | endif | ||
| 87 | if HOST_DARWIN | ||
| 88 | libcompat_la_SOURCES += compat/getentropy_osx.c | ||
| 89 | endif | ||
| 90 | if HOST_SOLARIS | ||
| 91 | libcompat_la_SOURCES += compat/getentropy_solaris.c | ||
| 92 | endif | ||
| 93 | if HOST_WIN | ||
| 94 | libcompat_la_SOURCES += compat/getentropy_win.c | ||
| 95 | endif | ||
| 96 | endif | ||
| 97 | |||
| 98 | endif | ||
| 99 | |||
| 100 | noinst_HEADERS = | ||
| 101 | noinst_HEADERS += compat/arc4random.h | ||
| 102 | noinst_HEADERS += compat/arc4random_aix.h | ||
| 103 | noinst_HEADERS += compat/arc4random_freebsd.h | ||
| 104 | noinst_HEADERS += compat/arc4random_hpux.h | ||
| 105 | noinst_HEADERS += compat/arc4random_linux.h | ||
| 106 | noinst_HEADERS += compat/arc4random_netbsd.h | ||
| 107 | noinst_HEADERS += compat/arc4random_osx.h | ||
| 108 | noinst_HEADERS += compat/arc4random_solaris.h | ||
| 109 | noinst_HEADERS += compat/arc4random_win.h | ||
| 110 | noinst_HEADERS += compat/chacha_private.h | ||
| 111 | 69 | ||
| 112 | libcrypto_la_SOURCES = | 70 | libcrypto_la_SOURCES = |
| 113 | EXTRA_libcrypto_la_SOURCES = | 71 | EXTRA_libcrypto_la_SOURCES = |
diff --git a/libtls-standalone/Makefile.am b/libtls-standalone/Makefile.am index 8881d8c..a108ada 100644 --- a/libtls-standalone/Makefile.am +++ b/libtls-standalone/Makefile.am | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | SUBDIRS = include src | 1 | SUBDIRS = include compat src app |
| 2 | ACLOCAL_AMFLAGS = -I m4 | 2 | ACLOCAL_AMFLAGS = -I m4 |
| 3 | 3 | ||
| 4 | pkgconfigdir = $(libdir)/pkgconfig | 4 | pkgconfigdir = $(libdir)/pkgconfig |
diff --git a/libtls-standalone/VERSION b/libtls-standalone/VERSION index 81ece01..fd2a018 100644 --- a/libtls-standalone/VERSION +++ b/libtls-standalone/VERSION | |||
| @@ -1 +1 @@ | |||
| 3:1:0 | 3.1.0 | ||
diff --git a/libtls-standalone/app/Makefile.am b/libtls-standalone/app/Makefile.am new file mode 100644 index 0000000..75a3dd6 --- /dev/null +++ b/libtls-standalone/app/Makefile.am | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | AM_CFLAGS = -I$(top_srcdir)/include | ||
| 2 | |||
| 3 | bin_PROGRAMS = test | ||
| 4 | |||
| 5 | test_SOURCES = test.c | ||
| 6 | test_LDADD = -lcrypto -lssl $(top_builddir)/src/libtls.la | ||
diff --git a/libtls-standalone/app/test.c b/libtls-standalone/app/test.c new file mode 100644 index 0000000..e3c3f76 --- /dev/null +++ b/libtls-standalone/app/test.c | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | #include <tls.h> | ||
| 2 | |||
| 3 | int main() | ||
| 4 | { | ||
| 5 | tls_init(); | ||
| 6 | } | ||
diff --git a/libtls-standalone/compat/Makefile.am b/libtls-standalone/compat/Makefile.am new file mode 100644 index 0000000..e1ec939 --- /dev/null +++ b/libtls-standalone/compat/Makefile.am | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | # | ||
| 2 | # Copyright (c) 2014-2015 Brent Cook | ||
| 3 | # | ||
| 4 | # Permission to use, copy, modify, and distribute this software for any | ||
| 5 | # purpose with or without fee is hereby granted, provided that the above | ||
| 6 | # copyright notice and this permission notice appear in all copies. | ||
| 7 | # | ||
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 14 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 15 | |||
| 16 | AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src | ||
| 17 | |||
| 18 | noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la | ||
| 19 | |||
| 20 | # compatibility functions that need to be built without optimizations | ||
| 21 | libcompatnoopt_la_CFLAGS = -O0 | ||
| 22 | libcompatnoopt_la_SOURCES = | ||
| 23 | |||
| 24 | if !HAVE_EXPLICIT_BZERO | ||
| 25 | libcompatnoopt_la_SOURCES += explicit_bzero.c | ||
| 26 | endif | ||
| 27 | |||
| 28 | # other compatibility functions | ||
| 29 | libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) | ||
| 30 | libcompat_la_SOURCES = | ||
| 31 | libcompat_la_LIBADD = $(PLATFORM_LDADD) | ||
| 32 | |||
| 33 | if !HAVE_ASPRINTF | ||
| 34 | libcompat_la_SOURCES += bsd-asprintf.c | ||
| 35 | endif | ||
| 36 | |||
| 37 | if !HAVE_STRLCPY | ||
| 38 | libcompat_la_SOURCES += strlcpy.c | ||
| 39 | endif | ||
| 40 | |||
| 41 | if !HAVE_STRSEP | ||
| 42 | libcompat_la_SOURCES += strsep.c | ||
| 43 | endif | ||
| 44 | |||
| 45 | include Makefile.am.arc4random | ||
diff --git a/libtls-standalone/configure.ac b/libtls-standalone/configure.ac index babb266..d52e22a 100644 --- a/libtls-standalone/configure.ac +++ b/libtls-standalone/configure.ac | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | # Copyright (c) 2014-2015 Brent Cook | ||
| 2 | # | ||
| 3 | # Permission to use, copy, modify, and distribute this software for any | ||
| 4 | # purpose with or without fee is hereby granted, provided that the above | ||
| 5 | # copyright notice and this permission notice appear in all copies. | ||
| 6 | # | ||
| 7 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 8 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 9 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 10 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 11 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 12 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 13 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 14 | |||
| 1 | AC_INIT([libtls], m4_esyscmd([tr -d '\n' < VERSION])) | 15 | AC_INIT([libtls], m4_esyscmd([tr -d '\n' < VERSION])) |
| 2 | 16 | ||
| 3 | AC_CANONICAL_HOST | 17 | AC_CANONICAL_HOST |
| @@ -15,238 +29,20 @@ AM_PROG_CC_C_O | |||
| 15 | AC_PROG_LIBTOOL | 29 | AC_PROG_LIBTOOL |
| 16 | LT_INIT | 30 | LT_INIT |
| 17 | 31 | ||
| 18 | CFLAGS="$CFLAGS -Wall -std=gnu99" | 32 | CHECK_OS_OPTIONS |
| 19 | |||
| 20 | case $host_os in | ||
| 21 | *aix*) | ||
| 22 | HOST_OS=aix | ||
| 23 | if test "`echo $CC | cut -d ' ' -f 1`" != "gcc" ; then | ||
| 24 | CFLAGS="$USER_CFLAGS" | ||
| 25 | fi | ||
| 26 | ;; | ||
| 27 | *cygwin*) | ||
| 28 | HOST_OS=cygwin | ||
| 29 | ;; | ||
| 30 | *darwin*) | ||
| 31 | HOST_OS=darwin | ||
| 32 | HOST_ABI=macosx | ||
| 33 | ;; | ||
| 34 | *freebsd*) | ||
| 35 | HOST_OS=freebsd | ||
| 36 | HOST_ABI=elf | ||
| 37 | ;; | ||
| 38 | *hpux*) | ||
| 39 | HOST_OS=hpux; | ||
| 40 | if test "`echo $CC | cut -d ' ' -f 1`" = "gcc" ; then | ||
| 41 | CFLAGS="$CFLAGS -mlp64" | ||
| 42 | else | ||
| 43 | CFLAGS="-g -O2 +DD64 $USER_CFLAGS" | ||
| 44 | fi | ||
| 45 | CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT" | ||
| 46 | AC_SUBST([PLATFORM_LDADD], ['-lpthread']) | ||
| 47 | ;; | ||
| 48 | *linux*) | ||
| 49 | HOST_OS=linux | ||
| 50 | HOST_ABI=elf | ||
| 51 | CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE" | ||
| 52 | ;; | ||
| 53 | *netbsd*) | ||
| 54 | HOST_OS=netbsd | ||
| 55 | CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE" | ||
| 56 | ;; | ||
| 57 | *openbsd*) | ||
| 58 | HOST_ABI=elf | ||
| 59 | AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) | ||
| 60 | ;; | ||
| 61 | *mingw*) | ||
| 62 | HOST_OS=win | ||
| 63 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_POSIX -D_POSIX_SOURCE -D__USE_MINGW_ANSI_STDIO" | ||
| 64 | CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS" | ||
| 65 | CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600" | ||
| 66 | CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG" | ||
| 67 | CFLAGS="$CFLAGS -static-libgcc" | ||
| 68 | LDFLAGS="$LDFLAGS -static-libgcc" | ||
| 69 | AC_SUBST([PLATFORM_LDADD], ['-lws2_32']) | ||
| 70 | ;; | ||
| 71 | *solaris*) | ||
| 72 | HOST_OS=solaris | ||
| 73 | HOST_ABI=elf | ||
| 74 | CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP" | ||
| 75 | AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket']) | ||
| 76 | ;; | ||
| 77 | *) ;; | ||
| 78 | esac | ||
| 79 | |||
| 80 | AM_CONDITIONAL([HOST_AIX], [test x$HOST_OS = xaix]) | ||
| 81 | AM_CONDITIONAL([HOST_CYGWIN], [test x$HOST_OS = xcygwin]) | ||
| 82 | AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) | ||
| 83 | AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) | ||
| 84 | AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) | ||
| 85 | AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) | ||
| 86 | AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd]) | ||
| 87 | AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) | ||
| 88 | AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) | ||
| 89 | |||
| 90 | AC_MSG_CHECKING([if compiling with clang]) | ||
| 91 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ | ||
| 92 | #ifndef __clang__ | ||
| 93 | not clang | ||
| 94 | #endif | ||
| 95 | ]])], | ||
| 96 | [CLANG=yes], | ||
| 97 | [CLANG=no] | ||
| 98 | ) | ||
| 99 | AC_MSG_RESULT([$CLANG]) | ||
| 100 | AS_IF([test "x$CLANG" = "xyes"], [CLANG_FLAGS=-Qunused-arguments]) | ||
| 101 | |||
| 102 | CFLAGS="$CFLAGS $CLANG_FLAGS" | ||
| 103 | LDFLAGS="$LDFLAGS $CLANG_FLAGS" | ||
| 104 | 33 | ||
| 105 | # We want to check for compiler flag support. Prior to clang v5.1, there was no | 34 | CHECK_C_HARDENING_OPTIONS |
| 106 | # way to make clang's "argument unused" warning fatal. So we invoke the | ||
| 107 | # compiler through a wrapper script that greps for this message. | ||
| 108 | saved_CC="$CC" | ||
| 109 | saved_LD="$LD" | ||
| 110 | flag_wrap="$srcdir/scripts/wrap-compiler-for-flag-check" | ||
| 111 | CC="$flag_wrap $CC" | ||
| 112 | LD="$flag_wrap $LD" | ||
| 113 | |||
| 114 | AC_ARG_ENABLE([hardening], | ||
| 115 | [AS_HELP_STRING([--disable-hardening], | ||
| 116 | [Disable options to frustrate memory corruption exploits])], | ||
| 117 | [], [enable_hardening=yes]) | ||
| 118 | |||
| 119 | AC_ARG_ENABLE([windows-ssp], | ||
| 120 | [AS_HELP_STRING([--enable-windows-ssp], | ||
| 121 | [Enable building the stack smashing protection on | ||
| 122 | Windows. This currently distributing libssp-0.dll.])]) | ||
| 123 | |||
| 124 | AC_DEFUN([CHECK_CFLAG], [ | ||
| 125 | AC_LANG_ASSERT(C) | ||
| 126 | AC_MSG_CHECKING([if $saved_CC supports "$1"]) | ||
| 127 | old_cflags="$CFLAGS" | ||
| 128 | CFLAGS="$1 -Wall -Werror" | ||
| 129 | AC_TRY_LINK([ | ||
| 130 | #include <stdio.h> | ||
| 131 | ], | ||
| 132 | [printf("Hello")], | ||
| 133 | AC_MSG_RESULT([yes]) | ||
| 134 | CFLAGS=$old_cflags | ||
| 135 | HARDEN_CFLAGS="$HARDEN_CFLAGS $1", | ||
| 136 | AC_MSG_RESULT([no]) | ||
| 137 | CFLAGS=$old_cflags | ||
| 138 | [$2]) | ||
| 139 | ]) | ||
| 140 | |||
| 141 | AC_DEFUN([CHECK_LDFLAG], [ | ||
| 142 | AC_LANG_ASSERT(C) | ||
| 143 | AC_MSG_CHECKING([if $saved_LD supports "$1"]) | ||
| 144 | old_ldflags="$LDFLAGS" | ||
| 145 | LDFLAGS="$1 -Wall -Werror" | ||
| 146 | AC_TRY_LINK([ | ||
| 147 | #include <stdio.h> | ||
| 148 | ], | ||
| 149 | [printf("Hello")], | ||
| 150 | AC_MSG_RESULT([yes]) | ||
| 151 | LDFLAGS=$old_ldflags | ||
| 152 | HARDEN_LDFLAGS="$HARDEN_LDFLAGS $1", | ||
| 153 | AC_MSG_RESULT([no]) | ||
| 154 | LDFLAGS=$old_ldflags | ||
| 155 | [$2]) | ||
| 156 | ]) | ||
| 157 | 35 | ||
| 158 | AS_IF([test "x$enable_hardening" = "xyes"], [ | 36 | DISABLE_COMPILER_WARNINGS |
| 159 | # Tell GCC to NOT optimize based on signed arithmetic overflow | ||
| 160 | CHECK_CFLAG([[-fno-strict-overflow]]) | ||
| 161 | 37 | ||
| 162 | # _FORTIFY_SOURCE replaces builtin functions with safer versions. | 38 | CHECK_LIBC_COMPAT |
| 163 | CHECK_CFLAG([[-D_FORTIFY_SOURCE=2]]) | 39 | CHECK_LIBC_CRYPTO_COMPAT |
| 164 | |||
| 165 | # Enable read only relocations | ||
| 166 | CHECK_LDFLAG([[-Wl,-z,relro]]) | ||
| 167 | CHECK_LDFLAG([[-Wl,-z,now]]) | ||
| 168 | |||
| 169 | # Windows security flags | ||
| 170 | AS_IF([test "x$HOST_OS" = "xwin"], [ | ||
| 171 | CHECK_LDFLAG([[-Wl,--nxcompat]]) | ||
| 172 | CHECK_LDFLAG([[-Wl,--dynamicbase]]) | ||
| 173 | CHECK_LDFLAG([[-Wl,--high-entropy-va]]) | ||
| 174 | ]) | ||
| 175 | |||
| 176 | # Use stack-protector-strong if available; if not, fallback to | ||
| 177 | # stack-protector-all which is considered to be overkill | ||
| 178 | AS_IF([test "x$enable_windows_ssp" = "xyes" -o "x$HOST_OS" != "xwin"], [ | ||
| 179 | CHECK_CFLAG([[-fstack-protector-strong]], | ||
| 180 | CHECK_CFLAG([[-fstack-protector-all]], | ||
| 181 | AC_MSG_WARN([compiler does not appear to support stack protection]) | ||
| 182 | ) | ||
| 183 | ) | ||
| 184 | AS_IF([test "x$HOST_OS" = "xwin"], [ | ||
| 185 | AC_SEARCH_LIBS([__stack_chk_guard],[ssp]) | ||
| 186 | ]) | ||
| 187 | ]) | ||
| 188 | ]) | ||
| 189 | |||
| 190 | |||
| 191 | # Restore CC, LD | ||
| 192 | CC="$saved_CC" | ||
| 193 | LD="$saved_LD" | ||
| 194 | |||
| 195 | CFLAGS="$CFLAGS $HARDEN_CFLAGS" | ||
| 196 | LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS" | ||
| 197 | |||
| 198 | # Removing the dependency on -Wno-pointer-sign should be a goal | ||
| 199 | save_cflags="$CFLAGS" | ||
| 200 | CFLAGS=-Wno-pointer-sign | ||
| 201 | AC_MSG_CHECKING([whether CC supports -Wno-pointer-sign]) | ||
| 202 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], | ||
| 203 | [AC_MSG_RESULT([yes])] | ||
| 204 | [AM_CFLAGS=-Wno-pointer-sign], | ||
| 205 | [AC_MSG_RESULT([no])] | ||
| 206 | ) | ||
| 207 | CFLAGS="$save_cflags $AM_CFLAGS" | ||
| 208 | |||
| 209 | save_cflags="$CFLAGS" | ||
| 210 | CFLAGS= | ||
| 211 | AC_MSG_CHECKING([whether AS supports .note.GNU-stack]) | ||
| 212 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
| 213 | __asm__(".section .note.GNU-stack,\"\",@progbits");]])], | ||
| 214 | [AC_MSG_RESULT([yes])] | ||
| 215 | [AM_CFLAGS=-DHAVE_GNU_STACK], | ||
| 216 | [AC_MSG_RESULT([no])] | ||
| 217 | ) | ||
| 218 | CFLAGS="$save_cflags $AM_CFLAGS" | ||
| 219 | AM_PROG_AS | ||
| 220 | |||
| 221 | AC_CHECK_FUNCS([explicit_bzero strsep]) | ||
| 222 | AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes]) | ||
| 223 | AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes]) | ||
| 224 | |||
| 225 | #AC_CHECK_FUNCS([arc4random_buf asprintf explicit_bzero funopen getauxval]) | ||
| 226 | #AC_CHECK_FUNCS([getentropy memmem poll reallocarray]) | ||
| 227 | #AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strtonum]) | ||
| 228 | #AC_CHECK_FUNCS([symlink]) | ||
| 229 | #AC_CHECK_FUNCS([timingsafe_bcmp timingsafe_memcmp]) | ||
| 230 | # | ||
| 231 | ## Share test results with automake | ||
| 232 | #AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], [test "x$ac_cv_func_arc4random_buf" = xyes]) | ||
| 233 | #AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) | ||
| 234 | #AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = xyes]) | ||
| 235 | #AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) | ||
| 236 | #AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes]) | ||
| 237 | #AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) | ||
| 238 | #AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes]) | ||
| 239 | #AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) | ||
| 240 | #AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes]) | ||
| 241 | #AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes]) | ||
| 242 | #AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) | ||
| 243 | #AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP], [test "x$ac_cv_func_timingsafe_bcmp" = xyes]) | ||
| 244 | #AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" = xyes]) | ||
| 245 | #AM_CONDITIONAL([BUILD_CERTHASH], [test "x$ac_cv_func_symlink" = xyes]) | ||
| 246 | 40 | ||
| 247 | AC_CONFIG_FILES([ | 41 | AC_CONFIG_FILES([ |
| 248 | Makefile | 42 | Makefile |
| 249 | include/Makefile | 43 | include/Makefile |
| 44 | app/Makefile | ||
| 45 | compat/Makefile | ||
| 250 | src/Makefile | 46 | src/Makefile |
| 251 | libtls.pc | 47 | libtls.pc |
| 252 | ]) | 48 | ]) |
diff --git a/libtls-standalone/include/Makefile.am b/libtls-standalone/include/Makefile.am index 7fbefdc..0783318 100644 --- a/libtls-standalone/include/Makefile.am +++ b/libtls-standalone/include/Makefile.am | |||
| @@ -1,27 +1,5 @@ | |||
| 1 | #noinst_HEADERS = err.h | 1 | noinst_HEADERS = stdlib.h |
| 2 | #noinst_HEADERS += netdb.h | 2 | noinst_HEADERS += string.h |
| 3 | #noinst_HEADERS += poll.h | 3 | noinst_HEADERS += unistd.h |
| 4 | #noinst_HEADERS += pqueue.h | ||
| 5 | #noinst_HEADERS += stdio.h | ||
| 6 | #noinst_HEADERS += stdlib.h | ||
| 7 | #noinst_HEADERS += string.h | ||
| 8 | #noinst_HEADERS += syslog.h | ||
| 9 | #noinst_HEADERS += unistd.h | ||
| 10 | #noinst_HEADERS += win32netcompat.h | ||
| 11 | # | ||
| 12 | #noinst_HEADERS += arpa/inet.h | ||
| 13 | # | ||
| 14 | #noinst_HEADERS += machine/endian.h | ||
| 15 | # | ||
| 16 | #noinst_HEADERS += netinet/in.h | ||
| 17 | #noinst_HEADERS += netinet/tcp.h | ||
| 18 | # | ||
| 19 | #noinst_HEADERS += sys/ioctl.h | ||
| 20 | #noinst_HEADERS += sys/mman.h | ||
| 21 | #noinst_HEADERS += sys/select.h | ||
| 22 | #noinst_HEADERS += sys/socket.h | ||
| 23 | #noinst_HEADERS += sys/times.h | ||
| 24 | #noinst_HEADERS += sys/types.h | ||
| 25 | #noinst_HEADERS += sys/uio.h | ||
| 26 | 4 | ||
| 27 | include_HEADERS = tls.h | 5 | include_HEADERS = tls.h |
diff --git a/libtls-standalone/include/string.h b/libtls-standalone/include/string.h index c42fcba..05d1ffc 100644 --- a/libtls-standalone/include/string.h +++ b/libtls-standalone/include/string.h | |||
| @@ -17,12 +17,57 @@ | |||
| 17 | #include <strings.h> | 17 | #include <strings.h> |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | #ifndef HAVE_EXPLICIT_BZERO | 20 | #ifndef HAVE_STRLCPY |
| 21 | void explicit_bzero(void *, size_t); | 21 | size_t strlcpy(char *dst, const char *src, size_t siz); |
| 22 | #endif | ||
| 23 | |||
| 24 | #ifndef HAVE_STRLCAT | ||
| 25 | size_t strlcat(char *dst, const char *src, size_t siz); | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #ifndef HAVE_STRNDUP | ||
| 29 | char * strndup(const char *str, size_t maxlen); | ||
| 30 | /* the only user of strnlen is strndup, so only build it if needed */ | ||
| 31 | #ifndef HAVE_STRNLEN | ||
| 32 | size_t strnlen(const char *str, size_t maxlen); | ||
| 33 | #endif | ||
| 22 | #endif | 34 | #endif |
| 23 | 35 | ||
| 24 | #ifndef HAVE_STRSEP | 36 | #ifndef HAVE_STRSEP |
| 25 | char *strsep(char **stringp, const char *delim); | 37 | char *strsep(char **stringp, const char *delim); |
| 26 | #endif | 38 | #endif |
| 27 | 39 | ||
| 40 | #ifndef HAVE_EXPLICIT_BZERO | ||
| 41 | void explicit_bzero(void *, size_t); | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #ifndef HAVE_TIMINGSAFE_BCMP | ||
| 45 | int timingsafe_bcmp(const void *b1, const void *b2, size_t n); | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #ifndef HAVE_TIMINGSAFE_MEMCMP | ||
| 49 | int timingsafe_memcmp(const void *b1, const void *b2, size_t len); | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #ifndef HAVE_MEMMEM | ||
| 53 | void * memmem(const void *big, size_t big_len, const void *little, | ||
| 54 | size_t little_len); | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifdef _WIN32 | ||
| 58 | #include <errno.h> | ||
| 59 | |||
| 60 | static inline char * | ||
| 61 | posix_strerror(int errnum) | ||
| 62 | { | ||
| 63 | if (errnum == ECONNREFUSED) { | ||
| 64 | return "Connection refused"; | ||
| 65 | } | ||
| 66 | return strerror(errnum); | ||
| 67 | } | ||
| 68 | |||
| 69 | #define strerror(errnum) posix_strerror(errnum) | ||
| 70 | |||
| 71 | #endif | ||
| 72 | |||
| 28 | #endif | 73 | #endif |
diff --git a/libtls-standalone/src/Makefile.am b/libtls-standalone/src/Makefile.am index d5bcc49..cb9dd7f 100644 --- a/libtls-standalone/src/Makefile.am +++ b/libtls-standalone/src/Makefile.am | |||
| @@ -4,6 +4,8 @@ lib_LTLIBRARIES = libtls.la | |||
| 4 | 4 | ||
| 5 | libtls_la_LDFLAGS = -no-undefined | 5 | libtls_la_LDFLAGS = -no-undefined |
| 6 | libtls_la_LIBADD = -lcrypto -lssl $(PLATFORM_LDADD) | 6 | libtls_la_LIBADD = -lcrypto -lssl $(PLATFORM_LDADD) |
| 7 | libtls_la_LIBADD += $(top_builddir)/compat/libcompat.la | ||
| 8 | libtls_la_LIBADD += $(top_builddir)/compat/libcompatnoopt.la | ||
| 7 | 9 | ||
| 8 | libtls_la_SOURCES = tls.c | 10 | libtls_la_SOURCES = tls.c |
| 9 | libtls_la_SOURCES += tls_client.c | 11 | libtls_la_SOURCES += tls_client.c |
| @@ -12,7 +14,3 @@ libtls_la_SOURCES += tls_server.c | |||
| 12 | libtls_la_SOURCES += tls_util.c | 14 | libtls_la_SOURCES += tls_util.c |
| 13 | libtls_la_SOURCES += tls_verify.c | 15 | libtls_la_SOURCES += tls_verify.c |
| 14 | noinst_HEADERS = tls_internal.h | 16 | noinst_HEADERS = tls_internal.h |
| 15 | |||
| 16 | if !HAVE_STRSEP | ||
| 17 | libtls_la_SOURCES += strsep.c | ||
| 18 | endif | ||
| @@ -43,7 +43,7 @@ source $libtls_src/shlib_version | |||
| 43 | libtls_version=$major:$minor:0 | 43 | libtls_version=$major:$minor:0 |
| 44 | echo "libtls version $libtls_version" | 44 | echo "libtls version $libtls_version" |
| 45 | echo $libtls_version > tls/VERSION | 45 | echo $libtls_version > tls/VERSION |
| 46 | echo $libtls_version > libtls-standalone/VERSION | 46 | echo $major.$minor.0 > libtls-standalone/VERSION |
| 47 | 47 | ||
| 48 | do_mv() { | 48 | do_mv() { |
| 49 | if ! cmp -s "$1" "$2" | 49 | if ! cmp -s "$1" "$2" |
| @@ -62,21 +62,35 @@ $CP $libcrypto_src/crypto/arch/amd64/opensslconf.h include/openssl | |||
| 62 | $CP $libssl_src/src/crypto/opensslfeatures.h include/openssl | 62 | $CP $libssl_src/src/crypto/opensslfeatures.h include/openssl |
| 63 | $CP $libssl_src/src/e_os2.h include/openssl | 63 | $CP $libssl_src/src/e_os2.h include/openssl |
| 64 | $CP $libssl_src/src/ssl/pqueue.h include | 64 | $CP $libssl_src/src/ssl/pqueue.h include |
| 65 | $CP $libtls_src/tls.h include | ||
| 66 | $CP $libtls_src/tls.h libtls-standalone/include | ||
| 67 | 65 | ||
| 68 | for i in explicit_bzero.c strlcpy.c strlcat.c strndup.c strnlen.c \ | 66 | sed -e "s/#define HEADER_TLS_H/#define HEADER_TLS_H\n#include <stddef.h>\n#include <stdint.h>/" \ |
| 69 | timingsafe_bcmp.c timingsafe_memcmp.c; do | 67 | $libtls_src/tls.h > include/tls.h |
| 70 | $CP $libc_src/string/$i crypto/compat | 68 | $CP include/tls.h libtls-standalone/include |
| 69 | |||
| 70 | for i in crypto/compat libtls-standalone/compat; do | ||
| 71 | $CP $libc_src/crypt/arc4random.c \ | ||
| 72 | $libc_src/crypt/chacha_private.h \ | ||
| 73 | $libc_src/string/explicit_bzero.c \ | ||
| 74 | $libc_src/stdlib/reallocarray.c \ | ||
| 75 | $libc_src/string/strlcpy.c \ | ||
| 76 | $libc_src/string/strlcat.c \ | ||
| 77 | $libc_src/string/strndup.c \ | ||
| 78 | $libc_src/string/strnlen.c \ | ||
| 79 | $libc_src/string/timingsafe_bcmp.c \ | ||
| 80 | $libc_src/string/timingsafe_memcmp.c \ | ||
| 81 | $libcrypto_src/crypto/getentropy_*.c \ | ||
| 82 | $libcrypto_src/crypto/arc4random_*.h \ | ||
| 83 | $i | ||
| 71 | done | 84 | done |
| 72 | $CP $libc_src/stdlib/reallocarray.c crypto/compat | ||
| 73 | $CP $libc_src/crypt/arc4random.c crypto/compat | ||
| 74 | $CP $libc_src/crypt/chacha_private.h crypto/compat | ||
| 75 | $CP $libcrypto_src/crypto/getentropy_*.c crypto/compat | ||
| 76 | $CP $libcrypto_src/crypto/arc4random_*.h crypto/compat | ||
| 77 | 85 | ||
| 78 | $CP $libcrypto_src/crypto/getentropy_*.c libtls-standalone/src/compat | 86 | $CP include/stdlib.h \ |
| 79 | $CP $libcrypto_src/crypto/arc4random_*.h libtls-standalone/src/compat | 87 | include/string.h \ |
| 88 | include/unistd.h \ | ||
| 89 | libtls-standalone/include | ||
| 90 | |||
| 91 | $CP crypto/compat/arc4random*.h \ | ||
| 92 | crypto/compat/bsd-asprintf.c \ | ||
| 93 | libtls-standalone/compat | ||
| 80 | 94 | ||
| 81 | (cd $libssl_src/src/crypto/objects/; | 95 | (cd $libssl_src/src/crypto/objects/; |
| 82 | perl objects.pl objects.txt obj_mac.num obj_mac.h; | 96 | perl objects.pl objects.txt obj_mac.num obj_mac.h; |
| @@ -179,7 +193,13 @@ for i in `awk '/SOURCES|HEADERS/ { print $3 }' tls/Makefile.am` ; do | |||
| 179 | fi | 193 | fi |
| 180 | done | 194 | done |
| 181 | $CP $libc_src/string/strsep.c tls | 195 | $CP $libc_src/string/strsep.c tls |
| 182 | $CP $libc_src/string/strsep.c libtls-standalone/src/compat | 196 | $CP $libc_src/string/strsep.c libtls-standalone/compat |
| 197 | mkdir -p libtls-standalone/m4 | ||
| 198 | $CP m4/check*.m4 \ | ||
| 199 | m4/disable*.m4 \ | ||
| 200 | libtls-standalone/m4 | ||
| 201 | sed -e "s/compat\///" crypto/Makefile.am.arc4random > \ | ||
| 202 | libtls-standalone/compat/Makefile.am.arc4random | ||
| 183 | 203 | ||
| 184 | # copy openssl(1) source | 204 | # copy openssl(1) source |
| 185 | echo "copying openssl(1) source" | 205 | echo "copying openssl(1) source" |
