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 / kernel / core / artifact_card.h

73 lines · 3558 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/* artifact_card.h -- the card artifact bundle of the Raspberry Pi 5 EL0 artifact qualification image
18 * (PI5-7 cut 3, build flag CK_ARTIFACT_CARD, "make pi5-artifact"; the same code boots in QEMU for the
19 * red-before-green run, see scripts/qemu_ck_artifact_card_test.sh).
20 *
21 * QUALIFICATION ONLY, TEST keys only. The Pi image has no Store stage and no NVMe, so the signed artifacts
22 * reach the loader as ONE file on the card's EFI partition, \EFI\AIENOS\ARTIFACT.BND, placed by the run
23 * tool before the run and deleted after it. The UEFI stub (native/boot/efi_artifact.c) reads it before
24 * ExitBootServices into ck_acard_buf; core/artifact_card_stage.c hands the entries to the unchanged core
25 * loader (core/artifact_loader.c) through the same hook the boot-disk Store uses (ck_stage_disk_artifacts).
26 * The loader then runs every check it always runs (format, TEST-key signature, digest, admission, W^X,
27 * EL0 containment, receipt): this file proves nothing about who wrote a byte, its bytes are untrusted.
28 *
29 * File layout: the existing bundle of tools/ck_artifact_tool.c (command "bundle OUT FILE...", the layout
30 * the QEMU gates already use), unchanged, all integers little endian:
31 * "AIENBND\0" u32 count (1..CK_ACARD_MAX_ENTRIES)
32 * count x { u16 name_len (1..32), name (printable ASCII 0x21..0x7e, unique in the file),
33 * u32 byte_len (1..CK_ACARD_ENTRY_MAX), byte_len bytes }
34 * and nothing after the last entry. The whole file is at most CK_ACARD_FILE_MAX bytes. Any deviation
35 * refuses the whole file: no entry of a refused file is offered to the loader. */
36#ifndef AIENOS_CK_ARTIFACT_CARD_H
37#define AIENOS_CK_ARTIFACT_CARD_H
38#include <stddef.h>
39#include <stdint.h>
40
41#define CK_ACARD_PATH "\\EFI\\AIENOS\\ARTIFACT.BND"
42#define CK_ACARD_FILE_MAX (128u * 1024u)
43#define CK_ACARD_MAX_ENTRIES 16u
44#define CK_ACARD_ENTRY_MAX (160u * 4096u) /* = the loader's MAX_BATCH pages */
45#define CK_ACARD_NAME_MAX 32u
46
47struct ck_acard_entry {
48 char name[CK_ACARD_NAME_MAX + 1];
49 uint32_t len;
50 const uint8_t *bytes; /* inside the buffer given to ck_acard_parse */
51};
52
53struct ck_acard {
54 uint32_t count;
55 struct ck_acard_entry e[CK_ACARD_MAX_ENTRIES];
56};
57
58/* 0 = well formed and *out filled (entries point into buf); else -1, *out zeroed and *why names the first
59 * failed check. */
60int ck_acard_parse(const uint8_t *buf, size_t n, struct ck_acard *out, const char **why);
61
62enum { CK_ACARD_NONE = 0, CK_ACARD_ABSENT = 1, CK_ACARD_REFUSED = 2, CK_ACARD_FOUND = 3 };
63
64/* What the UEFI stub found (the stub and the kernel are one image). */
65struct ck_acard_boot {
66 int state; /* CK_ACARD_* */
67 const char *why; /* ABSENT / REFUSED: what failed */
68 uint32_t file_len; /* bytes read, FOUND only */
69 struct ck_acard set; /* FOUND only */
70};
71extern struct ck_acard_boot ck_acard_boot;
72extern uint8_t ck_acard_buf[CK_ACARD_FILE_MAX + 1u];
73#endif