Skip to content

Commit

Permalink
breaking: align chacha20 with rfc (#16)
Browse files Browse the repository at this point in the history
* fix: align `chacha20` with rfc

* docs: add reference to RFC standard

* refactor: remove unnecessary fn from core

* docs: enhance docs

* docs: fix inline documentation
  • Loading branch information
mikesposito authored Dec 2, 2023
1 parent 74cab52 commit 58b3087
Show file tree
Hide file tree
Showing 11 changed files with 616 additions and 612 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

17 changes: 9 additions & 8 deletions benches/src/chacha20.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use criterion::{
criterion_group, criterion_main, BenchmarkId, Criterion, PlotConfiguration, Throughput,
};
use secured_cipher::chacha20::{ChaChaStream, KEY_SIZE, NONCE_SIZE};
use secured_cipher::{
permutation::core::{CHACHA20_NONCE_SIZE, KEY_SIZE},
Cipher, CipherMode,
};

const KB: usize = 1024;
const MB: usize = 1024 * KB;
const GB: usize = 1024 * MB;

fn bench(c: &mut Criterion) {
let mut group = c.benchmark_group("ChaChaStream");
let mut group = c.benchmark_group("ChaCha20");
let plot_config = PlotConfiguration::default().summary_scale(criterion::AxisScale::Logarithmic);
group.plot_config(plot_config);

Expand Down Expand Up @@ -36,17 +39,15 @@ fn bench(c: &mut Criterion) {
GB,
] {
let key = [0u8; KEY_SIZE];
let iv = [1u8; NONCE_SIZE];
let iv = [1u8; CHACHA20_NONCE_SIZE];

group.throughput(Throughput::Bytes(*size as u64));

// group.bench_with_input(BenchmarkId::new("new", size), size, |b, &_size| {
// b.iter(|| ChaChaStream::new(key, iv));
// });
let mut cipher = Cipher::new(CipherMode::ChaCha20);
cipher.init(&key, &iv);

let mut stream = ChaChaStream::new(key, iv);
group.bench_with_input(BenchmarkId::new("process", size), size, |b, &_size| {
b.iter(|| stream.process(&vec![0u8; *size]));
b.iter(|| cipher.encrypt(&vec![0u8; *size]));
});
}

Expand Down
4 changes: 0 additions & 4 deletions cipher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ description = "Pure Rust implementation of the ChaCha cipher family"
package = "secured-cipher-key"
path = "./key"
version = "0.1.0"

[dependencies.rayon]
package = "rayon"
version = "~1.8.0"
190 changes: 0 additions & 190 deletions cipher/src/chacha20/core.rs

This file was deleted.

111 changes: 0 additions & 111 deletions cipher/src/chacha20/mod.rs

This file was deleted.

Loading

0 comments on commit 58b3087

Please sign in to comment.