diff options
Diffstat (limited to 'src/lib/libcrypto/comp')
| -rw-r--r-- | src/lib/libcrypto/comp/Makefile.ssl | 114 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/c_rle.c | 62 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/c_zlib.c | 260 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp.h | 59 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp_err.c | 92 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp_lib.c | 78 |
6 files changed, 665 insertions, 0 deletions
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 | |||
| 5 | DIR= comp | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKE= make -f Makefile.ssl | ||
| 14 | MAKEDEPPROG= makedepend | ||
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 16 | MAKEFILE= Makefile.ssl | ||
| 17 | AR= ar r | ||
| 18 | |||
| 19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 20 | |||
| 21 | GENERAL=Makefile | ||
| 22 | TEST= | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 26 | LIBSRC= comp_lib.c comp_err.c \ | ||
| 27 | c_rle.c c_zlib.c | ||
| 28 | |||
| 29 | LIBOBJ= comp_lib.o comp_err.o \ | ||
| 30 | c_rle.o c_zlib.o | ||
| 31 | |||
| 32 | SRC= $(LIBSRC) | ||
| 33 | |||
| 34 | EXHEADER= comp.h | ||
| 35 | HEADER= $(EXHEADER) | ||
| 36 | |||
| 37 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 38 | |||
| 39 | top: | ||
| 40 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 41 | |||
| 42 | all: lib | ||
| 43 | |||
| 44 | lib: $(LIBOBJ) | ||
| 45 | $(AR) $(LIB) $(LIBOBJ) | ||
| 46 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 47 | @touch lib | ||
| 48 | |||
| 49 | files: | ||
| 50 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 51 | |||
| 52 | links: | ||
| 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 | |||
| 58 | install: | ||
| 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 | |||
| 65 | tags: | ||
| 66 | ctags $(SRC) | ||
| 67 | |||
| 68 | tests: | ||
| 69 | |||
| 70 | lint: | ||
| 71 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 72 | |||
| 73 | depend: | ||
| 74 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC) | ||
| 75 | |||
| 76 | dclean: | ||
| 77 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 78 | mv -f Makefile.new $(MAKEFILE) | ||
| 79 | |||
| 80 | clean: | ||
| 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 | |||
| 85 | c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 86 | c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h | ||
| 87 | c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 88 | c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 89 | c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 90 | c_rle.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 91 | c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h c_rle.c | ||
| 92 | c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 93 | c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h | ||
| 94 | c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 95 | c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 96 | c_zlib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 97 | c_zlib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
| 98 | c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 99 | c_zlib.o: c_zlib.c | ||
| 100 | comp_err.o: ../../include/openssl/bio.h ../../include/openssl/comp.h | ||
| 101 | comp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 102 | comp_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 103 | comp_err.o: ../../include/openssl/opensslconf.h | ||
| 104 | comp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 105 | comp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 106 | comp_err.o: comp_err.c | ||
| 107 | comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 108 | comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h | ||
| 109 | comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
| 110 | comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 111 | comp_lib.o: ../../include/openssl/opensslconf.h | ||
| 112 | comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 113 | comp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 114 | comp_lib.o: ../../include/openssl/symhacks.h comp_lib.c | ||
diff --git a/src/lib/libcrypto/comp/c_rle.c b/src/lib/libcrypto/comp/c_rle.c new file mode 100644 index 0000000000..efd366fa22 --- /dev/null +++ b/src/lib/libcrypto/comp/c_rle.c | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <openssl/objects.h> | ||
| 5 | #include <openssl/comp.h> | ||
| 6 | |||
| 7 | static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
| 8 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
| 9 | static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
| 10 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
| 11 | |||
| 12 | static COMP_METHOD rle_method={ | ||
| 13 | NID_rle_compression, | ||
| 14 | LN_rle_compression, | ||
| 15 | NULL, | ||
| 16 | NULL, | ||
| 17 | rle_compress_block, | ||
| 18 | rle_expand_block, | ||
| 19 | NULL, | ||
| 20 | NULL, | ||
| 21 | }; | ||
| 22 | |||
| 23 | COMP_METHOD *COMP_rle(void) | ||
| 24 | { | ||
| 25 | return(&rle_method); | ||
| 26 | } | ||
| 27 | |||
| 28 | static int rle_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
| 29 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
| 30 | { | ||
| 31 | /* int i; */ | ||
| 32 | |||
| 33 | if (olen < (ilen+1)) | ||
| 34 | { | ||
| 35 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
| 36 | return(-1); | ||
| 37 | } | ||
| 38 | |||
| 39 | *(out++)=0; | ||
| 40 | memcpy(out,in,ilen); | ||
| 41 | return(ilen+1); | ||
| 42 | } | ||
| 43 | |||
| 44 | static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
| 45 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
| 46 | { | ||
| 47 | int i; | ||
| 48 | |||
| 49 | if (olen < (ilen-1)) | ||
| 50 | { | ||
| 51 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | ||
| 52 | return(-1); | ||
| 53 | } | ||
| 54 | |||
| 55 | i= *(in++); | ||
| 56 | if (i == 0) | ||
| 57 | { | ||
| 58 | memcpy(out,in,ilen-1); | ||
| 59 | } | ||
| 60 | return(ilen-1); | ||
| 61 | } | ||
| 62 | |||
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c new file mode 100644 index 0000000000..8c0876151a --- /dev/null +++ b/src/lib/libcrypto/comp/c_zlib.c | |||
| @@ -0,0 +1,260 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <openssl/objects.h> | ||
| 5 | #include <openssl/comp.h> | ||
| 6 | |||
| 7 | COMP_METHOD *COMP_zlib(void ); | ||
| 8 | |||
| 9 | static COMP_METHOD zlib_method_nozlib={ | ||
| 10 | NID_undef, | ||
| 11 | "(undef)", | ||
| 12 | NULL, | ||
| 13 | NULL, | ||
| 14 | NULL, | ||
| 15 | NULL, | ||
| 16 | NULL, | ||
| 17 | NULL, | ||
| 18 | }; | ||
| 19 | |||
| 20 | #ifndef ZLIB | ||
| 21 | #undef ZLIB_SHARED | ||
| 22 | #else | ||
| 23 | |||
| 24 | #include <zlib.h> | ||
| 25 | |||
| 26 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
| 27 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
| 28 | static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
| 29 | unsigned int olen, unsigned char *in, unsigned int ilen); | ||
| 30 | |||
| 31 | static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | ||
| 32 | uLong sourceLen); | ||
| 33 | |||
| 34 | static COMP_METHOD zlib_method={ | ||
| 35 | NID_zlib_compression, | ||
| 36 | LN_zlib_compression, | ||
| 37 | NULL, | ||
| 38 | NULL, | ||
| 39 | zlib_compress_block, | ||
| 40 | zlib_expand_block, | ||
| 41 | NULL, | ||
| 42 | NULL, | ||
| 43 | }; | ||
| 44 | |||
| 45 | /* | ||
| 46 | * When OpenSSL is built on Windows, we do not want to require that | ||
| 47 | * the ZLIB.DLL be available in order for the OpenSSL DLLs to | ||
| 48 | * work. Therefore, all ZLIB routines are loaded at run time | ||
| 49 | * and we do not link to a .LIB file. | ||
| 50 | */ | ||
| 51 | #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) | ||
| 52 | # include <windows.h> | ||
| 53 | |||
| 54 | # define Z_CALLCONV _stdcall | ||
| 55 | # define ZLIB_SHARED | ||
| 56 | #else | ||
| 57 | # define Z_CALLCONV | ||
| 58 | #endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */ | ||
| 59 | |||
| 60 | #ifdef ZLIB_SHARED | ||
| 61 | #include <openssl/dso.h> | ||
| 62 | |||
| 63 | /* Prototypes for built in stubs */ | ||
| 64 | static int stub_compress(Bytef *dest,uLongf *destLen, | ||
| 65 | const Bytef *source, uLong sourceLen); | ||
| 66 | static int stub_inflateEnd(z_streamp strm); | ||
| 67 | static int stub_inflate(z_streamp strm, int flush); | ||
| 68 | static int stub_inflateInit_(z_streamp strm, const char * version, | ||
| 69 | int stream_size); | ||
| 70 | |||
| 71 | /* Function pointers */ | ||
| 72 | typedef int (Z_CALLCONV *compress_ft)(Bytef *dest,uLongf *destLen, | ||
| 73 | const Bytef *source, uLong sourceLen); | ||
| 74 | typedef int (Z_CALLCONV *inflateEnd_ft)(z_streamp strm); | ||
| 75 | typedef int (Z_CALLCONV *inflate_ft)(z_streamp strm, int flush); | ||
| 76 | typedef int (Z_CALLCONV *inflateInit__ft)(z_streamp strm, | ||
| 77 | const char * version, int stream_size); | ||
| 78 | static compress_ft p_compress=NULL; | ||
| 79 | static inflateEnd_ft p_inflateEnd=NULL; | ||
| 80 | static inflate_ft p_inflate=NULL; | ||
| 81 | static inflateInit__ft p_inflateInit_=NULL; | ||
| 82 | |||
| 83 | static int zlib_loaded = 0; /* only attempt to init func pts once */ | ||
| 84 | static DSO *zlib_dso = NULL; | ||
| 85 | |||
| 86 | #define compress stub_compress | ||
| 87 | #define inflateEnd stub_inflateEnd | ||
| 88 | #define inflate stub_inflate | ||
| 89 | #define inflateInit_ stub_inflateInit_ | ||
| 90 | #endif /* ZLIB_SHARED */ | ||
| 91 | |||
| 92 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | ||
| 93 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
| 94 | { | ||
| 95 | unsigned long l; | ||
| 96 | int i; | ||
| 97 | int clear=1; | ||
| 98 | |||
| 99 | if (ilen > 128) | ||
| 100 | { | ||
| 101 | out[0]=1; | ||
| 102 | l=olen-1; | ||
| 103 | i=compress(&(out[1]),&l,in,(unsigned long)ilen); | ||
| 104 | if (i != Z_OK) | ||
| 105 | return(-1); | ||
| 106 | if (ilen > l) | ||
| 107 | { | ||
| 108 | clear=0; | ||
| 109 | l++; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | if (clear) | ||
| 113 | { | ||
| 114 | out[0]=0; | ||
| 115 | memcpy(&(out[1]),in,ilen); | ||
| 116 | l=ilen+1; | ||
| 117 | } | ||
| 118 | #ifdef DEBUG_ZLIB | ||
| 119 | fprintf(stderr,"compress(%4d)->%4d %s\n", | ||
| 120 | ilen,(int)l,(clear)?"clear":"zlib"); | ||
| 121 | #endif | ||
| 122 | return((int)l); | ||
| 123 | } | ||
| 124 | |||
| 125 | static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, | ||
| 126 | unsigned int olen, unsigned char *in, unsigned int ilen) | ||
| 127 | { | ||
| 128 | unsigned long l; | ||
| 129 | int i; | ||
| 130 | |||
| 131 | if (in[0]) | ||
| 132 | { | ||
| 133 | l=olen; | ||
| 134 | i=zz_uncompress(out,&l,&(in[1]),(unsigned long)ilen-1); | ||
| 135 | if (i != Z_OK) | ||
| 136 | return(-1); | ||
| 137 | } | ||
| 138 | else | ||
| 139 | { | ||
| 140 | memcpy(out,&(in[1]),ilen-1); | ||
| 141 | l=ilen-1; | ||
| 142 | } | ||
| 143 | #ifdef DEBUG_ZLIB | ||
| 144 | fprintf(stderr,"expand (%4d)->%4d %s\n", | ||
| 145 | ilen,(int)l,in[0]?"zlib":"clear"); | ||
| 146 | #endif | ||
| 147 | return((int)l); | ||
| 148 | } | ||
| 149 | |||
| 150 | static int zz_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, | ||
| 151 | uLong sourceLen) | ||
| 152 | { | ||
| 153 | z_stream stream; | ||
| 154 | int err; | ||
| 155 | |||
| 156 | stream.next_in = (Bytef*)source; | ||
| 157 | stream.avail_in = (uInt)sourceLen; | ||
| 158 | /* Check for source > 64K on 16-bit machine: */ | ||
| 159 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; | ||
| 160 | |||
| 161 | stream.next_out = dest; | ||
| 162 | stream.avail_out = (uInt)*destLen; | ||
| 163 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; | ||
| 164 | |||
| 165 | stream.zalloc = (alloc_func)0; | ||
| 166 | stream.zfree = (free_func)0; | ||
| 167 | |||
| 168 | err = inflateInit(&stream); | ||
| 169 | if (err != Z_OK) return err; | ||
| 170 | |||
| 171 | err = inflate(&stream, Z_FINISH); | ||
| 172 | if (err != Z_STREAM_END) { | ||
| 173 | inflateEnd(&stream); | ||
| 174 | return err; | ||
| 175 | } | ||
| 176 | *destLen = stream.total_out; | ||
| 177 | |||
| 178 | err = inflateEnd(&stream); | ||
| 179 | return err; | ||
| 180 | } | ||
| 181 | |||
| 182 | #endif | ||
| 183 | |||
| 184 | COMP_METHOD *COMP_zlib(void) | ||
| 185 | { | ||
| 186 | COMP_METHOD *meth = &zlib_method_nozlib; | ||
| 187 | |||
| 188 | #ifdef ZLIB_SHARED | ||
| 189 | if (!zlib_loaded) | ||
| 190 | { | ||
| 191 | #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) | ||
| 192 | zlib_dso = DSO_load(NULL, "ZLIB", NULL, 0); | ||
| 193 | #else | ||
| 194 | zlib_dso = DSO_load(NULL, "z", NULL, 0); | ||
| 195 | #endif | ||
| 196 | if (zlib_dso != NULL) | ||
| 197 | { | ||
| 198 | p_compress | ||
| 199 | = (compress_ft) DSO_bind_func(zlib_dso, | ||
| 200 | "compress"); | ||
| 201 | p_inflateEnd | ||
| 202 | = (inflateEnd_ft) DSO_bind_func(zlib_dso, | ||
| 203 | "inflateEnd"); | ||
| 204 | p_inflate | ||
| 205 | = (inflate_ft) DSO_bind_func(zlib_dso, | ||
| 206 | "inflate"); | ||
| 207 | p_inflateInit_ | ||
| 208 | = (inflateInit__ft) DSO_bind_func(zlib_dso, | ||
| 209 | "inflateInit_"); | ||
| 210 | zlib_loaded++; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | #endif | ||
| 215 | #if defined(ZLIB) || defined(ZLIB_SHARED) | ||
| 216 | meth = &zlib_method; | ||
| 217 | #endif | ||
| 218 | |||
| 219 | return(meth); | ||
| 220 | } | ||
| 221 | |||
| 222 | #ifdef ZLIB_SHARED | ||
| 223 | /* Stubs for each function to be dynamicly loaded */ | ||
| 224 | static int | ||
| 225 | stub_compress(Bytef *dest,uLongf *destLen,const Bytef *source, uLong sourceLen) | ||
| 226 | { | ||
| 227 | if (p_compress) | ||
| 228 | return(p_compress(dest,destLen,source,sourceLen)); | ||
| 229 | else | ||
| 230 | return(Z_MEM_ERROR); | ||
| 231 | } | ||
| 232 | |||
| 233 | static int | ||
| 234 | stub_inflateEnd(z_streamp strm) | ||
| 235 | { | ||
| 236 | if ( p_inflateEnd ) | ||
| 237 | return(p_inflateEnd(strm)); | ||
| 238 | else | ||
| 239 | return(Z_MEM_ERROR); | ||
| 240 | } | ||
| 241 | |||
| 242 | static int | ||
| 243 | stub_inflate(z_streamp strm, int flush) | ||
| 244 | { | ||
| 245 | if ( p_inflate ) | ||
| 246 | return(p_inflate(strm,flush)); | ||
| 247 | else | ||
| 248 | return(Z_MEM_ERROR); | ||
| 249 | } | ||
| 250 | |||
| 251 | static int | ||
| 252 | stub_inflateInit_(z_streamp strm, const char * version, int stream_size) | ||
| 253 | { | ||
| 254 | if ( p_inflateInit_ ) | ||
| 255 | return(p_inflateInit_(strm,version,stream_size)); | ||
| 256 | else | ||
| 257 | return(Z_MEM_ERROR); | ||
| 258 | } | ||
| 259 | |||
| 260 | #endif /* ZLIB_SHARED */ | ||
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h new file mode 100644 index 0000000000..ab48b78ae9 --- /dev/null +++ b/src/lib/libcrypto/comp/comp.h | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | |||
| 2 | #ifndef HEADER_COMP_H | ||
| 3 | #define HEADER_COMP_H | ||
| 4 | |||
| 5 | #include <openssl/crypto.h> | ||
| 6 | |||
| 7 | #ifdef __cplusplus | ||
| 8 | extern "C" { | ||
| 9 | #endif | ||
| 10 | |||
| 11 | typedef struct comp_method_st | ||
| 12 | { | ||
| 13 | int type; /* NID for compression library */ | ||
| 14 | const char *name; /* A text string to identify the library */ | ||
| 15 | int (*init)(); | ||
| 16 | void (*finish)(); | ||
| 17 | int (*compress)(); | ||
| 18 | int (*expand)(); | ||
| 19 | long (*ctrl)(); | ||
| 20 | long (*callback_ctrl)(); | ||
| 21 | } COMP_METHOD; | ||
| 22 | |||
| 23 | typedef struct comp_ctx_st | ||
| 24 | { | ||
| 25 | COMP_METHOD *meth; | ||
| 26 | unsigned long compress_in; | ||
| 27 | unsigned long compress_out; | ||
| 28 | unsigned long expand_in; | ||
| 29 | unsigned long expand_out; | ||
| 30 | |||
| 31 | CRYPTO_EX_DATA ex_data; | ||
| 32 | } COMP_CTX; | ||
| 33 | |||
| 34 | |||
| 35 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); | ||
| 36 | void COMP_CTX_free(COMP_CTX *ctx); | ||
| 37 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | ||
| 38 | unsigned char *in, int ilen); | ||
| 39 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | ||
| 40 | unsigned char *in, int ilen); | ||
| 41 | COMP_METHOD *COMP_rle(void ); | ||
| 42 | COMP_METHOD *COMP_zlib(void ); | ||
| 43 | |||
| 44 | /* BEGIN ERROR CODES */ | ||
| 45 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 46 | * made after this point may be overwritten when the script is next run. | ||
| 47 | */ | ||
| 48 | void ERR_load_COMP_strings(void); | ||
| 49 | |||
| 50 | /* Error codes for the COMP functions. */ | ||
| 51 | |||
| 52 | /* Function codes. */ | ||
| 53 | |||
| 54 | /* Reason codes. */ | ||
| 55 | |||
| 56 | #ifdef __cplusplus | ||
| 57 | } | ||
| 58 | #endif | ||
| 59 | #endif | ||
diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c new file mode 100644 index 0000000000..1652b8c2c4 --- /dev/null +++ b/src/lib/libcrypto/comp/comp_err.c | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | /* crypto/comp/comp_err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/comp.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef OPENSSL_NO_ERR | ||
| 67 | static ERR_STRING_DATA COMP_str_functs[]= | ||
| 68 | { | ||
| 69 | {0,NULL} | ||
| 70 | }; | ||
| 71 | |||
| 72 | static ERR_STRING_DATA COMP_str_reasons[]= | ||
| 73 | { | ||
| 74 | {0,NULL} | ||
| 75 | }; | ||
| 76 | |||
| 77 | #endif | ||
| 78 | |||
| 79 | void ERR_load_COMP_strings(void) | ||
| 80 | { | ||
| 81 | static int init=1; | ||
| 82 | |||
| 83 | if (init) | ||
| 84 | { | ||
| 85 | init=0; | ||
| 86 | #ifndef OPENSSL_NO_ERR | ||
| 87 | ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); | ||
| 88 | ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); | ||
| 89 | #endif | ||
| 90 | |||
| 91 | } | ||
| 92 | } | ||
diff --git a/src/lib/libcrypto/comp/comp_lib.c b/src/lib/libcrypto/comp/comp_lib.c new file mode 100644 index 0000000000..beb98ce8cc --- /dev/null +++ b/src/lib/libcrypto/comp/comp_lib.c | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <openssl/objects.h> | ||
| 5 | #include <openssl/comp.h> | ||
| 6 | |||
| 7 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) | ||
| 8 | { | ||
| 9 | COMP_CTX *ret; | ||
| 10 | |||
| 11 | if ((ret=(COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) | ||
| 12 | { | ||
| 13 | /* ZZZZZZZZZZZZZZZZ */ | ||
| 14 | return(NULL); | ||
| 15 | } | ||
| 16 | memset(ret,0,sizeof(COMP_CTX)); | ||
| 17 | ret->meth=meth; | ||
| 18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | ||
| 19 | { | ||
| 20 | OPENSSL_free(ret); | ||
| 21 | ret=NULL; | ||
| 22 | } | ||
| 23 | #if 0 | ||
| 24 | else | ||
| 25 | CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data); | ||
| 26 | #endif | ||
| 27 | return(ret); | ||
| 28 | } | ||
| 29 | |||
| 30 | void COMP_CTX_free(COMP_CTX *ctx) | ||
| 31 | { | ||
| 32 | /* CRYPTO_free_ex_data(rsa_meth,(char *)ctx,&ctx->ex_data); */ | ||
| 33 | |||
| 34 | if(ctx == NULL) | ||
| 35 | return; | ||
| 36 | |||
| 37 | if (ctx->meth->finish != NULL) | ||
| 38 | ctx->meth->finish(ctx); | ||
| 39 | |||
| 40 | OPENSSL_free(ctx); | ||
| 41 | } | ||
| 42 | |||
| 43 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | ||
| 44 | unsigned char *in, int ilen) | ||
| 45 | { | ||
| 46 | int ret; | ||
| 47 | if (ctx->meth->compress == NULL) | ||
| 48 | { | ||
| 49 | /* ZZZZZZZZZZZZZZZZZ */ | ||
| 50 | return(-1); | ||
| 51 | } | ||
| 52 | ret=ctx->meth->compress(ctx,out,olen,in,ilen); | ||
| 53 | if (ret > 0) | ||
| 54 | { | ||
| 55 | ctx->compress_in+=ilen; | ||
| 56 | ctx->compress_out+=ret; | ||
| 57 | } | ||
| 58 | return(ret); | ||
| 59 | } | ||
| 60 | |||
| 61 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | ||
| 62 | unsigned char *in, int ilen) | ||
| 63 | { | ||
| 64 | int ret; | ||
| 65 | |||
| 66 | if (ctx->meth->expand == NULL) | ||
| 67 | { | ||
| 68 | /* ZZZZZZZZZZZZZZZZZ */ | ||
| 69 | return(-1); | ||
| 70 | } | ||
| 71 | ret=ctx->meth->expand(ctx,out,olen,in,ilen); | ||
| 72 | if (ret > 0) | ||
| 73 | { | ||
| 74 | ctx->expand_in+=ilen; | ||
| 75 | ctx->expand_out+=ret; | ||
| 76 | } | ||
| 77 | return(ret); | ||
| 78 | } | ||
