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 / tools / pi5_store_locate.h

45 lines · 2610 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/* pi5_store_locate.h -- host side only. Where the KeySlotManifest (Store object kind 21, ADR 0017 section
18 * 2.4) sits inside a copy of the Pi card's AIENOS partition, found the way the kernel finds it:
19 * the unkeyed st_open catalog (svc/store_boot.c ck_store_unlock_boot -> ss_keyslot_bootstrap) lists the
20 * object's first_unit; the Store view starts CK_LAYOUT_ANCHOR_UNITS units into the partition and ends
21 * before the 64-sector marker tail (core/pi5_marker.c ck_pi5_store_view). Used by the PI5-4 tamper run
22 * (flip one byte of the wrapped K_vol) and by its host rehearsal in dev/tests/pi5_unlock_test.c. */
23#ifndef AIENOS_CK_PI5_STORE_LOCATE_H
24#define AIENOS_CK_PI5_STORE_LOCATE_H
25#include <stddef.h>
26#include <stdint.h>
27
28typedef struct {
29 uint32_t keyslot_objects; /* kind-21 catalog entries found (the locator needs exactly one) */
30 uint64_t first_unit; /* catalog first_unit, relative to the Store region */
31 uint64_t byte_length; /* manifest bytes (640, raw-secret profile) */
32 uint64_t part_sector; /* first sector of the object, counted from the partition start */
33 uint64_t part_byte_offset; /* part_sector * 512 */
34 uint64_t wrapped_kvol_offset; /* partition byte of the first byte of the recovery slot's wrapped K_vol */
35 uint64_t wrap_tag_offset; /* partition byte of the first byte of that slot's wrap tag */
36} ck_pi5_ksm_loc;
37
38#define CK_PI5_KSM_RECOVERY_SLOT_OFF (128u + 128u * 1u) /* descriptor 1 of the manifest (m5_ksm_encode) */
39#define CK_PI5_KSM_WRAPPED_KVOL_OFF 56u /* inside a descriptor (m5_keyslot_encode) */
40#define CK_PI5_KSM_WRAP_TAG_OFF 88u
41
42/* path: a file holding the partition from its first sector (sparse beyond what was copied is fine as
43 * long as the file is the full partition length). 0 on success; else -1 and err says why. Read only. */
44int ck_pi5_locate_keyslot(const char *path, ck_pi5_ksm_loc *out, char *err, size_t errn);
45#endif