SaiTLS/src/fake_rng.rs

26 lines
655 B
Rust
Raw Normal View History

2020-10-29 17:34:03 +08:00
// A blank implementor of RngCore that is NOT random
// Justification: RSA padding scheme for verifying PSS signature
// 1. Why is there a static lifetime bound?
// 2. Why need random? It is just signature verification.
// Anyway, the RSAPublicKey::verify() method does NOT care about random at all :)
use rand_core::{RngCore, Error};
pub (crate) struct FakeRandom {}
impl RngCore for FakeRandom {
fn next_u32(&mut self) -> u32 {
0
}
fn next_u64(&mut self) -> u64 {
0
}
2020-11-16 18:14:59 +08:00
fn fill_bytes(&mut self, _dest: &mut [u8]) {}
2020-10-29 17:34:03 +08:00
2020-11-16 18:14:59 +08:00
fn try_fill_bytes(&mut self, _dest: &mut [u8]) -> Result<(), Error> {
2020-10-29 17:34:03 +08:00
Ok(())
}
}