stream-ciphers
stream-ciphers copied to clipboard
Replace `quarter_round` in xchacha with soft backend version
The quarter_round function is duplicated inside xchacha. We can just use the soft backend version, which is the same code.
https://github.com/RustCrypto/stream-ciphers/pull/348#pullrequestreview-1958048341
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.
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.
Perhaps it could be relocated somewhere it's always available. Failing other options, the toplevel of the module is a choice.
Ok!
Now I'm noticing we should really get #333 landed first
@oxarbitrage need to re-evaluate this PR now that #333 has been merged
Thanks!