Skip to main content

FakeDevice

Struct FakeDevice 

Source
pub struct FakeDevice { /* private fields */ }
Expand description

A configurable stand-in for a hardware trusted component.

Implementations§

Source§

impl FakeDevice

Source

pub fn working(kind: HardwareKind, device_id: u8) -> Self

An honest, working device of kind, keyed by device_id.

Two devices with different device_ids stand for two different machines.

Source

pub fn last_wrapped_content_key(&self) -> Option<[u8; 32]>

The last content key this device was asked to wrap, if any.

Test-only observability: it is what makes “the content key never appears in the stored bytes” an assertion about the actual key rather than about a value the test invented.

Source

pub fn absent(kind: HardwareKind) -> Self

A host with definitively no hardware.

Source

pub fn indeterminate(kind: HardwareKind, detail: &str) -> Self

A host whose hardware could not be inspected.

Source

pub fn with_probe(self, probe: HardwareProbe) -> Self

Override the probe outcome.

Source

pub fn with_custody(self, custody: KeyCustody) -> Self

Override the reported custody.

Source

pub fn with_behaviour(self, behaviour: WrapBehaviour) -> Self

Override the wrap/unwrap behaviour.

Source

pub fn with_kind(self, kind: HardwareKind) -> Self

Override the advertised kind independently of the probed kind, so the double can contradict itself.

Source

pub fn rotate_device_key(&self, device_id: u8)

Replace this device’s key material, as a TPM clear / re-enrolment does.

Blobs sealed before the rotation become unopenable by this device, which is precisely what a user sees after a firmware update clears the TPM. Clones share the slot, so a backend already holding this provider sees the change.

Source

pub fn failing_unwrap_after(self, n: usize) -> Self

Succeed at n more unwraps, then fail every one after that.

Models a component that is healthy when inspected and unusable moments later. The constructor self-test spends exactly one unwrap, so failing_unwrap_after(1) yields a device that resolves a genuine hardware tier and then cannot reopen the next thing it seals.

Trait Implementations§

Source§

impl Clone for FakeDevice

Source§

fn clone(&self) -> FakeDevice

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FakeDevice

Source§

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

Formats the value using the given formatter. Read more
Source§

impl HardwareProvider for FakeDevice

Source§

fn kind(&self) -> HardwareKind

Which hardware class this provider binds to.
Source§

fn probe(&self) -> HardwareProbe

Inspect the host for usable hardware. Read more
Source§

fn custody(&self) -> KeyCustody

Where this provider’s wrapping key lives.
Source§

fn wrap_key(&self, content_key: &ContentKey) -> Result<Vec<u8>>

Encrypt content_key to the hardware wrapping key. Read more
Source§

fn unwrap_key(&self, wrapped: &[u8]) -> Result<ContentKey>

Decrypt a previously wrapped content key using the hardware key. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.