From 4db0fa09db895f439a5a91029e7625e329fda730 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 27 Mar 1998 10:23:00 +0000 Subject: 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 --- lib/libmd/md5c.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'lib/libmd/md5c.c') 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 #ifdef KERNEL -#include #include #else #include @@ -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); -- cgit v1.1