A small, validation-first boot.img parser and verifier for the EriX project, written in Rust.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Erik Inkinen c5e5d7fe4e
All checks were successful
CI / markdown (push) Successful in 7s
CI / test (push) Successful in 29s
chore: Merge native CLI development into main
Merge the selected feature/native-cli history with an explicit two-parent commit so main retains the development lineage and the validated source snapshot. The resulting tree is identical to the selected feature commit; no dependency pins or runtime behavior are changed by this merge.

Previous main: 578f13ba74
Selected feature: 22158c9834

Publish this integration point following the requested cross-repository merge. Preserve the feature branch and immutable dependency objects for reproducibility; do not squash, rebase or rewrite existing commits.
2026-09-12 08:28:45 +03:00
.github build: Pin dependency and CI helper source commits 2026-09-12 07:32:31 +03:00
src refactor: authenticate boot images without allocation 2026-07-31 22:08:42 +03:00
tests refactor: authenticate boot images without allocation 2026-07-31 22:08:42 +03:00
.editorconfig Initial commit 2026-02-26 10:11:07 +01:00
.gitignore Ignore local .ci workspace 2026-04-15 21:52:45 +03:00
.markdownlint-cli2.yaml Tighten CI markdown policy 2026-05-22 15:10:10 +03:00
ARCHITECTURE.md build: Pin dependency and CI helper source commits 2026-09-12 07:32:31 +03:00
Cargo.toml build: Pin dependency and CI helper source commits 2026-09-12 07:32:31 +03:00
CODE_OF_CONDUCT.md docs: Synchronize shared contribution and review policies 2026-09-12 06:38:13 +03:00
CONTRIBUTING.md build: Pin dependency and CI helper source commits 2026-09-12 07:32:31 +03:00
LICENSE Initial commit 2026-02-26 10:11:07 +01:00
README.md build: Pin dependency and CI helper source commits 2026-09-12 07:32:31 +03:00
ROADMAP.md refactor: authenticate boot images without allocation 2026-07-31 22:08:42 +03:00
rustfmt.toml lib-bootimg: drop unstable rustfmt options for stable toolchains 2026-03-23 10:19:53 +02:00
SECURITY.md docs: Synchronize shared contribution and review policies 2026-09-12 06:38:13 +03:00

lib-bootimg

lib-bootimg is the validation-first boot image v1 format crate for EriX. It parses, verifies, and constructs deterministic images without performing I/O or selecting boot policy.

EriX is a clean-room, capability-based microkernel operating system written in Rust.

See:

Purpose of This Repository

The crate owns:

  • strict parsing of the boot image v1 header, section table, manifest, and signature block
  • canonical layout and deterministic construction
  • SHA-256 whole-image and per-section verification
  • Ed25519 signature verification using a caller-provided trusted public key
  • borrowed access to validated section metadata and bytes

The crate does not own:

  • file access, image discovery, or boot-device selection
  • trusted-key provisioning or key rotation
  • required-section, architecture-acceptance, or launch policy
  • ELF parsing, mapping, relocation, or process creation
  • private-key operations or signing

bootloader consumes the parser and verifier at boot. boot-tool consumes both the builder and verifier for host-side construction and inspection.

Clean-Room Policy

EriX follows a strict clean-room philosophy:

  • No external source code may be copied.
  • No external Rust crates are allowed.
  • No code generation tools may embed third-party code.
  • All code must be authored within the project.

The crate depends only on the sibling EriX lib-sha2, lib-ed25519, and lib-constant-time crates. Every Git dependency uses a full 40-character commit rev pin; Integration and CI caches preserve the selected Git object identities.

License

All EriX repositories are licensed under the ISC License.

Development Model

EriX development is modular, deterministic, reproducible, authority-explicit, security-first, and self-hosting oriented.

Current contract

BootImage::parse validates the complete structural representation, including canonical header → section table → manifest → section data → signature order. It walks canonical name and data order directly and retains only borrowed input plus fixed metadata; parsing has no allocator. BootImage::verify_with_key_id then checks the caller-selected key identifier, canonical whole-image hash, every section hash, and the Ed25519 signature. Canonical spans are hashed and authenticated as ordered borrowed fragments without a full-message copy.

Parsing success does not authenticate the bytes. Verification success authenticates the bytes against the caller's key; it does not grant load, mapping, or execution authority.

The builder sorts sections by encoded name, writes all padding and reserved bytes as zero, computes hashes, and exposes the exact canonical signing payload. It writes caller-supplied signature bytes but never obtains a private key.

Example

use bootimg::{BootImage, PublicKey};

fn authenticate(
    bytes: &[u8],
    trusted_key: &PublicKey,
    expected_key_id: u32,
) -> Result<(), bootimg::Error> {
    let image = BootImage::parse(bytes)?;
    image.verify_with_key_id(trusted_key, expected_key_id)?;

    if let Some(kernel) = image.section_by_name("kernel") {
        let _authenticated_kernel = kernel.data(bytes)?;
    }
    Ok(())
}

Every verifier call requires the expected signature key identifier. The library never selects trust policy.

Repository layout

lib-bootimg/
├── src/
│   ├── bootimg/       # Header types, section types, parser, and verifier
│   ├── build.rs       # Deterministic image construction
│   ├── error.rs       # Typed parse, build, and verification errors
│   ├── format.rs      # Shared v1 layout constants
│   ├── lib.rs         # Public API and crate contract
│   └── types.rs       # Public type assembly
├── tests/
│   ├── build_tests.rs
│   └── parse_tests.rs
├── ARCHITECTURE.md
├── README.md
└── ROADMAP.md

Validation

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
RUSTFLAGS="-D warnings" cargo test --all-targets --all-features
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features

The current suite covers deterministic construction, canonical signing payloads, structure round trips, key-ID policy, hash mutation, invalid header and manifest fields, metadata-region ordering, section overlap, and bounds.

Governance Principles

  • On-disk layout is defined by the normative v1 specification, not by caller convenience.
  • Unknown values and noncanonical reserved bytes fail closed.
  • Breaking pre-alpha Rust API changes are coordinated with bootloader, boot-tool, tests, and the manual.
  • Compatibility aliases with no current consumer are removed.
  • Key identifiers and valid signatures are authenticated metadata, not capabilities or launch authority.

Allocation boundary

Parsing and verification require no allocator and retain no storage authority. The optional default builder feature owns host-side Vec output and is disabled by the bootloader. Builder allocation policy therefore remains with host tooling and is absent from the firmware dependency surface.

Contact

Development occurs in the EriX organization. Design decisions require documented rationale. Maintainers can be reached at admin@erikinkinen.fi.