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 / crates / aienos-artifact / src / verify.rs

42 lines · 1555 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//! Structural parsing and identity entry points shared by host tooling and
17//! the kernel. Authentication is added in P2-3.
18
19use crate::canonical::payload_digest;
20use crate::error::ArtifactError;
21use crate::format::{Artifact, MAX_ARTIFACT_SIZE};
22use crate::id::{compute_artifact_id, ArtifactId};
23use aienos_crypto::sha256::Digest;
24
25#[derive(Clone, Copy, Debug, Eq, PartialEq)]
26pub struct IdentifiedArtifact<'a> {
27 pub artifact: Artifact<'a>,
28 pub artifact_id: ArtifactId,
29 pub payload_digest: Digest,
30}
31
32pub fn parse_and_identify(bytes: &[u8]) -> Result<IdentifiedArtifact<'_>, ArtifactError> {
33 if bytes.len() > MAX_ARTIFACT_SIZE {
34 return Err(ArtifactError::ResourceLimit);
35 }
36 let artifact = Artifact::parse(bytes)?;
37 Ok(IdentifiedArtifact {
38 artifact_id: compute_artifact_id(&artifact),
39 payload_digest: payload_digest(&artifact),
40 artifact,
41 })
42}