diff options
-rw-r--r-- | .gitignore | 172 | ||||
-rw-r--r-- | apps/Makefile.am.tpl | 11 | ||||
-rw-r--r-- | crypto/Makefile.am.tpl | 69 | ||||
-rw-r--r-- | crypto/compat/issetugid_linux.c | 47 | ||||
-rw-r--r-- | crypto/compat/thread_private.h | 6 | ||||
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/machine/endian.h | 14 | ||||
-rw-r--r-- | include/openssl/Makefile.am.tpl | 5 | ||||
-rw-r--r-- | include/stdlib.h | 16 | ||||
-rw-r--r-- | include/string.h | 25 | ||||
-rw-r--r-- | include/sys/types.h | 13 | ||||
-rw-r--r-- | include/unistd.h | 9 | ||||
-rw-r--r-- | ssl/Makefile.am.tpl | 9 | ||||
-rw-r--r-- | tests/Makefile.am.tpl | 8 | ||||
-rwxr-xr-x | tests/aeadtest.sh | 3 | ||||
-rwxr-xr-x | tests/arc4randomforktest.sh | 6 | ||||
-rwxr-xr-x | tests/evptest.sh | 3 | ||||
-rwxr-xr-x | tests/pq_test.sh | 3 | ||||
-rwxr-xr-x | tests/ssltest.sh | 4 |
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 | ||
29 | Makefile | ||
30 | Makefile.in | ||
31 | |||
32 | # Libtool stuff | ||
33 | .libs | ||
34 | *.lo | ||
35 | *.la | ||
36 | |||
37 | # tests | ||
38 | test-driver | ||
39 | *.log | ||
40 | *.trs | ||
41 | tests/aes_wrap* | ||
42 | tests/arc4random_fork* | ||
43 | tests/explicit_bzero* | ||
44 | tests/mont* | ||
45 | tests/timingsafe* | ||
46 | tests/*test*.c | ||
47 | tests/*.pem | ||
48 | tests/testssl | ||
49 | tests/*.txt | ||
50 | |||
51 | # ctags stuff | ||
52 | TAGS | ||
53 | |||
54 | ## The initial / makes these files only get ignored in particular directories. | ||
55 | /autom4te.cache | ||
56 | |||
57 | # Libtool adds these, at least sometimes | ||
58 | INSTALL | ||
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 | |||
83 | crypto/Makefile.am | ||
84 | include/openssl/Makefile.am | ||
85 | ssl/Makefile.am | ||
86 | apps/Makefile.am | ||
87 | tests/Makefile.am | ||
88 | |||
89 | ssl/*.c | ||
90 | ssl/*.h | ||
91 | include/pqueue.h | ||
92 | include/openssl/*.h | ||
93 | include/openssl/*.he | ||
94 | apps/*.c | ||
95 | apps/*.h | ||
96 | apps/*.cnf | ||
97 | apps/openssl | ||
98 | |||
99 | crypto/compat/arc4random.c | ||
100 | crypto/compat/chacha_private.h | ||
101 | crypto/compat/explicit_bzero.c | ||
102 | crypto/compat/getentropy_*.c | ||
103 | crypto/compat/reallocarray.c | ||
104 | crypto/compat/strlcat.c | ||
105 | crypto/compat/strlcpy.c | ||
106 | crypto/compat/strtonum.c | ||
107 | crypto/compat/timingsafe_bcmp.c | ||
108 | crypto/compat/timingsafe_memcmp.c | ||
109 | |||
110 | crypto/aes/ | ||
111 | crypto/asn1/ | ||
112 | crypto/bf/ | ||
113 | crypto/bio/ | ||
114 | crypto/bn/ | ||
115 | crypto/buffer/ | ||
116 | crypto/cast/ | ||
117 | crypto/chacha/ | ||
118 | crypto/cmac/ | ||
119 | crypto/comp/ | ||
120 | crypto/conf/ | ||
121 | crypto/cpt_err.c | ||
122 | crypto/cryptlib.c | ||
123 | crypto/cryptlib.h | ||
124 | crypto/cversion.c | ||
125 | crypto/des/ | ||
126 | crypto/dh/ | ||
127 | crypto/dsa/ | ||
128 | crypto/dso/ | ||
129 | crypto/ec/ | ||
130 | crypto/ecdh/ | ||
131 | crypto/ecdsa/ | ||
132 | crypto/engine/ | ||
133 | crypto/err/ | ||
134 | crypto/evp/ | ||
135 | crypto/ex_data.c | ||
136 | crypto/hmac/ | ||
137 | crypto/idea/ | ||
138 | crypto/krb5/ | ||
139 | crypto/lhash/ | ||
140 | crypto/malloc-wrapper.c | ||
141 | crypto/md32_common.h | ||
142 | crypto/md4/ | ||
143 | crypto/md5/ | ||
144 | crypto/mdc2/ | ||
145 | crypto/mem_clr.c | ||
146 | crypto/mem_dbg.c | ||
147 | crypto/modes/ | ||
148 | crypto/o_init.c | ||
149 | crypto/o_str.c | ||
150 | crypto/o_time.c | ||
151 | crypto/o_time.h | ||
152 | crypto/objects | ||
153 | crypto/ocsp/ | ||
154 | crypto/pem/ | ||
155 | crypto/pkcs12/ | ||
156 | crypto/pkcs7/ | ||
157 | crypto/poly1305/ | ||
158 | crypto/pqueue/ | ||
159 | crypto/rand/ | ||
160 | crypto/rc2/ | ||
161 | crypto/rc4/ | ||
162 | crypto/ripemd/ | ||
163 | crypto/rsa/ | ||
164 | crypto/sha/ | ||
165 | crypto/stack/ | ||
166 | crypto/ts/ | ||
167 | crypto/txt_db/ | ||
168 | crypto/ui/ | ||
169 | crypto/whrlpool/ | ||
170 | crypto/x509/ | ||
171 | crypto/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 @@ | |||
1 | include $(top_srcdir)/Makefile.am.common | ||
2 | |||
3 | bin_PROGRAMS = openssl | ||
4 | |||
5 | openssl_CFLAGS = $(USER_CFLAGS) | ||
6 | openssl_LDADD = $(PLATFORM_LDADD) | ||
7 | openssl_LDADD += $(top_builddir)/crypto/libcrypto.la | ||
8 | openssl_LDADD += $(top_builddir)/ssl/libssl.la | ||
9 | |||
10 | openssl_SOURCES = | ||
11 | noinst_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 @@ | |||
1 | include $(top_srcdir)/Makefile.am.common | ||
2 | |||
3 | AM_CPPFLAGS += -I$(top_srcdir)/crypto/asn1 | ||
4 | AM_CPPFLAGS += -I$(top_srcdir)/crypto/evp | ||
5 | AM_CPPFLAGS += -I$(top_srcdir)/crypto/modes | ||
6 | |||
7 | lib_LTLIBRARIES = libcrypto.la | ||
8 | |||
9 | libcrypto_la_LIBADD = libcompat.la libcompatnoopt.la | ||
10 | libcrypto_la_LDFLAGS = -version-info libcrypto-version | ||
11 | libcrypto_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) -DOPENSSL_NO_HW_PADLOCK | ||
12 | |||
13 | noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la | ||
14 | |||
15 | # compatibility functions that need to be built without optimizations | ||
16 | libcompatnoopt_la_CFLAGS = -O0 | ||
17 | libcompatnoopt_la_SOURCES = compat/explicit_bzero.c | ||
18 | |||
19 | # other compatibility functions | ||
20 | libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) | ||
21 | libcompat_la_SOURCES = | ||
22 | |||
23 | if NO_STRLCAT | ||
24 | libcompat_la_SOURCES += compat/strlcat.c | ||
25 | endif | ||
26 | |||
27 | if NO_STRLCPY | ||
28 | libcompat_la_SOURCES += compat/strlcpy.c | ||
29 | endif | ||
30 | |||
31 | if NO_REALLOCARRAY | ||
32 | libcompat_la_SOURCES += compat/reallocarray.c | ||
33 | endif | ||
34 | |||
35 | if NO_TIMINGSAFE_MEMCMP | ||
36 | libcompat_la_SOURCES += compat/timingsafe_memcmp.c | ||
37 | endif | ||
38 | |||
39 | if NO_TIMINGSAFE_BCMP | ||
40 | libcompat_la_SOURCES += compat/timingsafe_bcmp.c | ||
41 | endif | ||
42 | |||
43 | if NO_ARC4RANDOM_BUF | ||
44 | libcompat_la_SOURCES += compat/arc4random.c | ||
45 | |||
46 | if NO_GETENTROPY | ||
47 | if TARGET_LINUX | ||
48 | libcompat_la_SOURCES += compat/getentropy_linux.c | ||
49 | endif | ||
50 | if TARGET_DARWIN | ||
51 | libcompat_la_SOURCES += compat/getentropy_osx.c | ||
52 | endif | ||
53 | if TARGET_SOLARIS | ||
54 | libcompat_la_SOURCES += compat/getentropy_solaris.c | ||
55 | endif | ||
56 | endif | ||
57 | |||
58 | endif | ||
59 | |||
60 | if NO_ISSETUGID | ||
61 | libcompat_la_SOURCES += compat/issetugid_linux.c | ||
62 | endif | ||
63 | if NO_STRTONUM | ||
64 | libcompat_la_SOURCES += compat/strtonum.c | ||
65 | endif | ||
66 | |||
67 | noinst_HEADERS = des/ncbc_enc.c | ||
68 | libcrypto_la_SOURCES = | ||
69 | EXTRA_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 | |||
20 | int 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 | |||
3 | static 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 @@ | |||
1 | SUBDIRS = openssl | ||
2 | |||
3 | noinst_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 @@ | |||
1 | include $(top_srcdir)/Makefile.am.common | ||
2 | |||
3 | opensslincludedir=$(includedir)/openssl | ||
4 | |||
5 | opensslinclude_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 | |||
10 | uint32_t arc4random(void); | ||
11 | void arc4random_buf(void *_buf, size_t n); | ||
12 | void *reallocarray(void *, size_t, size_t); | ||
13 | long 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 | |||
15 | size_t strlcpy(char *dst, const char *src, size_t siz); | ||
16 | |||
17 | size_t strlcat(char *dst, const char *src, size_t siz); | ||
18 | |||
19 | void explicit_bzero(void *, size_t); | ||
20 | |||
21 | int timingsafe_bcmp(const void *b1, const void *b2, size_t n); | ||
22 | |||
23 | int 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 | ||
9 | typedef uint8_t u_int8_t; | ||
10 | typedef 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 | |||
6 | int getentropy(void *buf, size_t buflen); | ||
7 | int 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 @@ | |||
1 | include $(top_srcdir)/Makefile.am.common | ||
2 | |||
3 | lib_LTLIBRARIES = libssl.la | ||
4 | |||
5 | libssl_la_LDFLAGS = -version-info libssl-version | ||
6 | |||
7 | libssl_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS) | ||
8 | libssl_la_SOURCES = | ||
9 | noinst_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 @@ | |||
1 | include $(top_srcdir)/Makefile.am.common | ||
2 | |||
3 | AM_CPPFLAGS += -I $(top_srcdir)/crypto/modes | ||
4 | AM_CPPFLAGS += -I $(top_srcdir)/crypto/asn1 | ||
5 | |||
6 | TESTS = | ||
7 | check_PROGRAMS = | ||
8 | EXTRA_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 | ||
2 | set -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 | ||
2 | set -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 | ||
2 | set -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 | ||
2 | set -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 | ||
2 | set -e | ||
3 | export PATH=$srcdir/../apps:$PATH | ||
4 | $srcdir/testssl $srcdir/server.pem $srcdir/server.pem $srcdir/ca.pem | ||