Add AES128-GCM to the benchmark

This commit is contained in:
Rodolphe Bréard 2024-03-24 14:38:03 +01:00
parent 747163f433
commit 360917adb8
7 changed files with 46 additions and 15 deletions

View file

@ -7,10 +7,17 @@ pub const DATA_CTX: &[&str] = &[
// created_at: Sunday 21 February 2021 10:21:42 // created_at: Sunday 21 February 2021 10:21:42
// expire_at: Thursday 10 February 2180 10:21:42 // expire_at: Thursday 10 February 2180 10:21:42
// is_revoked: false // is_revoked: false
pub const IKML_AES128GCM_SHA256: &str =
"AQAAAA:AQAAAAIAAAAAsPHG8Eyb8uZBAUUyUuxIRdQ5mIO1v1QDBhWOzbCRvzY0MmAAAAAANsk0iwEAAAAA";
// created_at: Sunday 21 February 2021 10:21:42
// expire_at: Thursday 10 February 2180 10:21:42
// is_revoked: false
pub const IKML_XCHACHA20POLY1305_BLAKE3: &str = pub const IKML_XCHACHA20POLY1305_BLAKE3: &str =
"AQAAAA:AwAAAAEAAAAMoNIW9gIGkzegUDEsU3N1Rf_Zz0OMuylUSiQjUzLXqzY0MmAAAAAANsk0iwEAAAAA"; "AQAAAA:AwAAAAEAAAAMoNIW9gIGkzegUDEsU3N1Rf_Zz0OMuylUSiQjUzLXqzY0MmAAAAAANsk0iwEAAAAA";
pub const IKMLS: &[(&str, &str)] = pub const IKMLS: &[(&str, &str)] = &[
&[("XChaCha20Poly1305WithBlake3", IKML_XCHACHA20POLY1305_BLAKE3)]; ("Aes128GcmWithSha256", IKML_AES128GCM_SHA256),
("XChaCha20Poly1305WithBlake3", IKML_XCHACHA20POLY1305_BLAKE3),
];
pub const PLAIN_INPUTS: &[(&str, &str)] = &[ pub const PLAIN_INPUTS: &[(&str, &str)] = &[
("01 - 12 B", include_str!("data/plain_01_xs.txt")), ("01 - 12 B", include_str!("data/plain_01_xs.txt")),
("02 - 60 B", include_str!("data/plain_02_s.txt")), ("02 - 60 B", include_str!("data/plain_02_s.txt")),
@ -18,6 +25,13 @@ pub const PLAIN_INPUTS: &[(&str, &str)] = &[
("04 - 3 KB", include_str!("data/plain_04_l.txt")), ("04 - 3 KB", include_str!("data/plain_04_l.txt")),
("05 - 1 MB", include_str!("data/plain_05_xl.txt")), ("05 - 1 MB", include_str!("data/plain_05_xl.txt")),
]; ];
pub const AES128GCM_SHA256_INPUTS: &[(&str, &str)] = &[
("01 - 12 B", include_str!("data/aes128gcm-sha256_01_xs.txt")),
("02 - 60 B", include_str!("data/aes128gcm-sha256_02_s.txt")),
("03 - 500 B", include_str!("data/aes128gcm-sha256_03_m.txt")),
("04 - 3 KB", include_str!("data/aes128gcm-sha256_04_l.txt")),
("05 - 1 MB", include_str!("data/aes128gcm-sha256_05_xl.txt")),
];
pub const XCHACHA20POLY1305_BLAKE3_INPUTS: &[(&str, &str)] = &[ pub const XCHACHA20POLY1305_BLAKE3_INPUTS: &[(&str, &str)] = &[
( (
"01 - 12 B", "01 - 12 B",

View file

@ -0,0 +1 @@
AQAAAA:R4zK4C5eFBIAhG9y:hiJ1dc9rOHfBuHJwEJmCAq_9PpN7aVsEMUEoFw:NgAAAAAAAAA

View file

@ -0,0 +1 @@
AQAAAA:YD4jWQdLKz-V254H:L9vGvIhZBbohD_fRc1uRxriY4uinIP3IYnLLEl123EvK4w0ICA73sXEWZlHKSW_TZ7MHB7Yk-au1d589gSFyU3ipnXJ72yXMUQV-mQ:NgAAAAAAAAA

View file

@ -0,0 +1 @@
AQAAAA:fXP3E1yV4UYqkarE:NubJ-lawq314h3sCoZWvi54_3jZ7VT41_pazZLXRoqTlbEMyh2eBvypfLZfJbM9E4-6Gl2oFdvQgLC5vM66zt9ZC9Zrj3LREwf6a7lsBgblj1c2lT42tkFCo7E33LftyjMCiz0HlsNg_-my8okJ-3MR1QByeEqPgyaKL5t4lo0apHCWr3K_TYaA40gZM2GMfKMRNpOCA2z_smgttwrrRLkUMCRAxH3Ogfe2inX3HF0iHlm58FV-4kfdCOXheXquOXvGjfigiDfYE9Pj3IcGLgJwpdbZbhnXAsB4ySl3IhEk3v8Tvoij3fHSJFYbA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IPUGQ5f3VSYVzeP1iUg9QfLhsbkZVDz8yKTO8U2_OElWMisb0_JPifObQURyzAASPLuzeNqRdY4NKR_byxNaN21gm9SmK8O1X_Wblp_Ai-X1jN3RptFX086XMqi0QYORptqJHW7XonXMnR5w:NgAAAAAAAAA

File diff suppressed because one or more lines are too long

View file

@ -3,11 +3,22 @@ mod data;
use coffio::{CipherBox, DataContext, InputKeyMaterialList, KeyContext}; use coffio::{CipherBox, DataContext, InputKeyMaterialList, KeyContext};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use data::{ use data::{
Data, DATA_CTX, IKML_XCHACHA20POLY1305_BLAKE3, KEY_CTX, MEASUREMENT_TIME, Data, AES128GCM_SHA256_INPUTS, DATA_CTX, IKML_AES128GCM_SHA256, IKML_XCHACHA20POLY1305_BLAKE3,
XCHACHA20POLY1305_BLAKE3_INPUTS, KEY_CTX, MEASUREMENT_TIME, XCHACHA20POLY1305_BLAKE3_INPUTS,
}; };
use std::time::Duration; use std::time::Duration;
macro_rules! alg_group {
($group: ident, $name: expr, $inputs: ident, $ikml: ident) => {
for (input_name, input) in $inputs.iter() {
let data = Data { ikml: $ikml, input };
$group.bench_with_input(BenchmarkId::new($name, input_name), &data, |b, i| {
b.iter(|| decrypt_coffio(i.ikml, i.input))
});
}
};
}
fn decrypt_coffio(ikml: &str, input: &str) { fn decrypt_coffio(ikml: &str, input: &str) {
let ikm = InputKeyMaterialList::import(ikml).unwrap(); let ikm = InputKeyMaterialList::import(ikml).unwrap();
let key_ctx = KeyContext::from(KEY_CTX); let key_ctx = KeyContext::from(KEY_CTX);
@ -21,17 +32,18 @@ fn decrypt_coffio(ikml: &str, input: &str) {
pub fn decryption_benchmark(c: &mut Criterion) { pub fn decryption_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("Decryption"); let mut group = c.benchmark_group("Decryption");
group.measurement_time(Duration::from_secs(MEASUREMENT_TIME)); group.measurement_time(Duration::from_secs(MEASUREMENT_TIME));
for (input_name, input) in XCHACHA20POLY1305_BLAKE3_INPUTS.iter() { alg_group!(
let data = Data { group,
ikml: IKML_XCHACHA20POLY1305_BLAKE3, "Aes128GcmWithSha256",
input, AES128GCM_SHA256_INPUTS,
}; IKML_AES128GCM_SHA256
group.bench_with_input( );
BenchmarkId::new("XChaCha20Poly1305WithBlake3", input_name), alg_group!(
&data, group,
|b, i| b.iter(|| decrypt_coffio(i.ikml, i.input)), "XChaCha20Poly1305WithBlake3",
XCHACHA20POLY1305_BLAKE3_INPUTS,
IKML_XCHACHA20POLY1305_BLAKE3
); );
}
} }
criterion_group!(benches, decryption_benchmark); criterion_group!(benches, decryption_benchmark);