Skip to main content

load_or_generate_seal_material

Function load_or_generate_seal_material 

Source
pub fn load_or_generate_seal_material(
    seal_key: Option<&Path>,
    seal_cert: Option<&Path>,
    demo: bool,
) -> Result<(SealKey, Vec<u8>), String>
Expand description

Resolve seal material under the shared F07 policy — the single source of truth for the seal-material decision, consumed by the configured loader (orchestrate::load_seal_materials) and the one-shot hoike sign path. (hoike-core’s config validation mirrors the structural rules; it cannot depend on hoike-sign.)

  • both seal_key and seal_cert → load the persistent pair (the certificate is PEM/DER-normalized) and prove it with the real CMS preflight;
  • exactly one → error: a half-configured seal pair is always an error;
  • neither → error for production; explicit demo generates a distinct ephemeral pair (warned, NOT FOR PRODUCTION) and proves it the same way.

Errors are policy messages without caller context; callers prefix their own scope (CA label, flag-name guidance).