Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/artifact/osc_receipt.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / artifact / osc_receipt.h` 108 lines ยท 6499 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* osc_receipt.h -- verification of Omega realization receipts (receipt v1) for OSC unit launch (aienos#383). 18 * 19 * Contract: aien-dev/omega spec/one-layer-receipts.md (normative; section numbers below refer to it), the 20 * receipt format minted by omega's independent checker `checker2 receipt issue` (omega#448). This verifier was 21 * written from that spec; no checker2 code was copied. It reuses the in-tree SHA-256 (argus/sha256.c) and 22 * Ed25519 verify (sig/`ed25519`.c) and adds no crypto of its own. 23 * 24 * What a receipt says (spec section 1): checker2 judged one exact program (OSC IR) and accepted it, the 25 * executable is bound to it by hash only (evidence class 1 is NOT translation validation), and a key of a 26 * stated class vouches for that record. A receipt grants no capability: grants stay with the unit's 27 * capability table and the kernel's authority, unchanged. 28 * 29 * osc_receipt_verify is a pure function of (receipt bytes, admitted unit, policy): no allocation, no global 30 * state, no I/O. It runs AFTER osc_unit_admit accepted the unit and does not change admission. It returns 0 31 * (the receipt is valid for this unit under this policy) or the FIRST refusal in the fixed order of spec 32 * section 6, as a kernel code OSC_RCPT_BASE + the spec's stable reason number. 33 * 34 * Bound to the admitted unit: program = the unit's ir_sha256 (section 1 hash), executable = its code_sha256, 35 * target = SHA-256("OMEGA-TARGET-V1\0" || OSC_RCPT_TARGET_NAME), firmware = none (all zero unless the policy 36 * names one), dependencies = the empty list (the kernel resolves no dependency receipts, so any claimed 37 * dependency is refused). Checker identity: required to be in the policy's list (an empty list refuses every 38 * receipt). Producer: none (all zero unless the policy names one; the unit carries no producer identity). NOT bound by a receipt: the container 39 * manifest (entry table, capability table, stack and tick budgets); those stay bound by the unit signature. 40 * Requirements and input fields are NOT CHECKED. Evidence class 2 (LRAT): spec section 10 makes a class 2 receipt 41 * valid only when its proofs are given and replayed; the kernel has no proofs and no LRAT checker, so it refuses 42 * class 2 as RECEIPT_LRAT_PROOFS_REQUIRED (fail closed; see docs/osc-receipts.md). */ 43 #ifndef AIENOS_CK_OSC_RECEIPT_H 44 #define AIENOS_CK_OSC_RECEIPT_H 45 #include 46 #include 47 #include "osc_unit.h" 48 49 #define OSC_RCPT_BYTES 416u 50 #define OSC_RCPT_SIGNED_BYTES 352u 51 /* The kernel's target name (spec section 2, offset 208). Chosen for aienos#383: an OSC unit run as an EL0 task of 52 * the AIENOS C kernel on AArch64. Receipts for this kernel are issued with `--target aienos-ck-aarch64-el0`. */ 53 #define OSC_RCPT_TARGET_NAME "aienos-ck-aarch64-el0" 54 55 /* Kernel refusal codes: OSC_RCPT_BASE + the spec section 6 reason number (stable). They share the osc_code 56 * space of osc_unit.h (osc_code_name names them "RECEIPT_") and fit osc_result.refused_code. */ 57 #define OSC_RCPT_BASE 64u 58 enum osc_rcpt_code { 59 OSC_RCPT_MISSING = 64, /* kernel only: no receipt came with the unit */ 60 OSC_RCPT_SIZE = 65, /* 1: not exactly 416 bytes */ 61 OSC_RCPT_MAGIC = 66, /* 2 */ 62 OSC_RCPT_VERSION = 67, /* 3 */ 63 OSC_RCPT_SIGNATURE_ALGORITHM = 68, /* 4 */ 64 OSC_RCPT_SIGNER_CLASS = 69, /* 5 */ 65 OSC_RCPT_EVIDENCE_CLASS = 70, /* 6 */ 66 OSC_RCPT_EPOCH_ORDER = 71, /* 7: expiry below the policy epoch */ 67 OSC_RCPT_TEST_SIGNER_IN_PRODUCTION = 73, /* 9: release mode and not OWNER */ 68 OSC_RCPT_UNTRUSTED_SIGNER = 74, /* 10 */ 69 OSC_RCPT_BAD_SIGNATURE = 75, /* 11 */ 70 OSC_RCPT_REVOKED = 76, /* 12: receipt id, then signer key fingerprint */ 71 OSC_RCPT_STALE_EPOCH = 77, /* 13: policy epoch below the floor (replay of a superseded receipt) */ 72 OSC_RCPT_EXPIRED = 78, /* 14 */ 73 OSC_RCPT_NOT_YET_VALID = 79, /* 15 */ 74 OSC_RCPT_WRONG_TARGET = 80, /* 16 */ 75 OSC_RCPT_WRONG_FIRMWARE = 81, /* 17 */ 76 OSC_RCPT_PROGRAM_MISMATCH = 82, /* 18 */ 77 OSC_RCPT_EXECUTABLE_MISMATCH = 83, /* 19 */ 78 OSC_RCPT_ARGUMENT = 84, /* 20: verifier called without a unit or a policy */ 79 OSC_RCPT_UNTRUSTED_CHECKER = 86, /* 22 */ 80 OSC_RCPT_WRONG_PRODUCER = 87, /* 23 */ 81 OSC_RCPT_DEPENDENCIES_MISMATCH = 88, /* 24 */ 82 /* kernel-assigned: spec section 10 names LRAT-PROOFS-REQUIRED without a number. The kernel is given no LRAT 83 * proofs, so every evidence class 2 receipt that passes the section 6 steps is refused with it. */ 84 OSC_RCPT_LRAT_PROOFS_REQUIRED = 96 85 }; 86 87 enum { OSC_RCPT_REVOKED_ID = 1, OSC_RCPT_REVOKED_KEY = 2 }; 88 89 /* Facts about a receipt, filled as far as the verifier got (id once the length is right, the rest after the 90 * structure checks). Diagnostic only: nothing here is authority. */ 91 struct osc_receipt_info { 92 uint8_t id[32]; /* SHA-256 of the 416 bytes (spec section 2) */ 93 uint16_t signer_class; /* OSC_SIGNER_TEST or OSC_SIGNER_OWNER */ 94 uint16_t evidence_class; /* 1 IR_CHECKED, 2 IR_CHECKED_LRAT (refused: no proofs to replay) */ 95 uint64_t policy_epoch, expiry_epoch; 96 unsigned revoked; /* OSC_RCPT_REVOKED_ID or OSC_RCPT_REVOKED_KEY when the verdict is REVOKED */ 97 int have_id; 98 }; 99 100 /* 0: valid for unit *a under *p. Else the first refusal code (OSC_RCPT_*). r == NULL or len == 0 is 101 * OSC_RCPT_MISSING. info may be NULL. */ 102 unsigned osc_receipt_verify(const uint8_t *r, size_t len, const struct osc_accept *a, const struct osc_policy *p, 103 struct osc_receipt_info *info); 104 105 /* SHA-256("OMEGA-TARGET-V1\0" || name) (spec section 2, offset 208). */ 106 void osc_receipt_target_hash(const char *name, size_t name_len, uint8_t out[32]); 107 108 #endif