From ee5b58d3f868e8279d5d1916873b454771c0bde4 Mon Sep 17 00:00:00 2001 From: explorer Date: Thu, 4 Feb 1999 05:10:36 +0000 Subject: [PATCH] sync this with changes made in libkern. --- lib/libc/md/md5c.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/libc/md/md5c.c b/lib/libc/md/md5c.c index eb1b26e16ac5..6507e53edf90 100644 --- a/lib/libc/md/md5c.c +++ b/lib/libc/md/md5c.c @@ -1,4 +1,4 @@ -/* $NetBSD: md5c.c,v 1.7 1998/11/13 15:48:29 christos Exp $ */ +/* $NetBSD: md5c.c,v 1.8 1999/02/04 05:10:36 explorer Exp $ */ /* * This file is derived from the RSA Data Security, Inc. MD5 Message-Digest @@ -31,9 +31,10 @@ #if !defined(_KERNEL) #include "namespace.h" -#endif - #include +#else +#include +#endif #if defined(_KERNEL) || defined(_STANDALONE) #include @@ -43,7 +44,16 @@ #include #endif /* _KERNEL || _STANDALONE */ +/* + * XXX Kludge until there is resolution regarding mem*() functions + * XXX in the kernel. + */ +#if defined(_KERNEL) || defined(_STANDALONE) +#define memcpy(s, d, l) bcopy((d), (s), (l)) +#define ZEROIZE(d, l) bzero((d), (l)) +#else #define ZEROIZE(d, l) memset((d), 0, (l)) +#endif /* _KERNEL || _STANDALONE */ typedef unsigned char *POINTER; typedef u_int16_t UINT2; @@ -207,7 +217,8 @@ MD5Update(context, input, inputLen) /* Transform as many times as possible. */ if (inputLen >= partLen) { - memcpy(&context->buffer[idx], input, partLen); + memcpy((POINTER)&context->buffer[idx], + (POINTER)input, partLen); MD5Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) @@ -218,7 +229,8 @@ MD5Update(context, input, inputLen) i = 0; /* Buffer remaining input */ - memcpy(&context->buffer[idx], &input[i], inputLen - i); + memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i], + inputLen - i); } /* @@ -248,7 +260,7 @@ MD5Final(digest, context) Encode(digest, context->state, 16); /* Zeroize sensitive information. */ - ZEROIZE(context, sizeof(*context)); + ZEROIZE((POINTER)context, sizeof(*context)); } /* @@ -341,5 +353,5 @@ MD5Transform(state, block) state[3] += d; /* Zeroize sensitive information. */ - ZEROIZE(x, sizeof (x)); + ZEROIZE((POINTER)x, sizeof (x)); }