From e213be24151a368d8f31747dfad6706db41ddb35 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sat, 9 Feb 2019 15:03:48 +1100 Subject: [PATCH] hash/sha1: remove dependant operations from byte outputs --- hash/sha1.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hash/sha1.cpp b/hash/sha1.cpp index 7140798..33053e0 100644 --- a/hash/sha1.cpp +++ b/hash/sha1.cpp @@ -161,14 +161,14 @@ SHA1::operator() ( // Zero fill and append total length std::fill_n (std::begin (state.c) + offset, chunk - sizeof (total), 0); - state.c[BLOCK_BYTES - 1] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 2] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 3] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 4] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 5] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 6] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 7] = used & 0xFF; used >>= 8; - state.c[BLOCK_BYTES - 8] = used & 0xFF; + state.c[BLOCK_BYTES - 1] = (used >> 0 * 8) & 0xFF; + state.c[BLOCK_BYTES - 2] = (used >> 1 * 8) & 0xFF; + state.c[BLOCK_BYTES - 3] = (used >> 2 * 8) & 0xFF; + state.c[BLOCK_BYTES - 4] = (used >> 3 * 8) & 0xFF; + state.c[BLOCK_BYTES - 5] = (used >> 4 * 8) & 0xFF; + state.c[BLOCK_BYTES - 6] = (used >> 5 * 8) & 0xFF; + state.c[BLOCK_BYTES - 7] = (used >> 6 * 8) & 0xFF; + state.c[BLOCK_BYTES - 8] = (used >> 7 * 8) & 0xFF; total += chunk; process (H.w, state.W);