From: Andy Polyakov Date: Sat, 15 May 2004 11:29:55 +0000 (+0000) Subject: size_t-fication of message digest APIs. We should size_t-fy more APIs... X-Git-Tag: BEN_FIPS_TEST_6~14^2~259 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9e0aad9fd60635e240f7742fa1497eced6f1cd0b;p=oweals%2Fopenssl.git size_t-fication of message digest APIs. We should size_t-fy more APIs... --- diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c index 5e20555fc0..dd16d3bc6a 100644 --- a/crypto/engine/eng_openssl.c +++ b/crypto/engine/eng_openssl.c @@ -305,7 +305,7 @@ static int test_sha1_init(EVP_MD_CTX *ctx) #endif return SHA1_Init(ctx->md_data); } -static int test_sha1_update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int test_sha1_update(EVP_MD_CTX *ctx,const void *data,size_t count) { #ifdef TEST_ENG_OPENSSL_SHA_P_UPDATE fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_update() called\n"); diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index bd014ac81d..7d8421079b 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -208,9 +208,9 @@ skip_to_init: } int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, - unsigned int count) + size_t count) { - return ctx->digest->update(ctx,data,(unsigned long)count); + return ctx->digest->update(ctx,data,count); } /* The caller can assume that this removes any secret data from the context */ @@ -285,7 +285,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) return 1; } -int EVP_Digest(const void *data, unsigned int count, +int EVP_Digest(const void *data, size_t count, unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl) { EVP_MD_CTX ctx; diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h index 6adbe891a0..47c8fc72a0 100644 --- a/crypto/evp/evp.h +++ b/crypto/evp/evp.h @@ -227,7 +227,7 @@ struct env_md_st int md_size; unsigned long flags; int (*init)(EVP_MD_CTX *ctx); - int (*update)(EVP_MD_CTX *ctx,const void *data,unsigned long count); + int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count); int (*final)(EVP_MD_CTX *ctx,unsigned char *md); int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); int (*cleanup)(EVP_MD_CTX *ctx); @@ -490,9 +490,9 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); #define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs)) int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, - unsigned int cnt); + size_t cnt); int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); -int EVP_Digest(const void *data, unsigned int count, +int EVP_Digest(const void *data, size_t count, unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); diff --git a/crypto/evp/m_dss.c b/crypto/evp/m_dss.c index c4c5f0bbe6..020f19c44b 100644 --- a/crypto/evp/m_dss.c +++ b/crypto/evp/m_dss.c @@ -67,7 +67,7 @@ static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return SHA1_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_dss1.c b/crypto/evp/m_dss1.c index 6b65bfd54b..a20056f04b 100644 --- a/crypto/evp/m_dss1.c +++ b/crypto/evp/m_dss1.c @@ -69,7 +69,7 @@ static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return SHA1_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_ecdsa.c b/crypto/evp/m_ecdsa.c index 26e4206e5a..fad270faca 100644 --- a/crypto/evp/m_ecdsa.c +++ b/crypto/evp/m_ecdsa.c @@ -119,7 +119,7 @@ static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return SHA1_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_md2.c b/crypto/evp/m_md2.c index e577d26411..1eae4ed38c 100644 --- a/crypto/evp/m_md2.c +++ b/crypto/evp/m_md2.c @@ -70,7 +70,7 @@ static int init(EVP_MD_CTX *ctx) { return MD2_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return MD2_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_md4.c b/crypto/evp/m_md4.c index 787d6554c1..0fb84b6d1e 100644 --- a/crypto/evp/m_md4.c +++ b/crypto/evp/m_md4.c @@ -70,7 +70,7 @@ static int init(EVP_MD_CTX *ctx) { return MD4_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return MD4_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_md5.c b/crypto/evp/m_md5.c index a214315abe..21288ee636 100644 --- a/crypto/evp/m_md5.c +++ b/crypto/evp/m_md5.c @@ -70,7 +70,7 @@ static int init(EVP_MD_CTX *ctx) { return MD5_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return MD5_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_mdc2.c b/crypto/evp/m_mdc2.c index 14e8175790..36c4e9b134 100644 --- a/crypto/evp/m_mdc2.c +++ b/crypto/evp/m_mdc2.c @@ -70,7 +70,7 @@ static int init(EVP_MD_CTX *ctx) { return MDC2_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return MDC2_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_null.c b/crypto/evp/m_null.c index f6f0a1d2c0..cb0721699d 100644 --- a/crypto/evp/m_null.c +++ b/crypto/evp/m_null.c @@ -65,7 +65,7 @@ static int init(EVP_MD_CTX *ctx) { return 1; } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return 1; } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_ripemd.c b/crypto/evp/m_ripemd.c index 93910a44ab..087ad2d30a 100644 --- a/crypto/evp/m_ripemd.c +++ b/crypto/evp/m_ripemd.c @@ -70,7 +70,7 @@ static int init(EVP_MD_CTX *ctx) { return RIPEMD160_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return RIPEMD160_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_sha.c b/crypto/evp/m_sha.c index f3b9610757..64b397fa03 100644 --- a/crypto/evp/m_sha.c +++ b/crypto/evp/m_sha.c @@ -69,7 +69,7 @@ static int init(EVP_MD_CTX *ctx) { return SHA_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return SHA_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/evp/m_sha1.c b/crypto/evp/m_sha1.c index 364b368877..7a791a6f71 100644 --- a/crypto/evp/m_sha1.c +++ b/crypto/evp/m_sha1.c @@ -69,7 +69,7 @@ static int init(EVP_MD_CTX *ctx) { return SHA1_Init(ctx->md_data); } -static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) +static int update(EVP_MD_CTX *ctx,const void *data,size_t count) { return SHA1_Update(ctx->md_data,data,count); } static int final(EVP_MD_CTX *ctx,unsigned char *md) diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index f7392a0dae..50765e227b 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -121,7 +121,7 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, HMAC_Init_ex(ctx,key,len,md, NULL); } -void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len) +void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) { EVP_DigestUpdate(&ctx->md_ctx,data,len); } @@ -156,7 +156,7 @@ void HMAC_CTX_cleanup(HMAC_CTX *ctx) } unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, - const unsigned char *d, int n, unsigned char *md, + const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len) { HMAC_CTX c; diff --git a/crypto/hmac/hmac.h b/crypto/hmac/hmac.h index 72077ad19e..251c95fade 100644 --- a/crypto/hmac/hmac.h +++ b/crypto/hmac/hmac.h @@ -94,10 +94,10 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md); /* deprecated */ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md, ENGINE *impl); -void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len); +void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, - const unsigned char *d, int n, unsigned char *md, + const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len); diff --git a/crypto/md2/md2.h b/crypto/md2/md2.h index 6fcb9b1bdc..45bf4cc29c 100644 --- a/crypto/md2/md2.h +++ b/crypto/md2/md2.h @@ -81,9 +81,9 @@ typedef struct MD2state_st const char *MD2_options(void); int MD2_Init(MD2_CTX *c); -int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len); +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); int MD2_Final(unsigned char *md, MD2_CTX *c); -unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md); +unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md); #ifdef __cplusplus } #endif diff --git a/crypto/md2/md2_dgst.c b/crypto/md2/md2_dgst.c index ecb64f0ec4..15e77d60be 100644 --- a/crypto/md2/md2_dgst.c +++ b/crypto/md2/md2_dgst.c @@ -125,7 +125,7 @@ int MD2_Init(MD2_CTX *c) return 1; } -int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len) +int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len) { register UCHAR *p; @@ -145,7 +145,7 @@ int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len) } else { - memcpy(&(p[c->num]),data,(int)len); + memcpy(&(p[c->num]),data,len); /* data+=len; */ c->num+=(int)len; return 1; @@ -159,7 +159,7 @@ int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len) data+=MD2_BLOCK; len-=MD2_BLOCK; } - memcpy(p,data,(int)len); + memcpy(p,data,len); c->num=(int)len; return 1; } diff --git a/crypto/md2/md2_one.c b/crypto/md2/md2_one.c index 835160ef56..dab35071ac 100644 --- a/crypto/md2/md2_one.c +++ b/crypto/md2/md2_one.c @@ -63,7 +63,7 @@ /* This is a separate file so that #defines in cryptlib.h can * map my MD functions to different names */ -unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md) +unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md) { MD2_CTX c; static unsigned char m[MD2_DIGEST_LENGTH]; diff --git a/crypto/md32_common.h b/crypto/md32_common.h index 307ec30dfc..535ea85d16 100644 --- a/crypto/md32_common.h +++ b/crypto/md32_common.h @@ -410,21 +410,21 @@ * Time for some action:-) */ -int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len) +int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len) { const unsigned char *data=data_; register HASH_LONG * p; - register unsigned long l; + register HASH_LONG l; int sw,sc,ew,ec; if (len==0) return 1; - l=(c->Nl+(len<<3))&0xffffffffL; + l=(c->Nl+(((HASH_LONG)len)<<3))&0xffffffffUL; /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to * Wei Dai for pointing it out. */ if (l < c->Nl) /* overflow */ c->Nh++; - c->Nh+=(len>>29); + c->Nh+=(len>>29); /* might cause compiler warning on 16-bit */ c->Nl=l; if (c->num != 0) diff --git a/crypto/md4/md4.h b/crypto/md4/md4.h index 7a7b23682f..9a5b6603fe 100644 --- a/crypto/md4/md4.h +++ b/crypto/md4/md4.h @@ -105,9 +105,9 @@ typedef struct MD4state_st } MD4_CTX; int MD4_Init(MD4_CTX *c); -int MD4_Update(MD4_CTX *c, const void *data, unsigned long len); +int MD4_Update(MD4_CTX *c, const void *data, size_t len); int MD4_Final(unsigned char *md, MD4_CTX *c); -unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md); +unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); void MD4_Transform(MD4_CTX *c, const unsigned char *b); #ifdef __cplusplus } diff --git a/crypto/md4/md4_dgst.c b/crypto/md4/md4_dgst.c index 7afb7185b6..d4c7057f13 100644 --- a/crypto/md4/md4_dgst.c +++ b/crypto/md4/md4_dgst.c @@ -83,7 +83,7 @@ int MD4_Init(MD4_CTX *c) } #ifndef md4_block_host_order -void md4_block_host_order (MD4_CTX *c, const void *data, int num) +void md4_block_host_order (MD4_CTX *c, const void *data, size_t num) { const MD4_LONG *X=data; register unsigned MD32_REG_T A,B,C,D; @@ -159,7 +159,7 @@ void md4_block_host_order (MD4_CTX *c, const void *data, int num) #ifdef X #undef X #endif -void md4_block_data_order (MD4_CTX *c, const void *data_, int num) +void md4_block_data_order (MD4_CTX *c, const void *data_, size_t num) { const unsigned char *data=data_; register unsigned MD32_REG_T A,B,C,D,l; diff --git a/crypto/md4/md4_locl.h b/crypto/md4/md4_locl.h index a8d31d7a73..7e219b17ea 100644 --- a/crypto/md4/md4_locl.h +++ b/crypto/md4/md4_locl.h @@ -65,8 +65,8 @@ #define MD4_LONG_LOG2 2 /* default to 32 bits */ #endif -void md4_block_host_order (MD4_CTX *c, const void *p,int num); -void md4_block_data_order (MD4_CTX *c, const void *p,int num); +void md4_block_host_order (MD4_CTX *c, const void *p,size_t num); +void md4_block_data_order (MD4_CTX *c, const void *p,size_t num); #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) /* diff --git a/crypto/md4/md4_one.c b/crypto/md4/md4_one.c index 00565507e4..64601b62df 100644 --- a/crypto/md4/md4_one.c +++ b/crypto/md4/md4_one.c @@ -65,7 +65,7 @@ #include #endif -unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md) +unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md) { MD4_CTX c; static unsigned char m[MD4_DIGEST_LENGTH]; diff --git a/crypto/md5/md5.h b/crypto/md5/md5.h index a252e02115..587d947b9a 100644 --- a/crypto/md5/md5.h +++ b/crypto/md5/md5.h @@ -105,9 +105,9 @@ typedef struct MD5state_st } MD5_CTX; int MD5_Init(MD5_CTX *c); -int MD5_Update(MD5_CTX *c, const void *data, unsigned long len); +int MD5_Update(MD5_CTX *c, const void *data, size_t len); int MD5_Final(unsigned char *md, MD5_CTX *c); -unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md); +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); void MD5_Transform(MD5_CTX *c, const unsigned char *b); #ifdef __cplusplus } diff --git a/crypto/md5/md5_dgst.c b/crypto/md5/md5_dgst.c index 9c7abc3697..f97f48e55b 100644 --- a/crypto/md5/md5_dgst.c +++ b/crypto/md5/md5_dgst.c @@ -83,7 +83,7 @@ int MD5_Init(MD5_CTX *c) } #ifndef md5_block_host_order -void md5_block_host_order (MD5_CTX *c, const void *data, int num) +void md5_block_host_order (MD5_CTX *c, const void *data, size_t num) { const MD5_LONG *X=data; register unsigned MD32_REG_T A,B,C,D; @@ -176,7 +176,7 @@ void md5_block_host_order (MD5_CTX *c, const void *data, int num) #ifdef X #undef X #endif -void md5_block_data_order (MD5_CTX *c, const void *data_, int num) +void md5_block_data_order (MD5_CTX *c, const void *data_, size_t num) { const unsigned char *data=data_; register unsigned MD32_REG_T A,B,C,D,l; diff --git a/crypto/md5/md5_locl.h b/crypto/md5/md5_locl.h index 9e360da732..b29f0de7e3 100644 --- a/crypto/md5/md5_locl.h +++ b/crypto/md5/md5_locl.h @@ -69,13 +69,13 @@ # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) # define md5_block_host_order md5_block_asm_host_order # elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC) - void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,int num); + void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,size_t num); # define HASH_BLOCK_DATA_ORDER_ALIGNED md5_block_asm_data_order_aligned # endif #endif -void md5_block_host_order (MD5_CTX *c, const void *p,int num); -void md5_block_data_order (MD5_CTX *c, const void *p,int num); +void md5_block_host_order (MD5_CTX *c, const void *p,size_t num); +void md5_block_data_order (MD5_CTX *c, const void *p,size_t num); #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) /* diff --git a/crypto/md5/md5_one.c b/crypto/md5/md5_one.c index c5dd2d81db..9918243ea2 100644 --- a/crypto/md5/md5_one.c +++ b/crypto/md5/md5_one.c @@ -65,7 +65,7 @@ #include #endif -unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md) +unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) { MD5_CTX c; static unsigned char m[MD5_DIGEST_LENGTH]; diff --git a/crypto/mdc2/mdc2.h b/crypto/mdc2/mdc2.h index 793a8a0f13..6490e5c7d3 100644 --- a/crypto/mdc2/mdc2.h +++ b/crypto/mdc2/mdc2.h @@ -82,9 +82,9 @@ typedef struct mdc2_ctx_st int MDC2_Init(MDC2_CTX *c); -int MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len); +int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); int MDC2_Final(unsigned char *md, MDC2_CTX *c); -unsigned char *MDC2(const unsigned char *d, unsigned long n, +unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); #ifdef __cplusplus diff --git a/crypto/mdc2/mdc2_one.c b/crypto/mdc2/mdc2_one.c index 37f06c8d77..cd569aa865 100644 --- a/crypto/mdc2/mdc2_one.c +++ b/crypto/mdc2/mdc2_one.c @@ -60,7 +60,7 @@ #include "cryptlib.h" #include -unsigned char *MDC2(const unsigned char *d, unsigned long n, unsigned char *md) +unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md) { MDC2_CTX c; static unsigned char m[MDC2_DIGEST_LENGTH]; diff --git a/crypto/mdc2/mdc2dgst.c b/crypto/mdc2/mdc2dgst.c index 32daa9b0da..aa9ba0ee6b 100644 --- a/crypto/mdc2/mdc2dgst.c +++ b/crypto/mdc2/mdc2dgst.c @@ -74,7 +74,7 @@ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) -static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len); +static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len); int MDC2_Init(MDC2_CTX *c) { c->num=0; @@ -84,9 +84,9 @@ int MDC2_Init(MDC2_CTX *c) return 1; } -int MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) +int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len) { - int i,j; + size_t i,j; i=c->num; if (i != 0) @@ -94,7 +94,7 @@ int MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) if (i+len < MDC2_BLOCK) { /* partial block */ - memcpy(&(c->data[i]),in,(int)len); + memcpy(&(c->data[i]),in,len); c->num+=(int)len; return 1; } @@ -109,25 +109,25 @@ int MDC2_Update(MDC2_CTX *c, const unsigned char *in, unsigned long len) mdc2_body(c,&(c->data[0]),MDC2_BLOCK); } } - i=(int)(len&(unsigned long)~(MDC2_BLOCK-1)); + i=len&~((size_t)MDC2_BLOCK-1); if (i > 0) mdc2_body(c,in,i); - j=(int)len-i; + j=len-i; if (j > 0) { memcpy(&(c->data[0]),&(in[i]),j); - c->num=j; + c->num=(int)j; } return 1; } -static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) +static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len) { register DES_LONG tin0,tin1; register DES_LONG ttin0,ttin1; DES_LONG d[2],dd[2]; DES_key_schedule k; unsigned char *p; - unsigned int i; + size_t i; for (i=0; i #include -unsigned char *RIPEMD160(const unsigned char *d, unsigned long n, +unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md) { RIPEMD160_CTX c; diff --git a/crypto/sha/sha.h b/crypto/sha/sha.h index 9ef21414e5..aa4c9dd5d7 100644 --- a/crypto/sha/sha.h +++ b/crypto/sha/sha.h @@ -102,16 +102,16 @@ typedef struct SHAstate_st #ifndef OPENSSL_NO_SHA0 int SHA_Init(SHA_CTX *c); -int SHA_Update(SHA_CTX *c, const void *data, unsigned long len); +int SHA_Update(SHA_CTX *c, const void *data, size_t len); int SHA_Final(unsigned char *md, SHA_CTX *c); -unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); +unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); void SHA_Transform(SHA_CTX *c, const unsigned char *data); #endif #ifndef OPENSSL_NO_SHA1 int SHA1_Init(SHA_CTX *c); -int SHA1_Update(SHA_CTX *c, const void *data, unsigned long len); +int SHA1_Update(SHA_CTX *c, const void *data, size_t len); int SHA1_Final(unsigned char *md, SHA_CTX *c); -unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); void SHA1_Transform(SHA_CTX *c, const unsigned char *data); #endif diff --git a/crypto/sha/sha1_one.c b/crypto/sha/sha1_one.c index 20e660c71d..582b25394c 100644 --- a/crypto/sha/sha1_one.c +++ b/crypto/sha/sha1_one.c @@ -62,7 +62,7 @@ #include #ifndef OPENSSL_NO_SHA1 -unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md) +unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) { SHA_CTX c; static unsigned char m[SHA_DIGEST_LENGTH]; diff --git a/crypto/sha/sha_locl.h b/crypto/sha/sha_locl.h index 48c0ac6422..01fc6e22eb 100644 --- a/crypto/sha/sha_locl.h +++ b/crypto/sha/sha_locl.h @@ -92,8 +92,8 @@ # define HASH_BLOCK_DATA_ORDER sha_block_data_order # define Xupdate(a,ix,ia,ib,ic,id) (ix=(a)=(ia^ib^ic^id)) - void sha_block_host_order (SHA_CTX *c, const void *p,int num); - void sha_block_data_order (SHA_CTX *c, const void *p,int num); + void sha_block_host_order (SHA_CTX *c, const void *p,size_t num); + void sha_block_data_order (SHA_CTX *c, const void *p,size_t num); #elif defined(SHA_1) @@ -123,8 +123,8 @@ # define HASH_BLOCK_DATA_ORDER_ALIGNED sha1_block_asm_data_order # endif # endif - void sha1_block_host_order (SHA_CTX *c, const void *p,int num); - void sha1_block_data_order (SHA_CTX *c, const void *p,int num); + void sha1_block_host_order (SHA_CTX *c, const void *p,size_t num); + void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num); #else # error "Either SHA_0 or SHA_1 must be defined." @@ -223,7 +223,7 @@ int HASH_INIT (SHA_CTX *c) #endif #ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER -void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) +void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, size_t num) { const SHA_LONG *W=d; register unsigned MD32_REG_T A,B,C,D,E,T; @@ -348,7 +348,7 @@ void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) #endif #ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER -void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) +void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num) { const unsigned char *data=p; register unsigned MD32_REG_T A,B,C,D,E,T,l; @@ -505,7 +505,7 @@ void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) A=ROTATE(A,5)+T+xa; } while(0) #ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER -void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) +void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, size_t num) { const SHA_LONG *W=d; register unsigned MD32_REG_T A,B,C,D,E,T; @@ -551,7 +551,7 @@ void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) #endif #ifndef DONT_IMPLEMENT_BLOCK_DATA_ORDER -void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) +void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, size_t num) { const unsigned char *data=p; register unsigned MD32_REG_T A,B,C,D,E,T,l; diff --git a/crypto/sha/sha_one.c b/crypto/sha/sha_one.c index e61c63f3e9..371ffddac6 100644 --- a/crypto/sha/sha_one.c +++ b/crypto/sha/sha_one.c @@ -62,7 +62,7 @@ #include #ifndef OPENSSL_NO_SHA0 -unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md) +unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md) { SHA_CTX c; static unsigned char m[SHA_DIGEST_LENGTH];