Skip to content

Commit b247cd5

Browse files
authored
chacha20: fix big endian failure and test in CI (#447)
Fixes failure introduced in #437, and updates CI to catch similar issues in the future
1 parent 017db18 commit b247cd5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.github/workflows/chacha20.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,4 @@ jobs:
213213
toolchain: ${{ matrix.rust }}
214214
targets: ${{ matrix.target }}
215215
- uses: RustCrypto/actions/cross-install@master
216-
- run: RUSTFLAGS="${{ matrix.rustflags }}" cross test --package chacha20 --target ${{ matrix.target }}
216+
- run: RUSTFLAGS="${{ matrix.rustflags }}" cross test --package chacha20 --target ${{ matrix.target }} --all-features

chacha20/src/rng.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ macro_rules! impl_chacha_rng {
362362
#[inline]
363363
fn generate(&mut self, r: &mut Self::Results) {
364364
self.0.generate(&mut r.0);
365+
#[cfg(target_endian = "big")]
366+
for word in r.0.iter_mut() {
367+
*word = word.to_le();
368+
}
365369
}
366370
}
367371

@@ -1066,7 +1070,7 @@ pub(crate) mod tests {
10661070
tester_array = [0u8; LEN];
10671071
dest_pos = 0;
10681072

1069-
// test fill_bytes with lengths starting at N bytes, decreasing by 1,
1073+
// test fill_bytes with lengths starting at `N` bytes, decreasing by 1,
10701074
// down to 1 byte
10711075
for test_len in 1..=N {
10721076
let debug_start_word_pos = rng.get_word_pos();

0 commit comments

Comments
 (0)