Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information...
commit eea1acbaf0cd548972b40827c37667dcfdf5cbe5 1 parent 7001ddb
Kent Yoder authored Ben Hutchings committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  crypto/sha512_generic.c
View
2  crypto/sha512_generic.c
@@ -174,7 +174,7 @@ sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len)
index = sctx->count[0] & 0x7f;
/* Update number of bytes */
- if (!(sctx->count[0] += len))
+ if ((sctx->count[0] += len) < len)
sctx->count[1]++;
part_len = 128 - index;
Please sign in to comment.
Something went wrong with that request. Please try again.