Renamed MD5 functions and struct to avoid conflict with openssl.

Issue #260
This commit is contained in:
John McNamara 2020-01-07 23:45:34 +00:00
parent 85dfccd734
commit 18252b714e
4 changed files with 36 additions and 40 deletions

24
third_party/md5/md5.c vendored
View file

@ -79,16 +79,16 @@
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
(*(MD5_u32plus *)&ptr[(n) * 4])
(*(uint32_t *)&ptr[(n) * 4])
#define GET(n) \
SET(n)
#else
#define SET(n) \
(ctx->block[(n)] = \
(MD5_u32plus)ptr[(n) * 4] | \
((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
(uint32_t)ptr[(n) * 4] | \
((uint32_t)ptr[(n) * 4 + 1] << 8) | \
((uint32_t)ptr[(n) * 4 + 2] << 16) | \
((uint32_t)ptr[(n) * 4 + 3] << 24))
#define GET(n) \
(ctx->block[(n)])
#endif
@ -97,11 +97,11 @@
* This processes one or more 64-byte data blocks, but does NOT update the bit
* counters. There are no alignment requirements.
*/
static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
static const void *body(lxw_md5_ctx *ctx, const void *data, unsigned long size)
{
const unsigned char *ptr;
MD5_u32plus a, b, c, d;
MD5_u32plus saved_a, saved_b, saved_c, saved_d;
uint32_t a, b, c, d;
uint32_t saved_a, saved_b, saved_c, saved_d;
ptr = (const unsigned char *)data;
@ -204,7 +204,7 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
return ptr;
}
void MD5_Init(MD5_CTX *ctx)
void lxw_md5_init(lxw_md5_ctx *ctx)
{
ctx->a = 0x67452301;
ctx->b = 0xefcdab89;
@ -215,9 +215,9 @@ void MD5_Init(MD5_CTX *ctx)
ctx->hi = 0;
}
void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
void lxw_md5_update(lxw_md5_ctx *ctx, const void *data, unsigned long size)
{
MD5_u32plus saved_lo;
uint32_t saved_lo;
unsigned long used, available;
saved_lo = ctx->lo;
@ -255,7 +255,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
(dst)[2] = (unsigned char)((src) >> 16); \
(dst)[3] = (unsigned char)((src) >> 24);
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
void lxw_md5_final(unsigned char *result, lxw_md5_ctx *ctx)
{
unsigned long used, available;

22
third_party/md5/md5.h vendored
View file

@ -23,23 +23,21 @@
* See md5.c for more information.
*/
#ifdef HAVE_OPENSSL
#include <openssl/md5.h>
#elif !defined(_MD5_H)
#define _MD5_H
#ifndef __LXW_MD5_H__
#define __LXW_MD5_H__
/* Any 32-bit or wider unsigned integer data type will do */
typedef unsigned int MD5_u32plus;
typedef unsigned int uint32_t;
typedef struct {
MD5_u32plus lo, hi;
MD5_u32plus a, b, c, d;
uint32_t lo, hi;
uint32_t a, b, c, d;
unsigned char buffer[64];
MD5_u32plus block[16];
} MD5_CTX;
uint32_t block[16];
} lxw_md5_ctx;
extern void MD5_Init(MD5_CTX *ctx);
extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
extern void lxw_md5_init(lxw_md5_ctx *ctx);
extern void lxw_md5_update(lxw_md5_ctx *ctx, const void *data, unsigned long size);
extern void lxw_md5_final(unsigned char *result, lxw_md5_ctx *ctx);
#endif