Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Apr 1, 2023
1 parent 6673d86 commit b662654
Show file tree
Hide file tree
Showing 101 changed files with 29,487 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cargo.lock
.vscode
23 changes: 23 additions & 0 deletions Cargo.toml
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",
]
20 changes: 20 additions & 0 deletions aes/Cargo.toml
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
43 changes: 43 additions & 0 deletions aes/benches/benchmarks.rs
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);
Loading

0 comments on commit b662654

Please sign in to comment.