#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");
}
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 */
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;
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);
#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);
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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);
}
}
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;
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);
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
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;
}
else
{
- memcpy(&(p[c->num]),data,(int)len);
+ memcpy(&(p[c->num]),data,len);
/* data+=len; */
c->num+=(int)len;
return 1;
data+=MD2_BLOCK;
len-=MD2_BLOCK;
}
- memcpy(p,data,(int)len);
+ memcpy(p,data,len);
c->num=(int)len;
return 1;
}
/* 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];
* 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 <weidai@eskimo.com> 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)
} 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
}
}
#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;
#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;
#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__)
/*
#include <openssl/ebcdic.h>
#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];
} 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
}
}
#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;
#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;
# 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__)
/*
#include <openssl/ebcdic.h>
#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];
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
#include "cryptlib.h"
#include <openssl/mdc2.h>
-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];
*((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;
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)
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;
}
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<len; i+=8)
{
} RIPEMD160_CTX;
int RIPEMD160_Init(RIPEMD160_CTX *c);
-int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len);
+int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);
int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
-unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
+unsigned char *RIPEMD160(const unsigned char *d, size_t n,
unsigned char *md);
void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
#ifdef __cplusplus
const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
# ifdef RMD160_ASM
- void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num);
+ void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,size_t num);
# define ripemd160_block ripemd160_block_x86
# else
- void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num);
+ void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num);
# endif
int RIPEMD160_Init(RIPEMD160_CTX *c)
#undef X
#endif
#define X(i) XX[i]
-void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
+void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, size_t num)
{
const RIPEMD160_LONG *XX=p;
register unsigned MD32_REG_T A,B,C,D,E;
#ifdef X
#undef X
#endif
-void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num)
+void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, size_t num)
{
const unsigned char *data=p;
register unsigned MD32_REG_T A,B,C,D,E;
# endif
#endif
-void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
-void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);
+void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,size_t num);
+void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,size_t num);
#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
#define ripemd160_block_data_order ripemd160_block_host_order
#include <openssl/ripemd.h>
#include <openssl/crypto.h>
-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;
#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
#include <openssl/crypto.h>
#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];
# 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)
# 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."
#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;
#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;
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;
#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;
#include <openssl/crypto.h>
#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];