FapiCallbacks

Trait FapiCallbacks 

pub trait FapiCallbacks:
    AsAny
    + Send
    + 'static {
    // Provided methods
    fn auth_cb(
        &mut self,
        _param: AuthCbParam<'_>,
    ) -> CbResult<Cow<'static, str>> { ... }
    fn sign_cb(&mut self, _param: SignCbParam<'_>) -> CbResult<Vec<u8>> { ... }
    fn branch_cb(&mut self, _param: BranchCbParam<'_>) -> CbResult<usize> { ... }
    fn policy_action_cb(
        &mut self,
        _param: PolicyActionCbParam<'_>,
    ) -> CbResult<()> { ... }
}
Expand description

Represents the set of application-defined callback functions that the FAPI invokes.

An implementation is not required to override all callback functions, as the trait provides “blank” default implementations.

Generally, an application overrides only the callback functions that it actually needs.

Implementations of this trait are registered with a FAPI context via the FapiContext::set_callbacks() function.

§Example

Applications shall implement this trait as follows:

pub struct MyCallbacks;

impl FapiCallbacks for MyCallbacks {
    fn auth_cb(&mut self, param: AuthCbParam) -> CbResult<Cow<'static, str>> {
        /* ... */
    }

    fn sign_cb(&mut self, param: SignCbParam) -> CbResult<Vec<u8>> {
        /* ... */
    }

    fn branch_cb(&mut self, param: BranchCbParam) -> CbResult<usize> {
        /* ... */
    }

    fn policy_action_cb(&mut self, param: PolicyActionCbParam) -> CbResult<()> {
        /* ... */
    }
}

Provided Methods§

fn auth_cb(&mut self, _param: AuthCbParam<'_>) -> CbResult<Cow<'static, str>>

A callback function that allows the FAPI to request authorization values.

Return value: The authorization value for the requested object.

The default implementation of this function returns Err(Cancelled). Please override if needed!

See also: Fapi_SetAuthCB()

fn sign_cb(&mut self, _param: SignCbParam<'_>) -> CbResult<Vec<u8>>

A callback function that allows the FAPI to request signatures.

Signatures are requested for authorizing TPM objects.

Return value: The signature value that has been computed for the given challenge.

The default implementation of this function returns Err(Cancelled). Please override if needed!

See also: Fapi_SetSignCB()

fn branch_cb(&mut self, _param: BranchCbParam<'_>) -> CbResult<usize>

A callback function that allows the FAPI to request branch choices.

It is usually called during policy evaluation.

Return value: The index of the selected branch; must be in the 0 (inclusive) to branches.len() (exclusive) range.

The default implementation of this function returns Err(Cancelled). Please override if needed!

See also: Fapi_SetBranchCB()

fn policy_action_cb(&mut self, _param: PolicyActionCbParam<'_>) -> CbResult<()>

A callback function that allows the FAPI to notify the application.

It is usually called to announce policy actions.

Return value: The application returns () after the notification has been processed.

The default implementation of this function returns Err(Cancelled). Please override if needed!

See also: Fapi_SetPolicyActionCB()

Implementations§

§

impl dyn FapiCallbacks

pub fn downcast<T: 'static>(&self) -> Option<&T>

Downcast this dyn FapiCallbacks to a reference of the concrete type T.

pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Downcast this dyn FapiCallbacks to a mutable reference of the concrete type T.

Implementors§