summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/comp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/comp')
-rw-r--r--src/lib/libcrypto/comp/Makefile113
-rw-r--r--src/lib/libcrypto/comp/Makefile.ssl114
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c88
3 files changed, 299 insertions, 16 deletions
diff --git a/src/lib/libcrypto/comp/Makefile b/src/lib/libcrypto/comp/Makefile
new file mode 100644
index 0000000000..df1babec5c
--- /dev/null
+++ b/src/lib/libcrypto/comp/Makefile
@@ -0,0 +1,113 @@
1#
2# OpenSSL/crypto/comp/Makefile
3#
4
5DIR= comp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKEDEPPROG= makedepend
14MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile
16AR= ar r
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= comp_lib.c comp_err.c \
26 c_rle.c c_zlib.c
27
28LIBOBJ= comp_lib.o comp_err.o \
29 c_rle.o c_zlib.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= comp.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) || echo Never mind.
46 @touch lib
47
48files:
49 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
50
51links:
52 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
53 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
54 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
55
56install:
57 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
58 do \
59 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
60 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
61 done;
62
63tags:
64 ctags $(SRC)
65
66tests:
67
68lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70
71depend:
72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
73
74dclean:
75 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE)
77
78clean:
79 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81# DO NOT DELETE THIS LINE -- make depend depends on it.
82
83c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
84c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
85c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
86c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
87c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
88c_rle.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
89c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h c_rle.c
90c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
91c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
92c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
93c_zlib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
94c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
95c_zlib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
96c_zlib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
97c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
98c_zlib.o: c_zlib.c
99comp_err.o: ../../include/openssl/bio.h ../../include/openssl/comp.h
100comp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
101comp_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
102comp_err.o: ../../include/openssl/opensslconf.h
103comp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
104comp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
105comp_err.o: comp_err.c
106comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
107comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
108comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
109comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
110comp_lib.o: ../../include/openssl/opensslconf.h
111comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
112comp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
113comp_lib.o: ../../include/openssl/symhacks.h comp_lib.c
diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl
new file mode 100644
index 0000000000..f70ba1b285
--- /dev/null
+++ b/src/lib/libcrypto/comp/Makefile.ssl
@@ -0,0 +1,114 @@
1#
2# SSLeay/crypto/comp/Makefile
3#
4
5DIR= comp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC= comp_lib.c comp_err.c \
27 c_rle.c c_zlib.c
28
29LIBOBJ= comp_lib.o comp_err.o \
30 c_rle.o c_zlib.o
31
32SRC= $(LIBSRC)
33
34EXHEADER= comp.h
35HEADER= $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49files:
50 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
51
52links:
53 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
54 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
55 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
56 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
62 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
75
76dclean:
77 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83# DO NOT DELETE THIS LINE -- make depend depends on it.
84
85c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
86c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
87c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
89c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
90c_rle.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
91c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h c_rle.c
92c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
93c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
94c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
95c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96c_zlib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
97c_zlib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
98c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
99c_zlib.o: c_zlib.c
100comp_err.o: ../../include/openssl/bio.h ../../include/openssl/comp.h
101comp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
102comp_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
103comp_err.o: ../../include/openssl/opensslconf.h
104comp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
105comp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106comp_err.o: comp_err.c
107comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
108comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
109comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
110comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
111comp_lib.o: ../../include/openssl/opensslconf.h
112comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113comp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
114comp_lib.o: ../../include/openssl/symhacks.h comp_lib.c
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c
index 5fcb521ffb..1bd2850d15 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -51,17 +51,30 @@ static COMP_METHOD zlib_method={
51 */ 51 */
52#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) 52#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
53# include <windows.h> 53# include <windows.h>
54
55# define Z_CALLCONV _stdcall
56# define ZLIB_SHARED
57#else
58# define Z_CALLCONV
54#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */ 59#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */
55 60
56#ifdef ZLIB_SHARED 61#ifdef ZLIB_SHARED
57#include <openssl/dso.h> 62#include <openssl/dso.h>
58 63
64/* Prototypes for built in stubs */
65static int stub_compress(Bytef *dest,uLongf *destLen,
66 const Bytef *source, uLong sourceLen);
67static int stub_inflateEnd(z_streamp strm);
68static int stub_inflate(z_streamp strm, int flush);
69static int stub_inflateInit_(z_streamp strm, const char * version,
70 int stream_size);
71
59/* Function pointers */ 72/* Function pointers */
60typedef int (*compress_ft)(Bytef *dest,uLongf *destLen, 73typedef int (Z_CALLCONV *compress_ft)(Bytef *dest,uLongf *destLen,
61 const Bytef *source, uLong sourceLen); 74 const Bytef *source, uLong sourceLen);
62typedef int (*inflateEnd_ft)(z_streamp strm); 75typedef int (Z_CALLCONV *inflateEnd_ft)(z_streamp strm);
63typedef int (*inflate_ft)(z_streamp strm, int flush); 76typedef int (Z_CALLCONV *inflate_ft)(z_streamp strm, int flush);
64typedef int (*inflateInit__ft)(z_streamp strm, 77typedef int (Z_CALLCONV *inflateInit__ft)(z_streamp strm,
65 const char * version, int stream_size); 78 const char * version, int stream_size);
66static compress_ft p_compress=NULL; 79static compress_ft p_compress=NULL;
67static inflateEnd_ft p_inflateEnd=NULL; 80static inflateEnd_ft p_inflateEnd=NULL;
@@ -71,10 +84,10 @@ static inflateInit__ft p_inflateInit_=NULL;
71static int zlib_loaded = 0; /* only attempt to init func pts once */ 84static int zlib_loaded = 0; /* only attempt to init func pts once */
72static DSO *zlib_dso = NULL; 85static DSO *zlib_dso = NULL;
73 86
74#define compress p_compress 87#define compress stub_compress
75#define inflateEnd p_inflateEnd 88#define inflateEnd stub_inflateEnd
76#define inflate p_inflate 89#define inflate stub_inflate
77#define inflateInit_ p_inflateInit_ 90#define inflateInit_ stub_inflateInit_
78#endif /* ZLIB_SHARED */ 91#endif /* ZLIB_SHARED */
79 92
80static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, 93static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
@@ -178,6 +191,16 @@ COMP_METHOD *COMP_zlib(void)
178 { 191 {
179#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) 192#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
180 zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0); 193 zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0);
194 if (!zlib_dso)
195 {
196 zlib_dso = DSO_load(NULL, "ZLIB", NULL, 0);
197 if (zlib_dso)
198 {
199 /* Clear the errors from the first failed
200 DSO_load() */
201 ERR_clear_error();
202 }
203 }
181#else 204#else
182 zlib_dso = DSO_load(NULL, "z", NULL, 0); 205 zlib_dso = DSO_load(NULL, "z", NULL, 0);
183#endif 206#endif
@@ -195,21 +218,54 @@ COMP_METHOD *COMP_zlib(void)
195 p_inflateInit_ 218 p_inflateInit_
196 = (inflateInit__ft) DSO_bind_func(zlib_dso, 219 = (inflateInit__ft) DSO_bind_func(zlib_dso,
197 "inflateInit_"); 220 "inflateInit_");
198 221 zlib_loaded++;
199 if (p_compress && p_inflateEnd && p_inflate
200 && p_inflateInit_)
201 zlib_loaded++;
202 } 222 }
203 } 223 }
204 224
205#endif 225#endif
206#ifdef ZLIB_SHARED
207 if (zlib_loaded)
208#endif
209#if defined(ZLIB) || defined(ZLIB_SHARED) 226#if defined(ZLIB) || defined(ZLIB_SHARED)
210 meth = &zlib_method; 227 meth = &zlib_method;
211#endif 228#endif
212 229
213 return(meth); 230 return(meth);
214 } 231 }
215 232
233#ifdef ZLIB_SHARED
234/* Stubs for each function to be dynamicly loaded */
235static int
236stub_compress(Bytef *dest,uLongf *destLen,const Bytef *source, uLong sourceLen)
237 {
238 if (p_compress)
239 return(p_compress(dest,destLen,source,sourceLen));
240 else
241 return(Z_MEM_ERROR);
242 }
243
244static int
245stub_inflateEnd(z_streamp strm)
246 {
247 if ( p_inflateEnd )
248 return(p_inflateEnd(strm));
249 else
250 return(Z_MEM_ERROR);
251 }
252
253static int
254stub_inflate(z_streamp strm, int flush)
255 {
256 if ( p_inflate )
257 return(p_inflate(strm,flush));
258 else
259 return(Z_MEM_ERROR);
260 }
261
262static int
263stub_inflateInit_(z_streamp strm, const char * version, int stream_size)
264 {
265 if ( p_inflateInit_ )
266 return(p_inflateInit_(strm,version,stream_size));
267 else
268 return(Z_MEM_ERROR);
269 }
270
271#endif /* ZLIB_SHARED */