From 1b961b5b2f21887e2eb82c1b5f6e64098a8b77ad Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 14 Oct 2024 22:05:30 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- process.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/process.c b/process.c index 0189f56..945e9ee 100644 --- a/process.c +++ b/process.c @@ -45,8 +45,10 @@ process_portable(struct libsha1_state *restrict state, const unsigned char *rest state->w[i] |= (uint_least32_t)chunk[4 * i + 3]; } if (state->algorithm == LIBSHA1_1) { - for (; i < 80; i++) - state->w[i] = rorl(state->w[i - 3] ^ state->w[i - 8] ^ state->w[i - 14] ^ state->w[i - 16], 1); + for (; i < 80; i++) { + state->w[i] = state->w[i - 3] ^ state->w[i - 8] ^ state->w[i - 14] ^ state->w[i - 16]; + state->w[i] = rorl(state->w[i], 1); + } } else { for (; i < 80; i++) state->w[i] = state->w[i - 3] ^ state->w[i - 8] ^ state->w[i - 14] ^ state->w[i - 16]; @@ -117,7 +119,7 @@ process_x86_sha(struct libsha1_state *restrict state, const unsigned char *restr __m128i abcd_orig, e000_orig; size_t off = 0; - abcd_orig = _mm_shuffle_epi32(_mm_loadu_si128((const __m128i *)&state->h[0]), 32 - 5); + abcd_orig = _mm_shuffle_epi32(_mm_loadu_si128((const __m128i *)&state->h[0]), 033 /* 0b00'01'10'11 */); e000_orig = _mm_set_epi32((int)state->h[4], 0, 0, 0); for (; len >= off + sizeof(state->chunk); off += sizeof(state->chunk), data = &data[sizeof(state->chunk)]) { @@ -261,7 +263,7 @@ process_x86_sha(struct libsha1_state *restrict state, const unsigned char *restr abcd_orig = _mm_add_epi32(abcd, abcd_orig); } - _mm_storeu_si128((__m128i *)&state->h[0], _mm_shuffle_epi32(abcd_orig, 32 - 5)); + _mm_storeu_si128((__m128i *)&state->h[0], _mm_shuffle_epi32(abcd_orig, 033)); state->h[4] = (uint_least32_t)_mm_extract_epi32(e000_orig, 3); return off; -- cgit v1.2.3-70-g09d2