Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > fc11cd6e1c513a17304da94a5390f3cd > files > 438

kernel-2.6.18-194.11.1.el5.src.rpm

From: Neil Horman <nhorman@redhat.com>
Date: Thu, 11 Sep 2008 08:28:32 -0400
Subject: [crypto] fix panic in hmac self test
Message-id: 20080911122832.GA12618@hmsendeavour.rdu.redhat.com
O-Subject: Re: [RHEL 5.3 patch] crypto: Fix panic in hmac(md5) self test (bz 461537)
Bugzilla: 461537
RH-Acked-by: Jarod Wilson <jwilson@redhat.com>

On Wed, Sep 10, 2008 at 01:42:48PM -0400, Neil Horman wrote:

sorry for the noise, previous patch recindid.  It had an error, this is the
corrected version, written by Herbert, tested successfully by Jarod.

Neil

diff --git a/crypto/hmac.c b/crypto/hmac.c
index 28a713b..a2faf9d 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -56,9 +56,25 @@ static int hmac_setkey(struct crypto_hash *parent,
 
 	if (keylen > bs) {
 		struct scatterlist tmp;
+		int tmplen;
 
-		sg_init_one(&tmp, (u8 *)inkey, keylen);
-		crypto_digest_digest(tfm, &tmp, 1, digest);
+		crypto_digest_init(tfm);
+
+		tmplen = bs * 2 + ds;
+		sg_init_one(&tmp, ipad, tmplen);
+
+		for (; keylen > tmplen; inkey += tmplen, keylen -= tmplen) {
+			memcpy(ipad, inkey, tmplen);
+			crypto_digest_update(tfm, &tmp, 1);
+		}
+
+		if (keylen) {
+			memcpy(ipad, inkey, keylen);
+			tmp.length = keylen;
+			crypto_digest_update(tfm, &tmp, 1);
+		}
+
+		crypto_digest_final(tfm, digest);
 
 		inkey = digest;
 		keylen = ds;