Skip to main content

alien_signing/
lib.rs

1//! Signed statements for installs that run only what the vendor signed.
2//!
3//! The crate has no network code. Enforcers hand it bytes they received, the
4//! signing settings their setup wrote, the install id they derived and the
5//! install's ledger, and get back either a verified statement or the reason
6//! it was refused:
7//!
8//! - [`envelope`]: the one envelope every statement uses;
9//! - [`signer_list`]: the vendor's signer list and its chain of versions;
10//! - [`settings`]: what setup pins, how enforcers find it, and the install id;
11//! - [`ledger`]: what an install already accepted, shared by its enforcers;
12//! - [`verify`]: the checks every enforcer runs on every statement;
13//! - [`release`]: `release/v2` and building a workload from it;
14//! - [`config`]: the `config/v1` body;
15//! - [`binding`]: binding values computed from the install, not the control plane;
16//! - [`session`]: `session/v1` and the encrypted session channel;
17//! - [`recovery`]: the recovery code and the key it derives.
18
19#![expect(
20    clippy::result_large_err,
21    reason = "Alien errors retain structured metadata and causal context"
22)]
23
24pub mod binding;
25pub mod config;
26pub mod envelope;
27pub mod error;
28pub mod key;
29pub mod ledger;
30pub mod recovery;
31pub mod release;
32#[cfg(not(target_arch = "wasm32"))]
33pub mod session;
34pub mod settings;
35pub mod signer_list;
36pub mod verify;
37
38pub use binding::{
39    binding_env, binding_env_name, binding_env_with, check_own_binding, resolve_bindings,
40    BindingContext, Bindings, OwnBindingFacts,
41};
42pub use config::ConfigBody;
43pub use envelope::{Envelope, Kind, Opened, Role, Signature, SignedStatement};
44pub use error::{ErrorData, Result};
45pub use key::{PublicKey, SecretKey, PUBLIC_KEY_PREFIX};
46pub use ledger::{Entry, Ledger};
47pub use recovery::RecoveryCode;
48pub use release::{
49    build_workload, BuiltWorkload, LocalValues, ReleaseBody, SetupTemplate, Workload,
50    WorkloadRequest,
51};
52pub use settings::{candidate_prefixes, discover, InstallId, Lookup, SigningSettings};
53pub use signer_list::{
54    display_fingerprint, fingerprint, release_deny_entry, Keep, KeptKind, Signer, SignerChain,
55    SignerKind, SignerListBody, TrustedList, MAX_KEEP,
56};
57pub use verify::{Trust, Verified};
58
59impl SignedStatement {
60    /// Add `key`'s signature as `signer`.
61    pub fn sign_with(mut self, signer: &str, key: &SecretKey) -> Result<Self> {
62        let bytes = self.open()?.bytes;
63        self.signatures.push(Signature {
64            signer: signer.to_string(),
65            sig: key.sign(&bytes),
66        });
67        Ok(self)
68    }
69}