feat: updat eaegis test

This commit is contained in:
2023-08-19 23:34:41 +08:00
parent a321aae4d2
commit 45eb023741
4 changed files with 75 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ dependencies = [
"ascon-aead", "ascon-aead",
"benchmark-simple", "benchmark-simple",
"chacha20poly1305", "chacha20poly1305",
"rocca",
] ]
[[package]] [[package]]
@@ -297,6 +298,15 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "rocca"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b52de49d9fde07d1241f2156a8958b65c71ce615f2ff8256ae5106513eb1713e"
dependencies = [
"aes",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.4.0" version = "0.4.0"

View File

@@ -11,3 +11,4 @@ aes-gcm = "0.10.2"
ascon-aead = "0.4.2" ascon-aead = "0.4.2"
benchmark-simple = "0.1.8" benchmark-simple = "0.1.8"
chacha20poly1305 = "0.10.1" chacha20poly1305 = "0.10.1"
rocca = "0.3.0"

View File

@@ -0,0 +1,52 @@
Benchmark:
```shell
$ cargo r --release
aegis128l : 10.63 G/s
aes256-gcm : 546.31 M/s
aes128-gcm : 597.56 M/s
chacha20-poly1305 : 1.03 G/s
ascon128a : 330.85 M/s
rocca : 307.84 M/s
```
```shell
$ RUSTFLAGS="-Ctarget-feature=+aes,+sse4.1" cargo r --release
aegis128l : 10.68 G/s
aes256-gcm : 554.68 M/s
aes128-gcm : 608.58 M/s
chacha20-poly1305 : 1.04 G/s
ascon128a : 337.74 M/s
rocca : 2.75 G/s
```
```shell
$ RUSTFLAGS="-Ctarget-feature=+aes,+sse4.2" cargo r --release
aegis128l : 10.74 G/s
aes256-gcm : 706.54 M/s
aes128-gcm : 797.11 M/s
chacha20-poly1305 : 1.04 G/s
ascon128a : 338.19 M/s
rocca : 6.05 G/s
```
```shell
$ RUSTFLAGS="-C target-cpu=native -Ctarget-feature=+aes,+pclmulqdq,+sse4.1" cargo r --release
aegis128l : 10.62 G/s
aes256-gcm : 695.29 M/s
aes128-gcm : 778.97 M/s
chacha20-poly1305 : 1.17 G/s
ascon128a : 345.49 M/s
rocca : 4.28 G/s
```
```shell
$ RUSTFLAGS="-C target-cpu=native -Ctarget-feature=+aes,+pclmulqdq,+sse4.2" cargo r --release
aegis128l : 10.60 G/s
aes256-gcm : 692.76 M/s
aes128-gcm : 760.85 M/s
chacha20-poly1305 : 1.18 G/s
ascon128a : 344.81 M/s
rocca : 4.28 G/s
```

View File

@@ -5,6 +5,7 @@ use aes_gcm::{
}; };
use benchmark_simple::*; use benchmark_simple::*;
use chacha20poly1305::ChaCha20Poly1305; use chacha20poly1305::ChaCha20Poly1305;
use rocca::Rocca;
fn test_aes256gcm(m: &mut [u8]) { fn test_aes256gcm(m: &mut [u8]) {
let key = aes_gcm::Key::<Aes256Gcm>::from_slice(&[0u8; 32]); let key = aes_gcm::Key::<Aes256Gcm>::from_slice(&[0u8; 32]);
@@ -43,12 +44,19 @@ fn test_aegis128l(m: &mut [u8]) {
state.encrypt_in_place(m, &[]); state.encrypt_in_place(m, &[]);
} }
fn test_rocca(m: &mut [u8]) {
let key = [0u8; 32];
let nonce = [0u8; 16];
let state = Rocca::new(&nonce, &key);
state.encrypt_in_place(m, &[]);
}
fn main() { fn main() {
let bench = Bench::new(); let bench = Bench::new();
let mut m = vec![0xd0u8; 16384]; let mut m = vec![0xd0u8; 16384];
let options = &Options { let options = &Options {
iterations: 10_000, // 100_000 > 10_000 iterations: 10_000, // 100_000 -> 10_000 -> 1_000
warmup_iterations: 1_000, warmup_iterations: 1_000,
min_samples: 5, min_samples: 5,
max_samples: 10, max_samples: 10,
@@ -70,4 +78,7 @@ fn main() {
let res = bench.run(options, || test_ascon128a(&mut m)); let res = bench.run(options, || test_ascon128a(&mut m));
println!("ascon128a : {}", res.throughput(m.len() as _)); println!("ascon128a : {}", res.throughput(m.len() as _));
let res = bench.run(options, || test_rocca(&mut m));
println!("rocca : {}", res.throughput(m.len() as _));
} }