Skip to main content

initialize_with_tests

Function initialize_with_tests 

Source
pub fn initialize_with_tests(tests: &[KatEntry]) -> Result<(), Error>
Expand description

Initializes the module and runs every supplied power-up KAT.

This is the canonical entry point. It transitions PowerOff -> SelfTest, executes every entry in tests in order, and then transitions to Operational on success or to the terminal Error state on the first failure. The returned Error::SelfTestFailed carries the name of the failing test.

Concurrent calls are safe: exactly one caller wins the PowerOff -> SelfTest CAS; losers receive Error::AlreadyInitialized and should consult state to discover whether the winning call succeeded.

Note: the slice is passed by reference, not built up by magic. This repository deliberately avoids linker-section registration tricks: the full set of power-up tests is visible in source at every call site, which makes it straightforward to audit the module’s test inventory against the Security Policy.