chacha20: fix big endian failure and test in CI#447
chacha20: fix big endian failure and test in CI#447tarcieri merged 4 commits intoRustCrypto:masterfrom
Conversation
|
Not sure why it's only running fmt and clippy |
@nstilt1 yeah there's some pre-existing misconfiguration, it's missing the CI config in its triggers: on:
pull_request:
paths:
- ".github/workflows/chacha20.yml"
- "chacha20/**"
- "Cargo.*"
push:
branches: master
paths:
- ".github/workflows/chacha20.yml"
- "chacha20/**"
- "Cargo.*" |
|
There we go, there are the failing tests. Do you want me to move all of the
I'm not sure what you want me to do with that... I'm new to this CI/CD stuff. |
|
Or should I add that big endian cfg back in this PR? |
|
#448 fixes the CI misconfiguration I noted earlier. Thanks for reproducing the big endian failure. Now that we know it's broken if you can fix it in this same PR that'd be great, even if the fix is just changing it back to what it was before. |
chacha20: revised big endian tests to use all features| #[cfg(target_endian = "big")] | ||
| for word in r.0.iter_mut() { | ||
| *word = word.to_le(); | ||
| } |
There was a problem hiding this comment.
I believe this is wrong: there is no type change here (u32 to u32) so there should be no endian-switch.
We also don't do this in rand_chacha.
There was a problem hiding this comment.
I dug through rand_chacha and ppv-lite86 for a few minutes and couldn't find anywhere with endian conversions regarding the output. But multiple tests fail on big endian. If you look closely, you can see that the bytes within the words are in reverse order. I don't know why they are in reverse order, but the tests pass as soon as to_le() is called on all of the words.
https://github.com/RustCrypto/stream-ciphers/actions/runs/17169966574/job/48717538576
There was a problem hiding this comment.
I might have found the problem. Line 48 of soft.rs converts each word to little endian. Big endian code will most likely be hitting the soft.rs backend. Even if this isn't the culprit, then this part of the code should be using conditional compilation. Will change the code and run a test right quick
There was a problem hiding this comment.
Yeah, I'm pretty sure the backends shouldn't be doing any endian conversions.
Big endian tests don't currently run tests in
src/rng.rs. If they did they would fail. Working on getting this yml thing working.