aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2024-10-14 22:05:30 +0200
committerMattias Andrée <m@maandree.se>2024-10-14 22:05:30 +0200
commit1b961b5b2f21887e2eb82c1b5f6e64098a8b77ad (patch)
tree1b162c14903a864a9769a9e90f23331f938d54b1 /process.c
parentRename config.mk to config-x86.mk and add config-portable.mk (diff)
downloadlibsha1-1b961b5b2f21887e2eb82c1b5f6e64098a8b77ad.tar.gz
libsha1-1b961b5b2f21887e2eb82c1b5f6e64098a8b77ad.tar.bz2
libsha1-1b961b5b2f21887e2eb82c1b5f6e64098a8b77ad.tar.xz
m
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--process.c10
1 files 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;