pub struct ReseedingRng { /* private fields */ }Expand description
A OxiRng wrapper that automatically reseeds from OS entropy after
generating a configurable number of bytes (default: 1 MiB).
This implements a forward-secrecy interval consistent with NIST SP 800-90A §9.2 recommendations. After each reseed the internal byte counter resets.
§Observability
Use ReseedingRng::bytes_generated to inspect how many bytes have been
produced since the last reseed.
Implementations§
Source§impl ReseedingRng
impl ReseedingRng
Sourcepub fn new() -> Result<Self, CryptoError>
pub fn new() -> Result<Self, CryptoError>
Create a new ReseedingRng with the default 1 MiB reseed threshold.
Sourcepub fn with_threshold(threshold: u64) -> Result<Self, CryptoError>
pub fn with_threshold(threshold: u64) -> Result<Self, CryptoError>
Create a new ReseedingRng with a custom reseed threshold (bytes).
A threshold of 0 would reseed on every call — technically valid but
very slow. Reasonable values are 64 KiB to 64 MiB.
Sourcepub fn bytes_generated(&self) -> u64
pub fn bytes_generated(&self) -> u64
Number of bytes generated since the last reseed.
Sourcepub fn reseed_threshold(&self) -> u64
pub fn reseed_threshold(&self) -> u64
Configured reseed threshold in bytes.
Sourcepub fn reseed(&mut self) -> Result<(), CryptoError>
pub fn reseed(&mut self) -> Result<(), CryptoError>
Reseed immediately from OS entropy, regardless of the threshold.