Skip to main content

EntropyPool

Struct EntropyPool 

Source
pub struct EntropyPool { /* private fields */ }
Expand description

Thread-safe multi-source entropy pool.

Implementations§

Source§

impl EntropyPool

Source

pub fn new(seed: Option<&[u8]>) -> Self

Create an empty pool.

Source

pub fn auto() -> Self

Create a pool with all available sources on this machine.

Source

pub fn add_source(&mut self, source: Box<dyn EntropySource>, weight: f64)

Register an entropy source.

Source

pub fn source_count(&self) -> usize

Number of registered sources.

Source

pub fn collect_all(&self) -> usize

Collect entropy from every registered source (serial). Collect entropy from every registered source in parallel with per-source timeout (10s default). Sources that exceed the timeout are skipped.

Source

pub fn collect_all_parallel(&self, timeout_secs: f64) -> usize

Collect entropy from all sources in parallel using threads.

Source

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.

Source

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.

Source

pub fn get_raw_bytes(&self, n_bytes: usize) -> Vec<u8>

Return 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.

Source

pub fn get_random_bytes(&self, n_bytes: usize) -> Vec<u8>

Return n_bytes of conditioned random output.

Source

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 whitening
  • VonNeumann: debiased but structure-preserving
  • Sha256: full cryptographic conditioning (default)
Source

pub fn health_report(&self) -> HealthReport

Health report as structured data.

Source

pub fn print_health(&self)

Pretty-print health report.

Source

pub fn source_infos(&self) -> Vec<SourceInfoSnapshot>

Get source info for each registered source.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V