Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add SSE2 with soft fallback for non salsa20/20 variants #348

Merged
merged 12 commits into from
Apr 29, 2024

Conversation

oxarbitrage
Copy link
Contributor

Here i re-added the SSE2 with the caveat of variants.

salsa20/src/lib.rs Outdated Show resolved Hide resolved
salsa20/src/backends.rs Outdated Show resolved Hide resolved
Comment on lines 222 to 230
#[inline(always)]
fn get_block_pos(&self) -> u64 {
(self.state[8] as u64) + ((self.state[9] as u64) << 32)
self.state[8] as u64
}

#[inline(always)]
fn set_block_pos(&mut self, pos: u64) {
self.state[8] = (pos & 0xffff_ffff) as u32;
self.state[9] = ((pos >> 32) & 0xffff_ffff) as u32;
self.state[8] = pos as u32;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like you're switching from a 64-bit to a 32-bit counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing me to that. It seems i changed the counter a while back because the xsalsa_seek test was not passing but i never went back to it to fix.

The problem is that when we are in sse2 mode the state is shuffled so it needs to get and set the counter in the right positions.

This was fixed in 98bf204

@oxarbitrage
Copy link
Contributor Author

@baloo i think your comments were good and i wanted to give it a try however i was not able to find the time yet, iirc i tried that before i was not able to make the whole thing work so i ended up with the current layout. i might want to give it a new look. can you readd the comments ?

salsa20/src/xsalsa.rs Outdated Show resolved Hide resolved
@baloo
Copy link
Member

baloo commented Mar 25, 2024

@oxarbitrage I deleted my comments because they were incorrect. Situation is more complex than I initially thought.

@oxarbitrage
Copy link
Contributor Author

@oxarbitrage I deleted my comments because they were incorrect. Situation is more complex than I initially thought.

That makes sense, as i think i already tried what was in those comments without being able to make it work. Thanks.

@baloo
Copy link
Member

baloo commented Mar 25, 2024

https://github.com/objectx/salsa20/blob/20d595b37597320a73acf87b3d3cc3ad3c9b66e6/src/salsa20.cxx#L182-L185
This is another implementation of salsa20 with sse2.

I like a lot the visual representation of the matrices in this one.

I still think it should be possible to reproduce the quarter round in the soft backend. I might try that at some point when I have more time.

@tarcieri tarcieri merged commit e1269b1 into RustCrypto:master Apr 29, 2024
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants