aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / scripts / seed0b_machine1_prepare.sh
| 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 |
| 29 | set -euo pipefail |
| 30 | |
| 31 | out_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. |
| 34 | mkdir -p "${out_arg}" |
| 35 | out="$(cd "${out_arg}" && pwd)" |
| 36 | if [[ -n "$(ls -A "${out}")" ]]; then |
| 37 | echo "STOP: ${out} is not empty; prepare into a new or empty directory." >&2 |
| 38 | exit 1 |
| 39 | fi |
| 40 | repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 41 | cd "${repo_root}" |
| 42 | case "${out}/" in |
| 43 | "${repo_root}"/*) |
| 44 | echo "STOP: OUT_DIR ${out} is inside the repository." >&2 |
| 45 | exit 1 |
| 46 | ;; |
| 47 | esac |
| 48 | if [[ -n "$(git status --porcelain)" ]]; then |
| 49 | echo "STOP: worktree has uncommitted changes; qualification inputs must come from a commit." >&2 |
| 50 | exit 1 |
| 51 | fi |
| 52 | commit="$(git rev-parse HEAD)" |
| 53 | mkdir -p "${out}/ARTIFACTS" |
| 54 | |
| 55 | cargo build --quiet -p aienos-artifact-tool --features seed0b-test-signing |
| 56 | tool="target/debug/aienos-artifact-tool" |
| 57 | crates/aienos-artifact-tool/fixtures/p2_5/pack.sh "${tool}" "${out}/ARTIFACTS" |
| 58 | crates/aienos-artifact-tool/fixtures/p2_6/pack.sh "${tool}" "${out}/ARTIFACTS" |
| 59 | "${tool}" negative-corpus "${out}/ARTIFACTS" >/dev/null |
| 60 | mv "${out}/ARTIFACTS/ids.txt" "${out}/ids.txt" |
| 61 | mv "${out}/ARTIFACTS/expected.txt" "${out}/expected.txt" |
| 62 | |
| 63 | AIENOS_COMMIT="${commit}" cargo build --quiet --release -p aienos-boot \ |
| 64 | --target aarch64-unknown-uefi --features seed0b-qualification,hardware-staging --bin aienos-handoff |
| 65 | cp target/aarch64-unknown-uefi/release/aienos-handoff.efi "${out}/BOOTAA64.EFI" |
| 66 | cargo 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" |
| 73 | echo "PREPARED: ${out} from commit ${commit}" |
| 74 | echo "P26SEED ArtifactId: $(awk '$1 == "P26SEED.AIEN" {print $2}' "${out}/ids.txt")" |
| 75 | echo "NOT STAGED. The image is unsigned: with Secure Boot on (required) it will not" |
| 76 | echo "boot until the TRUST-1 owner-signed chain exists. Follow the procedure." |