aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
GitHub aien-dev/aienux#147 (code only)
Apply it
git checkout -b patch-710ea30e046b6f0f 19e7c0c2ff531f94904a3ba0adf5166f1d1d0ef4 curl -fsSL https://interplane.io/drakestapleton/aienux/patches/710ea30e046b6f0f.patch | git am
Provenance
github-import 1
aien-dev/aienux
147
d9ee43b6d7fc8b1f6423072b11e51b10df04f14d
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":147,"url":"https://github.com/aien-dev/aienux/pull/147","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:35:50Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/docs/M5_KEY_HIERARCHY_DESIGN_TREE.md b/docs/M5_KEY_HIERARCHY_DESIGN_TREE.md index 8e6de10c..63eb85c5 100644 --- a/docs/M5_KEY_HIERARCHY_DESIGN_TREE.md +++ b/docs/M5_KEY_HIERARCHY_DESIGN_TREE.md @@ -1,6 +1,6 @@ # M5: Key Hierarchy, Envelope Encryption, and Identity Design Tree -> **Status:** Architectural Decision Tree / Grilling Round Scaffold +> **Status:** Architectural Decision Tree & Specification Progress > **Milestone:** M5 (Encryption and Identity) > **Prerequisites:** M1–M3, SEED-0B, M4 Continuity ([ADR 0016](adr/0016-continuity-objects-over-store-v1.md)), Recovery Core ([ADR 0006](adr/0006-deterministic-recovery-core-and-offline-operator-authority.md), [ADR 0007](adr/0007-continuous-existence-provisioning-once.md)), Store v1 ([ADR 0015](adr/0015-system-store-v1-format.md)) @@ -19,70 +19,24 @@ M5 governs the **confidentiality, integrity sealing, and cryptographic identity* --- -## 2. The M5 Design Tree +## 2. Settled Decisions (Round 1) -```text -M5 Root - ├── 1. Encryption Boundary & Layering - │ ├── Option A: Object-level AEAD envelope (Payloads encrypted, metadata plaintext) - │ ├── Option B: Full virtual block-level encryption (LUKS/dm-crypt style) - │ └── Option C: Hybrid (AEAD payloads + Superblock-authenticated catalog AAD) [RECOMMENDED] - │ - ├── 2. Key Hierarchy & Root of Trust - │ ├── Option A: Pure TPM 2.0 sealed boot key - │ ├── Option B: Dual-path hierarchy (TPM seal + Operator break-glass KEK) [RECOMMENDED] - │ └── Option C: Attended passphrase on every cold start - │ - ├── 3. Symmetric Cipher Suite - │ ├── Option A: ChaCha20-Poly1305 (RFC 8439, pure software, constant-time) [RECOMMENDED] - │ ├── Option B: AES-256-GCM (ARMv8-A Cryptography Extensions / PMULL) - │ └── Option C: Dual-mode (ChaCha20 for bootstrap/QEMU, AES-GCM accelerated for bulk) - │ - ├── 4. Anti-Rollback Binding - │ ├── Option A: TPM 2.0 Monotonic NV Counter increment per Store commit - │ ├── Option B: Dynamic PCR extension / policy re-sealing per commit - │ └── Option C: Abstracted kernel interface; swTPM in QEMU, active under TRUST-1 [RECOMMENDED] - │ - ├── 5. Key Derivation & Stretching (Round 2 Frontier) - │ ├── Algorithm: Argon2id vs. HKDF-SHA256 vs. PBKDF2-HMAC-SHA256 - │ └── Salt Sources: Store UUID + Hardware Entropy (RNDR / TPM RNG) - │ - └── 6. Keyslot Metadata & On-Disk Format (Round 3 Frontier) - ├── Superblock v2 vs. Dedicated Crypto Header Region - └── Maximum keyslots and key retirement policy -``` +| Question | Decision | Core Architectural Invariant | +|---|---|---| +| **Q1: Encryption Boundary** | **Option C′ (Object Envelopes + Keyed SecurityManifest)** | Store v1 superblocks, CommitRecords, Catalogs, CRC32C, and generation semantics remain 100% frozen and unmodified. Application objects are wrapped in authenticated AEAD envelopes. A keyed `SecurityManifest` / `RootAuth` object authenticates the commit graph. Unkeyed inspection works in Recovery Core. | +| **Q2: Key Hierarchy** | **Option B′ (Independent `K_vol` + Multi-Slot Wrapping)** | `K_vol` is generated as an independent 256-bit random secret during provisioning. Slot 0 wraps `K_vol` via TPM 2.0 PCR authorization (owner-updatable via `PolicyAuthorize`). Slot 1 wraps `K_vol` via operator break-glass `K_recovery`. Domain-separated keys (`K_cortex`, `K_agent`, `K_artifact`, `K_root_auth`) derive from `K_vol` via HKDF-SHA256. `K_operator_auth` (ADR 0006 command authority), `K_recovery` (data decryption break-glass), and `K_vol` remain strictly separated. | +| **Q3: Cipher Suite** | **Option D (AES-256-GCM-SIV, RFC 8452)** | Nonce-misuse-resistant AEAD across cold boots, power loss, retries, and branching. 256-bit keys, 96-bit random nonces, 128-bit authentication tags. Streaming chunked authenticated envelope to avoid buffering large payloads in kernel memory. Software baseline first; ARMv9.2-A AES/POLYVAL acceleration later. | +| **Q4: Anti-Rollback** | **Option C′ (`AntiRollbackSource` Abstraction)** | Kernel introduces `trait AntiRollbackSource` with explicit `RollbackAnchor` semantics. Hardware-independent qualification in QEMU via mocks/swTPM. Physical NV / RPMB backend deferred until DGX Spark hardware characterization under TRUST-1. Rollback detection halts into `RecoveryRequired::RollbackDetected`, prohibiting normal agent continuation. | --- -## 3. Round 1 Frontier: Foundational Architecture - -### Decision 1: Encryption Boundary & Layering -- **Option A (Object AEAD Envelope)**: Payloads encrypted with a symmetric AEAD cipher; object descriptors, kinds, and superblocks remain plaintext. -- **Option B (Full Block Encryption)**: Virtual disk layer encrypting every block. Completely conceals metadata, but breaks unkeyed Recovery Core inspection. -- **Option C (Hybrid)**: Store v1 dual superblocks and catalog indexing remain unencrypted for deterministic inspection and tear recovery. All object payloads are AEAD-encrypted. Superblock commits bind an HMAC/AEAD authentication tag over the entire catalog using generation-dependent AAD. -- **Recommendation**: **Option C**. - -### Decision 2: Root-of-Trust & Key Hierarchy Separation -- **Master Storage Key (MSK)**: 256-bit symmetric key that never touches persistent disk in plaintext. -- **Key Slots**: - - `Slot 0 (Automated TPM Boot)`: MSK encrypted with `K_tpm`, sealed to TPM 2.0 Storage Root Key under PCR policy {PCR 0, PCR 7, PCR 11, PCR 12}. - - `Slot 1 (Operator Break-Glass)`: MSK encrypted with `K_recovery`, derived from an operator-held passphrase/seed using a hardened KDF. -- **Recommendation**: **Option B (Dual-Path)**. - -### Decision 3: Cipher Suite Selection -- **ChaCha20-Poly1305** requires zero hardware coprocessors, runs constant-time in pure `no_std` Rust, and avoids microarchitectural side-channels on shared cores. -- **AES-256-GCM** provides maximum throughput when ARMv8 Crypto Extensions are present, but adds complexity in bootstrap EL2/EL1 transitions. -- **Recommendation**: **Option A (ChaCha20-Poly1305)** as format baseline; optional AES-GCM cipher ID in object headers for bulk acceleration later. - -### Decision 4: Hardware Anti-Rollback Binding -- Store v1 generation counter increments monotonically in software, but physical NVMe media can be overwritten with an old raw image. -- Physical anti-rollback requires hardware state outside the disk: a TPM 2.0 NV counter index or RPMB (Replay Protected Memory Block). -- **Recommendation**: **Option C**. Define `AntiRollback` trait in kernel; verify in QEMU with swTPM NV indices; enforce as a hard gate on Machine 1 under TRUST-1. +## 3. The Active Frontier (Round 2) ---- - -## 4. Operational Invariants for M5 - -1. **Zero Interpreter Policy**: All cryptographic primitives and KDFs must compile as native `no_std` Rust within `aienos-kernel` or `aienos-crypto`. -2. **Deterministic Halt on Bad Unseal**: If TPM unseal fails (due to PCR mismatch or tampering), the boot must immediately halt into the read-only Recovery Core (ADR 0006). It must never boot into an unkeyed fallback state with write capability. -3. **Commit-Before-Observation**: Any update to keyslots or crypto metadata must follow Store v1 two-phase commit rules. +```text +Round 2 Frontier + ├── Q5: Chunked Authenticated Envelope Layout & Streaming AAD + ├── Q6: Keyslot Object Representation in Store v1 + ├── Q7: KDF Parameterization for Operator Break-Glass (K_recovery) + ├── Q8: Anti-Rollback Epoch Cadence & Anchor Granularity + └── Q9: Key Re-wrapping vs. Full Re-encryption Semantics +```