interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / m5 / README.md

174 lines · 13075 bytes Raw Blame History Source

native/m5: M5 encrypted objects and security layer in C

C port (gnu11, no outside libraries, no heap/clock/I/O in the library) of the M5 reference in crates/aienos-kernel/src/crypto/envelope.rs and crates/aienos-kernel/src/security.rs, built on native/crypto (AES-256-GCM-SIV, HMAC-SHA-256, constant-time compare, wipe) and native/argus/sha256.c. Target: the M5 table in docs/TRUST-1-M5-GATE-MATRIX.md and the Q rows of docs/M5_KEY_HIERARCHY_DESIGN_TREE.md.

make test       # rule tests, corruption matrix, header fuzz, owner-signed migration
                # (AIENOS_M5_MIGRATION_SIG: PASS, M5_MIGSIG_TOOL: PASS); last line M5_NATIVE: PASS
make sanitize   # same, and the tool test, under ASan + UBSan
make mutants    # each GUARD-tagged refusal removed in turn; tests must fail
make clean

All tests in this folder are host-only (hosted libc test program), and nothing measures time or energy. The kernel links m5_keys.c, m5_envelope.c and m5_state.c through the sealed Store (native/kernel/stage.mk), so those run in the QEMU Store gates and on the Raspberry Pi 5 with throwaway secrets (docs/native/PI5-4-UNLOCK-RUNS.md). m5_owner_sig.c stays host-only. None of this has run on the Spark.

What is covered

RequirementCodeTests
Owner-controlled key hierarchym5_derive_subkeys (K_vol -> identity/owner-generation root -> K_cortex, K_agent, K_artifact, K_root_auth), m5_derive_object_key, m5_keyslot_wrap/unwrap, m5_secman_seal/open (root-auth MAC, owner_hierarchy_generation field)t_hkdf_rfc5869_case1, t_subkeys_deterministic_and_separated, t_object_key_binds_every_field, t_keyslot_wrap_unwrap, t_keyslot_refusals, t_secman_* (incl. t_secman_roundtrip_rust_v1_layout)
AES-256-GCM-SIV object envelopesm5_envelope_seal/open/parse_headert_env_roundtrip_sizes, t_env_rust_v1_header_and_standard_aad, t_env_header_bounds_each_field, t_env_hostile_header_fuzz (20 000 random/edge headers, exact-size heap buffers under ASan)
All-or-nothing openm5_envelope_open, m5_recover_object zero the whole caller buffer on every errort_all_or_nothing_late_chunk_failure_zeroes_output; every refusal test asserts an all-zero buffer
Corruption matrixt_corrupt_header, t_corrupt_first_chunk, t_corrupt_middle_chunk, t_corrupt_last_chunk, t_corrupt_commit_record, t_corrupt_rollback_anchor, t_corrupt_key_generation, t_corrupt_store_generation, t_commit_check_object, t_truncate_drop_last_chunk, t_extend_append_chunk, t_reorder_chunks, t_splice_cross_object
Anti-rollback anchorsm5_anchor_seal/open, m5_evaluate_anti_rollbackt_anchor_caller_buffer_roundtrip, t_rb_*
Production/test identity separationidentity class in the hierarchy key (so in every object key and K_root_auth MAC), plus an explicit class byte in commit record, anchor and migration; open/verify take a modet_identity_production_refuses_test, t_identity_test_refuses_production, t_identity_relabel_breaks_mac
Migration authorization (MAC-bound)m5_migration_seal/authorizet_mig_*
Migration authorization (owner-signed, Ed25519)m5_owner_migration_body/sign_body/sign/verify, m5_envelope_set_digest, m5_migration_authorize_owner; CLI tools/m5_migsig.ctests/m5_migsig_test.c (13 tests, AIENOS_M5_MIGRATION_SIG: PASS), tests/m5_migsig_tool_test.sh (M5_MIGSIG_TOOL: PASS)
Deterministic recovery (object level)m5_recover_objectt_recovery_*

Formats and where they differ from the Rust reference

All integers little-endian, all reserved bytes must be zero, every MAC is HMAC-SHA-256 under K_root_auth over domain || bytes, compared in constant time.

Host-only, and what remains

AGENTS.md section 3 (resolved)

Chunk AAD is the V1 Standard Envelope AAD, and no ObjectId or Store generation enters any chunk AAD, object key or MAC body before sealing. Store and key generation are bound after sealing by the commit record and the anchor; ObjectId is the SHA-256 of the encrypted bytes and is referenced from the commit record.