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 / scripts / seed0b_machine1_prepare.sh

76 lines · 3375 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# P2-9 preparation ONLY: build the exact SEED-0B qualification inputs for an
18# attended Machine 1 boot into OUT_DIR. This script never touches the ESP,
19# BootOrder/BootNext, Secure Boot, TPM state or any firmware variable; the
20# operator stages OUT_DIR by the attended procedure in
21# docs/SEED0B_MACHINE1_QUALIFICATION.md.
22#
23# OUT_DIR/
24# BOOTAA64.EFI aienos-handoff --features seed0b-qualification,hardware-staging
25# ARTIFACTS/ the same signed .AIEN bytes the QEMU qualification uses
26# ids.txt NAME ARTIFACT_ID
27# expected.txt negative-matrix expectations
28# MANIFEST.sha256 sha256 of every file above, plus the commit
29set -euo pipefail
30
31out_arg="${1:?usage: seed0b_machine1_prepare.sh OUT_DIR}"
32# Resolve OUT_DIR against the caller's directory, and start from an empty one
33# so no stale file can enter ARTIFACTS/ or MANIFEST.sha256.
34mkdir -p "${out_arg}"
35out="$(cd "${out_arg}" && pwd)"
36if [[ -n "$(ls -A "${out}")" ]]; then
37 echo "STOP: ${out} is not empty; prepare into a new or empty directory." >&2
38 exit 1
39fi
40repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
41cd "${repo_root}"
42case "${out}/" in
43 "${repo_root}"/*)
44 echo "STOP: OUT_DIR ${out} is inside the repository." >&2
45 exit 1
46 ;;
47esac
48if [[ -n "$(git status --porcelain)" ]]; then
49 echo "STOP: worktree has uncommitted changes; qualification inputs must come from a commit." >&2
50 exit 1
51fi
52commit="$(git rev-parse HEAD)"
53mkdir -p "${out}/ARTIFACTS"
54
55cargo build --quiet -p aienos-artifact-tool --features seed0b-test-signing
56tool="target/debug/aienos-artifact-tool"
57crates/aienos-artifact-tool/fixtures/p2_5/pack.sh "${tool}" "${out}/ARTIFACTS"
58crates/aienos-artifact-tool/fixtures/p2_6/pack.sh "${tool}" "${out}/ARTIFACTS"
59"${tool}" negative-corpus "${out}/ARTIFACTS" >/dev/null
60mv "${out}/ARTIFACTS/ids.txt" "${out}/ids.txt"
61mv "${out}/ARTIFACTS/expected.txt" "${out}/expected.txt"
62
63AIENOS_COMMIT="${commit}" cargo build --quiet --release -p aienos-boot \
64 --target aarch64-unknown-uefi --features seed0b-qualification,hardware-staging --bin aienos-handoff
65cp target/aarch64-unknown-uefi/release/aienos-handoff.efi "${out}/BOOTAA64.EFI"
66cargo run --quiet --release -p aienos-evidence -- verify-efi "${out}/BOOTAA64.EFI"
67
68(
69 cd "${out}"
70 echo "# commit ${commit}"
71 find . -type f ! -name MANIFEST.sha256 -print0 | sort -z | xargs -0 sha256sum
72) >"${out}/MANIFEST.sha256"
73echo "PREPARED: ${out} from commit ${commit}"
74echo "P26SEED ArtifactId: $(awk '$1 == "P26SEED.AIEN" {print $2}' "${out}/ids.txt")"
75echo "NOT STAGED. The image is unsigned: with Secure Boot on (required) it will not"
76echo "boot until the TRUST-1 owner-signed chain exists. Follow the procedure."