Fix an 11 year old mistake: Let the hash functions take a void* instead

of unsigned char* argument.
This commit is contained in:
Poul-Henning Kamp 2006-01-17 15:35:57 +00:00
parent a1c10dcb4c
commit 25a14196dd
17 changed files with 41 additions and 33 deletions

View File

@ -34,13 +34,13 @@ typedef struct MD2Context {
__BEGIN_DECLS
void MD2Init(MD2_CTX *);
void MD2Update(MD2_CTX *, const unsigned char *, unsigned int);
void MD2Update(MD2_CTX *, const void *, unsigned int);
void MD2Pad(MD2_CTX *);
void MD2Final(unsigned char [16], MD2_CTX *);
char * MD2End(MD2_CTX *, char *);
char * MD2File(const char *, char *);
char * MD2FileChunk(const char *, char *, off_t, off_t);
char * MD2Data(const unsigned char *, unsigned int, char *);
char * MD2Data(const void *, unsigned int, char *);
__END_DECLS
#endif /* _MD2_H_ */

View File

@ -99,12 +99,13 @@ MD2_CTX *context; /* context */
operation, processing another message block, and updating the
context.
*/
void MD2Update (context, input, inputLen)
void MD2Update (context, in, inputLen)
MD2_CTX *context; /* context */
const unsigned char *input; /* input block */
const void *in; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, idx, partLen;
const unsigned char *input = in;
/* Update number of bytes mod 16 */
idx = context->count;

View File

@ -36,13 +36,13 @@ typedef struct MD4Context {
__BEGIN_DECLS
void MD4Init(MD4_CTX *);
void MD4Update(MD4_CTX *, const unsigned char *, unsigned int);
void MD4Update(MD4_CTX *, const void *, unsigned int);
void MD4Pad(MD4_CTX *);
void MD4Final(unsigned char [16], MD4_CTX *);
char * MD4End(MD4_CTX *, char *);
char * MD4File(const char *, char *);
char * MD4FileChunk(const char *, char *, off_t, off_t);
char * MD4Data(const unsigned char *, unsigned int, char *);
char * MD4Data(const void *, unsigned int, char *);
__END_DECLS
#endif /* _MD4_H_ */

View File

@ -107,12 +107,13 @@ MD4_CTX *context; /* context */
operation, processing another message block, and updating the
context.
*/
void MD4Update (context, input, inputLen)
void MD4Update (context, in, inputLen)
MD4_CTX *context; /* context */
const unsigned char *input; /* input block */
const void *in; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, idx, partLen;
const unsigned char *input = in;
/* Compute number of bytes mod 64 */
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);

View File

@ -147,12 +147,13 @@ MD5Init (context)
*/
void
MD5Update (context, input, inputLen)
MD5Update (context, in, inputLen)
MD5_CTX *context;
const unsigned char *input;
const void *in;
unsigned int inputLen;
{
unsigned int i, idx, partLen;
const unsigned char *input = in;
/* Compute number of bytes mod 64 */
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);

View File

@ -29,7 +29,7 @@
.Ft void
.Fn MDXInit "MDX_CTX *context"
.Ft void
.Fn MDXUpdate "MDX_CTX *context" "const unsigned char *data" "unsigned int len"
.Fn MDXUpdate "MDX_CTX *context" "const void *data" "unsigned int len"
.Ft void
.Fn MDXPad "MDX_CTX *context"
.Ft void
@ -41,7 +41,7 @@
.Ft "char *"
.Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
.Ft "char *"
.Fn MDXData "const unsigned char *data" "unsigned int len" "char *buf"
.Fn MDXData "const void *data" "unsigned int len" "char *buf"
.Sh DESCRIPTION
The MDX functions calculate a 128-bit cryptographic checksum (digest)
for any number of input bytes.

View File

@ -88,7 +88,7 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
}
char *
MDXData (const unsigned char *data, unsigned int len, char *buf)
MDXData (const void *data, unsigned int len, char *buf)
{
MDX_CTX ctx;

View File

@ -82,13 +82,13 @@ typedef struct RIPEMD160state_st {
__BEGIN_DECLS
void RIPEMD160_Init(RIPEMD160_CTX *c);
void RIPEMD160_Update(RIPEMD160_CTX *c, const unsigned char *data,
void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data,
size_t len);
void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
char *RIPEMD160_End(RIPEMD160_CTX *, char *);
char *RIPEMD160_File(const char *, char *);
char *RIPEMD160_FileChunk(const char *, char *, off_t, off_t);
char *RIPEMD160_Data(const unsigned char *, unsigned int, char *);
char *RIPEMD160_Data(const void *, unsigned int, char *);
__END_DECLS
#endif

View File

@ -101,14 +101,15 @@ RIPEMD160_CTX *c;
c->num=0;
}
void RIPEMD160_Update(c, data, len)
void RIPEMD160_Update(c, in, len)
RIPEMD160_CTX *c;
const unsigned char *data;
const void *in;
size_t len;
{
u_int32_t *p;
int sw,sc;
u_int32_t l;
const unsigned char *data = in;
if (len == 0) return;

View File

@ -80,19 +80,19 @@ typedef struct SHAstate_st {
__BEGIN_DECLS
void SHA_Init(SHA_CTX *c);
void SHA_Update(SHA_CTX *c, const unsigned char *data, size_t len);
void SHA_Update(SHA_CTX *c, const void *data, size_t len);
void SHA_Final(unsigned char *md, SHA_CTX *c);
char *SHA_End(SHA_CTX *, char *);
char *SHA_File(const char *, char *);
char *SHA_FileChunk(const char *, char *, off_t, off_t);
char *SHA_Data(const unsigned char *, unsigned int, char *);
char *SHA_Data(const void *, unsigned int, char *);
void SHA1_Init(SHA_CTX *c);
void SHA1_Update(SHA_CTX *c, const unsigned char *data, size_t len);
void SHA1_Update(SHA_CTX *c, const void *data, size_t len);
void SHA1_Final(unsigned char *md, SHA_CTX *c);
char *SHA1_End(SHA_CTX *, char *);
char *SHA1_File(const char *, char *);
char *SHA1_FileChunk(const char *, char *, off_t, off_t);
char *SHA1_Data(const unsigned char *, unsigned int, char *);
char *SHA1_Data(const void *, unsigned int, char *);
__END_DECLS
#endif /* !_SHA_H_ */

View File

@ -115,14 +115,15 @@ SHA_CTX *c;
c->num=0;
}
void SHA_Update(c, data, len)
void SHA_Update(c, in, len)
SHA_CTX *c;
const unsigned char *data;
const void *in;
size_t len;
{
u_int32_t *p;
int ew,ec,sw,sc;
u_int32_t l;
const unsigned char *data = in;
if (len == 0) return;

View File

@ -143,14 +143,15 @@ SHA_CTX *c;
}
void
SHA1_Update(c, data, len)
SHA1_Update(c, in, len)
SHA_CTX *c;
const unsigned char *data;
const void *in;
size_t len;
{
u_int32_t *p;
int ew,ec,sw,sc;
u_int32_t l;
const unsigned char *data = in;
if (len == 0) return;

View File

@ -39,12 +39,12 @@ typedef struct SHA256Context {
__BEGIN_DECLS
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX *, const unsigned char *, size_t);
void SHA256_Update(SHA256_CTX *, const void *, size_t);
void SHA256_Final(unsigned char [32], SHA256_CTX *);
char *SHA256_End(SHA256_CTX *, char *);
char *SHA256_File(const char *, char *);
char *SHA256_FileChunk(const char *, char *, off_t, off_t);
char *SHA256_Data(const unsigned char *, unsigned int, char *);
char *SHA256_Data(const void *, unsigned int, char *);
__END_DECLS
#endif /* !_SHA256_H_ */

View File

@ -240,10 +240,11 @@ SHA256_Init(SHA256_CTX * ctx)
/* Add bytes into the hash */
void
SHA256_Update(SHA256_CTX * ctx, const unsigned char *src, size_t len)
SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len)
{
uint32_t bitlen[2];
uint32_t r;
const unsigned char *src = in;
/* Number of bytes left in the buffer from previous updates */
r = (ctx->count[1] >> 3) & 0x3f;

View File

@ -61,7 +61,7 @@ typedef struct Algorithm_t {
DIGEST_Init *Init;
DIGEST_Update *Update;
DIGEST_End *End;
char *(*Data)(const unsigned char *, unsigned int, char *);
char *(*Data)(const void *, unsigned int, char *);
char *(*File)(const char *, char *);
} Algorithm_t;

View File

@ -145,12 +145,13 @@ MD5Init (context)
*/
void
MD5Update (context, input, inputLen)
MD5Update (context, in, inputLen)
MD5_CTX *context;
const unsigned char *input;
const void *in;
unsigned int inputLen;
{
unsigned int i, index, partLen;
const unsigned char *input = in;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);

View File

@ -38,11 +38,11 @@ typedef struct MD5Context {
__BEGIN_DECLS
void MD5Init (MD5_CTX *);
void MD5Update (MD5_CTX *, const unsigned char *, unsigned int);
void MD5Update (MD5_CTX *, const void *, unsigned int);
void MD5Final (unsigned char [16], MD5_CTX *);
char * MD5End(MD5_CTX *, char *);
char * MD5File(const char *, char *);
char * MD5FileChunk(const char *, char *, off_t, off_t);
char * MD5Data(const unsigned char *, unsigned int, char *);
char * MD5Data(const void *, unsigned int, char *);
__END_DECLS
#endif /* _SYS_MD5_H_ */