summaryrefslogtreecommitdiffstats
path: root/lib/libmd/md5c.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-03-27 10:23:00 +0000
committerphk <phk@FreeBSD.org>1998-03-27 10:23:00 +0000
commit4db0fa09db895f439a5a91029e7625e329fda730 (patch)
tree7280db4f963d90af6e88e2567a99dd70e34b3f35 /lib/libmd/md5c.c
parent1eaa978a478cdf6768e93ba276482ac8140c290d (diff)
downloadFreeBSD-src-4db0fa09db895f439a5a91029e7625e329fda730.zip
FreeBSD-src-4db0fa09db895f439a5a91029e7625e329fda730.tar.gz
Split the padding out into a separate function.
Synchronize the kernel and libmd versions of md5c.c PR: misc/6127 Reviewed by: phk Submitted by: Ari Suutari <ari@suutari.iki.fi>
Diffstat (limited to 'lib/libmd/md5c.c')
-rw-r--r--lib/libmd/md5c.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/libmd/md5c.c b/lib/libmd/md5c.c
index 583d009..c1fdc6d 100644
--- a/lib/libmd/md5c.c
+++ b/lib/libmd/md5c.c
@@ -22,7 +22,7 @@
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*
- * $Id$
+ * $Id: md5c.c,v 1.10 1997/10/21 13:28:36 phk Exp $
*
* This code is the same as the code published by RSA Inc. It has been
* edited for clarity and style only.
@@ -31,7 +31,6 @@
#include <sys/types.h>
#ifdef KERNEL
-#include <sys/param.h>
#include <sys/systm.h>
#else
#include <string.h>
@@ -174,7 +173,7 @@ MD5Update (context, input, inputLen)
/* Transform as many times as possible. */
if (inputLen >= partLen) {
- memcpy((void *)&context->buffer[index], (void *)input,
+ memcpy((void *)&context->buffer[index], (const void *)input,
partLen);
MD5Transform (context->state, context->buffer);
@@ -187,18 +186,16 @@ MD5Update (context, input, inputLen)
i = 0;
/* Buffer remaining input */
- memcpy ((void *)&context->buffer[index], (void *)&input[i],
+ memcpy ((void *)&context->buffer[index], (const void *)&input[i],
inputLen-i);
}
/*
- * MD5 finalization. Ends an MD5 message-digest operation, writing the
- * the message digest and zeroizing the context.
+ * MD5 padding. Adds padding followed by original length.
*/
void
-MD5Final (digest, context)
- unsigned char digest[16];
+MD5Pad (context)
MD5_CTX *context;
{
unsigned char bits[8];
@@ -214,6 +211,20 @@ MD5Final (digest, context)
/* Append length (before padding) */
MD5Update (context, bits, 8);
+}
+
+/*
+ * MD5 finalization. Ends an MD5 message-digest operation, writing the
+ * the message digest and zeroizing the context.
+ */
+
+void
+MD5Final (digest, context)
+ unsigned char digest[16];
+ MD5_CTX *context;
+{
+ /* Do padding. */
+ MD5Pad (context);
/* Store state in digest */
Encode (digest, context->state, 16);
OpenPOWER on IntegriCloud