mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Implement a ZeroDigest for use in benchmarks.
This commit is contained in:
parent
03f20fdae3
commit
1e2fa1025e
1 changed files with 23 additions and 0 deletions
|
|
@ -493,6 +493,8 @@ mod test {
|
|||
|
||||
#[cfg(all(test, feature = "bench"))]
|
||||
mod bench {
|
||||
use generic_array::GenericArray;
|
||||
use generic_array::typenum::{U64, U128};
|
||||
use test::Bencher;
|
||||
use rand::OsRng;
|
||||
use super::*;
|
||||
|
|
@ -516,6 +518,27 @@ mod bench {
|
|||
}
|
||||
}
|
||||
|
||||
/// A fake hash function which simply returns zeroes.
|
||||
struct ZeroDigest;
|
||||
|
||||
impl ZeroDigest {
|
||||
pub fn new() -> ZeroDigest {
|
||||
ZeroDigest
|
||||
}
|
||||
}
|
||||
|
||||
impl Digest for ZeroDigest {
|
||||
type OutputSize = U64;
|
||||
type BlockSize = U128;
|
||||
|
||||
fn input(&mut self, _input: &[u8]) { }
|
||||
fn result(self) -> GenericArray<u8, Self::OutputSize> { GenericArray::default() }
|
||||
}
|
||||
|
||||
impl Default for ZeroDigest {
|
||||
fn default() -> Self { Self::new() }
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn sign(b: &mut Bencher) {
|
||||
let mut cspring: OsRng = OsRng::new().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue