Skip to main content

AdaptiveProportionTest

Struct AdaptiveProportionTest 

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

SP 800-90B Section 4.4.2 Adaptive Proportion Test (APT) for raw noise samples.

Counts occurrences of the first sample in each fixed window of size window_size (512 for non-binary sources or 1,024 for binary sources) and fails permanently with [Error::EntropyHealthCheckFailed] if the count reaches cutoff.

Implementations§

Source§

impl AdaptiveProportionTest

Source

pub const fn new(window_size: usize, cutoff: u32) -> Result<Self>

Creates a new APT with window_size >= 2 and 2 <= cutoff <= window_size.

For approved SP 800-90B noise sources, prefer Self::for_source_kind or RawNoiseHealthMonitor::new, which lock window_size to 1,024 (binary) or 512 (non-binary).

Source

pub const fn for_source_kind(kind: AptSourceKind, cutoff: u32) -> Result<Self>

Creates an APT locked to the SP 800-90B Section 4.4.2 standard window for kind.

Source

pub fn observe(&mut self, sample: u64) -> Result<()>

Feeds one unconditioned raw noise sample into the APT.

Once failed, the test remains latched in the failure state.

Source

pub const fn is_failed(&self) -> bool

Returns true if the APT has latched a health-check failure.

Trait Implementations§

Source§

impl Drop for AdaptiveProportionTest

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Zeroize for AdaptiveProportionTest

Source§

fn zeroize(&mut self)

Overwrites all sensitive memory owned by self with zeros.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.