rust-crypto
rust-crypto copied to clipboard
gmac is slower than hmac?
Using ghash to create a gmac I noticed is slower than an hmac using sha256; I was under the impression gmac would be faster when c is left blank (no cypher). Am I using this incorrectly, or is this expected? Thanks
test msg::tests::ghash ... bench: 18,495 ns/iter (+/- 1,067)
test msg::tests::sha256 ... bench: 8,883 ns/iter (+/- 930)
#[bench]
fn ghash(b:&mut Bencher) {
let key = [random::<u8>();16];
let d = [random::<u8>();1400];
b.iter(||{
let mut ha = Ghash::new(&key);
ha.input(&d[..]);
let mut gmac = ha.result();
});
}
#[bench]
fn sha256(b:&mut Bencher) {
let key = [random::<u8>();32];
let d = [random::<u8>();1400];
b.iter(||{
let mut sha = Sha256::new();
sha.input(&d[..]);
let mut hmac = Hmac::new(sha,&key[..]).result();
});
}