Skip to content

Commit 32f733c

Browse files
committed
fixed sse2!
1 parent 64662db commit 32f733c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

chacha20/src/backends/sse2.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,10 @@ unsafe fn rounds<R: Rounds>(v: &[__m128i; 4]) -> [[__m128i; 4]; PAR_BLOCKS] {
146146
}
147147

148148
for block in 0..PAR_BLOCKS {
149-
for i in 0..4 {
149+
for i in 0..3 {
150150
res[block][i] = _mm_add_epi32(res[block][i], v[i]);
151151
}
152-
// add the counter since `v` is lacking updated counter values
153-
res[block][3] = _mm_add_epi32(res[block][3], _mm_set_epi32(0, 0, 0, block as i32));
152+
res[block][3] = _mm_add_epi32(res[block][3], _mm_add_epi64(v[3], _mm_set_epi64x(0, block as i64)));
154153
}
155154

156155
res

chacha20/src/rng.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ pub(crate) mod tests {
11931193
rng.fill_bytes(&mut result);
11941194
assert_eq!(first_blocks_end_word_pos, rng.get_word_pos());
11951195
assert_eq!(first_blocks_end_block_counter, rng.get_block_pos() - 3);
1196-
1196+
11971197
if first_blocks[0..64 * 4].ne(&result[64..]) {
11981198
for (i, (a, b)) in first_blocks.iter().zip(result.iter().skip(64)).enumerate() {
11991199
if a.ne(b) {

0 commit comments

Comments
 (0)