pub struct Tpm { /* private fields */ }Expand description
TPM 2.0 interface
Supports both hardware MMIO and software-emulated TPM operations.
Implementations§
Source§impl Tpm
impl Tpm
Sourcepub fn detect_hardware(&mut self) -> TpmResult<TpmInterfaceType>
pub fn detect_hardware(&mut self) -> TpmResult<TpmInterfaceType>
Detect TPM hardware
Sourcepub fn get_random(&self, num_bytes: usize) -> TpmResult<Vec<u8>>
pub fn get_random(&self, num_bytes: usize) -> TpmResult<Vec<u8>>
Get random bytes from TPM hardware RNG or software PRNG fallback.
Sourcepub fn pcr_read(&self, pcr_index: PcrIndex) -> TpmResult<[u8; 32]>
pub fn pcr_read(&self, pcr_index: PcrIndex) -> TpmResult<[u8; 32]>
Read Platform Configuration Register (PCR) value.
Returns the current 32-byte SHA-256 PCR value for the given index.
Sourcepub fn pcr_extend(
&mut self,
pcr_index: PcrIndex,
data: &[u8; 32],
) -> TpmResult<()>
pub fn pcr_extend( &mut self, pcr_index: PcrIndex, data: &[u8; 32], ) -> TpmResult<()>
Extend Platform Configuration Register with a measurement hash.
Computes: PCR[index] = SHA-256(PCR[index] || measurement)
Sourcepub fn quote(
&self,
pcr_selection: &[PcrIndex],
nonce: &[u8; 32],
) -> TpmResult<Vec<u8>>
pub fn quote( &self, pcr_selection: &[PcrIndex], nonce: &[u8; 32], ) -> TpmResult<Vec<u8>>
Create attestation quote over selected PCRs.
Returns a signed quote structure containing the PCR values and nonce.
Sourcepub fn seal(
&mut self,
data: &[u8],
pcr_selection: &[PcrIndex],
) -> TpmResult<Vec<u8>>
pub fn seal( &mut self, data: &[u8], pcr_selection: &[PcrIndex], ) -> TpmResult<Vec<u8>>
Seal data to current PCR values.
The sealed blob can only be unsealed when the PCRs match the values recorded at seal time. In software emulation mode, this uses a SHA-256 derived key for XOR encryption.
Sourcepub fn unseal(&self, sealed_blob: &[u8]) -> TpmResult<Vec<u8>>
pub fn unseal(&self, sealed_blob: &[u8]) -> TpmResult<Vec<u8>>
Unseal data from a sealed blob.
Checks that current PCR values match the policy recorded at seal time. Returns the original plaintext data on success.
Sourcepub fn create_signing_key(&self) -> TpmResult<TpmHandle>
pub fn create_signing_key(&self) -> TpmResult<TpmHandle>
Create signing key in TPM
Sourcepub fn sign(&self, handle: TpmHandle, data: &[u8]) -> TpmResult<Vec<u8>>
pub fn sign(&self, handle: TpmHandle, data: &[u8]) -> TpmResult<Vec<u8>>
Sign data with TPM key
Sourcepub fn verify_signature(
&self,
handle: TpmHandle,
data: &[u8],
signature: &[u8],
) -> TpmResult<bool>
pub fn verify_signature( &self, handle: TpmHandle, data: &[u8], signature: &[u8], ) -> TpmResult<bool>
Verify signature with TPM key
Sourcepub fn is_software_emulation(&self) -> bool
pub fn is_software_emulation(&self) -> bool
Check if the TPM is running in software emulation mode
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the TPM has been initialized