Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions .github/workflows/chacha20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --features zeroize
- uses: RustCrypto/actions/cargo-hack-install@master
- run: cargo hack build --feature-powerset --target ${{ matrix.target }}

minimal-versions:
if: false # TODO: temp disabled due to unpublished prerelease dependencies
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
with:
working-directory: ${{ github.workflow }}

# Tests for runtime AVX2 detection
# Tests for runtime CPU feature detection
autodetect:
runs-on: ubuntu-latest
strategy:
Expand All @@ -74,11 +73,10 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: ${{ matrix.deps }}
- run: cargo check --target ${{ matrix.target }} --all-features
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features zeroize
- run: cargo test --target ${{ matrix.target }} --all-features
- run: cargo hack test --feature-powerset --target ${{ matrix.target }}

# Tests for the AVX2 backend
avx2:
Expand Down Expand Up @@ -108,11 +106,10 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: ${{ matrix.deps }}
- run: cargo check --target ${{ matrix.target }} --all-features
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features zeroize
- run: cargo test --target ${{ matrix.target }} --all-features
- run: cargo hack test --feature-powerset --target ${{ matrix.target }}

# Tests for the SSE2 backend
sse2:
Expand Down Expand Up @@ -142,11 +139,10 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: ${{ matrix.deps }}
- run: cargo check --target ${{ matrix.target }} --all-features
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features zeroize
- run: cargo test --target ${{ matrix.target }} --all-features
- run: cargo hack test --feature-powerset --target ${{ matrix.target }}

# Tests for the portable software backend
soft:
Expand Down Expand Up @@ -176,11 +172,10 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: ${{ matrix.deps }}
- run: cargo check --target ${{ matrix.target }} --all-features
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features zeroize
- run: cargo test --target ${{ matrix.target }} --all-features
- run: cargo hack test --feature-powerset --target ${{ matrix.target }}

# Cross-compiled tests
cross:
Expand Down
2 changes: 1 addition & 1 deletion chacha20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rand_core-compatible RNGs based on those ciphers.
cfg-if = "1"
cipher = { version = "0.5.0-rc.1", optional = true, features = ["stream-wrapper"] }
rand_core = { version = "0.9", optional = true, default-features = false }
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }

# `zeroize` is an explicit dependency because this crate may be used without the `cipher` crate
zeroize = { version = "1.8.1", optional = true, default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions chacha20/src/backends.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(any(feature = "cipher", feature = "rng"))]

use cfg_if::cfg_if;

cfg_if! {
Expand Down
2 changes: 2 additions & 0 deletions chacha20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub use legacy::{ChaCha20Legacy, LegacyNonce};
pub use xchacha::{XChaCha8, XChaCha12, XChaCha20, XNonce, hchacha};

/// State initialization constant ("expand 32-byte k")
#[cfg(any(feature = "cipher", feature = "rng"))]
const CONSTANTS: [u32; 4] = [0x6170_7865, 0x3320_646e, 0x7962_2d32, 0x6b20_6574];

/// Number of 32-bit words in the ChaCha state
Expand Down Expand Up @@ -230,6 +231,7 @@ impl<R: Rounds, V: Variant> ChaChaCore<R, V> {
/// Constructs a ChaChaCore with the specified key, iv, and amount of rounds.
/// You must ensure that the iv is of the correct size when using this method
/// directly.
#[cfg(any(feature = "cipher", feature = "rng"))]
fn new(key: &[u8; 32], iv: &[u8]) -> Self {
let mut state = [0u32; STATE_WORDS];

Expand Down