azure_tpm/lib.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#![warn(missing_docs)]
5
6//! Platform-agnostic TPM 2.0 command interface for Azure guest VMs.
7//!
8//! This crate provides a platform-agnostic TPM 2.0 interface. It includes:
9//!
10//! - **Device access** ([`device`]): Platform-agnostic TPM device communication
11//! - **Commands** ([`commands`]): High-level TPM command implementations via [`TpmCommandExt`]
12//! - **Types** ([`types`]): TPM 2.0 data structures and marshaling
13//! - **Helpers** ([`helpers`]): Internal utilities for command building
14//! - **Event log** ([`event_log`]): TCG event log parsing
15//!
16//! # Architecture
17//!
18//! ```text
19//! ┌─────────────────────────────────────────┐
20//! │ TpmCommandExt Trait │
21//! │ (create_primary, sign, quote, etc.) │
22//! └─────────────────┬───────────────────────┘
23//! │
24//! ┌─────────────────▼───────────────────────┐
25//! │ RawTpm Trait │
26//! │ (transmit_raw bytes) │
27//! └─────────────────┬───────────────────────┘
28//! │
29//! ┌─────────────────▼───────────────────────┐
30//! │ Platform TPM Driver / vTPM / Ref │
31//! └─────────────────────────────────────────┘
32//! ```
33//!
34//! # Example
35//!
36//! ```no_run
37//! use azure_tpm::{Tpm, TpmCommandExt};
38//!
39//! fn main() -> Result<(), Box<dyn std::error::Error>> {
40//! // Open the platform TPM
41//! let tpm = Tpm::open()?;
42//!
43//! // Read PCR values
44//! let pcrs = tpm.read_pcrs_sha256(&[0, 1, 2, 7])?;
45//! for (index, digest) in &pcrs {
46//! println!("PCR{}: {}", index, hex::encode(digest));
47//! }
48//! Ok(())
49//! }
50//! ```
51
52/// High-level TPM command implementations.
53pub mod commands;
54/// Platform-agnostic TPM device communication.
55pub mod device;
56/// Dedicated error types for TPM 2.0 operations.
57pub mod error;
58/// TCG event log parsing.
59pub mod event_log;
60/// Internal utilities for command building.
61pub mod helpers;
62/// TPM 2.0 data structures and marshaling.
63pub mod types;
64
65pub use commands::TpmCommandExt;
66pub use device::{RawTpm, Tpm};
67pub use error::{TpmError, TpmResult};
68pub use types::TpmCommandCode;