* lib/sha3.c (sha3_process_bytes): Simplify.
---
 ChangeLog  |  3 +++
 lib/sha3.c | 15 +++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 599452f58d..cc847be3a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2026-02-22  Paul Eggert  <[email protected]>
 
+       crypto/sha3: simplify full-block processing
+       * lib/sha3.c (sha3_process_bytes): Simplify.
+
        crypto/sha3: fix partial-buffer bug
        * lib/sha3.c (sha3_process_bytes):
        Update ctx->buflen to 0 if all bytes were processed.
diff --git a/lib/sha3.c b/lib/sha3.c
index 352cea514a..7bf33dbf6b 100644
--- a/lib/sha3.c
+++ b/lib/sha3.c
@@ -155,15 +155,14 @@ sha3_process_bytes (const void *buffer, size_t len, 
struct sha3_ctx *ctx)
       len -= left;
       sha3_process_block (ctx->buffer, ctx->blocklen, ctx);
     }
+
   /* Process as many complete blocks as possible.  */
-  if (0 < len)
-    {
-      size_t full_blocks = (len / ctx->blocklen) * ctx->blocklen;
-      sha3_process_block (buf, full_blocks, ctx);
-      buf += full_blocks;
-      len -= full_blocks;
-      memcpy (ctx->buffer, buf, len);
-    }
+  size_t full_len = len - len % ctx->blocklen;
+  sha3_process_block (buf, full_len, ctx);
+  buf += full_len;
+  len -= full_len;
+
+  memcpy (ctx->buffer, buf, len);
   ctx->buflen = len;
   return true;
 }
-- 
2.51.0


Reply via email to