Skip to main content

initialize_with_profile

Function initialize_with_profile 

Source
pub fn initialize_with_profile(
    integrity: &[KatEntry],
    tests: &[KatEntry],
    profile: AlgorithmProfile,
) -> Result<(), Error>
Expand description

Initializes the module with a specific algorithm profile and runs every supplied power-up KAT.

This is the profile-aware entry point. The call that wins the PowerOff -> SelfTest transition runs the KATs and, on success, stores the selected profile and transitions to Operational. On failure the module latches a terminal state and the profile stays the default. KATs always run all algorithms regardless of the profile — the profile only restricts post-initialization service access via require_allowed.

A call that does not win that transition, whether it comes later or races the winner, leaves the active profile unchanged and returns Error::AlreadyInitialized when the winner succeeded, or Error::AlreadyFailed when it failed, as initialize_with_tests describes.

See initialize_with_tests for the backward-compatible wrapper that uses AlgorithmProfile::Unrestricted.

§Calling context

While the self-tests run, require_self_test_started admits the calling thread, so code the application runs on that thread during initialisation must not call the module. Do not call module services from a global allocator, panic hook or other callback that can run during initialisation, and do not call this function from a task inside a shared work-stealing pool, whose worker may run unrelated tasks while it waits. Initialise from a dedicated thread, then use the module once this function returns Ok.