diff options
Diffstat (limited to 'byterun/md5.c')
-rw-r--r-- | byterun/md5.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/byterun/md5.c b/byterun/md5.c index bdaa9244b..9c8b0bbc3 100644 --- a/byterun/md5.c +++ b/byterun/md5.c @@ -20,14 +20,14 @@ /* MD5 message digest */ struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - unsigned char in[64]; + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; }; static void MD5Init P((struct MD5Context *context)); static void MD5Update P((struct MD5Context *context, unsigned char *buf, - unsigned len)); + unsigned len)); static void MD5Final P((unsigned char digest[16], struct MD5Context *ctx)); static void MD5Transform P((uint32 buf[4], uint32 in[16])); @@ -84,7 +84,7 @@ value md5_chan(chan, len) /* ML */ */ #ifndef ARCH_BIG_ENDIAN -#define byteReverse(buf, len) /* Nothing */ +#define byteReverse(buf, len) /* Nothing */ #else void byteReverse(buf, longs) unsigned char *buf; @@ -92,10 +92,10 @@ void byteReverse(buf, longs) { uint32 t; do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; + t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + ((unsigned) buf[1] << 8 | buf[0]); + *(uint32 *) buf = t; + buf += 4; } while (--longs); } #endif @@ -131,35 +131,35 @@ static void MD5Update(ctx, buf, len) t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += t; - len -= t; + unsigned char *p = (unsigned char *) ctx->in + t; + + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + buf += t; + len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += 64; - len -= 64; + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + buf += 64; + len -= 64; } /* Handle any remaining bytes of data. */ @@ -191,16 +191,16 @@ static void MD5Final(digest, ctx) /* Pad out to 56 mod 64 */ if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); } byteReverse(ctx->in, 14); @@ -211,7 +211,7 @@ static void MD5Final(digest, ctx) MD5Transform(ctx->buf, (uint32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); 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 */ } /* The four core functions - F1 is optimized somewhat */ @@ -224,7 +224,7 @@ static void MD5Final(digest, ctx) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) + ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to |