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
29 changes: 10 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions src/chaff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions src/dec.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";

Expand Down Expand Up @@ -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<E>>(tokio::task::spawn_blocking({
let progress = progress.clone();
move || {
Expand Down
8 changes: 5 additions & 3 deletions src/enc.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use ssec_core::Encrypt;
use ssec_core::{Encrypt, EncryptArgs};
use futures_util::StreamExt;
use tokio::io::AsyncWriteExt;
use rand::rngs::SysRng;
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";

Expand Down Expand Up @@ -48,7 +48,9 @@ pub async fn enc<B: IoBundle>(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 {
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading