diff --git a/Cargo.lock b/Cargo.lock index 642fa33..9d1fbdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,13 +4,13 @@ version = 4 [[package]] name = "aes" -version = "0.9.0-rc.4" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04097e08a47d9ad181c2e1f4a5fabc9ae06ce8839a333ba9a949bcb0d31fd2a3" +checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8" dependencies = [ "cipher", "cpubits", - "cpufeatures 0.2.17", + "cpufeatures", "zeroize", ] @@ -87,7 +87,7 @@ checksum = "7af50940b73bf4e16c15c448a2b121c63f2d68e3e54b6a8731673cb4aa0cdff5" dependencies = [ "base64ct", "blake2", - "cpufeatures 0.3.0", + "cpufeatures", "password-hash", "zeroize", ] @@ -210,7 +210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" dependencies = [ "cfg-if", - "cpufeatures 0.3.0", + "cpufeatures", "rand_core 0.10.1", ] @@ -352,15 +352,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - [[package]] name = "cpufeatures" version = "0.3.0" @@ -381,9 +372,9 @@ dependencies = [ [[package]] name = "ctr" -version = "0.10.0-rc.4" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee683dd898fbd052617b4514bc31f98bc32081a83b69ec46adef3b1ef4ae36f" +checksum = "17469f8eb9bdbfad10f71f4cfddfd38b01143520c0e717d8796ccb4d44d44e42" dependencies = [ "cipher", ] @@ -1055,7 +1046,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e24a010dd405bd7ed803e5253182815b41bf2e6a80cc3bfc066658e03a198aa" dependencies = [ "cfg-if", - "cpufeatures 0.3.0", + "cpufeatures", ] [[package]] @@ -1721,9 +1712,9 @@ dependencies = [ [[package]] name = "ssec-core" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850207f1b3fb14e2719c2a91c7758db11e77cd2bcea0c42ebaed091a6abc40dd" +checksum = "713aa9aae93ae79f9acc0549dca3c3f77b344b19aad92c7e5c54cc744f246c68" dependencies = [ "aes", "argon2", diff --git a/Cargo.toml b/Cargo.toml index 1f63396..63e1d66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ version = "0.18" features = [ "tokio" ] [dependencies] -ssec-core = "0.8" +ssec-core = "0.9" futures-util = "0.3" zeroize = "1.8" rpassword = "7.5" diff --git a/src/chaff.rs b/src/chaff.rs index 29c7cee..d11b6cf 100644 --- a/src/chaff.rs +++ b/src/chaff.rs @@ -4,7 +4,7 @@ use rand::{TryRng, SeedableRng}; use rand::rngs::SysRng; use tokio::io::AsyncWriteExt; use futures_util::StreamExt; -use ssec_core::ChaffStream; +use ssec_core::{ChaffStream, ChaffStreamArgs}; use std::str::FromStr; use crate::cli::{Cli, ChaffArgs}; @@ -90,7 +90,9 @@ pub async fn chaff(args: ChaffArgs) -> Result<(), ()> { eprintln!("failed to open specified outout file {:?}: {e}", args.out_file); }).map(|f| tokio::io::BufWriter::with_capacity(f.max_buf_size(), f))?; - let mut chaff = ChaffStream::new(rand::rngs::StdRng::try_from_rng(&mut SysRng).unwrap(), size as usize, 8 * 1024).unwrap(); + let mut args = ChaffStreamArgs::with_length(size as usize); + args.set_chunk_size(8 * 1024).unwrap(); + let mut chaff = ChaffStream::new(args, rand::rngs::StdRng::try_from_rng(&mut SysRng).unwrap()); while let Some(bytes) = chaff.next().await { let b = bytes.unwrap(); diff --git a/src/dec.rs b/src/dec.rs index 0298bbc..10bc766 100644 --- a/src/dec.rs +++ b/src/dec.rs @@ -1,4 +1,4 @@ -use ssec_core::decrypt::{Decrypt, SsecHeaderError}; +use ssec_core::decrypt::{Decrypt, DecryptArgs, SsecHeaderError}; use futures_util::{Stream, StreamExt}; use tokio::io::AsyncWriteExt; use zeroize::Zeroizing; @@ -8,7 +8,7 @@ use crate::cli::{DecArgs, FetchArgs}; use crate::file::new_async_tempfile; use crate::password::prompt_password; use crate::io::IoBundle; -use crate::{DEFINITE_BAR_STYLE, INDEFINITE_BAR_STYLE}; +use crate::{DEFINITE_BAR_STYLE, INDEFINITE_BAR_STYLE, BYTES_PER_POLL}; const SPINNER_STYLE: &str = "{spinner} deriving decryption key"; @@ -48,7 +48,9 @@ where let (dec, f_out) = tokio::join!( async { - let dec = Decrypt::new(stream).await?; + let mut args = DecryptArgs::default(); + args.set_bytes_per_poll(BYTES_PER_POLL); + let dec = Decrypt::new(args, stream).await?; Ok::<_, SsecHeaderError>(tokio::task::spawn_blocking({ let progress = progress.clone(); move || { diff --git a/src/enc.rs b/src/enc.rs index 5ee339d..d702679 100644 --- a/src/enc.rs +++ b/src/enc.rs @@ -1,4 +1,4 @@ -use ssec_core::Encrypt; +use ssec_core::{Encrypt, EncryptArgs}; use futures_util::StreamExt; use tokio::io::AsyncWriteExt; use rand::rngs::SysRng; @@ -6,7 +6,7 @@ use indicatif::{ProgressBar, ProgressStyle}; use crate::cli::EncArgs; use crate::password::prompt_password; use crate::io::IoBundle; -use crate::DEFINITE_BAR_STYLE; +use crate::{DEFINITE_BAR_STYLE, BYTES_PER_POLL}; const SPINNER_STYLE: &str = "{spinner} deriving encryption key"; @@ -48,7 +48,9 @@ pub async fn enc(args: EncArgs, io: B) -> Result<(), ()> { spinner.set_style(ProgressStyle::with_template(SPINNER_STYLE).unwrap()); spinner.enable_steady_tick(std::time::Duration::from_millis(100)); - Encrypt::new_uncompressed(s, &password, &mut SysRng) + let mut args = EncryptArgs::default(); + args.set_bytes_per_poll(BYTES_PER_POLL); + Encrypt::new(args, &mut SysRng, &password, s) }).await.unwrap().unwrap(); let mut f_out = match args.out_file { diff --git a/src/lib.rs b/src/lib.rs index 86a5a1e..cac51b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,8 @@ mod tests; const DEFINITE_BAR_STYLE: &str = "[{elapsed_precise}] {binary_bytes_per_sec} {bar} {binary_bytes}/{binary_total_bytes} ({eta})"; const INDEFINITE_BAR_STYLE: &str = "[{elapsed_precise}] {binary_bytes_per_sec} ({eta})"; +const BYTES_PER_POLL: core::num::NonZeroUsize = core::num::NonZeroUsize::new(2048).unwrap(); + #[inline] fn handle_err(result: Result<(), ()>) -> std::process::ExitCode { match result {