diff options
| author | beck <> | 2002-05-15 02:29:21 +0000 |
|---|---|---|
| committer | beck <> | 2002-05-15 02:29:21 +0000 |
| commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
| tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/comp | |
| parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
| download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip | |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/comp')
| -rw-r--r-- | src/lib/libcrypto/comp/Makefile.ssl | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/c_rle.c | 1 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/c_zlib.c | 141 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp.h | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/comp/comp_err.c | 4 |
5 files changed, 167 insertions, 29 deletions
diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl index b696ac75fe..5dadb65cd4 100644 --- a/src/lib/libcrypto/comp/Makefile.ssl +++ b/src/lib/libcrypto/comp/Makefile.ssl | |||
| @@ -5,13 +5,14 @@ | |||
| 5 | DIR= comp | 5 | DIR= comp |
| 6 | TOP= ../.. | 6 | TOP= ../.. |
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= -I.. -I../../include | 8 | INCLUDES= -I.. -I$(TOP) -I../../include |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | 10 | INSTALL_PREFIX= |
| 11 | OPENSSLDIR= /usr/local/ssl | 11 | OPENSSLDIR= /usr/local/ssl |
| 12 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
| 13 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
| 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) | 14 | MAKEDEPPROG= makedepend |
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 15 | MAKEFILE= Makefile.ssl | 16 | MAKEFILE= Makefile.ssl |
| 16 | AR= ar r | 17 | AR= ar r |
| 17 | 18 | ||
| @@ -22,10 +23,10 @@ TEST= | |||
| 22 | APPS= | 23 | APPS= |
| 23 | 24 | ||
| 24 | LIB=$(TOP)/libcrypto.a | 25 | LIB=$(TOP)/libcrypto.a |
| 25 | LIBSRC= comp_lib.c \ | 26 | LIBSRC= comp_lib.c comp_err.c \ |
| 26 | c_rle.c c_zlib.c | 27 | c_rle.c c_zlib.c |
| 27 | 28 | ||
| 28 | LIBOBJ= comp_lib.o \ | 29 | LIBOBJ= comp_lib.o comp_err.o \ |
| 29 | c_rle.o c_zlib.o | 30 | c_rle.o c_zlib.o |
| 30 | 31 | ||
| 31 | SRC= $(LIBSRC) | 32 | SRC= $(LIBSRC) |
| @@ -42,8 +43,7 @@ all: lib | |||
| 42 | 43 | ||
| 43 | lib: $(LIBOBJ) | 44 | lib: $(LIBOBJ) |
| 44 | $(AR) $(LIB) $(LIBOBJ) | 45 | $(AR) $(LIB) $(LIBOBJ) |
| 45 | @echo You may get an error following this line. Please ignore. | 46 | $(RANLIB) $(LIB) || echo Never mind. |
| 46 | - $(RANLIB) $(LIB) | ||
| 47 | @touch lib | 47 | @touch lib |
| 48 | 48 | ||
| 49 | files: | 49 | files: |
| @@ -84,19 +84,31 @@ clean: | |||
| 84 | 84 | ||
| 85 | c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 85 | c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 86 | c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h | 86 | c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h |
| 87 | c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h | 87 | c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 88 | c_rle.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 88 | c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 89 | c_rle.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 89 | c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 90 | c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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 | ||
| 91 | c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 92 | c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 92 | c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h | 93 | c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h |
| 93 | c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h | 94 | c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 94 | c_zlib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 95 | c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 95 | c_zlib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.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 | ||
| 96 | c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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 | ||
| 97 | comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 107 | comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
| 98 | comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h | 108 | comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h |
| 99 | comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h | 109 | comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 100 | comp_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 110 | comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 101 | comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 111 | comp_lib.o: ../../include/openssl/opensslconf.h |
| 102 | comp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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 index 1a819e3737..efd366fa22 100644 --- a/src/lib/libcrypto/comp/c_rle.c +++ b/src/lib/libcrypto/comp/c_rle.c | |||
| @@ -17,6 +17,7 @@ static COMP_METHOD rle_method={ | |||
| 17 | rle_compress_block, | 17 | rle_compress_block, |
| 18 | rle_expand_block, | 18 | rle_expand_block, |
| 19 | NULL, | 19 | NULL, |
| 20 | NULL, | ||
| 20 | }; | 21 | }; |
| 21 | 22 | ||
| 22 | COMP_METHOD *COMP_rle(void) | 23 | COMP_METHOD *COMP_rle(void) |
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c index 6684ab4841..cd2f8a491b 100644 --- a/src/lib/libcrypto/comp/c_zlib.c +++ b/src/lib/libcrypto/comp/c_zlib.c | |||
| @@ -6,11 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | COMP_METHOD *COMP_zlib(void ); | 7 | COMP_METHOD *COMP_zlib(void ); |
| 8 | 8 | ||
| 9 | #ifndef ZLIB | 9 | static COMP_METHOD zlib_method_nozlib={ |
| 10 | |||
| 11 | static COMP_METHOD zlib_method={ | ||
| 12 | NID_undef, | 10 | NID_undef, |
| 13 | "(null)", | 11 | "(undef)", |
| 12 | NULL, | ||
| 14 | NULL, | 13 | NULL, |
| 15 | NULL, | 14 | NULL, |
| 16 | NULL, | 15 | NULL, |
| @@ -18,6 +17,8 @@ static COMP_METHOD zlib_method={ | |||
| 18 | NULL, | 17 | NULL, |
| 19 | }; | 18 | }; |
| 20 | 19 | ||
| 20 | #ifndef ZLIB | ||
| 21 | #undef ZLIB_SHARED | ||
| 21 | #else | 22 | #else |
| 22 | 23 | ||
| 23 | #include <zlib.h> | 24 | #include <zlib.h> |
| @@ -38,8 +39,56 @@ static COMP_METHOD zlib_method={ | |||
| 38 | zlib_compress_block, | 39 | zlib_compress_block, |
| 39 | zlib_expand_block, | 40 | zlib_expand_block, |
| 40 | NULL, | 41 | NULL, |
| 42 | NULL, | ||
| 41 | }; | 43 | }; |
| 42 | 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 | |||
| 43 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | 92 | static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, |
| 44 | unsigned int olen, unsigned char *in, unsigned int ilen) | 93 | unsigned int olen, unsigned char *in, unsigned int ilen) |
| 45 | { | 94 | { |
| @@ -66,7 +115,10 @@ static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, | |||
| 66 | memcpy(&(out[1]),in,ilen); | 115 | memcpy(&(out[1]),in,ilen); |
| 67 | l=ilen+1; | 116 | l=ilen+1; |
| 68 | } | 117 | } |
| 69 | fprintf(stderr,"compress(%4d)->%4d %s\n",ilen,(int)l,(clear)?"clear":"zlib"); | 118 | #ifdef DEBUG_ZLIB |
| 119 | fprintf(stderr,"compress(%4d)->%4d %s\n", | ||
| 120 | ilen,(int)l,(clear)?"clear":"zlib"); | ||
| 121 | #endif | ||
| 70 | return((int)l); | 122 | return((int)l); |
| 71 | } | 123 | } |
| 72 | 124 | ||
| @@ -88,7 +140,10 @@ static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out, | |||
| 88 | memcpy(out,&(in[1]),ilen-1); | 140 | memcpy(out,&(in[1]),ilen-1); |
| 89 | l=ilen-1; | 141 | l=ilen-1; |
| 90 | } | 142 | } |
| 91 | fprintf(stderr,"expand (%4d)->%4d %s\n",ilen,(int)l,in[0]?"zlib":"clear"); | 143 | #ifdef DEBUG_ZLIB |
| 144 | fprintf(stderr,"expand (%4d)->%4d %s\n", | ||
| 145 | ilen,(int)l,in[0]?"zlib":"clear"); | ||
| 146 | #endif | ||
| 92 | return((int)l); | 147 | return((int)l); |
| 93 | } | 148 | } |
| 94 | 149 | ||
| @@ -128,6 +183,78 @@ static int zz_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, | |||
| 128 | 183 | ||
| 129 | COMP_METHOD *COMP_zlib(void) | 184 | COMP_METHOD *COMP_zlib(void) |
| 130 | { | 185 | { |
| 131 | return(&zlib_method); | 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 | meth = &zlib_method; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | #elif defined(ZLIB) | ||
| 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); | ||
| 132 | } | 258 | } |
| 133 | 259 | ||
| 260 | #endif /* ZLIB_SHARED */ | ||
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h index 0922609542..ab48b78ae9 100644 --- a/src/lib/libcrypto/comp/comp.h +++ b/src/lib/libcrypto/comp/comp.h | |||
| @@ -39,14 +39,13 @@ int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | |||
| 39 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | 39 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, |
| 40 | unsigned char *in, int ilen); | 40 | unsigned char *in, int ilen); |
| 41 | COMP_METHOD *COMP_rle(void ); | 41 | COMP_METHOD *COMP_rle(void ); |
| 42 | #ifdef ZLIB | ||
| 43 | COMP_METHOD *COMP_zlib(void ); | 42 | COMP_METHOD *COMP_zlib(void ); |
| 44 | #endif | ||
| 45 | 43 | ||
| 46 | /* BEGIN ERROR CODES */ | 44 | /* BEGIN ERROR CODES */ |
| 47 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 45 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 48 | * made after this point may be overwritten when the script is next run. | 46 | * made after this point may be overwritten when the script is next run. |
| 49 | */ | 47 | */ |
| 48 | void ERR_load_COMP_strings(void); | ||
| 50 | 49 | ||
| 51 | /* Error codes for the COMP functions. */ | 50 | /* Error codes for the COMP functions. */ |
| 52 | 51 | ||
| @@ -58,4 +57,3 @@ COMP_METHOD *COMP_zlib(void ); | |||
| 58 | } | 57 | } |
| 59 | #endif | 58 | #endif |
| 60 | #endif | 59 | #endif |
| 61 | |||
diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c index c10282a73c..1652b8c2c4 100644 --- a/src/lib/libcrypto/comp/comp_err.c +++ b/src/lib/libcrypto/comp/comp_err.c | |||
| @@ -63,7 +63,7 @@ | |||
| 63 | #include <openssl/comp.h> | 63 | #include <openssl/comp.h> |
| 64 | 64 | ||
| 65 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
| 66 | #ifndef NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
| 67 | static ERR_STRING_DATA COMP_str_functs[]= | 67 | static ERR_STRING_DATA COMP_str_functs[]= |
| 68 | { | 68 | { |
| 69 | {0,NULL} | 69 | {0,NULL} |
| @@ -83,7 +83,7 @@ void ERR_load_COMP_strings(void) | |||
| 83 | if (init) | 83 | if (init) |
| 84 | { | 84 | { |
| 85 | init=0; | 85 | init=0; |
| 86 | #ifndef NO_ERR | 86 | #ifndef OPENSSL_NO_ERR |
| 87 | ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); | 87 | ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); |
| 88 | ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); | 88 | ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); |
| 89 | #endif | 89 | #endif |
