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/c_rle.c62
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c215
-rw-r--r--src/lib/libcrypto/comp/comp.h59
-rw-r--r--src/lib/libcrypto/comp/comp_err.c92
-rw-r--r--src/lib/libcrypto/comp/comp_lib.c78
5 files changed, 0 insertions, 506 deletions
diff --git a/src/lib/libcrypto/comp/c_rle.c b/src/lib/libcrypto/comp/c_rle.c
deleted file mode 100644
index efd366fa22..0000000000
--- a/src/lib/libcrypto/comp/c_rle.c
+++ /dev/null
@@ -1,62 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <openssl/objects.h>
5#include <openssl/comp.h>
6
7static int rle_compress_block(COMP_CTX *ctx, unsigned char *out,
8 unsigned int olen, unsigned char *in, unsigned int ilen);
9static int rle_expand_block(COMP_CTX *ctx, unsigned char *out,
10 unsigned int olen, unsigned char *in, unsigned int ilen);
11
12static 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
23COMP_METHOD *COMP_rle(void)
24 {
25 return(&rle_method);
26 }
27
28static 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
44static 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
deleted file mode 100644
index 5fcb521ffb..0000000000
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ /dev/null
@@ -1,215 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <openssl/objects.h>
5#include <openssl/comp.h>
6#include <openssl/err.h>
7
8COMP_METHOD *COMP_zlib(void );
9
10static COMP_METHOD zlib_method_nozlib={
11 NID_undef,
12 "(undef)",
13 NULL,
14 NULL,
15 NULL,
16 NULL,
17 NULL,
18 NULL,
19 };
20
21#ifndef ZLIB
22#undef ZLIB_SHARED
23#else
24
25#include <zlib.h>
26
27static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
28 unsigned int olen, unsigned char *in, unsigned int ilen);
29static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out,
30 unsigned int olen, unsigned char *in, unsigned int ilen);
31
32static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
33 uLong sourceLen);
34
35static COMP_METHOD zlib_method={
36 NID_zlib_compression,
37 LN_zlib_compression,
38 NULL,
39 NULL,
40 zlib_compress_block,
41 zlib_expand_block,
42 NULL,
43 NULL,
44 };
45
46/*
47 * When OpenSSL is built on Windows, we do not want to require that
48 * the ZLIB.DLL be available in order for the OpenSSL DLLs to
49 * work. Therefore, all ZLIB routines are loaded at run time
50 * and we do not link to a .LIB file.
51 */
52#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
53# include <windows.h>
54#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */
55
56#ifdef ZLIB_SHARED
57#include <openssl/dso.h>
58
59/* Function pointers */
60typedef int (*compress_ft)(Bytef *dest,uLongf *destLen,
61 const Bytef *source, uLong sourceLen);
62typedef int (*inflateEnd_ft)(z_streamp strm);
63typedef int (*inflate_ft)(z_streamp strm, int flush);
64typedef int (*inflateInit__ft)(z_streamp strm,
65 const char * version, int stream_size);
66static compress_ft p_compress=NULL;
67static inflateEnd_ft p_inflateEnd=NULL;
68static inflate_ft p_inflate=NULL;
69static inflateInit__ft p_inflateInit_=NULL;
70
71static int zlib_loaded = 0; /* only attempt to init func pts once */
72static DSO *zlib_dso = NULL;
73
74#define compress p_compress
75#define inflateEnd p_inflateEnd
76#define inflate p_inflate
77#define inflateInit_ p_inflateInit_
78#endif /* ZLIB_SHARED */
79
80static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
81 unsigned int olen, unsigned char *in, unsigned int ilen)
82 {
83 unsigned long l;
84 int i;
85 int clear=1;
86
87 if (ilen > 128)
88 {
89 out[0]=1;
90 l=olen-1;
91 i=compress(&(out[1]),&l,in,(unsigned long)ilen);
92 if (i != Z_OK)
93 return(-1);
94 if (ilen > l)
95 {
96 clear=0;
97 l++;
98 }
99 }
100 if (clear)
101 {
102 out[0]=0;
103 memcpy(&(out[1]),in,ilen);
104 l=ilen+1;
105 }
106#ifdef DEBUG_ZLIB
107 fprintf(stderr,"compress(%4d)->%4d %s\n",
108 ilen,(int)l,(clear)?"clear":"zlib");
109#endif
110 return((int)l);
111 }
112
113static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out,
114 unsigned int olen, unsigned char *in, unsigned int ilen)
115 {
116 unsigned long l;
117 int i;
118
119 if (in[0])
120 {
121 l=olen;
122 i=zz_uncompress(out,&l,&(in[1]),(unsigned long)ilen-1);
123 if (i != Z_OK)
124 return(-1);
125 }
126 else
127 {
128 memcpy(out,&(in[1]),ilen-1);
129 l=ilen-1;
130 }
131#ifdef DEBUG_ZLIB
132 fprintf(stderr,"expand (%4d)->%4d %s\n",
133 ilen,(int)l,in[0]?"zlib":"clear");
134#endif
135 return((int)l);
136 }
137
138static int zz_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source,
139 uLong sourceLen)
140{
141 z_stream stream;
142 int err;
143
144 stream.next_in = (Bytef*)source;
145 stream.avail_in = (uInt)sourceLen;
146 /* Check for source > 64K on 16-bit machine: */
147 if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
148
149 stream.next_out = dest;
150 stream.avail_out = (uInt)*destLen;
151 if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
152
153 stream.zalloc = (alloc_func)0;
154 stream.zfree = (free_func)0;
155
156 err = inflateInit(&stream);
157 if (err != Z_OK) return err;
158
159 err = inflate(&stream, Z_FINISH);
160 if (err != Z_STREAM_END) {
161 inflateEnd(&stream);
162 return err;
163 }
164 *destLen = stream.total_out;
165
166 err = inflateEnd(&stream);
167 return err;
168}
169
170#endif
171
172COMP_METHOD *COMP_zlib(void)
173 {
174 COMP_METHOD *meth = &zlib_method_nozlib;
175
176#ifdef ZLIB_SHARED
177 if (!zlib_loaded)
178 {
179#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
180 zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0);
181#else
182 zlib_dso = DSO_load(NULL, "z", NULL, 0);
183#endif
184 if (zlib_dso != NULL)
185 {
186 p_compress
187 = (compress_ft) DSO_bind_func(zlib_dso,
188 "compress");
189 p_inflateEnd
190 = (inflateEnd_ft) DSO_bind_func(zlib_dso,
191 "inflateEnd");
192 p_inflate
193 = (inflate_ft) DSO_bind_func(zlib_dso,
194 "inflate");
195 p_inflateInit_
196 = (inflateInit__ft) DSO_bind_func(zlib_dso,
197 "inflateInit_");
198
199 if (p_compress && p_inflateEnd && p_inflate
200 && p_inflateInit_)
201 zlib_loaded++;
202 }
203 }
204
205#endif
206#ifdef ZLIB_SHARED
207 if (zlib_loaded)
208#endif
209#if defined(ZLIB) || defined(ZLIB_SHARED)
210 meth = &zlib_method;
211#endif
212
213 return(meth);
214 }
215
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h
deleted file mode 100644
index ab48b78ae9..0000000000
--- a/src/lib/libcrypto/comp/comp.h
+++ /dev/null
@@ -1,59 +0,0 @@
1
2#ifndef HEADER_COMP_H
3#define HEADER_COMP_H
4
5#include <openssl/crypto.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11typedef 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
23typedef 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
35COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
36void COMP_CTX_free(COMP_CTX *ctx);
37int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
38 unsigned char *in, int ilen);
39int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
40 unsigned char *in, int ilen);
41COMP_METHOD *COMP_rle(void );
42COMP_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 */
48void 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
deleted file mode 100644
index 1652b8c2c4..0000000000
--- a/src/lib/libcrypto/comp/comp_err.c
+++ /dev/null
@@ -1,92 +0,0 @@
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
67static ERR_STRING_DATA COMP_str_functs[]=
68 {
69{0,NULL}
70 };
71
72static ERR_STRING_DATA COMP_str_reasons[]=
73 {
74{0,NULL}
75 };
76
77#endif
78
79void 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
deleted file mode 100644
index beb98ce8cc..0000000000
--- a/src/lib/libcrypto/comp/comp_lib.c
+++ /dev/null
@@ -1,78 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <openssl/objects.h>
5#include <openssl/comp.h>
6
7COMP_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
30void 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
43int 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
61int 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 }