Skip to content

Commit ecdd84b

Browse files
committed
Add pure-rust implementations of the parallel variants
Performance is not good, do not use them.
1 parent ff10a91 commit ecdd84b

19 files changed

+3538
-22
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ aes-gcm = "0.10.3"
2424
chacha20poly1305 = "0.10.1"
2525
sthash = "0.2.16"
2626
blake3 = "1.8.2"
27+
ct-codecs = "1.1"
28+
serde_json = "1.0"
2729

2830
[dependencies]
2931
aead = { optional = true, version = "0.6.0-rc.2", features = ["rand_core"] }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AEGIS is a new family of authenticated encryption algorithms, offering high secu
1010

1111
- `std`: allow dynamic allocations. This is the default.
1212

13-
- `pure-rust`: don't use the `cc` crate to take advantage of the implementations from [`libaegis`](https://github.com/jedisct1/libaegis). Setting this flag will substantially degrade performance, and parallel variants will not be available.
13+
- `pure-rust`: don't use the `cc` crate to take advantage of the implementations from [`libaegis`](https://github.com/jedisct1/libaegis). Setting this flag will substantially degrade performance and some features may not be available.
1414

1515
- `rustcrypto-traits-06`: add traits from `rust-crypto/aead` version 0.6. Alternative interfaces are available in the `compat` namespace.
1616

benches/benchmark.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use aegis::aegis128l::Aegis128L;
2-
use aegis::aegis256::Aegis256;
3-
4-
#[cfg(not(feature = "pure-rust"))]
52
use aegis::aegis128x2::Aegis128X2;
6-
#[cfg(not(feature = "pure-rust"))]
73
use aegis::aegis128x4::Aegis128X4;
4+
use aegis::aegis256::Aegis256;
5+
86
#[cfg(not(feature = "pure-rust"))]
97
use aegis::aegis256x2::Aegis256X2;
108
#[cfg(not(feature = "pure-rust"))]
@@ -81,15 +79,13 @@ fn test_aegis128l(m: &mut [u8]) {
8179
state.encrypt_in_place(m, &[]);
8280
}
8381

84-
#[cfg(not(feature = "pure-rust"))]
8582
fn test_aegis128x2(m: &mut [u8]) {
8683
let key = [0u8; 16];
8784
let nonce = [0u8; 16];
8885
let state = Aegis128X2::<16>::new(&nonce, &key);
8986
state.encrypt_in_place(m, &[]);
9087
}
9188

92-
#[cfg(not(feature = "pure-rust"))]
9389
fn test_aegis128x4(m: &mut [u8]) {
9490
let key = [0u8; 16];
9591
let nonce = [0u8; 16];
@@ -141,7 +137,10 @@ fn test_aegis128x4_mac(state: &Aegis128X4Mac<32>, m: &[u8]) {
141137
state.finalize();
142138
}
143139

144-
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
140+
#[cfg(all(
141+
not(feature = "pure-rust"),
142+
not(any(target_arch = "wasm32", target_arch = "wasm64"))
143+
))]
145144
fn test_hmac_sha256(m: &[u8]) {
146145
let md = boring::hash::MessageDigest::sha256();
147146
let mut h1 = boring::hash::hash(md, m).unwrap().to_vec();
@@ -221,20 +220,17 @@ fn main() {
221220
println!("* Encryption:");
222221
println!();
223222

224-
#[cfg(not(feature = "pure-rust"))]
225-
{
226-
let res = bench.run(options, || test_aegis128x4(&mut m));
227-
println!(
228-
"aegis128x4 : {}",
229-
res.throughput_bits(m.len() as _)
230-
);
223+
let res = bench.run(options, || test_aegis128x4(&mut m));
224+
println!(
225+
"aegis128x4 : {}",
226+
res.throughput_bits(m.len() as _)
227+
);
231228

232-
let res = bench.run(options, || test_aegis128x2(&mut m));
233-
println!(
234-
"aegis128x2 : {}",
235-
res.throughput_bits(m.len() as _)
236-
);
237-
}
229+
let res = bench.run(options, || test_aegis128x2(&mut m));
230+
println!(
231+
"aegis128x2 : {}",
232+
res.throughput_bits(m.len() as _)
233+
);
238234

239235
let res = bench.run(options, || test_aegis128l(&mut m));
240236
println!(

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ impl std::error::Error for Error {}
3434
pub mod compat;
3535

3636
#[cfg(test)]
37-
mod tests {
37+
mod tests;
38+
39+
#[cfg(test)]
40+
mod basic_tests {
3841

3942
#[test]
4043
#[cfg(feature = "std")]

0 commit comments

Comments
 (0)