forked from hacspec/specs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
29,487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Cargo.lock | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[workspace] | ||
members = [ | ||
"basic", | ||
"curve25519", | ||
"chacha20", | ||
"poly1305", | ||
"chacha20poly1305", | ||
"gimli", | ||
"sha256", | ||
"sha3", | ||
"hmac", | ||
"hkdf", | ||
"p256", | ||
"bls12-381", | ||
"ecdsa-p256-sha256", | ||
"aes", | ||
"aes_jazz", | ||
"gf128", | ||
"aes128-gcm", | ||
"bls12-381-hash", | ||
"edwards25519", | ||
"ed25519", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "hacspec-aes" | ||
version = "0.1.0" | ||
authors = ["Franziskus Kiefer <[email protected]>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
path = "src/aes.rs" | ||
|
||
[dependencies] | ||
hacspec-lib = { git = "https://github.com/hacspec/hacspec.git" } | ||
|
||
[dev-dependencies] | ||
criterion = "0.4" | ||
rand = "0.8" | ||
hacspec-dev = { git = "https://github.com/hacspec/hacspec.git" } | ||
|
||
[[bench]] | ||
name = "benchmarks" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#[macro_use] | ||
extern crate criterion; | ||
use criterion::{BatchSize, Criterion}; | ||
|
||
use hacspec_aes::*; | ||
use hacspec_dev::rand::random_byte_vec; | ||
use hacspec_lib::prelude::*; | ||
|
||
fn benchmark(c: &mut Criterion) { | ||
c.bench_function("AES 128 encrypt", |b| { | ||
b.iter_batched( | ||
|| { | ||
let key = Key128::from_public_slice(&random_byte_vec(16)); | ||
let nonce = AesNonce::from_public_slice(&random_byte_vec(12)); | ||
let data = ByteSeq::from_public_slice(&random_byte_vec(10_000)); | ||
(data, nonce, key) | ||
}, | ||
|(data, nonce, key)| { | ||
let _c = aes128_encrypt(key, nonce, U32(0), &data); | ||
}, | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
|
||
c.bench_function("AES 128 decrypt", |b| { | ||
b.iter_batched( | ||
|| { | ||
let key = Key128::from_public_slice(&random_byte_vec(16)); | ||
let nonce = AesNonce::from_public_slice(&random_byte_vec(12)); | ||
let data = ByteSeq::from_public_slice(&random_byte_vec(10_000)); | ||
let ctxt = aes128_encrypt(key, nonce, U32(0), &data); | ||
(ctxt, nonce, key) | ||
}, | ||
|(ctxt, nonce, key)| { | ||
let _m = aes128_decrypt(key, nonce, U32(0), &ctxt); | ||
}, | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, benchmark); | ||
criterion_main!(benches); |
Oops, something went wrong.