Commit Graph

139 Commits

Author SHA1 Message Date
Brent Cook
40974784c0 add constant_time_locl.h 2016-05-04 08:47:55 -05:00
kinichiro
bda62f7fe4 add cmake build options
- add cmake build options as configure provides
  * -DENABLE_ASM (default ON)
  * -DENABLE_EXTRATESTS (default OFF)
  * -DENABLE_NC (default OFF)
  * -DOPENSSLDIR (default ${CMAKE_INSTALL_PREFIX}/etc/ssl)

- add biotest and pidwraptest if ENABLE_EXTRATESTS is ON

- add compiler flag `-fno-common` if CMAKE_SYSTEM_NAME is Darwin
  to prevent link error Undefined symbols "_OPENSSL_ia32cap_P"
2016-04-14 15:16:52 +09:00
Brent Cook
752ad82d33 Land #188, add ASM support for cmake builds 2016-04-09 12:08:26 -05:00
kinichiro
2510a5e6f9 modify cmake to build nc
- modify structure of CMakeLists.txt under apps/
  * move apps/CMakeLists.txt to apps/openssl/ since this is for openssl build
  * create new apps/nc/CMakeLists.txt for nc build
  * modify apps/CMakeLists.txt just add_subdirectory()

- add checking and compile of arc4random_uniform()

- add installing man files, openssl.1 and nc.1
2016-04-09 12:06:40 -05:00
kinichiro
e1f8a1e160 modify cmake to build ASM
- add functionality compiling ASM with cmake
- to enable ASM, `cmake -DENABLE_ASM=on ..`
2016-04-08 15:09:07 +09:00
kinichiro
3207606f11 fix cmake on HP-UX
- CMakeLists.txt
  * add OS specific compiler flags and library
  * add checking size of time_t
  * add checking memmem()

- tests/CMakeLists.txt
  * add if(HAVE_MEMMEM) for explicit_bzero
  * add checking SMALL_TIME_T for rfc5280time

- crypto/CMakeLists.txt
  * add getentropy_hpux.c

- tls/CMakeLists.txt
  * fix checking strsep
2016-04-04 14:27:43 +09:00
Brent Cook
3af1387b18 Revert back to GetStdHandle, since it works fine with pipes.
Also include the formerly-missing NULL check, since this can fail in two
ways.
2015-12-11 09:22:12 -06:00
Brent Cook
bd8fe5868f include stdint.h uint*_t 2015-12-11 09:21:43 -06:00
Anthony Novatsis
5727d3274e Replace STDIN_FILENO with _fileno
Replace STDIN_FILENO with _fileno as STDIN_FILENO results in compile
errors with Visual Studio 2015 (using CMake).
2015-12-11 16:32:00 +11:00
Brent Cook
905e2a3b80 refresh nc(1) support 2015-12-06 23:32:18 -06:00
Brent Cook
afcc027da7 only set the console mode if stdin is a console (not a pipe)
This allows piping commands and running from a cygwin console.
2015-12-06 16:49:01 -06:00
Brent Cook
75ef5bb160 wrap gets on Windows, replacing '\r\n' with '\n' 2015-12-05 13:58:37 -06:00
Brent Cook
9574b6c8ec do not link libcompatnoopt if it is unneeded/built
from andy-js on github, fix #158
2015-11-22 17:31:51 -06:00
Brent Cook
9be9055791 remove a_gen/utctm.c for cmake 2015-10-21 22:19:09 -05:00
Brent Cook
3f79a49dd2 check bounds before casting (long long) to time_t 2015-10-21 22:17:13 -05:00
Brent Cook
959241fe88 remove a_gen/utctm.c 2015-10-21 21:39:59 -05:00
Brent Cook
0197a58969 Windows compatibility fixes
VS2013 has trouble with relative include paths for apps/openssl, so move
certhash_win/apps_win.c back to apps/openssl.

gmtime_r on mingw64 fails with negative time_t, override

gmtime_s fails all of the time unit tests, override

SHUT_RD/WR are defined in newer mingw64 headers, check before overriding
2015-10-18 09:28:10 -05:00
Brent Cook
a45e38e962 disable some tests with 32-bit time_t systems
Also disable use of _mkgmtime, it does not produce correct results.
2015-10-17 22:57:59 -05:00
Brent Cook
dadeeb0a2e check for timegm in cmake builds 2015-10-15 14:32:16 -05:00
Brent Cook
cac089b5d6 make internal functions static 2015-10-15 14:32:02 -05:00
Brent Cook
c02436645d use timegm from musl 2015-10-15 14:26:24 -05:00
Brent Cook
4298ac9305 include timegm fallback 2015-10-15 09:16:38 -05:00
Jeremy Huddleston Sequoia
448645d479 Use bundled headers instead of installed headers when building
The build system incorrectly set include directives in AM_CFLAGS which
causes them to be placed after the configured CPPFLAGS.  Thus, if
a user or packaging system sets CPPFLAGS to a location that has
libressl or openssl headers installed, they will be used instead
of the bundled versions.  This corrects that issue by setting up
the variables correctly.

https://github.com/libressl-portable/portable/issues/150

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2015-10-14 16:33:39 -05:00
Brent Cook
047926e06f updates for ASN.1 time handling 2015-10-06 06:21:17 -05:00
Brent Cook
4ce5342e86 remove SHA-0 from cmake builds 2015-09-17 05:39:55 -05:00
Brent Cook
f05cb999a6 final bit of SHA-0 removal 2015-09-17 05:30:24 -05:00
Brent Cook
9c55d0b851 remove SHA-0 2015-09-17 05:15:23 -05:00
Brent Cook
2cb6d19e10 remove ecdh/ech_ossl.c 2015-09-13 19:08:12 -05:00
Brent Cook
eeb286af5a fix spelling of OPENSSL_cleanse 2015-09-13 09:31:41 -05:00
Brent Cook
4bb70680a0 ech_ossl.h is gone 2015-09-13 09:03:04 -05:00
Brent Cook
adfb2bf722 Do not build lib-objects targets if we are just building static libs.
This confuses some cmake targets.
2015-09-09 06:03:52 -05:00
Brent Cook
9903a26661 distribute strcasecmp.c 2015-09-07 01:28:29 -05:00
Brent Cook
ca56c332e3 disable shared CMake builds for OS X / Windows for now 2015-09-07 01:05:33 -05:00
Jeff Davey
5461dea7f1 Add install targets and shared libraries to CMake 2015-08-18 13:20:19 -06:00
Brent Cook
13d910c11e disable explicit_bzero optimizations with CMake builds 2015-08-03 07:37:24 -05:00
Brent Cook
c66d80a438 add win32-specific explicit_bzero implementation 2015-08-03 06:56:59 -05:00
Brent Cook
6527c32039 initial Linux cmake suppport
tested on Ubuntu 14.04
2015-08-01 05:33:19 -05:00
Brent Cook
1828bcb9bf don't build eng_rsax.c anymore 2015-07-21 20:00:42 -05:00
Brent Cook
9d5eb631e3 move sleep shim to posix_win.c 2015-07-21 12:52:29 -06:00
Brent Cook
63161e85dc add initial build for arc4random/getentropy fallbacks 2015-07-21 12:52:14 -06:00
Brent Cook
5d8a1cf715 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.
2015-07-21 12:08:18 -05:00
Brent Cook
792a5acb67 eng_rsax is gone 2015-07-20 01:08:01 -05:00
Brent Cook
ddeb740426 win32 openssl CLI: preserve original echo state
Mirror the patch to ui_openssl.c, also fix the broken conditional that
made it not actually turn off echo in the first place.

ok guenther@
2015-07-16 10:27:57 -05:00
Brent Cook
db974c34e9 fixup how OPENSSLDIR is derived and expanded
As per
http://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html
we should not try to expand variables like sysconfdir in the
configure script, but rather derive the correct value in the Makefiles
instead. This fixes missing expansions as the preprocessor define.
2015-07-15 20:02:38 -05:00
Brent Cook
4cffda193b build libcrypto with -DLIBRESSL_INTERNAL
Since libcrypto defines its own CPPFLAGS, we need to set this for
libcrypto specifically.
2015-07-15 19:17:27 -05:00
Brent Cook
545454277a add check for inet_pton, nudge minimum win32 compat to 0x0501 2015-07-02 00:19:53 -05:00
Brent Cook
b9f1b83a79 update for mdc2 removal 2015-06-20 10:40:04 -05:00
Brent Cook
bc7b93470f add a missing header and fix typo in windows posix layer 2015-06-13 21:43:55 -05:00
Brent Cook
b4a6a61513 refactor win32 shims into posix_win.c
this also adds a rename shim that allows overwrites
2015-06-05 04:50:18 -05:00
Brent Cook
8dedbb4b2b add Makefile.am.arc4random 2015-05-23 19:27:57 -05:00
Brent Cook
769d58e494 further refactoring, working libtls-standalone 2015-05-23 19:27:57 -05:00
Brent Cook
3096ab0e45 remove issetuigid wrappers, now that all getenv calls are gone.
From deraadt@ upstream:

Remove all getenv() calls, especially those wrapped by issetugid().
getenv()'s wrapped by issetugid() are safe, but issetugid() is ...
difficult to impliment on many operating systems.  By accident, a grand
experiment was run over the last year, where issetugid() returned 1 (the
safe value) on a few operating systems.  Noone noticed & complained that
certain environment variables were not working.......
2015-04-14 07:55:23 -05:00
Brent Cook
fe3f7fc636 Add experimental AIX support.
This includes a WIP failsafe issetugid for now, while research continues
on the proper way to do this in a race-free fashion in AIX.
2015-03-31 09:25:21 -05:00
Brent Cook
ad2a38ab4a rework CFLAGS/CPPFLAGS settings during configuration
Move define adjustments to CPPFLAGS.
Adjust user CFLAGS directly, do not override during configuration.
USER_CFLAGS is not necessary to build libcompat_noopt correctly.
2015-03-22 07:43:55 -05:00
Brent Cook
a859b93ff5 disable system issetugid on OS X since it is not fork-safe
Noticed while testing similar code for AIX.
ok beck@
2015-02-17 18:15:17 -06:00
Brent Cook
adc416e922 remove getuid/getgid fallbacks from hp-ux issetugid emulation
Fail closed if we cannot obtain the process flags. Noticed while looking
at a similar function for AIX.
2015-02-16 22:30:27 -06:00
Brent Cook
9de5b8a963 c_all* have merged into c_all.c 2015-02-08 19:40:03 -06:00
Brent Cook
d88e90def9 add by_mem.c for X509_STORE_load_mem 2015-01-26 10:20:26 -06:00
Brent Cook
a223365127 add NetBSD shims for arc4random
The current NetBSD release, 6.1.5, fails to reseed arc4random fork. Work
around it by providing arc4random/getentropy shims. Revisit when NetBSD
7 is available.
2015-01-21 06:14:24 -06:00
kinichiro
0308b63cbf Add support for HP-UX
tested on: HP-UX 11.31 ia64,
               gcc 4.7.1(HP AllianceOne version)
               gcc 4.2.3(http://hpux.connect.org.uk)
	       HP C/aC++

HP-UX defaults to use LP32 and it treats long as 32 bit (= 4 bytes).
This build forces LP64 for treating long as 64 bit.
2015-01-06 17:47:16 -06:00
Brent Cook
d2342f36bc allow Windows DLLs to be built
based on a patch from Jan Engelhardt
2014-12-14 16:59:35 -06:00
Brent Cook
9c685415ab disable inline assembly on Windows for now
There are issues building with inline assembly on Windows 64-bit.
2014-12-07 18:02:06 -06:00
Brent Cook
03cd45e2c7 Enable optimized crypto operations for x86_64
This adds initial support for assembly crypto acceleration on x86_64 for
ELF (Linux, *BSD, Solaris) and Mach-O (OS-X) systems.

The build method is a little different than OpenSSL and OpenBSD.  All
the .s files are generated ahead of time when the tarball is generated,
so there are no complicated makefile rules at configure/build time. This
also means the builds are faster and perl is not required on the build
system.

Thanks to Wouter Clarie for providing the initial cleanup and patch
that this is based on.
2014-12-07 16:26:28 -06:00
Brent Cook
976f64d932 read all library versions directly from files
This makes building and testing easier because the library Makefile.am
files are use directly rather than as templates. Thanks to Wouter Clarie
for the idea.
2014-12-06 18:59:25 -06:00
Brent Cook
29804a73cc simplify packaging for libcrypto.
Remove a lot of complex shell code. Upstream churn has slowed down, so
it is now easier to maintain this directly as automake files. This is
also needed to start integrating CPU-specific acceleration support.

Since we are deriving the copy list from the Makefile.am files, we can
now get rid of copy_src/copy_crypto.
2014-12-06 17:48:03 -06:00
Brent Cook
58fcd3c39c Add conditional compilation for windows and posix functions.
This adds a Windows-specific versions of several symbols from libcrypto
and openssl(1).
2014-12-03 17:02:29 -06:00
Brent Cook
2103690cbf improve readability of generated Makefile.am files 2014-11-23 08:33:56 -06:00
宋冬生
648e913627 Use _WIN32 instead of __WIN32.
ok bcook@
2014-11-18 07:41:08 -06:00
Brent Cook
0aeb93b9fc override native arc4random_buf on FreeBSD
The FreeBSD-native arc4random_buf implementation falls back to weak
sources of entropy if the sysctl fails. Remove these dangerous fallbacks
by overriding locally.

Unfortunately, pthread_atfork() is broken on FreeBSD (at least 9 and 10)
if a program does not link to -lthr. Callbacks registered with
pthread_atfork() simply fail silently. So, it is not always possible to
detect a PID wraparound. I wish we could do better.

This improves arc4random_buf's safety compared to the native FreeBSD
implementation. Tested on FreeBSD 9 and 10.

ok beck@ deraadt@
2014-11-03 01:19:36 -06:00
Brent Cook
a2373f7007 wrap arc4random header
ok @doug
2014-10-30 19:15:20 -05:00
Brent Cook
a4cc953911 Improve and simplify function and header detection logic.
Simplify autoconf checks by using AC_CHECK_FUNCS/HEADERS.
Clarify some ambiguous dependencies around strnlen/strndup.
Unconditionally enable pidwraptest for all arc4random implementations.
Remove HAVE_VASPRINTF conditional, since asprintf requires vasprintf.

ok @doug
2014-10-30 19:15:11 -05:00
Brent Cook
00b51d5c25 conditionally build strnlen if needed.
it is only used by strndup

prodded by Sortie@
2014-08-02 21:59:36 -05:00
Brent Cook
b9ff0728e1 harmonize asprintf with OpenSSH
* use the original name for the file from OpenSSH (remove duplicate version)
 * add va_copy/__va_copy checks to configure
 * incorporate proposed fixes to openssh version:
   + include more system headers directly for various definitions
   + limit the scope of va_copy/va_end to their affected vsnprintf calls
   + simplify error handling, removing a dead assignment
2014-07-30 06:53:02 -05:00
Brent Cook
a07e337020 include comment on windows services 2014-07-29 18:21:58 -05:00
Brent Cook
983103b0db stub win32 issetugid implementation
ok deraadt@ beck@
2014-07-29 11:17:44 -05:00
Brent Cook
d328203f63 produce a error if platform has no arc4random hook
ok deraadt@ beck@
2014-07-29 11:17:27 -05:00
Brent Cook
35e2d8d048 add asprintf / vasprintf from OpenSSH portable
ok deraadt@ beck@
2014-07-29 11:17:22 -05:00
Brent Cook
0a74a4d464 add strndup/strnlen compat functions from OpenBSD 2014-07-28 07:07:23 -05:00
Brent Cook
6383a0722c remove thread_private.h, no longer needed 2014-07-27 06:09:51 -05:00
Brent Cook
f425f564d5 test for and use system explicit_bzero if it exists
ok beck@ guenther@
2014-07-21 19:54:07 -05:00
Brent Cook
edebb7a66e remove thread_private.h defines, moved to arc4random_*.h 2014-07-19 10:49:08 -05:00
Brent Cook
1b1bce16b1 update to newly-refactored arc4random compatibility shims
the thread-private bits can move next

ok beck@
2014-07-18 09:19:23 -05:00
Brent Cook
d697fdb4af initial underpinnings for mingw/cross compilation support
Use canonical host rather than target so that this works:
 CC=i686-w64-mingw32-gcc ./configure --host=i686-w64-mingw32

 Conditionally compile Linux issetugid compatibility function

ok beck@
2014-07-18 09:19:17 -05:00
Brent Cook
32d9eeeecf register the atfork handler from arc4random
From kettenis@

People have suggested using pthread_atfork(3) before, but discarded
the idea because it involves linking with -lpthread, which has other
undesirable consequences.  However:

* Most systems actually have pthread_atfork(3) in libc.  I verified
  this on OS X and Solaris.  I believe this is the case on Linux
  systems that use musl as well.

* On Linux systems that use glibc, this isn't the case.  However,
  those systems have __register_atfork(3), which is fully documented
  in the "Linux Standard Base Core Specification".

ok kettenis@ deraadt@ beck@
2014-07-15 14:50:05 -05:00
Brent Cook
65944782c3 add platform libraries to libcompat's LIBADD list
ok beck@
2014-07-12 03:34:08 -05:00
Bob Beck
c1f7374df0 We're probably gonna need this for solaris 10 2014-07-12 09:15:11 -06:00
Brent Cook
8b125f31bb build strtonum directly into apps/openssl
it is not needed as a library export

ok beck@
2014-07-11 04:47:03 -05:00
Charlie Root
abe7bee360 Make things build again - add some missing headers
ok bcook@
2014-07-10 08:36:47 -06:00
Brent Cook
2b6dbc39ef initial top-level import of subdirectories 2014-07-10 06:22:54 -05:00