mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-26 07:03:40 +08:00
update
This commit is contained in:
@@ -64,6 +64,8 @@ tests:
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
|
||||
|
||||
@@ -5,57 +5,58 @@
|
||||
#include <openssl/comp.h>
|
||||
|
||||
static int rle_compress_block(COMP_CTX *ctx, unsigned char *out,
|
||||
unsigned int olen, unsigned char *in, unsigned int ilen);
|
||||
unsigned int olen, unsigned char *in,
|
||||
unsigned int ilen);
|
||||
static int rle_expand_block(COMP_CTX *ctx, unsigned char *out,
|
||||
unsigned int olen, unsigned char *in, unsigned int ilen);
|
||||
unsigned int olen, unsigned char *in,
|
||||
unsigned int ilen);
|
||||
|
||||
static COMP_METHOD rle_method={
|
||||
NID_rle_compression,
|
||||
LN_rle_compression,
|
||||
NULL,
|
||||
NULL,
|
||||
rle_compress_block,
|
||||
rle_expand_block,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
static COMP_METHOD rle_method = {
|
||||
NID_rle_compression,
|
||||
LN_rle_compression,
|
||||
NULL,
|
||||
NULL,
|
||||
rle_compress_block,
|
||||
rle_expand_block,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
COMP_METHOD *COMP_rle(void)
|
||||
{
|
||||
return(&rle_method);
|
||||
}
|
||||
{
|
||||
return (&rle_method);
|
||||
}
|
||||
|
||||
static int rle_compress_block(COMP_CTX *ctx, unsigned char *out,
|
||||
unsigned int olen, unsigned char *in, unsigned int ilen)
|
||||
{
|
||||
/* int i; */
|
||||
unsigned int olen, unsigned char *in,
|
||||
unsigned int ilen)
|
||||
{
|
||||
/* int i; */
|
||||
|
||||
if (olen < (ilen+1))
|
||||
{
|
||||
/* ZZZZZZZZZZZZZZZZZZZZZZ */
|
||||
return(-1);
|
||||
}
|
||||
if (ilen == 0 || olen < (ilen - 1)) {
|
||||
/* ZZZZZZZZZZZZZZZZZZZZZZ */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
*(out++)=0;
|
||||
memcpy(out,in,ilen);
|
||||
return(ilen+1);
|
||||
}
|
||||
*(out++) = 0;
|
||||
memcpy(out, in, ilen);
|
||||
return (ilen + 1);
|
||||
}
|
||||
|
||||
static int rle_expand_block(COMP_CTX *ctx, unsigned char *out,
|
||||
unsigned int olen, unsigned char *in, unsigned int ilen)
|
||||
{
|
||||
int i;
|
||||
unsigned int olen, unsigned char *in,
|
||||
unsigned int ilen)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ilen == 0 || olen < (ilen-1))
|
||||
{
|
||||
/* ZZZZZZZZZZZZZZZZZZZZZZ */
|
||||
return(-1);
|
||||
}
|
||||
if (olen < (ilen - 1)) {
|
||||
/* ZZZZZZZZZZZZZZZZZZZZZZ */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
i= *(in++);
|
||||
if (i == 0)
|
||||
{
|
||||
memcpy(out,in,ilen-1);
|
||||
}
|
||||
return(ilen-1);
|
||||
}
|
||||
i = *(in++);
|
||||
if (i == 0) {
|
||||
memcpy(out, in, ilen - 1);
|
||||
}
|
||||
return (ilen - 1);
|
||||
}
|
||||
|
||||
Binary file not shown.
1249
crypto/comp/c_zlib.c
1249
crypto/comp/c_zlib.c
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
|
||||
#ifndef HEADER_COMP_H
|
||||
#define HEADER_COMP_H
|
||||
# define HEADER_COMP_H
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
# include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -10,53 +10,52 @@ extern "C" {
|
||||
|
||||
typedef struct comp_ctx_st COMP_CTX;
|
||||
|
||||
typedef struct comp_method_st
|
||||
{
|
||||
int type; /* NID for compression library */
|
||||
const char *name; /* A text string to identify the library */
|
||||
int (*init)(COMP_CTX *ctx);
|
||||
void (*finish)(COMP_CTX *ctx);
|
||||
int (*compress)(COMP_CTX *ctx,
|
||||
unsigned char *out, unsigned int olen,
|
||||
unsigned char *in, unsigned int ilen);
|
||||
int (*expand)(COMP_CTX *ctx,
|
||||
unsigned char *out, unsigned int olen,
|
||||
unsigned char *in, unsigned int ilen);
|
||||
/* The following two do NOTHING, but are kept for backward compatibility */
|
||||
long (*ctrl)(void);
|
||||
long (*callback_ctrl)(void);
|
||||
} COMP_METHOD;
|
||||
|
||||
struct comp_ctx_st
|
||||
{
|
||||
COMP_METHOD *meth;
|
||||
unsigned long compress_in;
|
||||
unsigned long compress_out;
|
||||
unsigned long expand_in;
|
||||
unsigned long expand_out;
|
||||
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
};
|
||||
typedef struct comp_method_st {
|
||||
int type; /* NID for compression library */
|
||||
const char *name; /* A text string to identify the library */
|
||||
int (*init) (COMP_CTX *ctx);
|
||||
void (*finish) (COMP_CTX *ctx);
|
||||
int (*compress) (COMP_CTX *ctx,
|
||||
unsigned char *out, unsigned int olen,
|
||||
unsigned char *in, unsigned int ilen);
|
||||
int (*expand) (COMP_CTX *ctx,
|
||||
unsigned char *out, unsigned int olen,
|
||||
unsigned char *in, unsigned int ilen);
|
||||
/*
|
||||
* The following two do NOTHING, but are kept for backward compatibility
|
||||
*/
|
||||
long (*ctrl) (void);
|
||||
long (*callback_ctrl) (void);
|
||||
} COMP_METHOD;
|
||||
|
||||
struct comp_ctx_st {
|
||||
COMP_METHOD *meth;
|
||||
unsigned long compress_in;
|
||||
unsigned long compress_out;
|
||||
unsigned long expand_in;
|
||||
unsigned long expand_out;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
};
|
||||
|
||||
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
|
||||
void COMP_CTX_free(COMP_CTX *ctx);
|
||||
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen);
|
||||
unsigned char *in, int ilen);
|
||||
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen);
|
||||
COMP_METHOD *COMP_rle(void );
|
||||
COMP_METHOD *COMP_zlib(void );
|
||||
unsigned char *in, int ilen);
|
||||
COMP_METHOD *COMP_rle(void);
|
||||
COMP_METHOD *COMP_zlib(void);
|
||||
void COMP_zlib_cleanup(void);
|
||||
|
||||
#ifdef HEADER_BIO_H
|
||||
#ifdef ZLIB
|
||||
# ifdef HEADER_BIO_H
|
||||
# ifdef ZLIB
|
||||
BIO_METHOD *BIO_f_zlib(void);
|
||||
#endif
|
||||
#endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_COMP_strings(void);
|
||||
@@ -64,15 +63,15 @@ void ERR_load_COMP_strings(void);
|
||||
/* Error codes for the COMP functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define COMP_F_BIO_ZLIB_FLUSH 99
|
||||
#define COMP_F_BIO_ZLIB_NEW 100
|
||||
#define COMP_F_BIO_ZLIB_READ 101
|
||||
#define COMP_F_BIO_ZLIB_WRITE 102
|
||||
# define COMP_F_BIO_ZLIB_FLUSH 99
|
||||
# define COMP_F_BIO_ZLIB_NEW 100
|
||||
# define COMP_F_BIO_ZLIB_READ 101
|
||||
# define COMP_F_BIO_ZLIB_WRITE 102
|
||||
|
||||
/* Reason codes. */
|
||||
#define COMP_R_ZLIB_DEFLATE_ERROR 99
|
||||
#define COMP_R_ZLIB_INFLATE_ERROR 100
|
||||
#define COMP_R_ZLIB_NOT_SUPPORTED 101
|
||||
# define COMP_R_ZLIB_DEFLATE_ERROR 99
|
||||
# define COMP_R_ZLIB_INFLATE_ERROR 100
|
||||
# define COMP_R_ZLIB_NOT_SUPPORTED 101
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
@@ -53,7 +53,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
||||
/*
|
||||
* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
||||
* made to it will be overwritten when the script next updates this file,
|
||||
* only reason strings will be preserved.
|
||||
*/
|
||||
@@ -65,36 +66,33 @@
|
||||
/* BEGIN ERROR CODES */
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
#define ERR_FUNC(func) ERR_PACK(ERR_LIB_COMP,func,0)
|
||||
#define ERR_REASON(reason) ERR_PACK(ERR_LIB_COMP,0,reason)
|
||||
# define ERR_FUNC(func) ERR_PACK(ERR_LIB_COMP,func,0)
|
||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_COMP,0,reason)
|
||||
|
||||
static ERR_STRING_DATA COMP_str_functs[]=
|
||||
{
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_FLUSH), "BIO_ZLIB_FLUSH"},
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_NEW), "BIO_ZLIB_NEW"},
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_READ), "BIO_ZLIB_READ"},
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_WRITE), "BIO_ZLIB_WRITE"},
|
||||
{0,NULL}
|
||||
};
|
||||
static ERR_STRING_DATA COMP_str_functs[] = {
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_FLUSH), "BIO_ZLIB_FLUSH"},
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_NEW), "BIO_ZLIB_NEW"},
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_READ), "BIO_ZLIB_READ"},
|
||||
{ERR_FUNC(COMP_F_BIO_ZLIB_WRITE), "BIO_ZLIB_WRITE"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static ERR_STRING_DATA COMP_str_reasons[]=
|
||||
{
|
||||
{ERR_REASON(COMP_R_ZLIB_DEFLATE_ERROR) ,"zlib deflate error"},
|
||||
{ERR_REASON(COMP_R_ZLIB_INFLATE_ERROR) ,"zlib inflate error"},
|
||||
{ERR_REASON(COMP_R_ZLIB_NOT_SUPPORTED) ,"zlib not supported"},
|
||||
{0,NULL}
|
||||
};
|
||||
static ERR_STRING_DATA COMP_str_reasons[] = {
|
||||
{ERR_REASON(COMP_R_ZLIB_DEFLATE_ERROR), "zlib deflate error"},
|
||||
{ERR_REASON(COMP_R_ZLIB_INFLATE_ERROR), "zlib inflate error"},
|
||||
{ERR_REASON(COMP_R_ZLIB_NOT_SUPPORTED), "zlib not supported"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void ERR_load_COMP_strings(void)
|
||||
{
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(COMP_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,COMP_str_functs);
|
||||
ERR_load_strings(0,COMP_str_reasons);
|
||||
}
|
||||
if (ERR_func_error_string(COMP_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings(0, COMP_str_functs);
|
||||
ERR_load_strings(0, COMP_str_reasons);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,68 +5,62 @@
|
||||
#include <openssl/comp.h>
|
||||
|
||||
COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
|
||||
{
|
||||
COMP_CTX *ret;
|
||||
{
|
||||
COMP_CTX *ret;
|
||||
|
||||
if ((ret=(COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL)
|
||||
{
|
||||
/* ZZZZZZZZZZZZZZZZ */
|
||||
return(NULL);
|
||||
}
|
||||
memset(ret,0,sizeof(COMP_CTX));
|
||||
ret->meth=meth;
|
||||
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
|
||||
{
|
||||
OPENSSL_free(ret);
|
||||
ret=NULL;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if ((ret = (COMP_CTX *)OPENSSL_malloc(sizeof(COMP_CTX))) == NULL) {
|
||||
/* ZZZZZZZZZZZZZZZZ */
|
||||
return (NULL);
|
||||
}
|
||||
memset(ret, 0, sizeof(COMP_CTX));
|
||||
ret->meth = meth;
|
||||
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
|
||||
OPENSSL_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void COMP_CTX_free(COMP_CTX *ctx)
|
||||
{
|
||||
if(ctx == NULL)
|
||||
return;
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
|
||||
if (ctx->meth->finish != NULL)
|
||||
ctx->meth->finish(ctx);
|
||||
if (ctx->meth->finish != NULL)
|
||||
ctx->meth->finish(ctx);
|
||||
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen)
|
||||
{
|
||||
int ret;
|
||||
if (ctx->meth->compress == NULL)
|
||||
{
|
||||
/* ZZZZZZZZZZZZZZZZZ */
|
||||
return(-1);
|
||||
}
|
||||
ret=ctx->meth->compress(ctx,out,olen,in,ilen);
|
||||
if (ret > 0)
|
||||
{
|
||||
ctx->compress_in+=ilen;
|
||||
ctx->compress_out+=ret;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
unsigned char *in, int ilen)
|
||||
{
|
||||
int ret;
|
||||
if (ctx->meth->compress == NULL) {
|
||||
/* ZZZZZZZZZZZZZZZZZ */
|
||||
return (-1);
|
||||
}
|
||||
ret = ctx->meth->compress(ctx, out, olen, in, ilen);
|
||||
if (ret > 0) {
|
||||
ctx->compress_in += ilen;
|
||||
ctx->compress_out += ret;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
|
||||
unsigned char *in, int ilen)
|
||||
{
|
||||
int ret;
|
||||
unsigned char *in, int ilen)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (ctx->meth->expand == NULL)
|
||||
{
|
||||
/* ZZZZZZZZZZZZZZZZZ */
|
||||
return(-1);
|
||||
}
|
||||
ret=ctx->meth->expand(ctx,out,olen,in,ilen);
|
||||
if (ret > 0)
|
||||
{
|
||||
ctx->expand_in+=ilen;
|
||||
ctx->expand_out+=ret;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
if (ctx->meth->expand == NULL) {
|
||||
/* ZZZZZZZZZZZZZZZZZ */
|
||||
return (-1);
|
||||
}
|
||||
ret = ctx->meth->expand(ctx, out, olen, in, ilen);
|
||||
if (ret > 0) {
|
||||
ctx->expand_in += ilen;
|
||||
ctx->expand_out += ret;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user