pub struct EntropyPool { /* private fields */ }Expand description
Thread-safe multi-source entropy pool.
Implementations§
Source§impl EntropyPool
impl EntropyPool
Sourcepub fn add_source(&mut self, source: Box<dyn EntropySource>, weight: f64)
pub fn add_source(&mut self, source: Box<dyn EntropySource>, weight: f64)
Register an entropy source.
Sourcepub fn source_count(&self) -> usize
pub fn source_count(&self) -> usize
Number of registered sources.
Sourcepub fn collect_all(&self) -> usize
pub fn collect_all(&self) -> usize
Collect entropy from every registered source in parallel.
Uses a 10s collection timeout per cycle. Slow sources are skipped and temporarily backed off to keep callers responsive.
Sourcepub fn collect_all_parallel(&self, timeout_secs: f64) -> usize
pub fn collect_all_parallel(&self, timeout_secs: f64) -> usize
Collect entropy from all sources in parallel using detached worker threads.
Slow or hung sources are skipped after timeout_secs. Timed-out sources
enter a backoff window to avoid thread buildup on repeated calls.
Sourcepub fn collect_all_parallel_n(
&self,
timeout_secs: f64,
n_samples: usize,
) -> usize
pub fn collect_all_parallel_n( &self, timeout_secs: f64, n_samples: usize, ) -> usize
Collect entropy from all sources in parallel using detached worker threads.
timeout_secs: max wall-clock time to wait for a collection cycle.n_samples: samples requested from each source in this cycle.
Slow or hung sources are skipped after timeout_secs. Timed-out sources
enter a backoff window to avoid thread buildup on repeated calls.
Sourcepub fn collect_enabled(&self, enabled_names: &[String]) -> usize
pub fn collect_enabled(&self, enabled_names: &[String]) -> usize
Collect entropy only from sources whose names are in the given list. Uses parallel threads. Collects 1000 samples per source.
Sourcepub fn collect_enabled_n(
&self,
enabled_names: &[String],
n_samples: usize,
) -> usize
pub fn collect_enabled_n( &self, enabled_names: &[String], n_samples: usize, ) -> usize
Collect n_samples of entropy from sources whose names are in the list.
Smaller n_samples values are faster — use this for interactive/TUI contexts.
Sourcepub fn get_raw_bytes(&self, n_bytes: usize) -> Vec<u8> ⓘ
pub fn get_raw_bytes(&self, n_bytes: usize) -> Vec<u8> ⓘ
Return up to n_bytes of raw, unconditioned entropy (XOR-combined only).
No SHA-256, no DRBG, no whitening. Preserves the raw hardware noise signal for researchers studying actual device entropy characteristics.
If sources cannot provide enough bytes after several collection rounds, this returns the available bytes rather than blocking indefinitely.
Sourcepub fn get_random_bytes(&self, n_bytes: usize) -> Vec<u8> ⓘ
pub fn get_random_bytes(&self, n_bytes: usize) -> Vec<u8> ⓘ
Return n_bytes of conditioned random output.
Sourcepub fn get_bytes(&self, n_bytes: usize, mode: ConditioningMode) -> Vec<u8> ⓘ
pub fn get_bytes(&self, n_bytes: usize, mode: ConditioningMode) -> Vec<u8> ⓘ
Return n_bytes of entropy with the specified conditioning mode.
Raw: XOR-combined source bytes, no whiteningVonNeumann: debiased but structure-preservingSha256: full cryptographic conditioning (default)
Sourcepub fn health_report(&self) -> HealthReport
pub fn health_report(&self) -> HealthReport
Health report as structured data.
Sourcepub fn print_health(&self)
pub fn print_health(&self)
Pretty-print health report.
Sourcepub fn get_source_bytes(
&self,
source_name: &str,
n_bytes: usize,
mode: ConditioningMode,
) -> Option<Vec<u8>>
pub fn get_source_bytes( &self, source_name: &str, n_bytes: usize, mode: ConditioningMode, ) -> Option<Vec<u8>>
Collect entropy from a single named source and return conditioned bytes.
Returns None if the source name doesn’t match any registered source.
Sourcepub fn get_source_raw_bytes(
&self,
source_name: &str,
n_samples: usize,
) -> Option<Vec<u8>>
pub fn get_source_raw_bytes( &self, source_name: &str, n_samples: usize, ) -> Option<Vec<u8>>
Collect raw bytes from a single named source.
Returns None if no source matches the name.
Sourcepub fn source_names(&self) -> Vec<String>
pub fn source_names(&self) -> Vec<String>
List all registered source names.
Sourcepub fn source_infos(&self) -> Vec<SourceInfoSnapshot>
pub fn source_infos(&self) -> Vec<SourceInfoSnapshot>
Get source info for each registered source.