mirror of
https://github.com/logos-blockchain/sponges.git
synced 2026-07-30 02:23:31 +00:00
Imports the source code of the `ascon` crate originally from: https://github.com/quininer/ascon Code is imported as of this commit: commit 997e51ff0cad48510ad31934f9c361d25bf5f938 Author: quininer kel <quininer@live.com> Date: Mon Feb 20 09:52:28 2017 +0800 refactor: remove no_std - Formatted code using rustfmt 1.5.1-stable (d5a82bbd 2023-02-07) - Fixed clippy nits from clippy 0.1.67 (d5a82bbd 2023-02-07) Dual licensed as Apache 2.0 + MIT Permission given here: https://github.com/RustCrypto/sponges/pull/30#discussion_r1103554334 Co-authored-by: quininer kel <quininer@live.com>
31 lines
687 B
Rust
31 lines
687 B
Rust
#![feature(test)]
|
|
|
|
extern crate ascon;
|
|
extern crate test;
|
|
|
|
use ascon::{aead_decrypt, aead_encrypt};
|
|
use test::Bencher;
|
|
|
|
#[bench]
|
|
fn ascon_encrypt_bench(b: &mut Bencher) {
|
|
let key = [4; 16];
|
|
let iv = [8; 16];
|
|
let aad = [3; 16];
|
|
let message = [99; 1025];
|
|
|
|
b.bytes = message.len() as u64;
|
|
b.iter(|| aead_encrypt(&key, &iv, &message, &aad));
|
|
}
|
|
|
|
#[bench]
|
|
fn ascon_decrypt_bench(b: &mut Bencher) {
|
|
let key = [4; 16];
|
|
let iv = [8; 16];
|
|
let aad = [3; 16];
|
|
let message = [99; 1025];
|
|
let (ciphertext, tag) = aead_encrypt(&key, &iv, &message, &aad);
|
|
|
|
b.bytes = message.len() as u64;
|
|
b.iter(|| aead_decrypt(&key, &iv, &ciphertext, &aad, &tag));
|
|
}
|