diff options
| author | Brent Cook <busterb@gmail.com> | 2014-07-10 22:06:10 -0500 |
|---|---|---|
| committer | Brent Cook <bcook@openbsd.org> | 2015-07-21 12:08:18 -0500 |
| commit | 5d8a1cf7155130bd8101090d7e1d0c2f90d9b123 (patch) | |
| tree | 286f7d12e3647f94bd1e6e8e180a4bf6215a0740 | |
| parent | 7a4a37cf596697ae96eeb1c555989e6d1a443187 (diff) | |
| download | portable-5d8a1cf7155130bd8101090d7e1d0c2f90d9b123.tar.gz portable-5d8a1cf7155130bd8101090d7e1d0c2f90d9b123.tar.bz2 portable-5d8a1cf7155130bd8101090d7e1d0c2f90d9b123.zip | |
add initial CMake and Visual Studio build support
This moves the compatibility include files from include to
include/compat so we can use the awful MS C compiler
<../include/> trick to emulate the GNU #include_next extension.
This also removes a few old compat files we do not need anymore.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | CMakeLists.txt | 130 | ||||
| -rw-r--r-- | Makefile.am | 1 | ||||
| -rw-r--r-- | Makefile.am.common | 2 | ||||
| -rw-r--r-- | apps/CMakeLists.txt | 84 | ||||
| -rw-r--r-- | apps/Makefile.am | 1 | ||||
| -rw-r--r-- | crypto/CMakeLists.txt | 624 | ||||
| -rw-r--r-- | crypto/Makefile.am | 3 | ||||
| -rw-r--r-- | crypto/compat/posix_win.c | 24 | ||||
| -rw-r--r-- | include/Makefile.am | 50 | ||||
| -rw-r--r-- | include/compat/arpa/inet.h (renamed from include/arpa/inet.h) | 2 | ||||
| -rw-r--r-- | include/compat/arpa/nameser.h (renamed from include/arpa/nameser.h) | 0 | ||||
| -rw-r--r-- | include/compat/dirent.h | 17 | ||||
| -rw-r--r-- | include/compat/dirent_msvc.h | 748 | ||||
| -rw-r--r-- | include/compat/err.h | 33 | ||||
| -rw-r--r-- | include/compat/machine/endian.h (renamed from include/machine/endian.h) | 0 | ||||
| -rw-r--r-- | include/compat/netdb.h (renamed from include/netdb.h) | 0 | ||||
| -rw-r--r-- | include/compat/netinet/in.h (renamed from include/netinet/in.h) | 0 | ||||
| -rw-r--r-- | include/compat/netinet/tcp.h (renamed from include/netinet/tcp.h) | 0 | ||||
| -rw-r--r-- | include/compat/poll.h (renamed from include/poll.h) | 2 | ||||
| -rw-r--r-- | include/compat/stdio.h (renamed from include/stdio.h) | 12 | ||||
| -rw-r--r-- | include/compat/stdlib.h (renamed from include/stdlib.h) | 11 | ||||
| -rw-r--r-- | include/compat/string.h (renamed from include/string.h) | 13 | ||||
| -rw-r--r-- | include/compat/sys/cdefs.h (renamed from include/sys/cdefs.h) | 0 | ||||
| -rw-r--r-- | include/compat/sys/ioctl.h (renamed from include/sys/ioctl.h) | 0 | ||||
| -rw-r--r-- | include/compat/sys/mman.h (renamed from include/sys/mman.h) | 0 | ||||
| -rw-r--r-- | include/compat/sys/param.h | 15 | ||||
| -rw-r--r-- | include/compat/sys/select.h (renamed from include/sys/select.h) | 0 | ||||
| -rw-r--r-- | include/compat/sys/socket.h (renamed from include/sys/socket.h) | 0 | ||||
| -rw-r--r-- | include/compat/sys/stat.h | 95 | ||||
| -rw-r--r-- | include/compat/sys/time.h | 16 | ||||
| -rw-r--r-- | include/compat/sys/types.h (renamed from include/sys/types.h) | 26 | ||||
| -rw-r--r-- | include/compat/sys/uio.h (renamed from include/sys/uio.h) | 0 | ||||
| -rw-r--r-- | include/compat/time.h | 16 | ||||
| -rw-r--r-- | include/compat/unistd.h | 36 | ||||
| -rw-r--r-- | include/compat/win32netcompat.h (renamed from include/win32netcompat.h) | 0 | ||||
| -rw-r--r-- | include/err.h | 33 | ||||
| -rw-r--r-- | include/sys/times.h | 10 | ||||
| -rw-r--r-- | include/syslog.h | 38 | ||||
| -rw-r--r-- | include/unistd.h | 15 | ||||
| -rw-r--r-- | libtls-standalone/include/string.h | 13 | ||||
| -rw-r--r-- | m4/check-os-options.m4 | 2 | ||||
| -rw-r--r-- | patches/arc4random.c.patch | 15 | ||||
| -rw-r--r-- | patches/openssl.c.patch | 27 | ||||
| -rw-r--r-- | patches/opensslconf.h.patch | 13 | ||||
| -rw-r--r-- | patches/ossl_typ.h.patch | 4 | ||||
| -rw-r--r-- | patches/pkcs7.h.patch | 4 | ||||
| -rw-r--r-- | patches/x509.h.patch | 6 | ||||
| -rw-r--r-- | ssl/CMakeLists.txt | 53 | ||||
| -rw-r--r-- | ssl/Makefile.am | 1 | ||||
| -rw-r--r-- | tls/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | tls/Makefile.am | 1 | ||||
| -rwxr-xr-x | update.sh | 16 |
53 files changed, 2082 insertions, 153 deletions
| @@ -124,6 +124,7 @@ include/openssl/*.he | |||
| 124 | !/crypto/compat/bsd_asprintf.c | 124 | !/crypto/compat/bsd_asprintf.c |
| 125 | !/crypto/compat/inet_pton.c | 125 | !/crypto/compat/inet_pton.c |
| 126 | !/crypto/compat/ui_openssl_win.c | 126 | !/crypto/compat/ui_openssl_win.c |
| 127 | !/crypto/CMakeLists.txt | ||
| 127 | 128 | ||
| 128 | /libtls-standalone/include/*.h | 129 | /libtls-standalone/include/*.h |
| 129 | /libtls-standalone/src/*.c | 130 | /libtls-standalone/src/*.c |
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e642bcc --- /dev/null +++ b/CMakeLists.txt | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | cmake_minimum_required (VERSION 3.2) | ||
| 2 | include(CheckFunctionExists) | ||
| 3 | |||
| 4 | project (LibreSSL) | ||
| 5 | |||
| 6 | if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD") | ||
| 7 | add_definitions(-DHAVE_ATTRIBUTE__BOUNDED__) | ||
| 8 | endif() | ||
| 9 | |||
| 10 | add_definitions(-DLIBRESSL_INTERNAL) | ||
| 11 | add_definitions(-DOPENSSL_NO_HW_PADLOCK) | ||
| 12 | add_definitions(-DOPENSSL_NO_ASM) | ||
| 13 | |||
| 14 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
| 15 | add_definitions(-Wno-pointer-sign) | ||
| 16 | endif() | ||
| 17 | |||
| 18 | if(MSVC) | ||
| 19 | add_definitions(-Dinline=__inline) | ||
| 20 | add_definitions(-Drestrict) | ||
| 21 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||
| 22 | add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS) | ||
| 23 | add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS) | ||
| 24 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501) | ||
| 25 | add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT) | ||
| 26 | |||
| 27 | set(MSVC_DISABLED_WARNINGS_LIST | ||
| 28 | "C4057" # C4057: 'initializing' : 'unsigned char *' differs in | ||
| 29 | # indirection to slightly different base types from 'char [2]' | ||
| 30 | "C4100" # 'exarg' : unreferenced formal parameter | ||
| 31 | "C4127" # conditional expression is constant | ||
| 32 | "C4242" # 'function' : conversion from 'int' to 'uint8_t', | ||
| 33 | # possible loss of data | ||
| 34 | "C4244" # 'function' : conversion from 'int' to 'uint8_t', | ||
| 35 | # possible loss of data | ||
| 36 | "C4706" # assignment within conditional expression | ||
| 37 | "C4820" # 'bytes' bytes padding added after construct 'member_name' | ||
| 38 | "C4996" # 'read': The POSIX name for this item is deprecated. Instead, | ||
| 39 | # use the ISO C++ conformant name: _read. | ||
| 40 | ) | ||
| 41 | string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR | ||
| 42 | ${MSVC_DISABLED_WARNINGS_LIST}) | ||
| 43 | set(CMAKE_C_FLAGS "-MP -W4 ${MSVC_DISABLED_WARNINGS_STR}") | ||
| 44 | endif() | ||
| 45 | |||
| 46 | check_function_exists(asprintf HAVE_ASPRINTF) | ||
| 47 | if(HAVE_ASPRINTF) | ||
| 48 | add_definitions(-DHAVE_ASPRINTF) | ||
| 49 | endif() | ||
| 50 | |||
| 51 | check_function_exists(inet_pton HAVE_INET_PTON) | ||
| 52 | if(HAVE_INET_PTON) | ||
| 53 | add_definitions(-DHAVE_INET_PTON) | ||
| 54 | endif() | ||
| 55 | |||
| 56 | check_function_exists(reallocarray HAVE_REALLOCARRAY) | ||
| 57 | if(HAVE_REALLOCARRAY) | ||
| 58 | add_definitions(-DHAVE_REALLOCARRAY) | ||
| 59 | endif() | ||
| 60 | |||
| 61 | check_function_exists(strcasecmp HAVE_STRCASECMP) | ||
| 62 | if(HAVE_STRCASECMP) | ||
| 63 | add_definitions(-DHAVE_STRCASECMP) | ||
| 64 | endif() | ||
| 65 | |||
| 66 | check_function_exists(strlcat HAVE_STRLCAT) | ||
| 67 | if(HAVE_STRLCAT) | ||
| 68 | add_definitions(-DHAVE_STRLCAT) | ||
| 69 | endif() | ||
| 70 | |||
| 71 | check_function_exists(strlcat HAVE_STRLCPY) | ||
| 72 | if(HAVE_STRLCPY) | ||
| 73 | add_definitions(-DHAVE_STRLCPY) | ||
| 74 | endif() | ||
| 75 | |||
| 76 | check_function_exists(strndup HAVE_STRNDUP) | ||
| 77 | if(HAVE_STRNDUP) | ||
| 78 | add_definitions(-DHAVE_STRNDUP) | ||
| 79 | endif() | ||
| 80 | |||
| 81 | if(MSVC) | ||
| 82 | set(HAVE_STRNLEN) | ||
| 83 | add_definitions(-DHAVE_STRNLEN) | ||
| 84 | else() | ||
| 85 | check_function_exists(strnlen HAVE_STRNLEN) | ||
| 86 | if(HAVE_STRNLEN) | ||
| 87 | add_definitions(-DHAVE_STRNLEN) | ||
| 88 | endif() | ||
| 89 | endif() | ||
| 90 | |||
| 91 | check_function_exists(strsep HAVE_STRSEP) | ||
| 92 | if(HAVE_STRSEP) | ||
| 93 | add_definitions(-DHAVE_STRSEP) | ||
| 94 | endif() | ||
| 95 | |||
| 96 | check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF) | ||
| 97 | if(HAVE_ARC4RANDOM_BUF) | ||
| 98 | add_definitions(-DHAVE_ARC4RANDOM_BUF) | ||
| 99 | endif() | ||
| 100 | |||
| 101 | check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO) | ||
| 102 | if(HAVE_EXPLICIT_BZERO) | ||
| 103 | add_definitions(-DHAVE_EXPLICIT_BZERO) | ||
| 104 | endif() | ||
| 105 | |||
| 106 | check_function_exists(getauxval HAVE_GETAUXVAL) | ||
| 107 | if(HAVE_GETAUXVAL) | ||
| 108 | add_definitions(-DHAVE_GETAUXVAL) | ||
| 109 | endif() | ||
| 110 | |||
| 111 | check_function_exists(getentropy HAVE_GETENTROPY) | ||
| 112 | if(HAVE_GETENTROPY) | ||
| 113 | add_definitions(-DHAVE_GETENTROPY) | ||
| 114 | endif() | ||
| 115 | |||
| 116 | check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP) | ||
| 117 | if(HAVE_TIMINGSAFE_BCMP) | ||
| 118 | add_definitions(-DHAVE_TIMINGSAFE_BCMP) | ||
| 119 | endif() | ||
| 120 | |||
| 121 | check_function_exists(timingsafe_memcmp HAVE_TIMINGSAFE_MEMCMP) | ||
| 122 | if(HAVE_MEMCMP) | ||
| 123 | add_definitions(-DHAVE_MEMCMP) | ||
| 124 | endif() | ||
| 125 | |||
| 126 | add_subdirectory(crypto) | ||
| 127 | add_subdirectory(ssl) | ||
| 128 | add_subdirectory(apps) | ||
| 129 | add_subdirectory(tls) | ||
| 130 | add_subdirectory(tests) | ||
diff --git a/Makefile.am b/Makefile.am index 46b7644..0804984 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -5,3 +5,4 @@ pkgconfigdir = $(libdir)/pkgconfig | |||
| 5 | pkgconfig_DATA = libcrypto.pc libssl.pc libtls.pc openssl.pc | 5 | pkgconfig_DATA = libcrypto.pc libssl.pc libtls.pc openssl.pc |
| 6 | 6 | ||
| 7 | EXTRA_DIST = README.md README.windows VERSION config scripts | 7 | EXTRA_DIST = README.md README.windows VERSION config scripts |
| 8 | EXTRA_DIST += CMakeLists.txt | ||
diff --git a/Makefile.am.common b/Makefile.am.common index 7a25d09..b00473d 100644 --- a/Makefile.am.common +++ b/Makefile.am.common | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | AM_CFLAGS = -I$(top_srcdir)/include | 1 | AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat |
| 2 | AM_CPPFLAGS = -DLIBRESSL_INTERNAL | 2 | AM_CPPFLAGS = -DLIBRESSL_INTERNAL |
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt new file mode 100644 index 0000000..13d6e9c --- /dev/null +++ b/apps/CMakeLists.txt | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | include_directories( | ||
| 2 | . | ||
| 3 | ../include | ||
| 4 | ../include/compat | ||
| 5 | ) | ||
| 6 | |||
| 7 | set( | ||
| 8 | OPENSSL_SRC | ||
| 9 | apps.c | ||
| 10 | asn1pars.c | ||
| 11 | ca.c | ||
| 12 | ciphers.c | ||
| 13 | cms.c | ||
| 14 | crl.c | ||
| 15 | crl2p7.c | ||
| 16 | dgst.c | ||
| 17 | dh.c | ||
| 18 | dhparam.c | ||
| 19 | dsa.c | ||
| 20 | dsaparam.c | ||
| 21 | ec.c | ||
| 22 | ecparam.c | ||
| 23 | enc.c | ||
| 24 | engine.c | ||
| 25 | errstr.c | ||
| 26 | gendh.c | ||
| 27 | gendsa.c | ||
| 28 | genpkey.c | ||
| 29 | genrsa.c | ||
| 30 | nseq.c | ||
| 31 | ocsp.c | ||
| 32 | openssl.c | ||
| 33 | passwd.c | ||
| 34 | pkcs12.c | ||
| 35 | pkcs7.c | ||
| 36 | pkcs8.c | ||
| 37 | pkey.c | ||
| 38 | pkeyparam.c | ||
| 39 | pkeyutl.c | ||
| 40 | prime.c | ||
| 41 | rand.c | ||
| 42 | req.c | ||
| 43 | rsa.c | ||
| 44 | rsautl.c | ||
| 45 | s_cb.c | ||
| 46 | s_client.c | ||
| 47 | s_server.c | ||
| 48 | s_socket.c | ||
| 49 | s_time.c | ||
| 50 | sess_id.c | ||
| 51 | smime.c | ||
| 52 | speed.c | ||
| 53 | spkac.c | ||
| 54 | ts.c | ||
| 55 | verify.c | ||
| 56 | version.c | ||
| 57 | x509.c | ||
| 58 | ) | ||
| 59 | |||
| 60 | if(CMAKE_HOST_UNIX) | ||
| 61 | set(OPENSSL_SRC ${OPENSSL_SRC} apps_posix.c) | ||
| 62 | set(OPENSSL_SRC ${OPENSSL_SRC} certhash.c) | ||
| 63 | endif() | ||
| 64 | |||
| 65 | if(CMAKE_HOST_WIN32) | ||
| 66 | set(OPENSSL_SRC ${OPENSSL_SRC} apps_win.c) | ||
| 67 | set(OPENSSL_SRC ${OPENSSL_SRC} certhash_disabled.c) | ||
| 68 | set(OPENSSL_SRC ${OPENSSL_SRC} poll_win.c) | ||
| 69 | endif() | ||
| 70 | |||
| 71 | check_function_exists(strtonum HAVE_STRTONUM) | ||
| 72 | if(HAVE_STRTONUM) | ||
| 73 | add_definitions(-DHAVE_STRTONUM) | ||
| 74 | else() | ||
| 75 | set(OPENSSL_SRC ${OPENSSL_SRC} strtonum.c) | ||
| 76 | endif() | ||
| 77 | |||
| 78 | set(OPENSSL_LIBS ssl crypto) | ||
| 79 | if(CMAKE_HOST_WIN32) | ||
| 80 | set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32) | ||
| 81 | endif() | ||
| 82 | |||
| 83 | add_executable(openssl ${OPENSSL_SRC}) | ||
| 84 | target_link_libraries(openssl ${OPENSSL_LIBS}) | ||
diff --git a/apps/Makefile.am b/apps/Makefile.am index 0547876..ce78b33 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am | |||
| @@ -88,6 +88,7 @@ noinst_HEADERS += timeouts.h | |||
| 88 | EXTRA_DIST = cert.pem | 88 | EXTRA_DIST = cert.pem |
| 89 | EXTRA_DIST += openssl.cnf | 89 | EXTRA_DIST += openssl.cnf |
| 90 | EXTRA_DIST += x509v3.cnf | 90 | EXTRA_DIST += x509v3.cnf |
| 91 | EXTRA_DIST += CMakeLists.txt | ||
| 91 | 92 | ||
| 92 | install-exec-hook: | 93 | install-exec-hook: |
| 93 | @if [ "@OPENSSLDIR@x" != "x" ]; then \ | 94 | @if [ "@OPENSSLDIR@x" != "x" ]; then \ |
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt new file mode 100644 index 0000000..1a058c4 --- /dev/null +++ b/crypto/CMakeLists.txt | |||
| @@ -0,0 +1,624 @@ | |||
| 1 | include_directories( | ||
| 2 | . | ||
| 3 | ../include | ||
| 4 | ../include/compat | ||
| 5 | asn1 | ||
| 6 | dsa | ||
| 7 | evp | ||
| 8 | modes | ||
| 9 | ) | ||
| 10 | |||
| 11 | set( | ||
| 12 | CRYPTO_SRC | ||
| 13 | |||
| 14 | aes/aes_cbc.c | ||
| 15 | aes/aes_core.c | ||
| 16 | camellia/camellia.c | ||
| 17 | camellia/cmll_cbc.c | ||
| 18 | rc4/rc4_enc.c | ||
| 19 | rc4/rc4_skey.c | ||
| 20 | whrlpool/wp_block.c | ||
| 21 | cpt_err.c | ||
| 22 | cryptlib.c | ||
| 23 | cversion.c | ||
| 24 | ex_data.c | ||
| 25 | malloc-wrapper.c | ||
| 26 | mem_clr.c | ||
| 27 | mem_dbg.c | ||
| 28 | o_init.c | ||
| 29 | o_str.c | ||
| 30 | o_time.c | ||
| 31 | aes/aes_cfb.c | ||
| 32 | aes/aes_ctr.c | ||
| 33 | aes/aes_ecb.c | ||
| 34 | aes/aes_ige.c | ||
| 35 | aes/aes_misc.c | ||
| 36 | aes/aes_ofb.c | ||
| 37 | aes/aes_wrap.c | ||
| 38 | asn1/a_bitstr.c | ||
| 39 | asn1/a_bool.c | ||
| 40 | asn1/a_bytes.c | ||
| 41 | asn1/a_d2i_fp.c | ||
| 42 | asn1/a_digest.c | ||
| 43 | asn1/a_dup.c | ||
| 44 | asn1/a_enum.c | ||
| 45 | asn1/a_gentm.c | ||
| 46 | asn1/a_i2d_fp.c | ||
| 47 | asn1/a_int.c | ||
| 48 | asn1/a_mbstr.c | ||
| 49 | asn1/a_object.c | ||
| 50 | asn1/a_octet.c | ||
| 51 | asn1/a_print.c | ||
| 52 | asn1/a_set.c | ||
| 53 | asn1/a_sign.c | ||
| 54 | asn1/a_strex.c | ||
| 55 | asn1/a_strnid.c | ||
| 56 | asn1/a_time.c | ||
| 57 | asn1/a_type.c | ||
| 58 | asn1/a_utctm.c | ||
| 59 | asn1/a_utf8.c | ||
| 60 | asn1/a_verify.c | ||
| 61 | asn1/ameth_lib.c | ||
| 62 | asn1/asn1_err.c | ||
| 63 | asn1/asn1_gen.c | ||
| 64 | asn1/asn1_lib.c | ||
| 65 | asn1/asn1_par.c | ||
| 66 | asn1/asn_mime.c | ||
| 67 | asn1/asn_moid.c | ||
| 68 | asn1/asn_pack.c | ||
| 69 | asn1/bio_asn1.c | ||
| 70 | asn1/bio_ndef.c | ||
| 71 | asn1/d2i_pr.c | ||
| 72 | asn1/d2i_pu.c | ||
| 73 | asn1/evp_asn1.c | ||
| 74 | asn1/f_enum.c | ||
| 75 | asn1/f_int.c | ||
| 76 | asn1/f_string.c | ||
| 77 | asn1/i2d_pr.c | ||
| 78 | asn1/i2d_pu.c | ||
| 79 | asn1/n_pkey.c | ||
| 80 | asn1/nsseq.c | ||
| 81 | asn1/p5_pbe.c | ||
| 82 | asn1/p5_pbev2.c | ||
| 83 | asn1/p8_pkey.c | ||
| 84 | asn1/t_bitst.c | ||
| 85 | asn1/t_crl.c | ||
| 86 | asn1/t_pkey.c | ||
| 87 | asn1/t_req.c | ||
| 88 | asn1/t_spki.c | ||
| 89 | asn1/t_x509.c | ||
| 90 | asn1/t_x509a.c | ||
| 91 | asn1/tasn_dec.c | ||
| 92 | asn1/tasn_enc.c | ||
| 93 | asn1/tasn_fre.c | ||
| 94 | asn1/tasn_new.c | ||
| 95 | asn1/tasn_prn.c | ||
| 96 | asn1/tasn_typ.c | ||
| 97 | asn1/tasn_utl.c | ||
| 98 | asn1/x_algor.c | ||
| 99 | asn1/x_attrib.c | ||
| 100 | asn1/x_bignum.c | ||
| 101 | asn1/x_crl.c | ||
| 102 | asn1/x_exten.c | ||
| 103 | asn1/x_info.c | ||
| 104 | asn1/x_long.c | ||
| 105 | asn1/x_name.c | ||
| 106 | asn1/x_nx509.c | ||
| 107 | asn1/x_pkey.c | ||
| 108 | asn1/x_pubkey.c | ||
| 109 | asn1/x_req.c | ||
| 110 | asn1/x_sig.c | ||
| 111 | asn1/x_spki.c | ||
| 112 | asn1/x_val.c | ||
| 113 | asn1/x_x509.c | ||
| 114 | asn1/x_x509a.c | ||
| 115 | bf/bf_cfb64.c | ||
| 116 | bf/bf_ecb.c | ||
| 117 | bf/bf_enc.c | ||
| 118 | bf/bf_ofb64.c | ||
| 119 | bf/bf_skey.c | ||
| 120 | bio/b_dump.c | ||
| 121 | bio/b_print.c | ||
| 122 | bio/b_sock.c | ||
| 123 | bio/bf_buff.c | ||
| 124 | bio/bf_nbio.c | ||
| 125 | bio/bf_null.c | ||
| 126 | bio/bio_cb.c | ||
| 127 | bio/bio_err.c | ||
| 128 | bio/bio_lib.c | ||
| 129 | bio/bss_acpt.c | ||
| 130 | bio/bss_bio.c | ||
| 131 | bio/bss_conn.c | ||
| 132 | bio/bss_dgram.c | ||
| 133 | bio/bss_fd.c | ||
| 134 | bio/bss_file.c | ||
| 135 | bio/bss_mem.c | ||
| 136 | bio/bss_null.c | ||
| 137 | bio/bss_sock.c | ||
| 138 | bn/bn_add.c | ||
| 139 | bn/bn_asm.c | ||
| 140 | bn/bn_blind.c | ||
| 141 | bn/bn_const.c | ||
| 142 | bn/bn_ctx.c | ||
| 143 | bn/bn_depr.c | ||
| 144 | bn/bn_div.c | ||
| 145 | bn/bn_err.c | ||
| 146 | bn/bn_exp.c | ||
| 147 | bn/bn_exp2.c | ||
| 148 | bn/bn_gcd.c | ||
| 149 | bn/bn_gf2m.c | ||
| 150 | bn/bn_kron.c | ||
| 151 | bn/bn_lib.c | ||
| 152 | bn/bn_mod.c | ||
| 153 | bn/bn_mont.c | ||
| 154 | bn/bn_mpi.c | ||
| 155 | bn/bn_mul.c | ||
| 156 | bn/bn_nist.c | ||
| 157 | bn/bn_prime.c | ||
| 158 | bn/bn_print.c | ||
| 159 | bn/bn_rand.c | ||
| 160 | bn/bn_recp.c | ||
| 161 | bn/bn_shift.c | ||
| 162 | bn/bn_sqr.c | ||
| 163 | bn/bn_sqrt.c | ||
| 164 | bn/bn_word.c | ||
| 165 | bn/bn_x931p.c | ||
| 166 | buffer/buf_err.c | ||
| 167 | buffer/buf_str.c | ||
| 168 | buffer/buffer.c | ||
| 169 | camellia/cmll_cfb.c | ||
| 170 | camellia/cmll_ctr.c | ||
| 171 | camellia/cmll_ecb.c | ||
| 172 | camellia/cmll_misc.c | ||
| 173 | camellia/cmll_ofb.c | ||
| 174 | cast/c_cfb64.c | ||
| 175 | cast/c_ecb.c | ||
| 176 | cast/c_enc.c | ||
| 177 | cast/c_ofb64.c | ||
| 178 | cast/c_skey.c | ||
| 179 | chacha/chacha.c | ||
| 180 | cmac/cm_ameth.c | ||
| 181 | cmac/cm_pmeth.c | ||
| 182 | cmac/cmac.c | ||
| 183 | comp/c_rle.c | ||
| 184 | comp/c_zlib.c | ||
| 185 | comp/comp_err.c | ||
| 186 | comp/comp_lib.c | ||
| 187 | conf/conf_api.c | ||
| 188 | conf/conf_def.c | ||
| 189 | conf/conf_err.c | ||
| 190 | conf/conf_lib.c | ||
| 191 | conf/conf_mall.c | ||
| 192 | conf/conf_mod.c | ||
| 193 | conf/conf_sap.c | ||
| 194 | des/cbc_cksm.c | ||
| 195 | des/cbc_enc.c | ||
| 196 | des/cfb64ede.c | ||
| 197 | des/cfb64enc.c | ||
| 198 | des/cfb_enc.c | ||
| 199 | des/des_enc.c | ||
| 200 | des/ecb3_enc.c | ||
| 201 | des/ecb_enc.c | ||
| 202 | des/ede_cbcm_enc.c | ||
| 203 | des/enc_read.c | ||
| 204 | des/enc_writ.c | ||
| 205 | des/fcrypt.c | ||
| 206 | des/fcrypt_b.c | ||
| 207 | des/ofb64ede.c | ||
| 208 | des/ofb64enc.c | ||
| 209 | des/ofb_enc.c | ||
| 210 | des/pcbc_enc.c | ||
| 211 | des/qud_cksm.c | ||
| 212 | des/rand_key.c | ||
| 213 | des/set_key.c | ||
| 214 | des/str2key.c | ||
| 215 | des/xcbc_enc.c | ||
| 216 | dh/dh_ameth.c | ||
| 217 | dh/dh_asn1.c | ||
| 218 | dh/dh_check.c | ||
| 219 | dh/dh_depr.c | ||
| 220 | dh/dh_err.c | ||
| 221 | dh/dh_gen.c | ||
| 222 | dh/dh_key.c | ||
| 223 | dh/dh_lib.c | ||
| 224 | dh/dh_pmeth.c | ||
| 225 | dh/dh_prn.c | ||
| 226 | dsa/dsa_ameth.c | ||
| 227 | dsa/dsa_asn1.c | ||
| 228 | dsa/dsa_depr.c | ||
| 229 | dsa/dsa_err.c | ||
| 230 | dsa/dsa_gen.c | ||
| 231 | dsa/dsa_key.c | ||
| 232 | dsa/dsa_lib.c | ||
| 233 | dsa/dsa_ossl.c | ||
| 234 | dsa/dsa_pmeth.c | ||
| 235 | dsa/dsa_prn.c | ||
| 236 | dsa/dsa_sign.c | ||
| 237 | dsa/dsa_vrf.c | ||
| 238 | dso/dso_dlfcn.c | ||
| 239 | dso/dso_err.c | ||
| 240 | dso/dso_lib.c | ||
| 241 | dso/dso_null.c | ||
| 242 | dso/dso_openssl.c | ||
| 243 | ec/ec2_mult.c | ||
| 244 | ec/ec2_oct.c | ||
| 245 | ec/ec2_smpl.c | ||
| 246 | ec/ec_ameth.c | ||
| 247 | ec/ec_asn1.c | ||
| 248 | ec/ec_check.c | ||
| 249 | ec/ec_curve.c | ||
| 250 | ec/ec_cvt.c | ||
| 251 | ec/ec_err.c | ||
| 252 | ec/ec_key.c | ||
| 253 | ec/ec_lib.c | ||
| 254 | ec/ec_mult.c | ||
| 255 | ec/ec_oct.c | ||
| 256 | ec/ec_pmeth.c | ||
| 257 | ec/ec_print.c | ||
| 258 | ec/eck_prn.c | ||
| 259 | ec/ecp_mont.c | ||
| 260 | ec/ecp_nist.c | ||
| 261 | ec/ecp_oct.c | ||
| 262 | ec/ecp_smpl.c | ||
| 263 | ecdh/ech_err.c | ||
| 264 | ecdh/ech_key.c | ||
| 265 | ecdh/ech_lib.c | ||
| 266 | ecdh/ech_ossl.c | ||
| 267 | ecdsa/ecs_asn1.c | ||
| 268 | ecdsa/ecs_err.c | ||
| 269 | ecdsa/ecs_lib.c | ||
| 270 | ecdsa/ecs_ossl.c | ||
| 271 | ecdsa/ecs_sign.c | ||
| 272 | ecdsa/ecs_vrf.c | ||
| 273 | engine/eng_all.c | ||
| 274 | engine/eng_cnf.c | ||
| 275 | engine/eng_ctrl.c | ||
| 276 | engine/eng_dyn.c | ||
| 277 | engine/eng_err.c | ||
| 278 | engine/eng_fat.c | ||
| 279 | engine/eng_init.c | ||
| 280 | engine/eng_lib.c | ||
| 281 | engine/eng_list.c | ||
| 282 | engine/eng_openssl.c | ||
| 283 | engine/eng_pkey.c | ||
| 284 | engine/eng_rsax.c | ||
| 285 | engine/eng_table.c | ||
| 286 | engine/tb_asnmth.c | ||
| 287 | engine/tb_cipher.c | ||
| 288 | engine/tb_dh.c | ||
| 289 | engine/tb_digest.c | ||
| 290 | engine/tb_dsa.c | ||
| 291 | engine/tb_ecdh.c | ||
| 292 | engine/tb_ecdsa.c | ||
| 293 | engine/tb_pkmeth.c | ||
| 294 | engine/tb_rand.c | ||
| 295 | engine/tb_rsa.c | ||
| 296 | engine/tb_store.c | ||
| 297 | err/err.c | ||
| 298 | err/err_all.c | ||
| 299 | err/err_prn.c | ||
| 300 | evp/bio_b64.c | ||
| 301 | evp/bio_enc.c | ||
| 302 | evp/bio_md.c | ||
| 303 | evp/c_all.c | ||
| 304 | evp/digest.c | ||
| 305 | evp/e_aes.c | ||
| 306 | evp/e_aes_cbc_hmac_sha1.c | ||
| 307 | evp/e_bf.c | ||
| 308 | evp/e_camellia.c | ||
| 309 | evp/e_cast.c | ||
| 310 | evp/e_chacha.c | ||
| 311 | evp/e_chacha20poly1305.c | ||
| 312 | evp/e_des.c | ||
| 313 | evp/e_des3.c | ||
| 314 | evp/e_gost2814789.c | ||
| 315 | evp/e_idea.c | ||
| 316 | evp/e_null.c | ||
| 317 | evp/e_old.c | ||
| 318 | evp/e_rc2.c | ||
| 319 | evp/e_rc4.c | ||
| 320 | evp/e_rc4_hmac_md5.c | ||
| 321 | evp/e_xcbc_d.c | ||
| 322 | evp/encode.c | ||
| 323 | evp/evp_aead.c | ||
| 324 | evp/evp_enc.c | ||
| 325 | evp/evp_err.c | ||
| 326 | evp/evp_key.c | ||
| 327 | evp/evp_lib.c | ||
| 328 | evp/evp_pbe.c | ||
| 329 | evp/evp_pkey.c | ||
| 330 | evp/m_dss.c | ||
| 331 | evp/m_dss1.c | ||
| 332 | evp/m_ecdsa.c | ||
| 333 | evp/m_gost2814789.c | ||
| 334 | evp/m_gostr341194.c | ||
| 335 | evp/m_md4.c | ||
| 336 | evp/m_md5.c | ||
| 337 | evp/m_null.c | ||
| 338 | evp/m_ripemd.c | ||
| 339 | evp/m_sha.c | ||
| 340 | evp/m_sha1.c | ||
| 341 | evp/m_sigver.c | ||
| 342 | evp/m_streebog.c | ||
| 343 | evp/m_wp.c | ||
| 344 | evp/names.c | ||
| 345 | evp/p5_crpt.c | ||
| 346 | evp/p5_crpt2.c | ||
| 347 | evp/p_dec.c | ||
| 348 | evp/p_enc.c | ||
| 349 | evp/p_lib.c | ||
| 350 | evp/p_open.c | ||
| 351 | evp/p_seal.c | ||
| 352 | evp/p_sign.c | ||
| 353 | evp/p_verify.c | ||
| 354 | evp/pmeth_fn.c | ||
| 355 | evp/pmeth_gn.c | ||
| 356 | evp/pmeth_lib.c | ||
| 357 | gost/gost2814789.c | ||
| 358 | gost/gost89_keywrap.c | ||
| 359 | gost/gost89_params.c | ||
| 360 | gost/gost89imit_ameth.c | ||
| 361 | gost/gost89imit_pmeth.c | ||
| 362 | gost/gost_asn1.c | ||
| 363 | gost/gost_err.c | ||
| 364 | gost/gostr341001.c | ||
| 365 | gost/gostr341001_ameth.c | ||
| 366 | gost/gostr341001_key.c | ||
| 367 | gost/gostr341001_params.c | ||
| 368 | gost/gostr341001_pmeth.c | ||
| 369 | gost/gostr341194.c | ||
| 370 | gost/streebog.c | ||
| 371 | hmac/hm_ameth.c | ||
| 372 | hmac/hm_pmeth.c | ||
| 373 | hmac/hmac.c | ||
| 374 | idea/i_cbc.c | ||
| 375 | idea/i_cfb64.c | ||
| 376 | idea/i_ecb.c | ||
| 377 | idea/i_ofb64.c | ||
| 378 | idea/i_skey.c | ||
| 379 | krb5/krb5_asn.c | ||
| 380 | lhash/lh_stats.c | ||
| 381 | lhash/lhash.c | ||
| 382 | md4/md4_dgst.c | ||
| 383 | md4/md4_one.c | ||
| 384 | md5/md5_dgst.c | ||
| 385 | md5/md5_one.c | ||
| 386 | modes/cbc128.c | ||
| 387 | modes/ccm128.c | ||
| 388 | modes/cfb128.c | ||
| 389 | modes/ctr128.c | ||
| 390 | modes/cts128.c | ||
| 391 | modes/gcm128.c | ||
| 392 | modes/ofb128.c | ||
| 393 | modes/xts128.c | ||
| 394 | objects/o_names.c | ||
| 395 | objects/obj_dat.c | ||
| 396 | objects/obj_err.c | ||
| 397 | objects/obj_lib.c | ||
| 398 | objects/obj_xref.c | ||
| 399 | ocsp/ocsp_asn.c | ||
| 400 | ocsp/ocsp_cl.c | ||
| 401 | ocsp/ocsp_err.c | ||
| 402 | ocsp/ocsp_ext.c | ||
| 403 | ocsp/ocsp_ht.c | ||
| 404 | ocsp/ocsp_lib.c | ||
| 405 | ocsp/ocsp_prn.c | ||
| 406 | ocsp/ocsp_srv.c | ||
| 407 | ocsp/ocsp_vfy.c | ||
| 408 | pem/pem_all.c | ||
| 409 | pem/pem_err.c | ||
| 410 | pem/pem_info.c | ||
| 411 | pem/pem_lib.c | ||
| 412 | pem/pem_oth.c | ||
| 413 | pem/pem_pk8.c | ||
| 414 | pem/pem_pkey.c | ||
| 415 | pem/pem_seal.c | ||
| 416 | pem/pem_sign.c | ||
| 417 | pem/pem_x509.c | ||
| 418 | pem/pem_xaux.c | ||
| 419 | pem/pvkfmt.c | ||
| 420 | pkcs12/p12_add.c | ||
| 421 | pkcs12/p12_asn.c | ||
| 422 | pkcs12/p12_attr.c | ||
| 423 | pkcs12/p12_crpt.c | ||
| 424 | pkcs12/p12_crt.c | ||
| 425 | pkcs12/p12_decr.c | ||
| 426 | pkcs12/p12_init.c | ||
| 427 | pkcs12/p12_key.c | ||
| 428 | pkcs12/p12_kiss.c | ||
| 429 | pkcs12/p12_mutl.c | ||
| 430 | pkcs12/p12_npas.c | ||
| 431 | pkcs12/p12_p8d.c | ||
| 432 | pkcs12/p12_p8e.c | ||
| 433 | pkcs12/p12_utl.c | ||
| 434 | pkcs12/pk12err.c | ||
| 435 | pkcs7/bio_pk7.c | ||
| 436 | pkcs7/pk7_asn1.c | ||
| 437 | pkcs7/pk7_attr.c | ||
| 438 | pkcs7/pk7_doit.c | ||
| 439 | pkcs7/pk7_lib.c | ||
| 440 | pkcs7/pk7_mime.c | ||
| 441 | pkcs7/pk7_smime.c | ||
| 442 | pkcs7/pkcs7err.c | ||
| 443 | poly1305/poly1305.c | ||
| 444 | rand/rand_err.c | ||
| 445 | rand/rand_lib.c | ||
| 446 | rand/randfile.c | ||
| 447 | rc2/rc2_cbc.c | ||
| 448 | rc2/rc2_ecb.c | ||
| 449 | rc2/rc2_skey.c | ||
| 450 | rc2/rc2cfb64.c | ||
| 451 | rc2/rc2ofb64.c | ||
| 452 | ripemd/rmd_dgst.c | ||
| 453 | ripemd/rmd_one.c | ||
| 454 | rsa/rsa_ameth.c | ||
| 455 | rsa/rsa_asn1.c | ||
| 456 | rsa/rsa_chk.c | ||
| 457 | rsa/rsa_crpt.c | ||
| 458 | rsa/rsa_depr.c | ||
| 459 | rsa/rsa_eay.c | ||
| 460 | rsa/rsa_err.c | ||
| 461 | rsa/rsa_gen.c | ||
| 462 | rsa/rsa_lib.c | ||
| 463 | rsa/rsa_none.c | ||
| 464 | rsa/rsa_oaep.c | ||
| 465 | rsa/rsa_pk1.c | ||
| 466 | rsa/rsa_pmeth.c | ||
| 467 | rsa/rsa_prn.c | ||
| 468 | rsa/rsa_pss.c | ||
| 469 | rsa/rsa_saos.c | ||
| 470 | rsa/rsa_sign.c | ||
| 471 | rsa/rsa_ssl.c | ||
| 472 | rsa/rsa_x931.c | ||
| 473 | sha/sha1_one.c | ||
| 474 | sha/sha1dgst.c | ||
| 475 | sha/sha256.c | ||
| 476 | sha/sha512.c | ||
| 477 | sha/sha_dgst.c | ||
| 478 | sha/sha_one.c | ||
| 479 | stack/stack.c | ||
| 480 | ts/ts_asn1.c | ||
| 481 | ts/ts_conf.c | ||
| 482 | ts/ts_err.c | ||
| 483 | ts/ts_lib.c | ||
| 484 | ts/ts_req_print.c | ||
| 485 | ts/ts_req_utils.c | ||
| 486 | ts/ts_rsp_print.c | ||
| 487 | ts/ts_rsp_sign.c | ||
| 488 | ts/ts_rsp_utils.c | ||
| 489 | ts/ts_rsp_verify.c | ||
| 490 | ts/ts_verify_ctx.c | ||
| 491 | txt_db/txt_db.c | ||
| 492 | ui/ui_err.c | ||
| 493 | ui/ui_lib.c | ||
| 494 | ui/ui_util.c | ||
| 495 | whrlpool/wp_dgst.c | ||
| 496 | x509/by_dir.c | ||
| 497 | x509/by_file.c | ||
| 498 | x509/by_mem.c | ||
| 499 | x509/x509_att.c | ||
| 500 | x509/x509_cmp.c | ||
| 501 | x509/x509_d2.c | ||
| 502 | x509/x509_def.c | ||
| 503 | x509/x509_err.c | ||
| 504 | x509/x509_ext.c | ||
| 505 | x509/x509_lu.c | ||
| 506 | x509/x509_obj.c | ||
| 507 | x509/x509_r2x.c | ||
| 508 | x509/x509_req.c | ||
| 509 | x509/x509_set.c | ||
| 510 | x509/x509_trs.c | ||
| 511 | x509/x509_txt.c | ||
| 512 | x509/x509_v3.c | ||
| 513 | x509/x509_vfy.c | ||
| 514 | x509/x509_vpm.c | ||
| 515 | x509/x509cset.c | ||
| 516 | x509/x509name.c | ||
| 517 | x509/x509rset.c | ||
| 518 | x509/x509spki.c | ||
| 519 | x509/x509type.c | ||
| 520 | x509/x_all.c | ||
| 521 | x509v3/pcy_cache.c | ||
| 522 | x509v3/pcy_data.c | ||
| 523 | x509v3/pcy_lib.c | ||
| 524 | x509v3/pcy_map.c | ||
| 525 | x509v3/pcy_node.c | ||
| 526 | x509v3/pcy_tree.c | ||
| 527 | x509v3/v3_akey.c | ||
| 528 | x509v3/v3_akeya.c | ||
| 529 | x509v3/v3_alt.c | ||
| 530 | x509v3/v3_bcons.c | ||
| 531 | x509v3/v3_bitst.c | ||
| 532 | x509v3/v3_conf.c | ||
| 533 | x509v3/v3_cpols.c | ||
| 534 | x509v3/v3_crld.c | ||
| 535 | x509v3/v3_enum.c | ||
| 536 | x509v3/v3_extku.c | ||
| 537 | x509v3/v3_genn.c | ||
| 538 | x509v3/v3_ia5.c | ||
| 539 | x509v3/v3_info.c | ||
| 540 | x509v3/v3_int.c | ||
| 541 | x509v3/v3_lib.c | ||
| 542 | x509v3/v3_ncons.c | ||
| 543 | x509v3/v3_ocsp.c | ||
| 544 | x509v3/v3_pci.c | ||
| 545 | x509v3/v3_pcia.c | ||
| 546 | x509v3/v3_pcons.c | ||
| 547 | x509v3/v3_pku.c | ||
| 548 | x509v3/v3_pmaps.c | ||
| 549 | x509v3/v3_prn.c | ||
| 550 | x509v3/v3_purp.c | ||
| 551 | x509v3/v3_skey.c | ||
| 552 | x509v3/v3_sxnet.c | ||
| 553 | x509v3/v3_utl.c | ||
| 554 | x509v3/v3err.c | ||
| 555 | ) | ||
| 556 | |||
| 557 | if(CMAKE_HOST_UNIX) | ||
| 558 | set(CRYPTO_SRC ${CRYPTO_SRC} bio/b_posix.c) | ||
| 559 | set(CRYPTO_SRC ${CRYPTO_SRC} bio/bss_log.c) | ||
| 560 | set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl.c) | ||
| 561 | endif() | ||
| 562 | |||
| 563 | if(CMAKE_HOST_WIN32) | ||
| 564 | set(CRYPTO_SRC ${CRYPTO_SRC} bio/b_win.c) | ||
| 565 | set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl_win.c) | ||
| 566 | endif() | ||
| 567 | |||
| 568 | if(CMAKE_HOST_WIN32) | ||
| 569 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/posix_win.c) | ||
| 570 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/arc4random.c) | ||
| 571 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/getentropy_win.c) | ||
| 572 | endif() | ||
| 573 | |||
| 574 | if(NOT HAVE_ASPRINTF) | ||
| 575 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/bsd-asprintf.c) | ||
| 576 | endif() | ||
| 577 | |||
| 578 | if(NOT HAVE_INET_PTON) | ||
| 579 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/inet_pton.c) | ||
| 580 | endif() | ||
| 581 | |||
| 582 | if(NOT HAVE_REALLOCARRAY) | ||
| 583 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/reallocarray.c) | ||
| 584 | endif() | ||
| 585 | |||
| 586 | if(NOT HAVE_STRCASECMP) | ||
| 587 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strcasecmp.c) | ||
| 588 | endif() | ||
| 589 | |||
| 590 | if(NOT HAVE_STRLCAT) | ||
| 591 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strlcat.c) | ||
| 592 | endif() | ||
| 593 | |||
| 594 | if(NOT HAVE_STRLCPY) | ||
| 595 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strlcpy.c) | ||
| 596 | endif() | ||
| 597 | |||
| 598 | if(NOT HAVE_STRNDUP) | ||
| 599 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strndup.c) | ||
| 600 | if(NOT HAVE_STRNLEN) | ||
| 601 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/strnlen.c) | ||
| 602 | endif() | ||
| 603 | endif() | ||
| 604 | |||
| 605 | if(NOT HAVE_EXPLICIT_BZERO) | ||
| 606 | if(CMAKE_HOST_WIN32) | ||
| 607 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/explicit_bzero_win.c) | ||
| 608 | else() | ||
| 609 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/explicit_bzero.c) | ||
| 610 | endif() | ||
| 611 | endif() | ||
| 612 | |||
| 613 | if(NOT HAVE_GETENTROPY) | ||
| 614 | endif() | ||
| 615 | |||
| 616 | if(NOT HAVE_TIMINGSAFE_BCMP) | ||
| 617 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/timingsafe_bcmp.c) | ||
| 618 | endif() | ||
| 619 | |||
| 620 | if(NOT HAVE_TIMINGSAFE_MEMCMP) | ||
| 621 | set(CRYPTO_SRC ${CRYPTO_SRC} compat/timingsafe_memcmp.c) | ||
| 622 | endif() | ||
| 623 | |||
| 624 | add_library(crypto ${CRYPTO_SRC}) | ||
diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 1799969..b988d77 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am | |||
| @@ -7,6 +7,7 @@ AM_CFLAGS += -I$(top_srcdir)/crypto/modes | |||
| 7 | lib_LTLIBRARIES = libcrypto.la | 7 | lib_LTLIBRARIES = libcrypto.la |
| 8 | 8 | ||
| 9 | EXTRA_DIST = VERSION | 9 | EXTRA_DIST = VERSION |
| 10 | EXTRA_DIST += CMakeLists.txt | ||
| 10 | 11 | ||
| 11 | libcrypto_la_LDFLAGS = -version-info @LIBCRYPTO_VERSION@ -no-undefined | 12 | libcrypto_la_LDFLAGS = -version-info @LIBCRYPTO_VERSION@ -no-undefined |
| 12 | libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la | 13 | libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la |
| @@ -236,7 +237,9 @@ libcrypto_la_SOURCES += bio/bss_conn.c | |||
| 236 | libcrypto_la_SOURCES += bio/bss_dgram.c | 237 | libcrypto_la_SOURCES += bio/bss_dgram.c |
| 237 | libcrypto_la_SOURCES += bio/bss_fd.c | 238 | libcrypto_la_SOURCES += bio/bss_fd.c |
| 238 | libcrypto_la_SOURCES += bio/bss_file.c | 239 | libcrypto_la_SOURCES += bio/bss_file.c |
| 240 | if !HOST_WIN | ||
| 239 | libcrypto_la_SOURCES += bio/bss_log.c | 241 | libcrypto_la_SOURCES += bio/bss_log.c |
| 242 | endif | ||
| 240 | libcrypto_la_SOURCES += bio/bss_mem.c | 243 | libcrypto_la_SOURCES += bio/bss_mem.c |
| 241 | libcrypto_la_SOURCES += bio/bss_null.c | 244 | libcrypto_la_SOURCES += bio/bss_null.c |
| 242 | libcrypto_la_SOURCES += bio/bss_sock.c | 245 | libcrypto_la_SOURCES += bio/bss_sock.c |
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 855406b..f8a46ab 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
| @@ -166,3 +166,27 @@ posix_setsockopt(int sockfd, int level, int optname, | |||
| 166 | int rc = setsockopt(sockfd, level, optname, (char *)optval, optlen); | 166 | int rc = setsockopt(sockfd, level, optname, (char *)optval, optlen); |
| 167 | return rc == 0 ? 0 : wsa_errno(WSAGetLastError()); | 167 | return rc == 0 ? 0 : wsa_errno(WSAGetLastError()); |
| 168 | } | 168 | } |
| 169 | |||
| 170 | #ifdef _MSC_VER | ||
| 171 | int gettimeofday(struct timeval * tp, struct timezone * tzp) | ||
| 172 | { | ||
| 173 | /* | ||
| 174 | * Note: some broken versions only have 8 trailing zero's, the correct | ||
| 175 | * epoch has 9 trailing zero's | ||
| 176 | */ | ||
| 177 | static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); | ||
| 178 | |||
| 179 | SYSTEMTIME system_time; | ||
| 180 | FILETIME file_time; | ||
| 181 | uint64_t time; | ||
| 182 | |||
| 183 | GetSystemTime(&system_time); | ||
| 184 | SystemTimeToFileTime(&system_time, &file_time); | ||
| 185 | time = ((uint64_t)file_time.dwLowDateTime); | ||
| 186 | time += ((uint64_t)file_time.dwHighDateTime) << 32; | ||
| 187 | |||
| 188 | tp->tv_sec = (long)((time - EPOCH) / 10000000L); | ||
| 189 | tp->tv_usec = (long)(system_time.wMilliseconds * 1000); | ||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | #endif | ||
diff --git a/include/Makefile.am b/include/Makefile.am index 92ee9e7..c24d1ae 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
| @@ -2,32 +2,36 @@ include $(top_srcdir)/Makefile.am.common | |||
| 2 | 2 | ||
| 3 | SUBDIRS = openssl | 3 | SUBDIRS = openssl |
| 4 | 4 | ||
| 5 | noinst_HEADERS = err.h | 5 | noinst_HEADERS = pqueue.h |
| 6 | noinst_HEADERS += netdb.h | 6 | noinst_HEADERS += compat/dirent.h |
| 7 | noinst_HEADERS += poll.h | 7 | noinst_HEADERS += compat/dirent_msvc.h |
| 8 | noinst_HEADERS += pqueue.h | 8 | noinst_HEADERS += compat/err.h |
| 9 | noinst_HEADERS += stdio.h | 9 | noinst_HEADERS += compat/netdb.h |
| 10 | noinst_HEADERS += stdlib.h | 10 | noinst_HEADERS += compat/poll.h |
| 11 | noinst_HEADERS += string.h | 11 | noinst_HEADERS += compat/stdio.h |
| 12 | noinst_HEADERS += syslog.h | 12 | noinst_HEADERS += compat/stdlib.h |
| 13 | noinst_HEADERS += unistd.h | 13 | noinst_HEADERS += compat/string.h |
| 14 | noinst_HEADERS += win32netcompat.h | 14 | noinst_HEADERS += compat/time.h |
| 15 | noinst_HEADERS += compat/unistd.h | ||
| 16 | noinst_HEADERS += compat/win32netcompat.h | ||
| 15 | 17 | ||
| 16 | noinst_HEADERS += arpa/inet.h | 18 | noinst_HEADERS += compat/arpa/inet.h |
| 17 | noinst_HEADERS += arpa/nameser.h | 19 | noinst_HEADERS += compat/arpa/nameser.h |
| 18 | 20 | ||
| 19 | noinst_HEADERS += machine/endian.h | 21 | noinst_HEADERS += compat/machine/endian.h |
| 20 | 22 | ||
| 21 | noinst_HEADERS += netinet/in.h | 23 | noinst_HEADERS += compat/netinet/in.h |
| 22 | noinst_HEADERS += netinet/tcp.h | 24 | noinst_HEADERS += compat/netinet/tcp.h |
| 23 | 25 | ||
| 24 | noinst_HEADERS += sys/cdefs.h | 26 | noinst_HEADERS += compat/sys/cdefs.h |
| 25 | noinst_HEADERS += sys/ioctl.h | 27 | noinst_HEADERS += compat/sys/ioctl.h |
| 26 | noinst_HEADERS += sys/mman.h | 28 | noinst_HEADERS += compat/sys/mman.h |
| 27 | noinst_HEADERS += sys/select.h | 29 | noinst_HEADERS += compat/sys/param.h |
| 28 | noinst_HEADERS += sys/socket.h | 30 | noinst_HEADERS += compat/sys/select.h |
| 29 | noinst_HEADERS += sys/times.h | 31 | noinst_HEADERS += compat/sys/stat.h |
| 30 | noinst_HEADERS += sys/types.h | 32 | noinst_HEADERS += compat/sys/socket.h |
| 31 | noinst_HEADERS += sys/uio.h | 33 | noinst_HEADERS += compat/sys/time.h |
| 34 | noinst_HEADERS += compat/sys/types.h | ||
| 35 | noinst_HEADERS += compat/sys/uio.h | ||
| 32 | 36 | ||
| 33 | include_HEADERS = tls.h | 37 | include_HEADERS = tls.h |
diff --git a/include/arpa/inet.h b/include/compat/arpa/inet.h index 67740c6..0cea8c4 100644 --- a/include/arpa/inet.h +++ b/include/compat/arpa/inet.h | |||
| @@ -15,5 +15,5 @@ | |||
| 15 | #endif | 15 | #endif |
| 16 | 16 | ||
| 17 | #ifndef HAVE_INET_PTON | 17 | #ifndef HAVE_INET_PTON |
| 18 | int inet_pton(int af, const char * restrict src, void * restrict dst); | 18 | int inet_pton(int af, const char * src, void * dst); |
| 19 | #endif | 19 | #endif |
diff --git a/include/arpa/nameser.h b/include/compat/arpa/nameser.h index 0126a60..0126a60 100644 --- a/include/arpa/nameser.h +++ b/include/compat/arpa/nameser.h | |||
diff --git a/include/compat/dirent.h b/include/compat/dirent.h new file mode 100644 index 0000000..753e4a0 --- /dev/null +++ b/include/compat/dirent.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * dirent.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_DIRENT_H | ||
| 7 | #define LIBCRYPTOCOMPAT_DIRENT_H | ||
| 8 | |||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <windows.h> | ||
| 11 | #include <dirent_msvc.h> | ||
| 12 | #else | ||
| 13 | #include_next <dirent.h> | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #endif | ||
| 17 | |||
diff --git a/include/compat/dirent_msvc.h b/include/compat/dirent_msvc.h new file mode 100644 index 0000000..bf9cf1a --- /dev/null +++ b/include/compat/dirent_msvc.h | |||
| @@ -0,0 +1,748 @@ | |||
| 1 | /* | ||
| 2 | * dirent.h - dirent API for Microsoft Visual Studio | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006-2012 Toni Ronkko | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining | ||
| 7 | * a copy of this software and associated documentation files (the | ||
| 8 | * ``Software''), to deal in the Software without restriction, including | ||
| 9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to | ||
| 11 | * permit persons to whom the Software is furnished to do so, subject to | ||
| 12 | * the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice shall be included | ||
| 15 | * in all copies or substantial portions of the Software. | ||
| 16 | * | ||
| 17 | * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| 20 | * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
| 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
| 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 23 | * OTHER DEALINGS IN THE SOFTWARE. | ||
| 24 | * | ||
| 25 | * $Id: dirent.h,v 1.20 2014/03/19 17:52:23 tronkko Exp $ | ||
| 26 | */ | ||
| 27 | #ifndef DIRENT_MSVC_H | ||
| 28 | #define DIRENT_MSVC_H | ||
| 29 | |||
| 30 | #include <windows.h> | ||
| 31 | |||
| 32 | #include <../include/stdio.h> | ||
| 33 | #include <../include/stdarg.h> | ||
| 34 | #include <../include/wchar.h> | ||
| 35 | #include <../include/string.h> | ||
| 36 | #include <../include/stdlib.h> | ||
| 37 | #include <../include/malloc.h> | ||
| 38 | #include <../include/sys/types.h> | ||
| 39 | #include <sys/stat.h> | ||
| 40 | #include <../include/errno.h> | ||
| 41 | |||
| 42 | /* Indicates that d_type field is available in dirent structure */ | ||
| 43 | #define _DIRENT_HAVE_D_TYPE | ||
| 44 | |||
| 45 | /* Indicates that d_namlen field is available in dirent structure */ | ||
| 46 | #define _DIRENT_HAVE_D_NAMLEN | ||
| 47 | |||
| 48 | /* Entries missing from MSVC 6.0 */ | ||
| 49 | #if !defined(FILE_ATTRIBUTE_DEVICE) | ||
| 50 | # define FILE_ATTRIBUTE_DEVICE 0x40 | ||
| 51 | #endif | ||
| 52 | |||
| 53 | /* Maximum length of file name */ | ||
| 54 | #if !defined(PATH_MAX) | ||
| 55 | # define PATH_MAX MAX_PATH | ||
| 56 | #endif | ||
| 57 | #if !defined(FILENAME_MAX) | ||
| 58 | # define FILENAME_MAX MAX_PATH | ||
| 59 | #endif | ||
| 60 | #if !defined(NAME_MAX) | ||
| 61 | # define NAME_MAX FILENAME_MAX | ||
| 62 | #endif | ||
| 63 | |||
| 64 | /* Return the exact length of d_namlen without zero terminator */ | ||
| 65 | #define _D_EXACT_NAMLEN(p) ((p)->d_namlen) | ||
| 66 | |||
| 67 | /* Return number of bytes needed to store d_namlen */ | ||
| 68 | #define _D_ALLOC_NAMLEN(p) (PATH_MAX) | ||
| 69 | |||
| 70 | |||
| 71 | #ifdef __cplusplus | ||
| 72 | extern "C" { | ||
| 73 | #endif | ||
| 74 | |||
| 75 | |||
| 76 | /* Wide-character version */ | ||
| 77 | struct _wdirent { | ||
| 78 | long d_ino; /* Always zero */ | ||
| 79 | unsigned short d_reclen; /* Structure size */ | ||
| 80 | size_t d_namlen; /* Length of name without \0 */ | ||
| 81 | int d_type; /* File type */ | ||
| 82 | wchar_t d_name[PATH_MAX]; /* File name */ | ||
| 83 | }; | ||
| 84 | typedef struct _wdirent _wdirent; | ||
| 85 | |||
| 86 | struct _WDIR { | ||
| 87 | struct _wdirent ent; /* Current directory entry */ | ||
| 88 | WIN32_FIND_DATAW data; /* Private file data */ | ||
| 89 | int cached; /* True if data is valid */ | ||
| 90 | HANDLE handle; /* Win32 search handle */ | ||
| 91 | wchar_t *patt; /* Initial directory name */ | ||
| 92 | }; | ||
| 93 | typedef struct _WDIR _WDIR; | ||
| 94 | |||
| 95 | static _WDIR *_wopendir (const wchar_t *dirname); | ||
| 96 | static struct _wdirent *_wreaddir (_WDIR *dirp); | ||
| 97 | static int _wclosedir (_WDIR *dirp); | ||
| 98 | static void _wrewinddir (_WDIR* dirp); | ||
| 99 | |||
| 100 | |||
| 101 | /* For compatibility with Symbian */ | ||
| 102 | #define wdirent _wdirent | ||
| 103 | #define WDIR _WDIR | ||
| 104 | #define wopendir _wopendir | ||
| 105 | #define wreaddir _wreaddir | ||
| 106 | #define wclosedir _wclosedir | ||
| 107 | #define wrewinddir _wrewinddir | ||
| 108 | |||
| 109 | |||
| 110 | /* Multi-byte character versions */ | ||
| 111 | struct dirent { | ||
| 112 | long d_ino; /* Always zero */ | ||
| 113 | unsigned short d_reclen; /* Structure size */ | ||
| 114 | size_t d_namlen; /* Length of name without \0 */ | ||
| 115 | int d_type; /* File type */ | ||
| 116 | char d_name[PATH_MAX]; /* File name */ | ||
| 117 | }; | ||
| 118 | typedef struct dirent dirent; | ||
| 119 | |||
| 120 | struct DIR { | ||
| 121 | struct dirent ent; | ||
| 122 | struct _WDIR *wdirp; | ||
| 123 | }; | ||
| 124 | typedef struct DIR DIR; | ||
| 125 | |||
| 126 | static DIR *opendir (const char *dirname); | ||
| 127 | static struct dirent *readdir (DIR *dirp); | ||
| 128 | static int closedir (DIR *dirp); | ||
| 129 | static void rewinddir (DIR* dirp); | ||
| 130 | |||
| 131 | |||
| 132 | /* Internal utility functions */ | ||
| 133 | static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp); | ||
| 134 | static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp); | ||
| 135 | |||
| 136 | static int dirent_mbstowcs_s( | ||
| 137 | size_t *pReturnValue, | ||
| 138 | wchar_t *wcstr, | ||
| 139 | size_t sizeInWords, | ||
| 140 | const char *mbstr, | ||
| 141 | size_t count); | ||
| 142 | |||
| 143 | static int dirent_wcstombs_s( | ||
| 144 | size_t *pReturnValue, | ||
| 145 | char *mbstr, | ||
| 146 | size_t sizeInBytes, | ||
| 147 | const wchar_t *wcstr, | ||
| 148 | size_t count); | ||
| 149 | |||
| 150 | static void dirent_set_errno (int error); | ||
| 151 | |||
| 152 | /* | ||
| 153 | * Open directory stream DIRNAME for read and return a pointer to the | ||
| 154 | * internal working area that is used to retrieve individual directory | ||
| 155 | * entries. | ||
| 156 | */ | ||
| 157 | static _WDIR* | ||
| 158 | _wopendir( | ||
| 159 | const wchar_t *dirname) | ||
| 160 | { | ||
| 161 | _WDIR *dirp = NULL; | ||
| 162 | int error; | ||
| 163 | |||
| 164 | /* Must have directory name */ | ||
| 165 | if (dirname == NULL || dirname[0] == '\0') { | ||
| 166 | dirent_set_errno (ENOENT); | ||
| 167 | return NULL; | ||
| 168 | } | ||
| 169 | |||
| 170 | /* Allocate new _WDIR structure */ | ||
| 171 | dirp = (_WDIR*) malloc (sizeof (struct _WDIR)); | ||
| 172 | if (dirp != NULL) { | ||
| 173 | DWORD n; | ||
| 174 | |||
| 175 | /* Reset _WDIR structure */ | ||
| 176 | dirp->handle = INVALID_HANDLE_VALUE; | ||
| 177 | dirp->patt = NULL; | ||
| 178 | dirp->cached = 0; | ||
| 179 | |||
| 180 | /* Compute the length of full path plus zero terminator */ | ||
| 181 | n = GetFullPathNameW (dirname, 0, NULL, NULL); | ||
| 182 | |||
| 183 | /* Allocate room for absolute directory name and search pattern */ | ||
| 184 | dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16); | ||
| 185 | if (dirp->patt) { | ||
| 186 | |||
| 187 | /* | ||
| 188 | * Convert relative directory name to an absolute one. This | ||
| 189 | * allows rewinddir() to function correctly even when current | ||
| 190 | * working directory is changed between opendir() and rewinddir(). | ||
| 191 | */ | ||
| 192 | n = GetFullPathNameW (dirname, n, dirp->patt, NULL); | ||
| 193 | if (n > 0) { | ||
| 194 | wchar_t *p; | ||
| 195 | |||
| 196 | /* Append search pattern \* to the directory name */ | ||
| 197 | p = dirp->patt + n; | ||
| 198 | if (dirp->patt < p) { | ||
| 199 | switch (p[-1]) { | ||
| 200 | case '\\': | ||
| 201 | case '/': | ||
| 202 | case ':': | ||
| 203 | /* Directory ends in path separator, e.g. c:\temp\ */ | ||
| 204 | /*NOP*/; | ||
| 205 | break; | ||
| 206 | |||
| 207 | default: | ||
| 208 | /* Directory name doesn't end in path separator */ | ||
| 209 | *p++ = '\\'; | ||
| 210 | } | ||
| 211 | } | ||
| 212 | *p++ = '*'; | ||
| 213 | *p = '\0'; | ||
| 214 | |||
| 215 | /* Open directory stream and retrieve the first entry */ | ||
| 216 | if (dirent_first (dirp)) { | ||
| 217 | /* Directory stream opened successfully */ | ||
| 218 | error = 0; | ||
| 219 | } else { | ||
| 220 | /* Cannot retrieve first entry */ | ||
| 221 | error = 1; | ||
| 222 | dirent_set_errno (ENOENT); | ||
| 223 | } | ||
| 224 | |||
| 225 | } else { | ||
| 226 | /* Cannot retrieve full path name */ | ||
| 227 | dirent_set_errno (ENOENT); | ||
| 228 | error = 1; | ||
| 229 | } | ||
| 230 | |||
| 231 | } else { | ||
| 232 | /* Cannot allocate memory for search pattern */ | ||
| 233 | error = 1; | ||
| 234 | } | ||
| 235 | |||
| 236 | } else { | ||
| 237 | /* Cannot allocate _WDIR structure */ | ||
| 238 | error = 1; | ||
| 239 | } | ||
| 240 | |||
| 241 | /* Clean up in case of error */ | ||
| 242 | if (error && dirp) { | ||
| 243 | _wclosedir (dirp); | ||
| 244 | dirp = NULL; | ||
| 245 | } | ||
| 246 | |||
| 247 | return dirp; | ||
| 248 | } | ||
| 249 | |||
| 250 | /* | ||
| 251 | * Read next directory entry. The directory entry is returned in dirent | ||
| 252 | * structure in the d_name field. Individual directory entries returned by | ||
| 253 | * this function include regular files, sub-directories, pseudo-directories | ||
| 254 | * "." and ".." as well as volume labels, hidden files and system files. | ||
| 255 | */ | ||
| 256 | static struct _wdirent* | ||
| 257 | _wreaddir( | ||
| 258 | _WDIR *dirp) | ||
| 259 | { | ||
| 260 | WIN32_FIND_DATAW *datap; | ||
| 261 | struct _wdirent *entp; | ||
| 262 | |||
| 263 | /* Read next directory entry */ | ||
| 264 | datap = dirent_next (dirp); | ||
| 265 | if (datap) { | ||
| 266 | size_t n; | ||
| 267 | DWORD attr; | ||
| 268 | |||
| 269 | /* Pointer to directory entry to return */ | ||
| 270 | entp = &dirp->ent; | ||
| 271 | |||
| 272 | /* | ||
| 273 | * Copy file name as wide-character string. If the file name is too | ||
| 274 | * long to fit in to the destination buffer, then truncate file name | ||
| 275 | * to PATH_MAX characters and zero-terminate the buffer. | ||
| 276 | */ | ||
| 277 | n = 0; | ||
| 278 | while (n + 1 < PATH_MAX && datap->cFileName[n] != 0) { | ||
| 279 | entp->d_name[n] = datap->cFileName[n]; | ||
| 280 | n++; | ||
| 281 | } | ||
| 282 | dirp->ent.d_name[n] = 0; | ||
| 283 | |||
| 284 | /* Length of file name excluding zero terminator */ | ||
| 285 | entp->d_namlen = n; | ||
| 286 | |||
| 287 | /* File type */ | ||
| 288 | attr = datap->dwFileAttributes; | ||
| 289 | if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { | ||
| 290 | entp->d_type = DT_CHR; | ||
| 291 | } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { | ||
| 292 | entp->d_type = DT_DIR; | ||
| 293 | } else { | ||
| 294 | entp->d_type = DT_REG; | ||
| 295 | } | ||
| 296 | |||
| 297 | /* Reset dummy fields */ | ||
| 298 | entp->d_ino = 0; | ||
| 299 | entp->d_reclen = sizeof (struct _wdirent); | ||
| 300 | |||
| 301 | } else { | ||
| 302 | |||
| 303 | /* Last directory entry read */ | ||
| 304 | entp = NULL; | ||
| 305 | |||
| 306 | } | ||
| 307 | |||
| 308 | return entp; | ||
| 309 | } | ||
| 310 | |||
| 311 | /* | ||
| 312 | * Close directory stream opened by opendir() function. This invalidates the | ||
| 313 | * DIR structure as well as any directory entry read previously by | ||
| 314 | * _wreaddir(). | ||
| 315 | */ | ||
| 316 | static int | ||
| 317 | _wclosedir( | ||
| 318 | _WDIR *dirp) | ||
| 319 | { | ||
| 320 | int ok; | ||
| 321 | if (dirp) { | ||
| 322 | |||
| 323 | /* Release search handle */ | ||
| 324 | if (dirp->handle != INVALID_HANDLE_VALUE) { | ||
| 325 | FindClose (dirp->handle); | ||
| 326 | dirp->handle = INVALID_HANDLE_VALUE; | ||
| 327 | } | ||
| 328 | |||
| 329 | /* Release search pattern */ | ||
| 330 | if (dirp->patt) { | ||
| 331 | free (dirp->patt); | ||
| 332 | dirp->patt = NULL; | ||
| 333 | } | ||
| 334 | |||
| 335 | /* Release directory structure */ | ||
| 336 | free (dirp); | ||
| 337 | ok = /*success*/0; | ||
| 338 | |||
| 339 | } else { | ||
| 340 | /* Invalid directory stream */ | ||
| 341 | dirent_set_errno (EBADF); | ||
| 342 | ok = /*failure*/-1; | ||
| 343 | } | ||
| 344 | return ok; | ||
| 345 | } | ||
| 346 | |||
| 347 | /* | ||
| 348 | * Rewind directory stream such that _wreaddir() returns the very first | ||
| 349 | * file name again. | ||
| 350 | */ | ||
| 351 | static void | ||
| 352 | _wrewinddir( | ||
| 353 | _WDIR* dirp) | ||
| 354 | { | ||
| 355 | if (dirp) { | ||
| 356 | /* Release existing search handle */ | ||
| 357 | if (dirp->handle != INVALID_HANDLE_VALUE) { | ||
| 358 | FindClose (dirp->handle); | ||
| 359 | } | ||
| 360 | |||
| 361 | /* Open new search handle */ | ||
| 362 | dirent_first (dirp); | ||
| 363 | } | ||
| 364 | } | ||
| 365 | |||
| 366 | /* Get first directory entry (internal) */ | ||
| 367 | static WIN32_FIND_DATAW* | ||
| 368 | dirent_first( | ||
| 369 | _WDIR *dirp) | ||
| 370 | { | ||
| 371 | WIN32_FIND_DATAW *datap; | ||
| 372 | |||
| 373 | /* Open directory and retrieve the first entry */ | ||
| 374 | dirp->handle = FindFirstFileW (dirp->patt, &dirp->data); | ||
| 375 | if (dirp->handle != INVALID_HANDLE_VALUE) { | ||
| 376 | |||
| 377 | /* a directory entry is now waiting in memory */ | ||
| 378 | datap = &dirp->data; | ||
| 379 | dirp->cached = 1; | ||
| 380 | |||
| 381 | } else { | ||
| 382 | |||
| 383 | /* Failed to re-open directory: no directory entry in memory */ | ||
| 384 | dirp->cached = 0; | ||
| 385 | datap = NULL; | ||
| 386 | |||
| 387 | } | ||
| 388 | return datap; | ||
| 389 | } | ||
| 390 | |||
| 391 | /* Get next directory entry (internal) */ | ||
| 392 | static WIN32_FIND_DATAW* | ||
| 393 | dirent_next( | ||
| 394 | _WDIR *dirp) | ||
| 395 | { | ||
| 396 | WIN32_FIND_DATAW *p; | ||
| 397 | |||
| 398 | /* Get next directory entry */ | ||
| 399 | if (dirp->cached != 0) { | ||
| 400 | |||
| 401 | /* A valid directory entry already in memory */ | ||
| 402 | p = &dirp->data; | ||
| 403 | dirp->cached = 0; | ||
| 404 | |||
| 405 | } else if (dirp->handle != INVALID_HANDLE_VALUE) { | ||
| 406 | |||
| 407 | /* Get the next directory entry from stream */ | ||
| 408 | if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) { | ||
| 409 | /* Got a file */ | ||
| 410 | p = &dirp->data; | ||
| 411 | } else { | ||
| 412 | /* The very last entry has been processed or an error occured */ | ||
| 413 | FindClose (dirp->handle); | ||
| 414 | dirp->handle = INVALID_HANDLE_VALUE; | ||
| 415 | p = NULL; | ||
| 416 | } | ||
| 417 | |||
| 418 | } else { | ||
| 419 | |||
| 420 | /* End of directory stream reached */ | ||
| 421 | p = NULL; | ||
| 422 | |||
| 423 | } | ||
| 424 | |||
| 425 | return p; | ||
| 426 | } | ||
| 427 | |||
| 428 | /* | ||
| 429 | * Open directory stream using plain old C-string. | ||
| 430 | */ | ||
| 431 | static DIR* | ||
| 432 | opendir( | ||
| 433 | const char *dirname) | ||
| 434 | { | ||
| 435 | struct DIR *dirp; | ||
| 436 | int error; | ||
| 437 | |||
| 438 | /* Must have directory name */ | ||
| 439 | if (dirname == NULL || dirname[0] == '\0') { | ||
| 440 | dirent_set_errno (ENOENT); | ||
| 441 | return NULL; | ||
| 442 | } | ||
| 443 | |||
| 444 | /* Allocate memory for DIR structure */ | ||
| 445 | dirp = (DIR*) malloc (sizeof (struct DIR)); | ||
| 446 | if (dirp) { | ||
| 447 | wchar_t wname[PATH_MAX]; | ||
| 448 | size_t n; | ||
| 449 | |||
| 450 | /* Convert directory name to wide-character string */ | ||
| 451 | error = dirent_mbstowcs_s (&n, wname, PATH_MAX, dirname, PATH_MAX); | ||
| 452 | if (!error) { | ||
| 453 | |||
| 454 | /* Open directory stream using wide-character name */ | ||
| 455 | dirp->wdirp = _wopendir (wname); | ||
| 456 | if (dirp->wdirp) { | ||
| 457 | /* Directory stream opened */ | ||
| 458 | error = 0; | ||
| 459 | } else { | ||
| 460 | /* Failed to open directory stream */ | ||
| 461 | error = 1; | ||
| 462 | } | ||
| 463 | |||
| 464 | } else { | ||
| 465 | /* | ||
| 466 | * Cannot convert file name to wide-character string. This | ||
| 467 | * occurs if the string contains invalid multi-byte sequences or | ||
| 468 | * the output buffer is too small to contain the resulting | ||
| 469 | * string. | ||
| 470 | */ | ||
| 471 | error = 1; | ||
| 472 | } | ||
| 473 | |||
| 474 | } else { | ||
| 475 | /* Cannot allocate DIR structure */ | ||
| 476 | error = 1; | ||
| 477 | } | ||
| 478 | |||
| 479 | /* Clean up in case of error */ | ||
| 480 | if (error && dirp) { | ||
| 481 | free (dirp); | ||
| 482 | dirp = NULL; | ||
| 483 | } | ||
| 484 | |||
| 485 | return dirp; | ||
| 486 | } | ||
| 487 | |||
| 488 | /* | ||
| 489 | * Read next directory entry. | ||
| 490 | * | ||
| 491 | * When working with text consoles, please note that file names returned by | ||
| 492 | * readdir() are represented in the default ANSI code page while any output to | ||
| 493 | * console is typically formatted on another code page. Thus, non-ASCII | ||
| 494 | * characters in file names will not usually display correctly on console. The | ||
| 495 | * problem can be fixed in two ways: (1) change the character set of console | ||
| 496 | * to 1252 using chcp utility and use Lucida Console font, or (2) use | ||
| 497 | * _cprintf function when writing to console. The _cprinf() will re-encode | ||
| 498 | * ANSI strings to the console code page so many non-ASCII characters will | ||
| 499 | * display correcly. | ||
| 500 | */ | ||
| 501 | static struct dirent* | ||
| 502 | readdir( | ||
| 503 | DIR *dirp) | ||
| 504 | { | ||
| 505 | WIN32_FIND_DATAW *datap; | ||
| 506 | struct dirent *entp; | ||
| 507 | |||
| 508 | /* Read next directory entry */ | ||
| 509 | datap = dirent_next (dirp->wdirp); | ||
| 510 | if (datap) { | ||
| 511 | size_t n; | ||
| 512 | int error; | ||
| 513 | |||
| 514 | /* Attempt to convert file name to multi-byte string */ | ||
| 515 | error = dirent_wcstombs_s( | ||
| 516 | &n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX); | ||
| 517 | |||
| 518 | /* | ||
| 519 | * If the file name cannot be represented by a multi-byte string, | ||
| 520 | * then attempt to use old 8+3 file name. This allows traditional | ||
| 521 | * Unix-code to access some file names despite of unicode | ||
| 522 | * characters, although file names may seem unfamiliar to the user. | ||
| 523 | * | ||
| 524 | * Be ware that the code below cannot come up with a short file | ||
| 525 | * name unless the file system provides one. At least | ||
| 526 | * VirtualBox shared folders fail to do this. | ||
| 527 | */ | ||
| 528 | if (error && datap->cAlternateFileName[0] != '\0') { | ||
| 529 | error = dirent_wcstombs_s( | ||
| 530 | &n, dirp->ent.d_name, PATH_MAX, | ||
| 531 | datap->cAlternateFileName, PATH_MAX); | ||
| 532 | } | ||
| 533 | |||
| 534 | if (!error) { | ||
| 535 | DWORD attr; | ||
| 536 | |||
| 537 | /* Initialize directory entry for return */ | ||
| 538 | entp = &dirp->ent; | ||
| 539 | |||
| 540 | /* Length of file name excluding zero terminator */ | ||
| 541 | entp->d_namlen = n - 1; | ||
| 542 | |||
| 543 | /* File attributes */ | ||
| 544 | attr = datap->dwFileAttributes; | ||
| 545 | if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) { | ||
| 546 | entp->d_type = DT_CHR; | ||
| 547 | } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { | ||
| 548 | entp->d_type = DT_DIR; | ||
| 549 | } else { | ||
| 550 | entp->d_type = DT_REG; | ||
| 551 | } | ||
| 552 | |||
| 553 | /* Reset dummy fields */ | ||
| 554 | entp->d_ino = 0; | ||
| 555 | entp->d_reclen = sizeof (struct dirent); | ||
| 556 | |||
| 557 | } else { | ||
| 558 | /* | ||
| 559 | * Cannot convert file name to multi-byte string so construct | ||
| 560 | * an errornous directory entry and return that. Note that | ||
| 561 | * we cannot return NULL as that would stop the processing | ||
| 562 | * of directory entries completely. | ||
| 563 | */ | ||
| 564 | entp = &dirp->ent; | ||
| 565 | entp->d_name[0] = '?'; | ||
| 566 | entp->d_name[1] = '\0'; | ||
| 567 | entp->d_namlen = 1; | ||
| 568 | entp->d_type = DT_UNKNOWN; | ||
| 569 | entp->d_ino = 0; | ||
| 570 | entp->d_reclen = 0; | ||
| 571 | } | ||
| 572 | |||
| 573 | } else { | ||
| 574 | /* No more directory entries */ | ||
| 575 | entp = NULL; | ||
| 576 | } | ||
| 577 | |||
| 578 | return entp; | ||
| 579 | } | ||
| 580 | |||
| 581 | /* | ||
| 582 | * Close directory stream. | ||
| 583 | */ | ||
| 584 | static int | ||
| 585 | closedir( | ||
| 586 | DIR *dirp) | ||
| 587 | { | ||
| 588 | int ok; | ||
| 589 | if (dirp) { | ||
| 590 | |||
| 591 | /* Close wide-character directory stream */ | ||
| 592 | ok = _wclosedir (dirp->wdirp); | ||
| 593 | dirp->wdirp = NULL; | ||
| 594 | |||
| 595 | /* Release multi-byte character version */ | ||
| 596 | free (dirp); | ||
| 597 | |||
| 598 | } else { | ||
| 599 | |||
| 600 | /* Invalid directory stream */ | ||
| 601 | dirent_set_errno (EBADF); | ||
| 602 | ok = /*failure*/-1; | ||
| 603 | |||
| 604 | } | ||
| 605 | return ok; | ||
| 606 | } | ||
| 607 | |||
| 608 | /* | ||
| 609 | * Rewind directory stream to beginning. | ||
| 610 | */ | ||
| 611 | static void | ||
| 612 | rewinddir( | ||
| 613 | DIR* dirp) | ||
| 614 | { | ||
| 615 | /* Rewind wide-character string directory stream */ | ||
| 616 | _wrewinddir (dirp->wdirp); | ||
| 617 | } | ||
| 618 | |||
| 619 | /* Convert multi-byte string to wide character string */ | ||
| 620 | static int | ||
| 621 | dirent_mbstowcs_s( | ||
| 622 | size_t *pReturnValue, | ||
| 623 | wchar_t *wcstr, | ||
| 624 | size_t sizeInWords, | ||
| 625 | const char *mbstr, | ||
| 626 | size_t count) | ||
| 627 | { | ||
| 628 | int error; | ||
| 629 | |||
| 630 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | ||
| 631 | |||
| 632 | /* Microsoft Visual Studio 2005 or later */ | ||
| 633 | error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count); | ||
| 634 | |||
| 635 | #else | ||
| 636 | |||
| 637 | /* Older Visual Studio or non-Microsoft compiler */ | ||
| 638 | size_t n; | ||
| 639 | |||
| 640 | /* Convert to wide-character string (or count characters) */ | ||
| 641 | n = mbstowcs (wcstr, mbstr, sizeInWords); | ||
| 642 | if (!wcstr || n < count) { | ||
| 643 | |||
| 644 | /* Zero-terminate output buffer */ | ||
| 645 | if (wcstr && sizeInWords) { | ||
| 646 | if (n >= sizeInWords) { | ||
| 647 | n = sizeInWords - 1; | ||
| 648 | } | ||
| 649 | wcstr[n] = 0; | ||
| 650 | } | ||
| 651 | |||
| 652 | /* Length of resuting multi-byte string WITH zero terminator */ | ||
| 653 | if (pReturnValue) { | ||
| 654 | *pReturnValue = n + 1; | ||
| 655 | } | ||
| 656 | |||
| 657 | /* Success */ | ||
| 658 | error = 0; | ||
| 659 | |||
| 660 | } else { | ||
| 661 | |||
| 662 | /* Could not convert string */ | ||
| 663 | error = 1; | ||
| 664 | |||
| 665 | } | ||
| 666 | |||
| 667 | #endif | ||
| 668 | |||
| 669 | return error; | ||
| 670 | } | ||
| 671 | |||
| 672 | /* Convert wide-character string to multi-byte string */ | ||
| 673 | static int | ||
| 674 | dirent_wcstombs_s( | ||
| 675 | size_t *pReturnValue, | ||
| 676 | char *mbstr, | ||
| 677 | size_t sizeInBytes, /* max size of mbstr */ | ||
| 678 | const wchar_t *wcstr, | ||
| 679 | size_t count) | ||
| 680 | { | ||
| 681 | int error; | ||
| 682 | |||
| 683 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | ||
| 684 | |||
| 685 | /* Microsoft Visual Studio 2005 or later */ | ||
| 686 | error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count); | ||
| 687 | |||
| 688 | #else | ||
| 689 | |||
| 690 | /* Older Visual Studio or non-Microsoft compiler */ | ||
| 691 | size_t n; | ||
| 692 | |||
| 693 | /* Convert to multi-byte string (or count the number of bytes needed) */ | ||
| 694 | n = wcstombs (mbstr, wcstr, sizeInBytes); | ||
| 695 | if (!mbstr || n < count) { | ||
| 696 | |||
| 697 | /* Zero-terminate output buffer */ | ||
| 698 | if (mbstr && sizeInBytes) { | ||
| 699 | if (n >= sizeInBytes) { | ||
| 700 | n = sizeInBytes - 1; | ||
| 701 | } | ||
| 702 | mbstr[n] = '\0'; | ||
| 703 | } | ||
| 704 | |||
| 705 | /* Lenght of resulting multi-bytes string WITH zero-terminator */ | ||
| 706 | if (pReturnValue) { | ||
| 707 | *pReturnValue = n + 1; | ||
| 708 | } | ||
| 709 | |||
| 710 | /* Success */ | ||
| 711 | error = 0; | ||
| 712 | |||
| 713 | } else { | ||
| 714 | |||
| 715 | /* Cannot convert string */ | ||
| 716 | error = 1; | ||
| 717 | |||
| 718 | } | ||
| 719 | |||
| 720 | #endif | ||
| 721 | |||
| 722 | return error; | ||
| 723 | } | ||
| 724 | |||
| 725 | /* Set errno variable */ | ||
| 726 | static void | ||
| 727 | dirent_set_errno( | ||
| 728 | int error) | ||
| 729 | { | ||
| 730 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | ||
| 731 | |||
| 732 | /* Microsoft Visual Studio 2005 and later */ | ||
| 733 | _set_errno (error); | ||
| 734 | |||
| 735 | #else | ||
| 736 | |||
| 737 | /* Non-Microsoft compiler or older Microsoft compiler */ | ||
| 738 | errno = error; | ||
| 739 | |||
| 740 | #endif | ||
| 741 | } | ||
| 742 | |||
| 743 | |||
| 744 | #ifdef __cplusplus | ||
| 745 | } | ||
| 746 | #endif | ||
| 747 | #endif /*DIRENT_H*/ | ||
| 748 | |||
diff --git a/include/compat/err.h b/include/compat/err.h new file mode 100644 index 0000000..af68a26 --- /dev/null +++ b/include/compat/err.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * err.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifdef HAVE_ERR_H | ||
| 7 | |||
| 8 | #include_next <err.h> | ||
| 9 | |||
| 10 | #else | ||
| 11 | |||
| 12 | #ifndef LIBCRYPTOCOMPAT_ERR_H | ||
| 13 | #define LIBCRYPTOCOMPAT_ERR_H | ||
| 14 | |||
| 15 | #include <errno.h> | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <string.h> | ||
| 18 | |||
| 19 | #define err(exitcode, format, ...) \ | ||
| 20 | errx(exitcode, format ": %s", __VA_ARGS__, strerror(errno)) | ||
| 21 | |||
| 22 | #define errx(exitcode, format, ...) \ | ||
| 23 | do { warnx(format, __VA_ARGS__); exit(exitcode); } while (0) | ||
| 24 | |||
| 25 | #define warn(format, ...) \ | ||
| 26 | warnx(format ": %s", __VA_ARGS__, strerror(errno)) | ||
| 27 | |||
| 28 | #define warnx(format, ...) \ | ||
| 29 | fprintf(stderr, format "\n", __VA_ARGS__) | ||
| 30 | |||
| 31 | #endif | ||
| 32 | |||
| 33 | #endif | ||
diff --git a/include/machine/endian.h b/include/compat/machine/endian.h index 5ec39af..5ec39af 100644 --- a/include/machine/endian.h +++ b/include/compat/machine/endian.h | |||
diff --git a/include/netdb.h b/include/compat/netdb.h index d36b91d..d36b91d 100644 --- a/include/netdb.h +++ b/include/compat/netdb.h | |||
diff --git a/include/netinet/in.h b/include/compat/netinet/in.h index 20e57b8..20e57b8 100644 --- a/include/netinet/in.h +++ b/include/compat/netinet/in.h | |||
diff --git a/include/netinet/tcp.h b/include/compat/netinet/tcp.h index c98cf74..c98cf74 100644 --- a/include/netinet/tcp.h +++ b/include/compat/netinet/tcp.h | |||
diff --git a/include/poll.h b/include/compat/poll.h index c02a560..e9204cf 100644 --- a/include/poll.h +++ b/include/compat/poll.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #ifndef LIBCRYPTOCOMPAT_POLL_H | 14 | #ifndef LIBCRYPTOCOMPAT_POLL_H |
| 15 | #define LIBCRYPTOCOMPAT_POLL_H | 15 | #define LIBCRYPTOCOMPAT_POLL_H |
| 16 | 16 | ||
| 17 | #ifdef HAVE_POLL | 17 | #ifndef _WIN32 |
| 18 | #include_next <poll.h> | 18 | #include_next <poll.h> |
| 19 | #else | 19 | #else |
| 20 | 20 | ||
diff --git a/include/stdio.h b/include/compat/stdio.h index 76bd9da..973faa4 100644 --- a/include/stdio.h +++ b/include/compat/stdio.h | |||
| @@ -3,11 +3,15 @@ | |||
| 3 | * stdio.h compatibility shim | 3 | * stdio.h compatibility shim |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include_next <stdio.h> | ||
| 7 | |||
| 8 | #ifndef LIBCRYPTOCOMPAT_STDIO_H | 6 | #ifndef LIBCRYPTOCOMPAT_STDIO_H |
| 9 | #define LIBCRYPTOCOMPAT_STDIO_H | 7 | #define LIBCRYPTOCOMPAT_STDIO_H |
| 10 | 8 | ||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <../include/stdio.h> | ||
| 11 | #else | ||
| 12 | #include_next <stdio.h> | ||
| 13 | #endif | ||
| 14 | |||
| 11 | #ifndef HAVE_ASPRINTF | 15 | #ifndef HAVE_ASPRINTF |
| 12 | #include <stdarg.h> | 16 | #include <stdarg.h> |
| 13 | int vasprintf(char **str, const char *fmt, va_list ap); | 17 | int vasprintf(char **str, const char *fmt, va_list ap); |
| @@ -26,6 +30,10 @@ int posix_rename(const char *oldpath, const char *newpath); | |||
| 26 | #define rename(oldpath, newpath) posix_rename(oldpath, newpath) | 30 | #define rename(oldpath, newpath) posix_rename(oldpath, newpath) |
| 27 | #endif | 31 | #endif |
| 28 | 32 | ||
| 33 | #ifdef _MSC_VER | ||
| 34 | #define snprintf _snprintf | ||
| 35 | #endif | ||
| 36 | |||
| 29 | #endif | 37 | #endif |
| 30 | 38 | ||
| 31 | #endif | 39 | #endif |
diff --git a/include/stdlib.h b/include/compat/stdlib.h index e77f0b4..47189fd 100644 --- a/include/stdlib.h +++ b/include/compat/stdlib.h | |||
| @@ -3,13 +3,18 @@ | |||
| 3 | * Public domain | 3 | * Public domain |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include_next <stdlib.h> | ||
| 7 | |||
| 8 | #ifndef LIBCRYPTOCOMPAT_STDLIB_H | 6 | #ifndef LIBCRYPTOCOMPAT_STDLIB_H |
| 9 | #define LIBCRYPTOCOMPAT_STDLIB_H | 7 | #define LIBCRYPTOCOMPAT_STDLIB_H |
| 10 | 8 | ||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <../include/stdlib.h> | ||
| 11 | #else | ||
| 12 | #include_next <stdlib.h> | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #include <sys/types.h> | ||
| 11 | #include <sys/stat.h> | 16 | #include <sys/stat.h> |
| 12 | #include <sys/time.h> | 17 | //#include <sys/time.h> |
| 13 | #include <stdint.h> | 18 | #include <stdint.h> |
| 14 | 19 | ||
| 15 | #ifndef HAVE_ARC4RANDOM_BUF | 20 | #ifndef HAVE_ARC4RANDOM_BUF |
diff --git a/include/string.h b/include/compat/string.h index 05d1ffc..eabc4c4 100644 --- a/include/string.h +++ b/include/compat/string.h | |||
| @@ -3,11 +3,15 @@ | |||
| 3 | * string.h compatibility shim | 3 | * string.h compatibility shim |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include_next <string.h> | ||
| 7 | |||
| 8 | #ifndef LIBCRYPTOCOMPAT_STRING_H | 6 | #ifndef LIBCRYPTOCOMPAT_STRING_H |
| 9 | #define LIBCRYPTOCOMPAT_STRING_H | 7 | #define LIBCRYPTOCOMPAT_STRING_H |
| 10 | 8 | ||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <../include/string.h> | ||
| 11 | #else | ||
| 12 | #include_next <string.h> | ||
| 13 | #endif | ||
| 14 | |||
| 11 | #include <sys/types.h> | 15 | #include <sys/types.h> |
| 12 | 16 | ||
| 13 | #if defined(__sun) || defined(__hpux) | 17 | #if defined(__sun) || defined(__hpux) |
| @@ -17,6 +21,11 @@ | |||
| 17 | #include <strings.h> | 21 | #include <strings.h> |
| 18 | #endif | 22 | #endif |
| 19 | 23 | ||
| 24 | #ifndef HAVE_STRCASECMP | ||
| 25 | int strcasecmp(const char *s1, const char *s2); | ||
| 26 | int strncasecmp(const char *s1, const char *s2, size_t len); | ||
| 27 | #endif | ||
| 28 | |||
| 20 | #ifndef HAVE_STRLCPY | 29 | #ifndef HAVE_STRLCPY |
| 21 | size_t strlcpy(char *dst, const char *src, size_t siz); | 30 | size_t strlcpy(char *dst, const char *src, size_t siz); |
| 22 | #endif | 31 | #endif |
diff --git a/include/sys/cdefs.h b/include/compat/sys/cdefs.h index 21ef031..21ef031 100644 --- a/include/sys/cdefs.h +++ b/include/compat/sys/cdefs.h | |||
diff --git a/include/sys/ioctl.h b/include/compat/sys/ioctl.h index a255506..a255506 100644 --- a/include/sys/ioctl.h +++ b/include/compat/sys/ioctl.h | |||
diff --git a/include/sys/mman.h b/include/compat/sys/mman.h index d9eb6a9..d9eb6a9 100644 --- a/include/sys/mman.h +++ b/include/compat/sys/mman.h | |||
diff --git a/include/compat/sys/param.h b/include/compat/sys/param.h new file mode 100644 index 0000000..70488f8 --- /dev/null +++ b/include/compat/sys/param.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * sys/param.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_SYS_PARAM_H | ||
| 7 | #define LIBCRYPTOCOMPAT_SYS_PARAM_H | ||
| 8 | |||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <winsock2.h> | ||
| 11 | #else | ||
| 12 | #include_next <sys/param.h> | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #endif | ||
diff --git a/include/sys/select.h b/include/compat/sys/select.h index 5ca0ea1..5ca0ea1 100644 --- a/include/sys/select.h +++ b/include/compat/sys/select.h | |||
diff --git a/include/sys/socket.h b/include/compat/sys/socket.h index 17e84f1..17e84f1 100644 --- a/include/sys/socket.h +++ b/include/compat/sys/socket.h | |||
diff --git a/include/compat/sys/stat.h b/include/compat/sys/stat.h new file mode 100644 index 0000000..55135d8 --- /dev/null +++ b/include/compat/sys/stat.h | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * sys/stat.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_SYS_STAT_H | ||
| 7 | #define LIBCRYPTOCOMPAT_SYS_STAT_H | ||
| 8 | |||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <windows.h> | ||
| 11 | #include <../include/sys/stat.h> | ||
| 12 | |||
| 13 | /* File type and permission flags for stat() */ | ||
| 14 | #if !defined(S_IFMT) | ||
| 15 | # define S_IFMT _S_IFMT /* File type mask */ | ||
| 16 | #endif | ||
| 17 | #if !defined(S_IFDIR) | ||
| 18 | # define S_IFDIR _S_IFDIR /* Directory */ | ||
| 19 | #endif | ||
| 20 | #if !defined(S_IFCHR) | ||
| 21 | # define S_IFCHR _S_IFCHR /* Character device */ | ||
| 22 | #endif | ||
| 23 | #if !defined(S_IFFIFO) | ||
| 24 | # define S_IFFIFO _S_IFFIFO /* Pipe */ | ||
| 25 | #endif | ||
| 26 | #if !defined(S_IFREG) | ||
| 27 | # define S_IFREG _S_IFREG /* Regular file */ | ||
| 28 | #endif | ||
| 29 | #if !defined(S_IREAD) | ||
| 30 | # define S_IREAD _S_IREAD /* Read permission */ | ||
| 31 | #endif | ||
| 32 | #if !defined(S_IWRITE) | ||
| 33 | # define S_IWRITE _S_IWRITE /* Write permission */ | ||
| 34 | #endif | ||
| 35 | #if !defined(S_IEXEC) | ||
| 36 | # define S_IEXEC _S_IEXEC /* Execute permission */ | ||
| 37 | #endif | ||
| 38 | #if !defined(S_IFIFO) | ||
| 39 | # define S_IFIFO _S_IFIFO /* Pipe */ | ||
| 40 | #endif | ||
| 41 | #if !defined(S_IFBLK) | ||
| 42 | # define S_IFBLK 0 /* Block device */ | ||
| 43 | #endif | ||
| 44 | #if !defined(S_IFLNK) | ||
| 45 | # define S_IFLNK 0 /* Link */ | ||
| 46 | #endif | ||
| 47 | #if !defined(S_IFSOCK) | ||
| 48 | # define S_IFSOCK 0 /* Socket */ | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #if defined(_MSC_VER) | ||
| 52 | # define S_IRUSR S_IREAD /* Read user */ | ||
| 53 | # define S_IWUSR S_IWRITE /* Write user */ | ||
| 54 | # define S_IXUSR 0 /* Execute user */ | ||
| 55 | # define S_IRGRP 0 /* Read group */ | ||
| 56 | # define S_IWGRP 0 /* Write group */ | ||
| 57 | # define S_IXGRP 0 /* Execute group */ | ||
| 58 | # define S_IROTH 0 /* Read others */ | ||
| 59 | # define S_IWOTH 0 /* Write others */ | ||
| 60 | # define S_IXOTH 0 /* Execute others */ | ||
| 61 | #endif | ||
| 62 | |||
| 63 | /* File type flags for d_type */ | ||
| 64 | #define DT_UNKNOWN 0 | ||
| 65 | #define DT_REG S_IFREG | ||
| 66 | #define DT_DIR S_IFDIR | ||
| 67 | #define DT_FIFO S_IFIFO | ||
| 68 | #define DT_SOCK S_IFSOCK | ||
| 69 | #define DT_CHR S_IFCHR | ||
| 70 | #define DT_BLK S_IFBLK | ||
| 71 | #define DT_LNK S_IFLNK | ||
| 72 | |||
| 73 | /* Macros for converting between st_mode and d_type */ | ||
| 74 | #define IFTODT(mode) ((mode) & S_IFMT) | ||
| 75 | #define DTTOIF(type) (type) | ||
| 76 | |||
| 77 | /* | ||
| 78 | * File type macros. Note that block devices, sockets and links cannot be | ||
| 79 | * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are | ||
| 80 | * only defined for compatibility. These macros should always return false | ||
| 81 | * on Windows. | ||
| 82 | */ | ||
| 83 | #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) | ||
| 84 | #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) | ||
| 85 | #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) | ||
| 86 | #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) | ||
| 87 | #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) | ||
| 88 | #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) | ||
| 89 | #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) | ||
| 90 | |||
| 91 | #else | ||
| 92 | #include_next <sys/stat.h> | ||
| 93 | #endif | ||
| 94 | |||
| 95 | #endif | ||
diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h new file mode 100644 index 0000000..235bc6e --- /dev/null +++ b/include/compat/sys/time.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * sys/time.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_SYS_TIME_H | ||
| 7 | #define LIBCRYPTOCOMPAT_SYS_TIME_H | ||
| 8 | |||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <winsock2.h> | ||
| 11 | int gettimeofday(struct timeval *tp, void *tzp); | ||
| 12 | #else | ||
| 13 | #include_next <sys/time.h> | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #endif | ||
diff --git a/include/sys/types.h b/include/compat/sys/types.h index bceedc2..9929dd5 100644 --- a/include/sys/types.h +++ b/include/compat/sys/types.h | |||
| @@ -3,17 +3,39 @@ | |||
| 3 | * sys/types.h compatibility shim | 3 | * sys/types.h compatibility shim |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include_next <sys/types.h> | ||
| 7 | |||
| 8 | #ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H | 6 | #ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H |
| 9 | #define LIBCRYPTOCOMPAT_SYS_TYPES_H | 7 | #define LIBCRYPTOCOMPAT_SYS_TYPES_H |
| 10 | 8 | ||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <../include/sys/types.h> | ||
| 11 | #else | ||
| 12 | #include_next <sys/types.h> | ||
| 13 | #endif | ||
| 14 | |||
| 11 | #include <stdint.h> | 15 | #include <stdint.h> |
| 12 | 16 | ||
| 13 | #ifdef __MINGW32__ | 17 | #ifdef __MINGW32__ |
| 14 | #include <_bsd_types.h> | 18 | #include <_bsd_types.h> |
| 15 | #endif | 19 | #endif |
| 16 | 20 | ||
| 21 | #ifdef _MSC_VER | ||
| 22 | typedef unsigned char u_char; | ||
| 23 | typedef unsigned short u_short; | ||
| 24 | typedef unsigned int u_int; | ||
| 25 | |||
| 26 | #include <basetsd.h> | ||
| 27 | typedef SSIZE_T ssize_t; | ||
| 28 | |||
| 29 | #ifndef SSIZE_MAX | ||
| 30 | #ifdef _WIN64 | ||
| 31 | #define SSIZE_MAX _I64_MAX | ||
| 32 | #else | ||
| 33 | #define SSIZE_MAX INT_MAX | ||
| 34 | #endif | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #endif | ||
| 38 | |||
| 17 | #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) | 39 | #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) |
| 18 | # define __bounded__(x, y, z) | 40 | # define __bounded__(x, y, z) |
| 19 | #endif | 41 | #endif |
diff --git a/include/sys/uio.h b/include/compat/sys/uio.h index b4aee9e..b4aee9e 100644 --- a/include/sys/uio.h +++ b/include/compat/sys/uio.h | |||
diff --git a/include/compat/time.h b/include/compat/time.h new file mode 100644 index 0000000..d363d42 --- /dev/null +++ b/include/compat/time.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * sys/time.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_TIME_H | ||
| 7 | #define LIBCRYPTOCOMPAT_TIME_H | ||
| 8 | |||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <../include/time.h> | ||
| 11 | #define gmtime_r(tp, tm) ((gmtime_s((tm), (tp)) == 0) ? (tm) : NULL) | ||
| 12 | #else | ||
| 13 | #include_next <time.h> | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #endif | ||
diff --git a/include/compat/unistd.h b/include/compat/unistd.h new file mode 100644 index 0000000..4676dc8 --- /dev/null +++ b/include/compat/unistd.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * unistd.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_UNISTD_H | ||
| 7 | #define LIBCRYPTOCOMPAT_UNISTD_H | ||
| 8 | |||
| 9 | #ifndef _MSC_VER | ||
| 10 | #include_next <unistd.h> | ||
| 11 | #else | ||
| 12 | |||
| 13 | #include <stdlib.h> | ||
| 14 | #include <io.h> | ||
| 15 | #include <process.h> | ||
| 16 | |||
| 17 | #define R_OK 4 | ||
| 18 | #define W_OK 2 | ||
| 19 | #define X_OK 0 | ||
| 20 | #define F_OK 0 | ||
| 21 | |||
| 22 | #define access _access | ||
| 23 | |||
| 24 | static inline unsigned int sleep(unsigned int seconds) | ||
| 25 | { | ||
| 26 | Sleep(seconds * 1000); | ||
| 27 | return seconds; | ||
| 28 | } | ||
| 29 | |||
| 30 | #endif | ||
| 31 | |||
| 32 | #ifndef HAVE_GETENTROPY | ||
| 33 | int getentropy(void *buf, size_t buflen); | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #endif | ||
diff --git a/include/win32netcompat.h b/include/compat/win32netcompat.h index 452cfba..452cfba 100644 --- a/include/win32netcompat.h +++ b/include/compat/win32netcompat.h | |||
diff --git a/include/err.h b/include/err.h deleted file mode 100644 index ec90327..0000000 --- a/include/err.h +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * err.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifdef HAVE_ERR_H | ||
| 7 | |||
| 8 | #include_next <err.h> | ||
| 9 | |||
| 10 | #else | ||
| 11 | |||
| 12 | #ifndef LIBCRYPTOCOMPAT_ERR_H | ||
| 13 | #define LIBCRYPTOCOMPAT_ERR_H | ||
| 14 | |||
| 15 | #include <errno.h> | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <string.h> | ||
| 18 | |||
| 19 | #define err(exitcode, format, args...) \ | ||
| 20 | errx(exitcode, format ": %s", ## args, strerror(errno)) | ||
| 21 | |||
| 22 | #define errx(exitcode, format, args...) \ | ||
| 23 | do { warnx(format, ## args); exit(exitcode); } while (0) | ||
| 24 | |||
| 25 | #define warn(format, args...) \ | ||
| 26 | warnx(format ": %s", ## args, strerror(errno)) | ||
| 27 | |||
| 28 | #define warnx(format, args...) \ | ||
| 29 | fprintf(stderr, format "\n", ## args) | ||
| 30 | |||
| 31 | #endif | ||
| 32 | |||
| 33 | #endif | ||
diff --git a/include/sys/times.h b/include/sys/times.h deleted file mode 100644 index 5b9841b..0000000 --- a/include/sys/times.h +++ /dev/null | |||
| @@ -1,10 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * sys/times.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef _WIN32 | ||
| 7 | #include_next <sys/times.h> | ||
| 8 | #else | ||
| 9 | #include <win32netcompat.h> | ||
| 10 | #endif | ||
diff --git a/include/syslog.h b/include/syslog.h deleted file mode 100644 index f61e33b..0000000 --- a/include/syslog.h +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * syslog.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef LIBCRYPTOCOMPAT_SYSLOG_H | ||
| 7 | #define LIBCRYPTOCOMPAT_SYSLOG_H | ||
| 8 | |||
| 9 | #ifndef _WIN32 | ||
| 10 | #include_next <syslog.h> | ||
| 11 | #else | ||
| 12 | |||
| 13 | /* priorities */ | ||
| 14 | #define LOG_EMERG 0 | ||
| 15 | #define LOG_ALERT 1 | ||
| 16 | #define LOG_CRIT 2 | ||
| 17 | #define LOG_ERR 3 | ||
| 18 | #define LOG_WARNING 4 | ||
| 19 | #define LOG_NOTICE 5 | ||
| 20 | #define LOG_INFO 6 | ||
| 21 | #define LOG_DEBUG 7 | ||
| 22 | |||
| 23 | /* facility codes */ | ||
| 24 | #define LOG_KERN (0<<3) | ||
| 25 | #define LOG_USER (1<<3) | ||
| 26 | #define LOG_DAEMON (3<<3) | ||
| 27 | |||
| 28 | /* flags for openlog */ | ||
| 29 | #define LOG_PID 0x01 | ||
| 30 | #define LOG_CONS 0x02 | ||
| 31 | |||
| 32 | extern void openlog(const char *ident, int option, int facility); | ||
| 33 | extern void syslog(int priority, const char *fmt, ...) | ||
| 34 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
| 35 | extern void closelog (void); | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #endif /* LIBCRYPTOCOMPAT_SYSLOG_H */ | ||
diff --git a/include/unistd.h b/include/unistd.h deleted file mode 100644 index 9b12034..0000000 --- a/include/unistd.h +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Public domain | ||
| 3 | * unistd.h compatibility shim | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include_next <unistd.h> | ||
| 7 | |||
| 8 | #ifndef LIBCRYPTOCOMPAT_UNISTD_H | ||
| 9 | #define LIBCRYPTOCOMPAT_UNISTD_H | ||
| 10 | |||
| 11 | #ifndef HAVE_GETENTROPY | ||
| 12 | int getentropy(void *buf, size_t buflen); | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #endif | ||
diff --git a/libtls-standalone/include/string.h b/libtls-standalone/include/string.h index 05d1ffc..eabc4c4 100644 --- a/libtls-standalone/include/string.h +++ b/libtls-standalone/include/string.h | |||
| @@ -3,11 +3,15 @@ | |||
| 3 | * string.h compatibility shim | 3 | * string.h compatibility shim |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include_next <string.h> | ||
| 7 | |||
| 8 | #ifndef LIBCRYPTOCOMPAT_STRING_H | 6 | #ifndef LIBCRYPTOCOMPAT_STRING_H |
| 9 | #define LIBCRYPTOCOMPAT_STRING_H | 7 | #define LIBCRYPTOCOMPAT_STRING_H |
| 10 | 8 | ||
| 9 | #ifdef _MSC_VER | ||
| 10 | #include <../include/string.h> | ||
| 11 | #else | ||
| 12 | #include_next <string.h> | ||
| 13 | #endif | ||
| 14 | |||
| 11 | #include <sys/types.h> | 15 | #include <sys/types.h> |
| 12 | 16 | ||
| 13 | #if defined(__sun) || defined(__hpux) | 17 | #if defined(__sun) || defined(__hpux) |
| @@ -17,6 +21,11 @@ | |||
| 17 | #include <strings.h> | 21 | #include <strings.h> |
| 18 | #endif | 22 | #endif |
| 19 | 23 | ||
| 24 | #ifndef HAVE_STRCASECMP | ||
| 25 | int strcasecmp(const char *s1, const char *s2); | ||
| 26 | int strncasecmp(const char *s1, const char *s2, size_t len); | ||
| 27 | #endif | ||
| 28 | |||
| 20 | #ifndef HAVE_STRLCPY | 29 | #ifndef HAVE_STRLCPY |
| 21 | size_t strlcpy(char *dst, const char *src, size_t siz); | 30 | size_t strlcpy(char *dst, const char *src, size_t siz); |
| 22 | #endif | 31 | #endif |
diff --git a/m4/check-os-options.m4 b/m4/check-os-options.m4 index 4a7aec8..d1695f6 100644 --- a/m4/check-os-options.m4 +++ b/m4/check-os-options.m4 | |||
| @@ -51,7 +51,7 @@ case $host_os in | |||
| 51 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_POSIX -D_POSIX_SOURCE -D__USE_MINGW_ANSI_STDIO" | 51 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_POSIX -D_POSIX_SOURCE -D__USE_MINGW_ANSI_STDIO" |
| 52 | CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS" | 52 | CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS" |
| 53 | CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501" | 53 | CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501" |
| 54 | CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG" | 54 | CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_SPEED" |
| 55 | CFLAGS="$CFLAGS -static-libgcc" | 55 | CFLAGS="$CFLAGS -static-libgcc" |
| 56 | LDFLAGS="$LDFLAGS -static-libgcc" | 56 | LDFLAGS="$LDFLAGS -static-libgcc" |
| 57 | AC_SUBST([PLATFORM_LDADD], ['-lws2_32']) | 57 | AC_SUBST([PLATFORM_LDADD], ['-lws2_32']) |
diff --git a/patches/arc4random.c.patch b/patches/arc4random.c.patch new file mode 100644 index 0000000..9f9c476 --- /dev/null +++ b/patches/arc4random.c.patch | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --- crypto/compat/arc4random.c.orig 2015-07-20 07:41:17.000000000 -0600 | ||
| 2 | +++ crypto/compat/arc4random.c 2015-07-20 07:41:58.000000000 -0600 | ||
| 3 | @@ -36,8 +36,11 @@ | ||
| 4 | #define KEYSTREAM_ONLY | ||
| 5 | #include "chacha_private.h" | ||
| 6 | |||
| 7 | +#ifndef min | ||
| 8 | #define min(a, b) ((a) < (b) ? (a) : (b)) | ||
| 9 | -#ifdef __GNUC__ | ||
| 10 | +#endif | ||
| 11 | + | ||
| 12 | +#if defined(__GNUC__) || defined(_MSC_VER) | ||
| 13 | #define inline __inline | ||
| 14 | #else /* !__GNUC__ */ | ||
| 15 | #define inline | ||
diff --git a/patches/openssl.c.patch b/patches/openssl.c.patch index c086ba5..275e9ea 100644 --- a/patches/openssl.c.patch +++ b/patches/openssl.c.patch | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | --- apps/openssl.c.orig 2015-06-05 03:42:12.956112944 -0500 | 1 | --- apps/openssl.c.orig 2015-07-20 02:01:42.000000000 -0600 |
| 2 | +++ apps/openssl.c 2015-06-05 03:41:54.215381908 -0500 | 2 | +++ apps/openssl.c 2015-07-20 02:02:00.000000000 -0600 |
| 3 | @@ -130,6 +130,18 @@ | 3 | @@ -130,6 +130,19 @@ |
| 4 | #include <openssl/engine.h> | 4 | #include <openssl/engine.h> |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | +#ifdef _WIN32 | 7 | +#ifdef _WIN32 |
| 8 | +#include <io.h> | ||
| 8 | +#include <fcntl.h> | 9 | +#include <fcntl.h> |
| 9 | +static void set_stdio_binary(void) | 10 | +static void set_stdio_binary(void) |
| 10 | +{ | 11 | +{ |
| @@ -18,12 +19,22 @@ | |||
| 18 | + | 19 | + |
| 19 | #include "progs.h" | 20 | #include "progs.h" |
| 20 | #include "s_apps.h" | 21 | #include "s_apps.h" |
| 21 | 22 | ||
| 22 | @@ -216,6 +228,7 @@ | 23 | @@ -204,7 +216,9 @@ |
| 24 | static void | ||
| 25 | openssl_startup(void) | ||
| 26 | { | ||
| 27 | +#ifndef _WIN32 | ||
| 28 | signal(SIGPIPE, SIG_IGN); | ||
| 29 | +#endif | ||
| 30 | |||
| 31 | CRYPTO_malloc_init(); | ||
| 32 | OpenSSL_add_all_algorithms(); | ||
| 33 | @@ -216,6 +230,7 @@ | ||
| 23 | #endif | 34 | #endif |
| 24 | 35 | ||
| 25 | setup_ui_method(); | 36 | setup_ui_method(); |
| 26 | + set_stdio_binary(); | 37 | + set_stdio_binary(); |
| 27 | } | 38 | } |
| 28 | 39 | ||
| 29 | static void | 40 | static void |
diff --git a/patches/opensslconf.h.patch b/patches/opensslconf.h.patch new file mode 100644 index 0000000..0507c92 --- /dev/null +++ b/patches/opensslconf.h.patch | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --- include/openssl/opensslconf.h.orig 2015-07-19 23:21:47.000000000 -0600 | ||
| 2 | +++ include/openssl/opensslconf.h 2015-07-19 23:21:17.000000000 -0600 | ||
| 3 | @@ -1,6 +1,10 @@ | ||
| 4 | #include <openssl/opensslfeatures.h> | ||
| 5 | /* crypto/opensslconf.h.in */ | ||
| 6 | |||
| 7 | +#if defined(_MSC_VER) && !defined(__attribute__) | ||
| 8 | +#define __attribute__(a) | ||
| 9 | +#endif | ||
| 10 | + | ||
| 11 | /* Generate 80386 code? */ | ||
| 12 | #undef I386_ONLY | ||
| 13 | |||
diff --git a/patches/ossl_typ.h.patch b/patches/ossl_typ.h.patch index af9419a..f213347 100644 --- a/patches/ossl_typ.h.patch +++ b/patches/ossl_typ.h.patch | |||
| @@ -1,15 +1,17 @@ | |||
| 1 | --- include/openssl/ossl_typ.h.orig 2015-07-06 13:21:18.788571423 -0700 | 1 | --- include/openssl/ossl_typ.h.orig 2015-07-06 13:21:18.788571423 -0700 |
| 2 | +++ include/openssl/ossl_typ.h 2015-07-06 13:24:14.906468003 -0700 | 2 | +++ include/openssl/ossl_typ.h 2015-07-06 13:24:14.906468003 -0700 |
| 3 | @@ -100,6 +100,20 @@ | 3 | @@ -100,6 +100,22 @@ |
| 4 | typedef struct ASN1_ITEM_st ASN1_ITEM; | 4 | typedef struct ASN1_ITEM_st ASN1_ITEM; |
| 5 | typedef struct asn1_pctx_st ASN1_PCTX; | 5 | typedef struct asn1_pctx_st ASN1_PCTX; |
| 6 | 6 | ||
| 7 | +#if defined(_WIN32) && defined(__WINCRYPT_H__) | 7 | +#if defined(_WIN32) && defined(__WINCRYPT_H__) |
| 8 | +#ifndef LIBRESSL_INTERNAL | ||
| 8 | +#ifdef _MSC_VER | 9 | +#ifdef _MSC_VER |
| 9 | +#pragma message("Warning, overriding WinCrypt defines") | 10 | +#pragma message("Warning, overriding WinCrypt defines") |
| 10 | +#else | 11 | +#else |
| 11 | +#warning overriding WinCrypt defines | 12 | +#warning overriding WinCrypt defines |
| 12 | +#endif | 13 | +#endif |
| 14 | +#endif | ||
| 13 | +#undef X509_NAME | 15 | +#undef X509_NAME |
| 14 | +#undef X509_CERT_PAIR | 16 | +#undef X509_CERT_PAIR |
| 15 | +#undef X509_EXTENSIONS | 17 | +#undef X509_EXTENSIONS |
diff --git a/patches/pkcs7.h.patch b/patches/pkcs7.h.patch index fa8b297..4c6f6ba 100644 --- a/patches/pkcs7.h.patch +++ b/patches/pkcs7.h.patch | |||
| @@ -1,15 +1,17 @@ | |||
| 1 | --- include/openssl/pkcs7.h.orig 2015-07-06 13:26:27.369203527 -0700 | 1 | --- include/openssl/pkcs7.h.orig 2015-07-06 13:26:27.369203527 -0700 |
| 2 | +++ include/openssl/pkcs7.h 2015-07-06 13:27:37.637051967 -0700 | 2 | +++ include/openssl/pkcs7.h 2015-07-06 13:27:37.637051967 -0700 |
| 3 | @@ -69,6 +69,16 @@ | 3 | @@ -69,6 +69,18 @@ |
| 4 | extern "C" { | 4 | extern "C" { |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | +#if defined(_WIN32) && defined(__WINCRYPT_H__) | 7 | +#if defined(_WIN32) && defined(__WINCRYPT_H__) |
| 8 | +#ifndef LIBRESSL_INTERNAL | ||
| 8 | +#ifdef _MSC_VER | 9 | +#ifdef _MSC_VER |
| 9 | +#pragma message("Warning, overriding WinCrypt defines") | 10 | +#pragma message("Warning, overriding WinCrypt defines") |
| 10 | +#else | 11 | +#else |
| 11 | +#warning overriding WinCrypt defines | 12 | +#warning overriding WinCrypt defines |
| 12 | +#endif | 13 | +#endif |
| 14 | +#endif | ||
| 13 | +#undef PKCS7_ISSUER_AND_SERIAL | 15 | +#undef PKCS7_ISSUER_AND_SERIAL |
| 14 | +#undef PKCS7_SIGNER_INFO | 16 | +#undef PKCS7_SIGNER_INFO |
| 15 | +#endif | 17 | +#endif |
diff --git a/patches/x509.h.patch b/patches/x509.h.patch index 13686c1..f0e59b2 100644 --- a/patches/x509.h.patch +++ b/patches/x509.h.patch | |||
| @@ -1,15 +1,17 @@ | |||
| 1 | --- include/openssl/x509.h.orig 2015-07-06 13:15:15.059306046 -0700 | 1 | --- include/openssl/x509.h.orig 2015-07-06 13:15:15.059306046 -0700 |
| 2 | +++ include/openssl/x509.h 2015-07-06 13:16:10.506118278 -0700 | 2 | +++ include/openssl/x509.h 2015-07-06 13:16:10.506118278 -0700 |
| 3 | @@ -112,6 +112,17 @@ | 3 | @@ -112,6 +112,19 @@ |
| 4 | extern "C" { | 4 | extern "C" { |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | +#if defined(_WIN32) && defined(__WINCRYPT_H__) | 7 | +#if defined(_WIN32) |
| 8 | +#ifndef LIBRESSL_INTERNAL | ||
| 8 | +#ifdef _MSC_VER | 9 | +#ifdef _MSC_VER |
| 9 | +#pragma message("Warning, overriding WinCrypt defines") | 10 | +#pragma message("Warning, overriding WinCrypt defines") |
| 10 | +#else | 11 | +#else |
| 11 | +#warning overriding WinCrypt defines | 12 | +#warning overriding WinCrypt defines |
| 12 | +#endif | 13 | +#endif |
| 14 | +#endif | ||
| 13 | +#undef X509_NAME | 15 | +#undef X509_NAME |
| 14 | +#undef X509_CERT_PAIR | 16 | +#undef X509_CERT_PAIR |
| 15 | +#undef X509_EXTENSIONS | 17 | +#undef X509_EXTENSIONS |
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt new file mode 100644 index 0000000..c26f2b4 --- /dev/null +++ b/ssl/CMakeLists.txt | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | include_directories( | ||
| 2 | . | ||
| 3 | ../include | ||
| 4 | ../include/compat | ||
| 5 | ) | ||
| 6 | |||
| 7 | add_library( | ||
| 8 | ssl | ||
| 9 | |||
| 10 | bio_ssl.c | ||
| 11 | bs_ber.c | ||
| 12 | bs_cbb.c | ||
| 13 | bs_cbs.c | ||
| 14 | d1_both.c | ||
| 15 | d1_clnt.c | ||
| 16 | d1_enc.c | ||
| 17 | d1_lib.c | ||
| 18 | d1_meth.c | ||
| 19 | d1_pkt.c | ||
| 20 | d1_srtp.c | ||
| 21 | d1_srvr.c | ||
| 22 | pqueue.c | ||
| 23 | s23_clnt.c | ||
| 24 | s23_lib.c | ||
| 25 | s23_meth.c | ||
| 26 | s23_pkt.c | ||
| 27 | s23_srvr.c | ||
| 28 | s3_both.c | ||
| 29 | s3_cbc.c | ||
| 30 | s3_clnt.c | ||
| 31 | s3_enc.c | ||
| 32 | s3_lib.c | ||
| 33 | s3_meth.c | ||
| 34 | s3_pkt.c | ||
| 35 | s3_srvr.c | ||
| 36 | ssl_algs.c | ||
| 37 | ssl_asn1.c | ||
| 38 | ssl_cert.c | ||
| 39 | ssl_ciph.c | ||
| 40 | ssl_err.c | ||
| 41 | ssl_err2.c | ||
| 42 | ssl_lib.c | ||
| 43 | ssl_rsa.c | ||
| 44 | ssl_sess.c | ||
| 45 | ssl_stat.c | ||
| 46 | ssl_txt.c | ||
| 47 | t1_clnt.c | ||
| 48 | t1_enc.c | ||
| 49 | t1_lib.c | ||
| 50 | t1_meth.c | ||
| 51 | t1_reneg.c | ||
| 52 | t1_srvr.c | ||
| 53 | ) | ||
diff --git a/ssl/Makefile.am b/ssl/Makefile.am index db60775..6c36cf2 100644 --- a/ssl/Makefile.am +++ b/ssl/Makefile.am | |||
| @@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.am.common | |||
| 3 | lib_LTLIBRARIES = libssl.la | 3 | lib_LTLIBRARIES = libssl.la |
| 4 | 4 | ||
| 5 | EXTRA_DIST = VERSION | 5 | EXTRA_DIST = VERSION |
| 6 | EXTRA_DIST += CMakeLists.txt | ||
| 6 | 7 | ||
| 7 | libssl_la_LDFLAGS = -version-info @LIBSSL_VERSION@ -no-undefined | 8 | libssl_la_LDFLAGS = -version-info @LIBSSL_VERSION@ -no-undefined |
| 8 | libssl_la_LIBADD = ../crypto/libcrypto.la | 9 | libssl_la_LIBADD = ../crypto/libcrypto.la |
diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt new file mode 100644 index 0000000..3e61844 --- /dev/null +++ b/tls/CMakeLists.txt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | include_directories( | ||
| 2 | . | ||
| 3 | ../include | ||
| 4 | ../include/compat | ||
| 5 | ) | ||
| 6 | |||
| 7 | set( | ||
| 8 | TLS_SRC | ||
| 9 | tls.c | ||
| 10 | tls_client.c | ||
| 11 | tls_config.c | ||
| 12 | tls_server.c | ||
| 13 | tls_util.c | ||
| 14 | tls_verify.c | ||
| 15 | ) | ||
| 16 | |||
| 17 | |||
| 18 | if(NOT HAVE_STRCASECMP) | ||
| 19 | set(TLS_SRC ${TLS_SRC} strsep.c) | ||
| 20 | endif() | ||
| 21 | |||
| 22 | add_library(tls ${TLS_SRC}) | ||
diff --git a/tls/Makefile.am b/tls/Makefile.am index e8c4713..82ec211 100644 --- a/tls/Makefile.am +++ b/tls/Makefile.am | |||
| @@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.am.common | |||
| 3 | lib_LTLIBRARIES = libtls.la | 3 | lib_LTLIBRARIES = libtls.la |
| 4 | 4 | ||
| 5 | EXTRA_DIST = VERSION | 5 | EXTRA_DIST = VERSION |
| 6 | EXTRA_DIST += CMakeLists.txt | ||
| 6 | 7 | ||
| 7 | libtls_la_LDFLAGS = -version-info @LIBTLS_VERSION@ -no-undefined | 8 | libtls_la_LDFLAGS = -version-info @LIBTLS_VERSION@ -no-undefined |
| 8 | libtls_la_LIBADD = ../crypto/libcrypto.la ../ssl/libssl.la $(PLATFORM_LDADD) | 9 | libtls_la_LIBADD = ../crypto/libcrypto.la ../ssl/libssl.la $(PLATFORM_LDADD) |
| @@ -70,6 +70,7 @@ for i in crypto/compat libtls-standalone/compat; do | |||
| 70 | $libc_src/crypt/chacha_private.h \ | 70 | $libc_src/crypt/chacha_private.h \ |
| 71 | $libc_src/string/explicit_bzero.c \ | 71 | $libc_src/string/explicit_bzero.c \ |
| 72 | $libc_src/stdlib/reallocarray.c \ | 72 | $libc_src/stdlib/reallocarray.c \ |
| 73 | $libc_src/string/strcasecmp.c \ | ||
| 73 | $libc_src/string/strlcpy.c \ | 74 | $libc_src/string/strlcpy.c \ |
| 74 | $libc_src/string/strlcat.c \ | 75 | $libc_src/string/strlcat.c \ |
| 75 | $libc_src/string/strndup.c \ | 76 | $libc_src/string/strndup.c \ |
| @@ -81,9 +82,9 @@ for i in crypto/compat libtls-standalone/compat; do | |||
| 81 | $i | 82 | $i |
| 82 | done | 83 | done |
| 83 | 84 | ||
| 84 | $CP include/stdlib.h \ | 85 | $CP include/compat/stdlib.h \ |
| 85 | include/string.h \ | 86 | include/compat/string.h \ |
| 86 | include/unistd.h \ | 87 | include/compat/unistd.h \ |
| 87 | libtls-standalone/include | 88 | libtls-standalone/include |
| 88 | 89 | ||
| 89 | $CP crypto/compat/arc4random*.h \ | 90 | $CP crypto/compat/arc4random*.h \ |
| @@ -210,10 +211,6 @@ for i in `awk '/SOURCES|HEADERS/ { print $3 }' apps/Makefile.am` ; do | |||
| 210 | $CP $openssl_app_src/$i apps | 211 | $CP $openssl_app_src/$i apps |
| 211 | fi | 212 | fi |
| 212 | done | 213 | done |
| 213 | patch -p0 < patches/openssl.c.patch | ||
| 214 | patch -p0 < patches/ossl_typ.h.patch | ||
| 215 | patch -p0 < patches/pkcs7.h.patch | ||
| 216 | patch -p0 < patches/x509.h.patch | ||
| 217 | 214 | ||
| 218 | # copy libssl source | 215 | # copy libssl source |
| 219 | echo "copying libssl source" | 216 | echo "copying libssl source" |
| @@ -276,6 +273,11 @@ add_man_links() { | |||
| 276 | done | 273 | done |
| 277 | } | 274 | } |
| 278 | 275 | ||
| 276 | # apply local patches (Windows support) | ||
| 277 | for i in patches/*.patch; do | ||
| 278 | patch -p0 < $i | ||
| 279 | done | ||
| 280 | |||
| 279 | # copy manpages | 281 | # copy manpages |
| 280 | echo "copying manpages" | 282 | echo "copying manpages" |
| 281 | echo dist_man_MANS= > man/Makefile.am | 283 | echo dist_man_MANS= > man/Makefile.am |
