sha256: do not artificially restrict buffer length to be < 2^32
authorJim Meyering <meyering@redhat.com>
Mon, 26 May 2008 17:29:50 +0000 (19:29 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 26 May 2008 17:29:50 +0000 (19:29 +0200)
* lib/sha256.h (struct sha256_ctx) [buflen]: Change type from
uint32_t to size_t.
* lib/sha256.c (sha256_conclude_ctx): Change type of a local
to match.

ChangeLog
lib/sha256.c
lib/sha256.h

index 9aea4e6..a72b682 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-05-26  Jim Meyering  <meyering@redhat.com>
 
+       sha256: do not artificially restrict buffer length to be < 2^32
+       * lib/sha256.h (struct sha256_ctx) [buflen]: Change type from
+       uint32_t to size_t.
+       * lib/sha256.c (sha256_conclude_ctx): Change type of a local
+       to match.
+
        avoid unaligned access errors, e.g., on sparc
        * lib/sha512.c (sha512_conclude_ctx): Use set_uint64 rather than
        direct access through a possibly-unaligned uint64* pointer.
index a1362ca..0ad9444 100644 (file)
@@ -126,7 +126,7 @@ static void
 sha256_conclude_ctx (struct sha256_ctx *ctx)
 {
   /* Take yet unprocessed bytes into account.  */
-  uint32_t bytes = ctx->buflen;
+  size_t bytes = ctx->buflen;
   size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
 
   /* Now count remaining bytes.  */
index c35d6c1..3aa1ce9 100644 (file)
@@ -27,7 +27,7 @@ struct sha256_ctx
   uint32_t state[8];
 
   uint32_t total[2];
-  uint32_t buflen;
+  size_t buflen;
   uint32_t buffer[32];
 };