Skip to content
This repository
Browse code

crypto: sha512 - Fix byte counter overflow in SHA-512

commit 25c3d30 upstream.

The current code only increments the upper 64 bits of the SHA-512 byte
counter when the number of bytes hashed happens to hit 2^64 exactly.

This patch increments the upper 64 bits whenever the lower 64 bits
overflows.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information...
commit ee6c90f9e96bc7d334f626b6076817d57cf861a1 1 parent 26cf838
authored April 05, 2012 gregkh committed April 27, 2012

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  crypto/sha512_generic.c
2  crypto/sha512_generic.c
@@ -174,7 +174,7 @@ sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len)
174 174
 	index = sctx->count[0] & 0x7f;
175 175
 
176 176
 	/* Update number of bytes */
177  
-	if (!(sctx->count[0] += len))
  177
+	if ((sctx->count[0] += len) < len)
178 178
 		sctx->count[1]++;
179 179
 
180 180
         part_len = 128 - index;

0 notes on commit ee6c90f

Please sign in to comment.
Something went wrong with that request. Please try again.