Skip to content

Commit 58b3087

Browse files
authored
breaking: align chacha20 with rfc (#16)
* fix: align `chacha20` with rfc * docs: add reference to RFC standard * refactor: remove unnecessary fn from core * docs: enhance docs * docs: fix inline documentation
1 parent 74cab52 commit 58b3087

File tree

11 files changed

+616
-612
lines changed

11 files changed

+616
-612
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benches/src/chacha20.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
use criterion::{
22
criterion_group, criterion_main, BenchmarkId, Criterion, PlotConfiguration, Throughput,
33
};
4-
use secured_cipher::chacha20::{ChaChaStream, KEY_SIZE, NONCE_SIZE};
4+
use secured_cipher::{
5+
permutation::core::{CHACHA20_NONCE_SIZE, KEY_SIZE},
6+
Cipher, CipherMode,
7+
};
58

69
const KB: usize = 1024;
710
const MB: usize = 1024 * KB;
811
const GB: usize = 1024 * MB;
912

1013
fn bench(c: &mut Criterion) {
11-
let mut group = c.benchmark_group("ChaChaStream");
14+
let mut group = c.benchmark_group("ChaCha20");
1215
let plot_config = PlotConfiguration::default().summary_scale(criterion::AxisScale::Logarithmic);
1316
group.plot_config(plot_config);
1417

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

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

43-
// group.bench_with_input(BenchmarkId::new("new", size), size, |b, &_size| {
44-
// b.iter(|| ChaChaStream::new(key, iv));
45-
// });
46+
let mut cipher = Cipher::new(CipherMode::ChaCha20);
47+
cipher.init(&key, &iv);
4648

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

cipher/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ description = "Pure Rust implementation of the ChaCha cipher family"
1010
package = "secured-cipher-key"
1111
path = "./key"
1212
version = "0.1.0"
13-
14-
[dependencies.rayon]
15-
package = "rayon"
16-
version = "~1.8.0"

cipher/src/chacha20/core.rs

Lines changed: 0 additions & 190 deletions
This file was deleted.

cipher/src/chacha20/mod.rs

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)