Skip to content

Add TpmTransport abstraction and no_std support#7

Merged
HarryR merged 2 commits into
mainfrom
no-std-tpm-transport
Jun 12, 2026
Merged

Add TpmTransport abstraction and no_std support#7
HarryR merged 2 commits into
mainfrom
no-std-tpm-transport

Conversation

@HarryR

@HarryR HarryR commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What

Extracts a TpmTransport trait so vaportpm-attest can run in environments without /dev/tpm*, and makes the crate no_std-capable — enabling reuse from a bare UEFI bootloader over EFI_TCG2_PROTOCOL.

Why

All TPM I/O already funnelled through a single Tpm::transmit. lockboot is gaining a kernel-less stage0 UEFI netboot loader that must measure a downloaded payload into the TPM before executing it. Rather than reimplement TPM command marshalling, it supplies a TCG2-backed transport and reuses pcr_extend verbatim.

Changes

  • TpmTransport trait; Tpm now holds a Box<dyn TpmTransport>. The Linux device path becomes FileTransport behind a default std feature. Tpm::open()/open_path()/open_direct() are unchanged — existing callers (stage1) are unaffected.
  • no_std (default std on): the core (lib.rs types, command/response buffers, pcr, ek, nv) builds for *-unknown-uefi with only alloc. cert/roots/nsm/a9n/CLI bin + heavy deps gated behind std.
  • UEFI targets force force-soft sha1/sha2 (SIMD paths can't be lowered for the soft-float UEFI ABI).

Verification

  • Linux build unchanged; all tests pass (cargo test).
  • No-default-features core compiles for x86_64-unknown-uefi and aarch64-unknown-uefi.

No behavioural or public-API change for existing (Linux) consumers.

🤖 Generated with Claude Code

HarryR and others added 2 commits June 11, 2026 21:19
All TPM I/O already funnelled through a single `Tpm::transmit`, so extract
that into a `TpmTransport` trait and have `Tpm` hold a `Box<dyn TpmTransport>`.
The Linux device path becomes `FileTransport` behind a default `std` feature;
`Tpm::open()/open_path()/open_direct()` are unchanged for existing callers.

This lets a UEFI caller supply a transport over `EFI_TCG2_PROTOCOL` and reuse
the command marshalling + PCR ops (e.g. `pcr_extend`) verbatim, without any
re-implementation.

Make the crate `no_std` (default `std` feature on):
- Core (`lib.rs` types, `CommandBuffer`/`ResponseBuffer`, `pcr`, `ek`, `nv`)
  compiles for `*-unknown-uefi` with only `alloc`.
- `cert`, `roots`, `nsm`, `a9n`, the CLI bin and the heavy deps
  (der/x509-cert/serde/serde_json/ciborium/base64/thiserror) are gated behind
  `std`.
- UEFI targets force the `force-soft` sha1/sha2 backends (their SIMD paths
  can't be lowered for the soft-float UEFI ABI).

No behavioural change for the Linux build: same public API, all tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Apply rustfmt to the new transmit() body.
- Drop the intra-doc link to the private `Tpm::transmit` from the
  `TpmTransport` docs (rejected under `-D warnings`); reference the public
  `Tpm` wrapper instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@HarryR HarryR merged commit 15770b1 into main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant