TpmDevice

Struct TpmDevice 

Source
pub struct TpmDevice { /* private fields */ }

Implementations§

Source§

impl TpmDevice

Source

pub fn builder() -> TpmDeviceBuilder

Creates a new builder for TpmDevice.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Debug for TpmDevice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more