From: Paul Mackerras Date: Sun, 18 Jun 2006 23:25:16 GMT Subject: [PATCH] Fix PPC SHA1 routine for large input buffers Message-ID: <17557.57564.267469.561683@cargo.ozlabs.ibm.com> In-Reply-To: The PPC SHA1 routine had an overflow which meant that it gave incorrect results for input buffers >= 512MB. This fixes it by ensuring that the update of the total length in bits is done using 64-bit arithmetic. Signed-off-by: Paul Mackerras --- Linus Torvalds writes: > Paul - I think the ppc SHA1_Update() overflows in 32 bits, when the length > of the memory area to be checksummed is huge. Yep. I checked the assembly output of this, and it looks right, but I haven't actually tested it by running it... Paul. diff --git a/ppc/sha1.c b/ppc/sha1.c index 5ba4fc5..0820398 100644 --- a/ppc/sha1.c +++ b/ppc/sha1.c @@ -30,7 +30,7 @@ int SHA1_Update(SHA_CTX *c, const void * unsigned long nb; const unsigned char *p = ptr; - c->len += n << 3; + c->len += (uint64_t) n << 3; while (n != 0) { if (c->cnt || n < 64) { nb = 64 - c->cnt;