Skip to content

Commit

Permalink
removed unnecessary dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nstilt1 committed Dec 14, 2023
1 parent d4d4ab6 commit 6bbfba3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 103 deletions.
51 changes: 0 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions chacha20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ cipher = { version = "0.4.4", features = ["dev"] }
hex-literal = "0.3.3"
rand_chacha = "0.3.1"
serde_json = "1.0" # Only to test serde1
sha2 = "0.10" # For testing fill_bytes()
sha3 = "0.10" # Also for testing fill_bytes(), but it may be unnecessary

[features]
default = ["cipher"]
Expand Down
51 changes: 1 addition & 50 deletions chacha20/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,56 +1033,7 @@ mod tests {
assert_eq!(rng.get_word_pos(), 0);
}

#[test]
/// The hash values from this are from a previous working version of the RNG
fn test_fill_bytes_hashes() {
use hex_literal::hex;
use sha2::{Digest, Sha256, Sha512};
use sha3::{Sha3_256, Sha3_512};

let mut rng = ChaCha20Rng::from_seed([0u8; 32]);
let mut samples = [0u8; 4192];
rng.fill_bytes(&mut samples[0..3]);
rng.fill_bytes(&mut samples[3..15]);
rng.fill_bytes(&mut samples[15..907]);
rng.fill_bytes(&mut samples[907..938]);
rng.fill_bytes(&mut samples[938..1735]);
rng.fill_bytes(&mut samples[1735..1800]);
rng.fill_bytes(&mut samples[1800..2204]);
rng.fill_bytes(&mut samples[2204..2222]);
rng.fill_bytes(&mut samples[2222..2500]);
rng.fill_bytes(&mut samples[2500..2525]);
rng.fill_bytes(&mut samples[2525..3001]);
rng.fill_bytes(&mut samples[3001..3800]);
rng.fill_bytes(&mut samples[3800..4192]);

let mut hasher = Sha256::new();
hasher.update(samples);
let sha256 = hasher.finalize();
assert_eq!(
sha256,
hex!("ded7b3a2b6a1cce08021a7130fee540ee44271af307b296b67c712c3543c3d66").into()
);
let mut hasher = Sha512::new();
hasher.update(samples);
let sha512 = hasher.finalize();
assert_eq!(sha512, hex!("378c5ccb5f7239635a5a2470168a7c9d9ed03780d83e52ec046429fb0061ea202f2f603fa51c8f33f73fbf889fc666394ab33963a640d658e18fd32041d86ed6").into());

let mut hasher = Sha3_256::new();
hasher.update(samples);
let sha3_256 = hasher.finalize();
assert_eq!(
sha3_256,
hex!("8c7a9aeb2f5a5c2b2f9a045acd6ca9961b466be6a4d6939c76a6edb714ded194").into()
);

// testing
let mut hasher = Sha3_512::new();
hasher.update(samples);
let sha3_512 = hasher.finalize();
assert_eq!(sha3_512, hex!("299604773b3aa69c28376677c7fb8a242d6fda6083f8ecabbb637a0bbf500f6a45006b1705b08d2a268a02319f97a8bc257600fb29bd7029fb5116039b4809fb").into());
}

// test for next rand_core version
// #[test]
// fn test_trait_objects() {
// use rand_core::CryptoRng;
Expand Down

0 comments on commit 6bbfba3

Please sign in to comment.