diff options
author | Brent Cook <busterb@gmail.com> | 2014-07-10 06:21:51 -0500 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2014-07-10 06:22:54 -0500 |
commit | 2b6dbc39ef274d5298daad1ff864be8fc3c56537 (patch) | |
tree | bed05f6232bad0278f952bcfa173c50c202f4309 /crypto | |
parent | e9eff5016a4ec2153c037c1b888acd2755965755 (diff) | |
download | portable-2b6dbc39ef274d5298daad1ff864be8fc3c56537.tar.gz portable-2b6dbc39ef274d5298daad1ff864be8fc3c56537.tar.bz2 portable-2b6dbc39ef274d5298daad1ff864be8fc3c56537.zip |
initial top-level import of subdirectories
Diffstat (limited to 'crypto')
-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 |
3 files changed, 122 insertions, 0 deletions
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) | ||