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/scripts/pi5_unlock_req.sh # 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 / scripts / pi5_unlock_req.sh` 48 lines ยท 2346 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 # pi5_unlock_req.sh -- write a THROWAWAY unlock request file for the PI5-4 qualification image 18 # (make pi5-unlock-card). QUALIFICATION ONLY. Layout: native/kernel/core/unlock_req.h 19 # (512 bytes: magic AIENUNQ1, version 1, flags 0, tag QUALIF-THROWAWAY, 32-byte secret, zero padding). 20 # 21 # pi5_unlock_req.sh [] 22 # 23 # With no secret file, 32 random bytes come from /dev/urandom. Refuses an output path inside a git 24 # checkout (a secret must never be committed) and an existing output file. The secret is never printed. 25 # Use a different secret file to make a "wrong secret" request, or the same one to reopen. 26 set -euo pipefail 27 out="${1:?output file}" 28 sec="${2:-}" 29 [[ ! -e "${out}" ]] || { echo "refusing: ${out} exists" >&2; exit 1; } 30 dir="$(cd "$(dirname "${out}")" && pwd)" 31 if git -C "${dir}" rev-parse --git-dir >/dev/null 2>&1; then echo "refusing: ${dir} is inside a git checkout" >&2; exit 1; fi 32 tmp="$(mktemp)"; trap 'rm -f "${tmp}"' EXIT 33 if [[ -n "${sec}" ]]; then 34 [[ "$(stat -c %s "${sec}")" == 32 ]] || { echo "secret file must be exactly 32 bytes" >&2; exit 1; } 35 cp "${sec}" "${tmp}" 36 else 37 head -c 32 /dev/urandom > "${tmp}" 38 fi 39 # not all zero, not one repeated byte (the kernel refuses those too) 40 [[ "$(od -An -v -tx1 "${tmp}" | tr -s ' \n' '\n\n' | sort -u | grep -c .)" -gt 1 ]] || { echo "weak secret refused" >&2; exit 1; } 41 umask 077 42 { 43 printf 'AIENUNQ1\x01\x00\x00\x00\x00\x00\x00\x00QUALIF-THROWAWAY' 44 cat "${tmp}" 45 head -c 448 /dev/zero 46 } > "${out}" 47 [[ "$(stat -c %s "${out}")" == 512 ]] || { rm -f "${out}"; echo "internal error: size" >&2; exit 1; } 48 echo "wrote ${out} (512 bytes, throwaway secret not shown)"