hash/sha1: remove dependant operations from byte outputs

This commit is contained in:
Danny Robson 2019-02-09 15:03:48 +11:00
parent 180ecaae5f
commit e213be2415

View File

@ -161,14 +161,14 @@ SHA1::operator() (
// Zero fill and append total length // Zero fill and append total length
std::fill_n (std::begin (state.c) + offset, chunk - sizeof (total), 0); 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 - 1] = (used >> 0 * 8) & 0xFF;
state.c[BLOCK_BYTES - 2] = used & 0xFF; used >>= 8; state.c[BLOCK_BYTES - 2] = (used >> 1 * 8) & 0xFF;
state.c[BLOCK_BYTES - 3] = used & 0xFF; used >>= 8; state.c[BLOCK_BYTES - 3] = (used >> 2 * 8) & 0xFF;
state.c[BLOCK_BYTES - 4] = used & 0xFF; used >>= 8; state.c[BLOCK_BYTES - 4] = (used >> 3 * 8) & 0xFF;
state.c[BLOCK_BYTES - 5] = used & 0xFF; used >>= 8; state.c[BLOCK_BYTES - 5] = (used >> 4 * 8) & 0xFF;
state.c[BLOCK_BYTES - 6] = used & 0xFF; used >>= 8; state.c[BLOCK_BYTES - 6] = (used >> 5 * 8) & 0xFF;
state.c[BLOCK_BYTES - 7] = used & 0xFF; used >>= 8; state.c[BLOCK_BYTES - 7] = (used >> 6 * 8) & 0xFF;
state.c[BLOCK_BYTES - 8] = used & 0xFF; state.c[BLOCK_BYTES - 8] = (used >> 7 * 8) & 0xFF;
total += chunk; total += chunk;
process (H.w, state.W); process (H.w, state.W);