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

chacha20: unify quarter_round in soft backend and xchacha #349

Merged
merged 2 commits into from
May 7, 2024

Conversation

oxarbitrage
Copy link
Contributor

The quarter_round function is duplicated inside xchacha. We can just use the soft backend version, which is the same code.

#348 (review)

@tarcieri
Copy link
Member

tarcieri commented Mar 25, 2024

It seems it was duplicated because soft isn't always available:

https://github.com/RustCrypto/stream-ciphers/actions/runs/8427139184/job/23077019314?pr=349#step:7:106

   Compiling chacha20 v0.10.0-pre (/project/chacha20)
error[E0432]: unresolved import `crate::backends::soft`
  --> chacha20/src/xchacha.rs:11:22
   |
11 | use crate::backends::soft::quarter_round;
   |                      ^^^^ could not find `soft` in `backends`

Perhaps it could be relocated somewhere it's always available. Failing other options, the toplevel of the module module of the crate is a choice.

@oxarbitrage
Copy link
Contributor Author

Ok, i remember now the problem on using the soft backend version here and in xsalsa20. The soft backend is not compiled when we are in sse2 (or other) mode so is not available.

In salsa20 we made this available because we are using soft when we are in any no salsa20/20 variant. https://github.com/RustCrypto/stream-ciphers/pull/348/files#diff-7b9d071b5f65d5c089bd999ab817ac1b72b33a365f1ec2e0ced9ef43d6495efeR1

I guess we can make it available for xchacha as well but i am unsure if compiling the extra code will be acceptable.

@oxarbitrage
Copy link
Contributor Author

Perhaps it could be relocated somewhere it's always available. Failing other options, the toplevel of the module is a choice.

Ok!

@tarcieri
Copy link
Member

Now I'm noticing we should really get #333 landed first

@tarcieri
Copy link
Member

@oxarbitrage need to re-evaluate this PR now that #333 has been merged

@tarcieri tarcieri changed the title Replace quarter_round in xchacha with soft backend version chacha20: unify quarter_round in soft backend and xchacha May 7, 2024
@tarcieri tarcieri merged commit 6a51902 into RustCrypto:master May 7, 2024
28 checks passed
@tarcieri
Copy link
Member

tarcieri commented May 7, 2024

Thanks!

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.

2 participants