pub struct TpmDevice { /* private fields */ }Implementations§
Source§impl TpmDevice
impl TpmDevice
Sourcepub fn builder() -> TpmDeviceBuilder
pub fn builder() -> TpmDeviceBuilder
Creates a new builder for TpmDevice.
Sourcepub fn transmit<C: TpmFrame>(
&mut self,
command: &C,
sessions: &[TpmsAuthCommand],
) -> Result<(TpmResponse, TpmAuthResponses), TpmDeviceError>
pub fn transmit<C: TpmFrame>( &mut self, command: &C, sessions: &[TpmsAuthCommand], ) -> Result<(TpmResponse, TpmAuthResponses), TpmDeviceError>
Performs the whole TPM command transmission process.
§Errors
Returns Interrupted when the
interrupt callback requests cancellation.
Returns Timeout when the TPM does
not respond within the configured timeout.
Returns Io when a write, flush, or read
operation on the device file fails, or when polling the device file
descriptor fails.
Returns InvalidResponse or
UnexpectedEof when the TPM
reply is malformed, truncated, or longer than the announced size.
Returns Marshal or
Unmarshal when encoding the
command or decoding the response fails.
Returns TpmRc when the TPM returns an
error code.
Sourcepub fn fetch_algorithm_properties(
&mut self,
) -> Result<Vec<TpmsAlgProperty>, TpmDeviceError>
pub fn fetch_algorithm_properties( &mut self, ) -> Result<Vec<TpmsAlgProperty>, TpmDeviceError>
Retrieves all algorithm properties supported by the TPM.
§Errors
Returns OperationFailed when
the handle count cannot be represented as u32. Propagates any
TpmDeviceError from
get_capability, including
CapabilityMissing when the
TPM does not report algorithm properties.
Sourcepub fn fetch_handles(
&mut self,
class: TpmHt,
) -> Result<Vec<TpmHandle>, TpmDeviceError>
pub fn fetch_handles( &mut self, class: TpmHt, ) -> Result<Vec<TpmHandle>, TpmDeviceError>
Retrieves all handles of a specific type from the TPM.
§Errors
Returns OperationFailed when
the handle count cannot be represented as u32. Propagates any
TpmDeviceError from
get_capability, including
CapabilityMissing when the
TPM does not report handles of the requested class.
Sourcepub fn fetch_ecc_curves(&mut self) -> Result<Vec<TpmEccCurve>, TpmDeviceError>
pub fn fetch_ecc_curves(&mut self) -> Result<Vec<TpmEccCurve>, TpmDeviceError>
Retrieves all available ECC curves supported by the TPM.
§Errors
Returns OperationFailed when
the handle count cannot be represented as u32. Propagates any
TpmDeviceError from
get_capability, including
CapabilityMissing when the
TPM does not report ECC curves.
Sourcepub fn fetch_pcr_bank_list(
&mut self,
) -> Result<(Vec<TpmAlgId>, TpmsPcrSelect), TpmDeviceError>
pub fn fetch_pcr_bank_list( &mut self, ) -> Result<(Vec<TpmAlgId>, TpmsPcrSelect), TpmDeviceError>
Retrieves the list of active PCR banks and the bank selection mask.
§Errors
Returns OperationFailed when
the handle count cannot be represented as u32. Propagates any
TpmDeviceError from
get_capability, including
CapabilityMissing when the
TPM does not report PCRs.
Returns PcrBanksNotAvailable
if the list of banks is empty or if no banks have allocated PCRs.
Returns PcrBankSelectionMismatch
if the PCR selection mask is not identical across all active banks.
Sourcepub fn get_tpm_property(
&mut self,
property: TpmPt,
) -> Result<TpmUint32, TpmDeviceError>
pub fn get_tpm_property( &mut self, property: TpmPt, ) -> Result<TpmUint32, TpmDeviceError>
Reads a specific TPM property.
§Errors
Returns CapabilityMissing
when the TPM does not report the requested property. Propagates any
TpmDeviceError from
get_capability_page.
Sourcepub fn read_public(
&mut self,
handle: TpmHandle,
) -> Result<(TpmtPublic, Tpm2bName), TpmDeviceError>
pub fn read_public( &mut self, handle: TpmHandle, ) -> Result<(TpmtPublic, Tpm2bName), TpmDeviceError>
Reads the public area of a TPM object.
§Errors
Propagates any TpmDeviceError from
transmit. Returns
ResponseMismatch when the
TPM response does not contain TPM2_ReadPublic data.
Sourcepub fn find_persistent(
&mut self,
target_name: &Tpm2bName,
) -> Result<Option<TpmHandle>, TpmDeviceError>
pub fn find_persistent( &mut self, target_name: &Tpm2bName, ) -> Result<Option<TpmHandle>, TpmDeviceError>
Finds a persistent handle by its Tpm2bName.
§Errors
Propagates any TpmDeviceError from
fetch_handles and
read_public, except for TPM reference and
handle errors with base
ReferenceH0 or
Handle, which are treated as
invalid handles and skipped.
Sourcepub fn save_context(
&mut self,
save_handle: TpmHandle,
) -> Result<TpmsContext, TpmDeviceError>
pub fn save_context( &mut self, save_handle: TpmHandle, ) -> Result<TpmsContext, TpmDeviceError>
Saves the context of a transient object or session.
§Errors
Propagates any TpmDeviceError from
transmit. Returns
ResponseMismatch when the
TPM response does not contain TPM2_ContextSave data.
Sourcepub fn load_context(
&mut self,
context: TpmsContext,
) -> Result<TpmHandle, TpmDeviceError>
pub fn load_context( &mut self, context: TpmsContext, ) -> Result<TpmHandle, TpmDeviceError>
Loads a TPM context and returns the handle.
§Errors
Propagates any TpmDeviceError from
transmit. Returns
ResponseMismatch when the
TPM response does not contain TPM2_ContextLoad data.
Sourcepub fn flush_context(&mut self, handle: TpmHandle) -> Result<(), TpmDeviceError>
pub fn flush_context(&mut self, handle: TpmHandle) -> Result<(), TpmDeviceError>
Flushes a transient object or session from the TPM and removes it from the cache.
§Errors
Propagates any TpmDeviceError from
transmit.
Sourcepub fn flush_session(
&mut self,
context: TpmsContext,
) -> Result<(), TpmDeviceError>
pub fn flush_session( &mut self, context: TpmsContext, ) -> Result<(), TpmDeviceError>
Loads a session context and then flushes the resulting handle.
§Errors
Propagates any TpmDeviceError from
load_context or
flush_context except for TPM reference
errors with base
ReferenceH0 or
Handle, which are treated as
a successful no-op.
Sourcepub fn refresh_key(
&mut self,
context: TpmsContext,
) -> Result<bool, TpmDeviceError>
pub fn refresh_key( &mut self, context: TpmsContext, ) -> Result<bool, TpmDeviceError>
Refreshes a key context. Returns true if the context is still valid,
and false if it is stale.
§Errors
Propagates any TpmDeviceError from
load_context or
flush_context except for TPM reference
errors with base
ReferenceH0, which are
treated as a stale context and reported as Ok(false).