[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / lib / misc / cbits / md5.c
index 0606846..7f00bec 100644 (file)
@@ -15,6 +15,8 @@
  * will fill a supplied 16-byte array with the digest.
  */
 
+#include <string.h>
+
 typedef unsigned long word32;
 typedef unsigned char byte;
 
@@ -79,11 +81,11 @@ MD5Update(struct MD5Context *ctx, byte const *buf, int len)
 
        t = 64 - (t & 0x3f);    /* Space available in ctx->in (at least 1) */
        if ((unsigned)t > len) {
-               bcopy(buf, (byte *)ctx->in + 64 - (unsigned)t, len);
+               memcpy((byte *)ctx->in + 64 - (unsigned)t, buf, len);
                return;
        }
        /* First chunk is an odd size */
-       bcopy(buf,(byte *)ctx->in + 64 - (unsigned)t, (unsigned)t);
+       memcpy((byte *)ctx->in + 64 - (unsigned)t, buf, (unsigned)t);
        byteSwap(ctx->in, 16);
        MD5Transform(ctx->buf, ctx->in);
        buf += (unsigned)t;
@@ -91,7 +93,7 @@ MD5Update(struct MD5Context *ctx, byte const *buf, int len)
 
        /* Process data in 64-byte chunks */
        while (len >= 64) {
-               bcopy(buf, ctx->in, 64);
+               memcpy(ctx->in, buf, 64);
                byteSwap(ctx->in, 16);
                MD5Transform(ctx->buf, ctx->in);
                buf += 64;
@@ -99,7 +101,7 @@ MD5Update(struct MD5Context *ctx, byte const *buf, int len)
        }
 
        /* Handle any remaining bytes of data. */
-       bcopy(buf, ctx->in, len);
+       memcpy(ctx->in, buf, len);
 }
 
 /*
@@ -119,13 +121,13 @@ MD5Final(byte digest[16], struct MD5Context *ctx)
        count = 56 - 1 - count;
 
        if (count < 0) {        /* Padding forces an extra block */
-               bzero(p, count+8);
+               memset(p, 0, count+8);
                byteSwap(ctx->in, 16);
                MD5Transform(ctx->buf, ctx->in);
                p = (byte *)ctx->in;
                count = 56;
        }
-       bzero(p, count+8);
+       memset(p, 0, count+8);
        byteSwap(ctx->in, 14);
 
        /* Append length in bits and transform */
@@ -134,8 +136,8 @@ MD5Final(byte digest[16], struct MD5Context *ctx)
        MD5Transform(ctx->buf, ctx->in);
 
        byteSwap(ctx->buf, 4);
-       bcopy(ctx->buf, digest, 16);
-       bzero(ctx,sizeof(ctx));
+       memcpy(digest, ctx->buf, 16);
+       memset(ctx,0,sizeof(ctx));
 }