From ari@osku.suutari.iki.fi  Wed Mar 25 00:09:43 1998
Received: from osku.suutari.iki.fi (kn6-045.ktvlpr.inet.fi [194.197.169.45])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA28732
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 25 Mar 1998 00:09:41 -0800 (PST)
          (envelope-from ari@osku.suutari.iki.fi)
Received: (from ari@localhost)
	by osku.suutari.iki.fi (8.8.7/8.8.5) id KAA07111;
	Wed, 25 Mar 1998 10:09:38 +0200 (EET)
Message-Id: <199803250809.KAA07111@osku.suutari.iki.fi>
Date: Wed, 25 Mar 1998 10:09:38 +0200 (EET)
From: ari@suutari.iki.fi
Reply-To: ari@suutari.iki.fi
To: FreeBSD-gnats-submit@freebsd.org
Subject: MD5Final in libmd 
X-Send-Pr-Version: 3.2

>Number:         6127
>Category:       misc
>Synopsis:       MD5Final in libmd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 25 00:10:03 PST 1998
>Closed-Date:    Fri Mar 27 02:23:38 PST 1998
>Last-Modified:  Fri Mar 27 02:24:53 PST 1998
>Originator:     Ari Suutari
>Release:        FreeBSD 2.2.5-RELEASE i386
>Organization:
>Environment:

	

>Description:

	To be able to use libmd MD5 routines in my user-process
	implementation of RFC1828, an additional routine
	would be required to be able to pad key data in
	same way as done by MD5Final. 

>How-To-Repeat:

	

>Fix:
	
	Split MD5Final into two functions: MD5Pad and MD5Final. 
	MD5Pad does the padding currently done by first part
	of MD5Final. MD5Final would first call MD5Pad.
	Like this:

	void
	MD5Final (digest, context)
		unsigned char digest[16];
		MD5_CTX *context;
	{ 
		/* Padding */
	 
		MD5Pad (context);
 
		/* Store state in digest */
		Encode (digest, context->state, 16);
 
		/* Zeroize sensitive information. */
		memset ((void *)context, 0, sizeof (*context));
	} 

	void
	MD5Pad (context)
		MD5_CTX *context; 
	{       
		unsigned char bits[8];
		unsigned int index, padLen;
        
		/* Save number of bits */
		Encode (bits, context->count, 8);
        
		/* Pad out to 56 mod 64. */
		index = (unsigned int)((context->count[0] >> 3) & 0x3f);
		padLen = (index < 56) ? (56 - index) : (120 - index);
		MD5Update (context, PADDING, padLen);
        
		/* Append length (before padding) */
		MD5Update (context, bits, 8);
	}
>Release-Note:
>Audit-Trail:

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: ari@suutari.iki.fi
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/6127: MD5Final in libmd 
Date: Thu, 26 Mar 1998 10:41:08 +0100

 >>Description:
 >
 >	To be able to use libmd MD5 routines in my user-process
 >	implementation of RFC1828, an additional routine
 >	would be required to be able to pad key data in
 >	same way as done by MD5Final. 
 
 Looks sensible, could you send a patch ?
 
 --
 Poul-Henning Kamp             FreeBSD coreteam member
 phk@FreeBSD.ORG               "Real hackers run -current on their laptop."
 "Drink MONO-tonic, it goes down but it will NEVER come back up!"
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Fri Mar 27 02:23:38 PST 1998 
State-Changed-Why:  
Patch received and applied. 
>Unformatted:
