Skip to main content

Crate azure_tpm

Crate azure_tpm 

Source
Expand description

Platform-agnostic TPM 2.0 command interface for Azure guest VMs.

This crate provides a platform-agnostic TPM 2.0 interface. It includes:

  • Device access (device): Platform-agnostic TPM device communication
  • Commands (commands): High-level TPM command implementations via TpmCommandExt
  • Types (types): TPM 2.0 data structures and marshaling
  • Helpers (helpers): Internal utilities for command building
  • Event log (event_log): TCG event log parsing

§Architecture

┌─────────────────────────────────────────┐
│         TpmCommandExt Trait             │
│  (create_primary, sign, quote, etc.)    │
└─────────────────┬───────────────────────┘
                  │
┌─────────────────▼───────────────────────┐
│           RawTpm Trait                  │
│        (transmit_raw bytes)             │
└─────────────────┬───────────────────────┘
                  │
┌─────────────────▼───────────────────────┐
│    Platform TPM Driver / vTPM / Ref     │
└─────────────────────────────────────────┘

§Example

use azure_tpm::{Tpm, TpmCommandExt};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open the platform TPM
    let tpm = Tpm::open()?;

    // Read PCR values
    let pcrs = tpm.read_pcrs_sha256(&[0, 1, 2, 7])?;
    for (index, digest) in &pcrs {
        println!("PCR{}: {}", index, hex::encode(digest));
    }
    Ok(())
}

Re-exports§

pub use commands::TpmCommandExt;
pub use device::RawTpm;
pub use device::Tpm;
pub use error::TpmError;
pub use error::TpmResult;
pub use types::TpmCommandCode;

Modules§

commands
High-level TPM command implementations. TPM 2.0 command implementations.
device
Platform-agnostic TPM device communication.
error
Dedicated error types for TPM 2.0 operations. Dedicated error types for TPM 2.0 operations.
event_log
TCG event log parsing.
helpers
Internal utilities for command building.
types
TPM 2.0 data structures and marshaling. Minimal TPM2 type definitions with binary (un)marshalling helpers. These are intentionally partial and only cover what current code paths need.