pub fn initialize_with_tests(
integrity: &[KatEntry],
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 and runs the tests on its own thread. A
caller that does not win waits for the winner’s outcome and receives
Error::AlreadyInitialized if it succeeded or Error::AlreadyFailed
if it failed. A call on a module that has already left PowerOff runs
no test and changes nothing: initialisation happens once per process,
and a failed one is terminal until the process restarts. A call made
from inside a self-test, on the thread running them, returns
Error::NotOperational naming SelfTest.
On a platform that gives the calling thread no id the module can
record, the winning call latches Error and returns
Error::SelfTestFailed naming THREAD_ID_CHECK.
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.