aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore172
-rw-r--r--apps/Makefile.am.tpl11
-rw-r--r--crypto/Makefile.am.tpl69
-rw-r--r--crypto/compat/issetugid_linux.c47
-rw-r--r--crypto/compat/thread_private.h6
-rw-r--r--include/Makefile.am3
-rw-r--r--include/machine/endian.h14
-rw-r--r--include/openssl/Makefile.am.tpl5
-rw-r--r--include/stdlib.h16
-rw-r--r--include/string.h25
-rw-r--r--include/sys/types.h13
-rw-r--r--include/unistd.h9
-rw-r--r--ssl/Makefile.am.tpl9
-rw-r--r--tests/Makefile.am.tpl8
-rwxr-xr-xtests/aeadtest.sh3
-rwxr-xr-xtests/arc4randomforktest.sh6
-rwxr-xr-xtests/evptest.sh3
-rwxr-xr-xtests/pq_test.sh3
-rwxr-xr-xtests/ssltest.sh4
19 files changed, 426 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01afda2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,172 @@
1### These files shkuld get ignored no matter where they appear.
2
3# Editors leave these lying around
4\#*\#
5.#*
6*~
7*.swp
8
9# C stuff
10*.o
11
12# Windows stuff
13*.obj
14*.exe
15*.lib
16
17# Patch leaves these lying arround
18*.orig
19*.rej
20
21# gcov stuff
22*.gcno
23*.gcov
24*.gcda
25
26# Autotools stuff
27.deps
28.dirstamp
29Makefile
30Makefile.in
31
32# Libtool stuff
33.libs
34*.lo
35*.la
36
37# tests
38test-driver
39*.log
40*.trs
41tests/aes_wrap*
42tests/arc4random_fork*
43tests/explicit_bzero*
44tests/mont*
45tests/timingsafe*
46tests/*test*.c
47tests/*.pem
48tests/testssl
49tests/*.txt
50
51# ctags stuff
52TAGS
53
54## The initial / makes these files only get ignored in particular directories.
55/autom4te.cache
56
57# Libtool adds these, at least sometimes
58INSTALL
59/m4/libtool.m4
60/m4/ltoptions.m4
61/m4/ltsugar.m4
62/m4/ltversion.m4
63/m4/lt~obsolete.m4
64
65/aclocal.m4
66/compile
67/doxygen
68/config.guess
69/config.log
70/config.status
71/config.sub
72/configure
73/depcomp
74/config.h
75/config.h.in
76/install-sh
77/libtool
78/ltmain.sh
79/missing
80/stamp-h1
81/stamp-h2
82
83crypto/Makefile.am
84include/openssl/Makefile.am
85ssl/Makefile.am
86apps/Makefile.am
87tests/Makefile.am
88
89ssl/*.c
90ssl/*.h
91include/pqueue.h
92include/openssl/*.h
93include/openssl/*.he
94apps/*.c
95apps/*.h
96apps/*.cnf
97apps/openssl
98
99crypto/compat/arc4random.c
100crypto/compat/chacha_private.h
101crypto/compat/explicit_bzero.c
102crypto/compat/getentropy_*.c
103crypto/compat/reallocarray.c
104crypto/compat/strlcat.c
105crypto/compat/strlcpy.c
106crypto/compat/strtonum.c
107crypto/compat/timingsafe_bcmp.c
108crypto/compat/timingsafe_memcmp.c
109
110crypto/aes/
111crypto/asn1/
112crypto/bf/
113crypto/bio/
114crypto/bn/
115crypto/buffer/
116crypto/cast/
117crypto/chacha/
118crypto/cmac/
119crypto/comp/
120crypto/conf/
121crypto/cpt_err.c
122crypto/cryptlib.c
123crypto/cryptlib.h
124crypto/cversion.c
125crypto/des/
126crypto/dh/
127crypto/dsa/
128crypto/dso/
129crypto/ec/
130crypto/ecdh/
131crypto/ecdsa/
132crypto/engine/
133crypto/err/
134crypto/evp/
135crypto/ex_data.c
136crypto/hmac/
137crypto/idea/
138crypto/krb5/
139crypto/lhash/
140crypto/malloc-wrapper.c
141crypto/md32_common.h
142crypto/md4/
143crypto/md5/
144crypto/mdc2/
145crypto/mem_clr.c
146crypto/mem_dbg.c
147crypto/modes/
148crypto/o_init.c
149crypto/o_str.c
150crypto/o_time.c
151crypto/o_time.h
152crypto/objects
153crypto/ocsp/
154crypto/pem/
155crypto/pkcs12/
156crypto/pkcs7/
157crypto/poly1305/
158crypto/pqueue/
159crypto/rand/
160crypto/rc2/
161crypto/rc4/
162crypto/ripemd/
163crypto/rsa/
164crypto/sha/
165crypto/stack/
166crypto/ts/
167crypto/txt_db/
168crypto/ui/
169crypto/whrlpool/
170crypto/x509/
171crypto/x509v3/
172
diff --git a/apps/Makefile.am.tpl b/apps/Makefile.am.tpl
new file mode 100644
index 0000000..ea6174d
--- /dev/null
+++ b/apps/Makefile.am.tpl
@@ -0,0 +1,11 @@
1include $(top_srcdir)/Makefile.am.common
2
3bin_PROGRAMS = openssl
4
5openssl_CFLAGS = $(USER_CFLAGS)
6openssl_LDADD = $(PLATFORM_LDADD)
7openssl_LDADD += $(top_builddir)/crypto/libcrypto.la
8openssl_LDADD += $(top_builddir)/ssl/libssl.la
9
10openssl_SOURCES =
11noinst_HEADERS =
diff --git a/crypto/Makefile.am.tpl b/crypto/Makefile.am.tpl
new file mode 100644
index 0000000..6f94fdf
--- /dev/null
+++ b/crypto/Makefile.am.tpl
@@ -0,0 +1,69 @@
1include $(top_srcdir)/Makefile.am.common
2
3AM_CPPFLAGS += -I$(top_srcdir)/crypto/asn1
4AM_CPPFLAGS += -I$(top_srcdir)/crypto/evp
5AM_CPPFLAGS += -I$(top_srcdir)/crypto/modes
6
7lib_LTLIBRARIES = libcrypto.la
8
9libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la
10libcrypto_la_LDFLAGS = -version-info libcrypto-version
11libcrypto_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) -DOPENSSL_NO_HW_PADLOCK
12
13noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la
14
15# compatibility functions that need to be built without optimizations
16libcompatnoopt_la_CFLAGS = -O0
17libcompatnoopt_la_SOURCES = compat/explicit_bzero.c
18
19# other compatibility functions
20libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
21libcompat_la_SOURCES =
22
23if NO_STRLCAT
24libcompat_la_SOURCES += compat/strlcat.c
25endif
26
27if NO_STRLCPY
28libcompat_la_SOURCES += compat/strlcpy.c
29endif
30
31if NO_REALLOCARRAY
32libcompat_la_SOURCES += compat/reallocarray.c
33endif
34
35if NO_TIMINGSAFE_MEMCMP
36libcompat_la_SOURCES += compat/timingsafe_memcmp.c
37endif
38
39if NO_TIMINGSAFE_BCMP
40libcompat_la_SOURCES += compat/timingsafe_bcmp.c
41endif
42
43if NO_ARC4RANDOM_BUF
44libcompat_la_SOURCES += compat/arc4random.c
45
46if NO_GETENTROPY
47if TARGET_LINUX
48libcompat_la_SOURCES += compat/getentropy_linux.c
49endif
50if TARGET_DARWIN
51libcompat_la_SOURCES += compat/getentropy_osx.c
52endif
53if TARGET_SOLARIS
54libcompat_la_SOURCES += compat/getentropy_solaris.c
55endif
56endif
57
58endif
59
60if NO_ISSETUGID
61libcompat_la_SOURCES += compat/issetugid_linux.c
62endif
63if NO_STRTONUM
64libcompat_la_SOURCES += compat/strtonum.c
65endif
66
67noinst_HEADERS = des/ncbc_enc.c
68libcrypto_la_SOURCES =
69EXTRA_libcrypto_la_SOURCES =
diff --git a/crypto/compat/issetugid_linux.c b/crypto/compat/issetugid_linux.c
new file mode 100644
index 0000000..669edce
--- /dev/null
+++ b/crypto/compat/issetugid_linux.c
@@ -0,0 +1,47 @@
1/*
2 * issetugid implementation for Linux
3 * Public domain
4 */
5
6#include <errno.h>
7#include <gnu/libc-version.h>
8#include <string.h>
9#include <sys/types.h>
10#include <unistd.h>
11
12/*
13 * Linux-specific glibc 2.16+ interface for determining if a process was
14 * launched setuid/setgid or with additional capabilities.
15 */
16#ifdef HAVE_GETAUXVAL
17#include <sys/auxv.h>
18#endif
19
20int issetugid(void)
21{
22#ifdef HAVE_GETAUXVAL
23 /*
24 * The API for glibc < 2.19 does not indicate if there is an error with
25 * getauxval. While it should not be the case that any 2.6 or greater
26 * kernel ever does not supply AT_SECURE, an emulated software environment
27 * might rewrite the aux vector.
28 *
29 * See https://sourceware.org/bugzilla/show_bug.cgi?id=15846
30 *
31 * Perhaps this code should just read the aux vector itself, so we have
32 * backward-compatibility and error handling in older glibc versions.
33 * info: http://lwn.net/Articles/519085/
34 *
35 */
36 const char *glcv = gnu_get_libc_version();
37 if (strverscmp(glcv, "2.19") >= 0) {
38 errno = 0;
39 if (getauxval(AT_SECURE) == 0) {
40 if (errno != ENOENT) {
41 return 0;
42 }
43 }
44 }
45#endif
46 return 1;
47}
diff --git a/crypto/compat/thread_private.h b/crypto/compat/thread_private.h
new file mode 100644
index 0000000..3286a7c
--- /dev/null
+++ b/crypto/compat/thread_private.h
@@ -0,0 +1,6 @@
1#include <pthread.h>
2
3static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER;
4
5#define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx)
6#define _ARC4_UNLOCK() pthread_mutex_unlock(&arc4random_mtx)
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 0000000..f2860a4
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,3 @@
1SUBDIRS = openssl
2
3noinst_HEADERS = pqueue.h stdlib.h string.h machine/endian.h
diff --git a/include/machine/endian.h b/include/machine/endian.h
new file mode 100644
index 0000000..4d96a6d
--- /dev/null
+++ b/include/machine/endian.h
@@ -0,0 +1,14 @@
1#ifndef _COMPAT_BYTE_ORDER_H_
2#define _COMPAT_BYTE_ORDER_H_
3
4#ifdef __linux__
5#include <endian.h>
6#else
7#ifdef __sun
8#include <arpa/nameser_compat.h>
9#else
10#include_next <machine/endian.h>
11#endif
12#endif
13
14#endif
diff --git a/include/openssl/Makefile.am.tpl b/include/openssl/Makefile.am.tpl
new file mode 100644
index 0000000..1375956
--- /dev/null
+++ b/include/openssl/Makefile.am.tpl
@@ -0,0 +1,5 @@
1include $(top_srcdir)/Makefile.am.common
2
3opensslincludedir=$(includedir)/openssl
4
5opensslinclude_HEADERS =
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..6c2de93
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,16 @@
1#include_next <stdlib.h>
2
3#ifndef LIBCRYPTOCOMPAT_STDLIB_H
4#define LIBCRYPTOCOMPAT_STDLIB_H
5
6#include <sys/stat.h>
7#include <sys/time.h>
8#include <stdint.h>
9
10uint32_t arc4random(void);
11void arc4random_buf(void *_buf, size_t n);
12void *reallocarray(void *, size_t, size_t);
13long long strtonum(const char *nptr, long long minval,
14 long long maxval, const char **errstr);
15
16#endif
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..acdde6c
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,25 @@
1#include_next <string.h>
2
3#ifndef LIBCRYPTOCOMPAT_STRING_H
4#define LIBCRYPTOCOMPAT_STRING_H
5
6#include <sys/types.h>
7
8#ifdef __sun
9/* Some functions historically defined in string.h were placed in strings.h by
10 * SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris.
11 */
12#include <strings.h>
13#endif
14
15size_t strlcpy(char *dst, const char *src, size_t siz);
16
17size_t strlcat(char *dst, const char *src, size_t siz);
18
19void explicit_bzero(void *, size_t);
20
21int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
22
23int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
24
25#endif
diff --git a/include/sys/types.h b/include/sys/types.h
new file mode 100644
index 0000000..05fc05b
--- /dev/null
+++ b/include/sys/types.h
@@ -0,0 +1,13 @@
1#include_next <sys/types.h>
2
3#ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H
4#define LIBCRYPTOCOMPAT_SYS_TYPES_H
5
6#include <stdint.h>
7
8#ifdef __sun
9typedef uint8_t u_int8_t;
10typedef uint32_t u_int32_t;
11#endif
12
13#endif
diff --git a/include/unistd.h b/include/unistd.h
new file mode 100644
index 0000000..ae82b95
--- /dev/null
+++ b/include/unistd.h
@@ -0,0 +1,9 @@
1#include_next <unistd.h>
2
3#ifndef LIBCRYPTOCOMPAT_UNISTD_H
4#define LIBCRYPTOCOMPAT_UNISTD_H
5
6int getentropy(void *buf, size_t buflen);
7int issetugid(void);
8
9#endif
diff --git a/ssl/Makefile.am.tpl b/ssl/Makefile.am.tpl
new file mode 100644
index 0000000..16caa92
--- /dev/null
+++ b/ssl/Makefile.am.tpl
@@ -0,0 +1,9 @@
1include $(top_srcdir)/Makefile.am.common
2
3lib_LTLIBRARIES = libssl.la
4
5libssl_la_LDFLAGS = -version-info libssl-version
6
7libssl_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
8libssl_la_SOURCES =
9noinst_HEADERS =
diff --git a/tests/Makefile.am.tpl b/tests/Makefile.am.tpl
new file mode 100644
index 0000000..0b9ae4c
--- /dev/null
+++ b/tests/Makefile.am.tpl
@@ -0,0 +1,8 @@
1include $(top_srcdir)/Makefile.am.common
2
3AM_CPPFLAGS += -I $(top_srcdir)/crypto/modes
4AM_CPPFLAGS += -I $(top_srcdir)/crypto/asn1
5
6TESTS =
7check_PROGRAMS =
8EXTRA_DIST =
diff --git a/tests/aeadtest.sh b/tests/aeadtest.sh
new file mode 100755
index 0000000..d51dd29
--- /dev/null
+++ b/tests/aeadtest.sh
@@ -0,0 +1,3 @@
1#!/bin/sh
2set -e
3./aeadtest $srcdir/aeadtests.txt
diff --git a/tests/arc4randomforktest.sh b/tests/arc4randomforktest.sh
new file mode 100755
index 0000000..fe03068
--- /dev/null
+++ b/tests/arc4randomforktest.sh
@@ -0,0 +1,6 @@
1#!/bin/sh
2set -e
3./arc4randomforktest
4./arc4randomforktest -b
5./arc4randomforktest -p
6./arc4randomforktest -bp
diff --git a/tests/evptest.sh b/tests/evptest.sh
new file mode 100755
index 0000000..8e1d106
--- /dev/null
+++ b/tests/evptest.sh
@@ -0,0 +1,3 @@
1#!/bin/sh
2set -e
3./evptest $srcdir/evptests.txt
diff --git a/tests/pq_test.sh b/tests/pq_test.sh
new file mode 100755
index 0000000..35c4dcb
--- /dev/null
+++ b/tests/pq_test.sh
@@ -0,0 +1,3 @@
1#!/bin/sh
2set -e
3./pq_test | cmp $srcdir/pq_expected.txt /dev/stdin
diff --git a/tests/ssltest.sh b/tests/ssltest.sh
new file mode 100755
index 0000000..90701f5
--- /dev/null
+++ b/tests/ssltest.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2set -e
3export PATH=$srcdir/../apps:$PATH
4$srcdir/testssl $srcdir/server.pem $srcdir/server.pem $srcdir/ca.pem