aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/md5.c
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-04-27 13:39:41 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-04-27 13:39:41 +0000
commit55a5e9a51345fadf72f9cd2fb955a713bf27ea2f (patch)
treec9973cc5b00f41b12e3d6e313c4dffd3025daf32 /code/qcommon/md5.c
parent4b70806fcb6735314cf79557ce84379fa7542cad (diff)
downloadioquake3-aero-55a5e9a51345fadf72f9cd2fb955a713bf27ea2f.tar.gz
ioquake3-aero-55a5e9a51345fadf72f9cd2fb955a713bf27ea2f.zip
- Introduced various new typedefs for windows platform (int32_t, int64_t, etc...)
- Applied md5 64-bit safety patch by Tony White. git-svn-id: svn://svn.icculus.org/quake3/trunk@727 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon/md5.c')
-rw-r--r--code/qcommon/md5.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/code/qcommon/md5.c b/code/qcommon/md5.c
index 452d4ff..ffe7752 100644
--- a/code/qcommon/md5.c
+++ b/code/qcommon/md5.c
@@ -18,8 +18,8 @@
#include "qcommon.h"
typedef struct MD5Context {
- unsigned long int buf[4];
- unsigned long int bits[2];
+ uint32_t buf[4];
+ uint32_t bits[2];
unsigned char in[64];
} MD5_CTX;
@@ -33,12 +33,12 @@ typedef struct MD5Context {
*/
static void byteReverse(unsigned char *buf, unsigned longs)
{
- unsigned long int t;
+ uint32_t t;
do {
- t = (unsigned long int)
+ t = (uint32_t)
((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
- *(unsigned long int *) buf = t;
+ *(uint32_t *) buf = t;
buf += 4;
} while (--longs);
}
@@ -75,10 +75,10 @@ static void MD5Init(struct MD5Context *ctx)
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
-static void MD5Transform(unsigned long int buf[4],
- unsigned long int const in[16])
+static void MD5Transform(uint32_t buf[4],
+ uint32_t const in[16])
{
- register unsigned long int a, b, c, d;
+ register uint32_t a, b, c, d;
a = buf[0];
b = buf[1];
@@ -166,12 +166,12 @@ static void MD5Transform(unsigned long int buf[4],
static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
unsigned len)
{
- register unsigned long int t;
+ uint32_t t;
/* Update bitcount */
t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((unsigned long int) len << 3)) < t)
+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
@@ -189,7 +189,7 @@ static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += t;
len -= t;
}
@@ -198,7 +198,7 @@ static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += 64;
len -= 64;
}
@@ -215,7 +215,7 @@ static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
*/
static void MD5Final(struct MD5Context *ctx, unsigned char *digest)
{
- unsigned long int count;
+ unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
@@ -234,7 +234,7 @@ static void MD5Final(struct MD5Context *ctx, unsigned char *digest)
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
@@ -245,15 +245,15 @@ static void MD5Final(struct MD5Context *ctx, unsigned char *digest)
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
- ((unsigned long int *) ctx->in)[14] = ctx->bits[0];
- ((unsigned long int *) ctx->in)[15] = ctx->bits[1];
+ ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+ ((uint32_t *) ctx->in)[15] = ctx->bits[1];
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
if (digest!=NULL)
memcpy(digest, ctx->buf, 16);
- //memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}