1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#![no_std]
#![feature(test)]
extern crate test;
use hmac::Hmac;
use pbkdf2::pbkdf2;
use test::Bencher;
#[bench]
pub fn pbkdf2_hmac_sha1_16384_20(bh: &mut Bencher) {
let password = b"my secure password";
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha1::Sha1>>(password, salt, 16_384, &mut buf);
test::black_box(&buf);
});
}
#[bench]
pub fn pbkdf2_hmac_sha256_16384_20(bh: &mut Bencher) {
let password = b"my secure password";
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha2::Sha256>>(password, salt, 16_384, &mut buf);
test::black_box(&buf);
});
}
#[bench]
pub fn pbkdf2_hmac_sha512_16384_20(bh: &mut Bencher) {
let password = b"my secure password";
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha2::Sha512>>(password, salt, 16_384, &mut buf);
test::black_box(&buf);
});
}
|