Skip to main content

SelfTest

Trait SelfTest 

Source
pub trait SelfTest {
    const NAME: &'static str;

    // Required method
    fn run() -> Result<(), SelfTestFailure>;
}
Expand description

A single power-up self-test.

Each approved algorithm crate will implement this trait for at least one test vector, per SP 800-140B. The initialize routine runs every registered test sequentially before the module can leave the SelfTest state.

Implementations must be deterministic, must not allocate, and must not read from any input the caller controls: the whole point of a KAT is that its inputs and expected outputs are baked into the module binary.

Required Associated Constants§

Source

const NAME: &'static str

Stable, human-readable identifier for this test. Appears in Error::SelfTestFailed and in audit logs.

Required Methods§

Source

fn run() -> Result<(), SelfTestFailure>

Runs the test. Returns Ok(()) on success, Err(SelfTestFailure) on any mismatch. The runner converts the Err into Error::SelfTestFailed using Self::NAME.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§