From ef5f9af1559b043755d0af03c31676cd66fa40e7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 26 May 2008 19:29:50 +0200 Subject: [PATCH] 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. --- ChangeLog | 6 ++++++ lib/sha256.c | 2 +- lib/sha256.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9aea4e6b3..a72b682a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-05-26 Jim Meyering + 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. diff --git a/lib/sha256.c b/lib/sha256.c index a1362caec..0ad944435 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -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. */ diff --git a/lib/sha256.h b/lib/sha256.h index c35d6c1fe..3aa1ce97b 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -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]; }; -- 2.11.0