pub struct FakeDevice { /* private fields */ }Expand description
A configurable stand-in for a hardware trusted component.
Implementations§
Source§impl FakeDevice
impl FakeDevice
Sourcepub fn working(kind: HardwareKind, device_id: u8) -> Self
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.
Sourcepub fn last_wrapped_content_key(&self) -> Option<[u8; 32]>
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.
Sourcepub fn absent(kind: HardwareKind) -> Self
pub fn absent(kind: HardwareKind) -> Self
A host with definitively no hardware.
Sourcepub fn indeterminate(kind: HardwareKind, detail: &str) -> Self
pub fn indeterminate(kind: HardwareKind, detail: &str) -> Self
A host whose hardware could not be inspected.
Sourcepub fn with_probe(self, probe: HardwareProbe) -> Self
pub fn with_probe(self, probe: HardwareProbe) -> Self
Override the probe outcome.
Sourcepub fn with_custody(self, custody: KeyCustody) -> Self
pub fn with_custody(self, custody: KeyCustody) -> Self
Override the reported custody.
Sourcepub fn with_behaviour(self, behaviour: WrapBehaviour) -> Self
pub fn with_behaviour(self, behaviour: WrapBehaviour) -> Self
Override the wrap/unwrap behaviour.
Sourcepub fn with_kind(self, kind: HardwareKind) -> Self
pub fn with_kind(self, kind: HardwareKind) -> Self
Override the advertised kind independently of the probed kind, so the double can contradict itself.
Sourcepub fn rotate_device_key(&self, device_id: u8)
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.
Sourcepub fn failing_unwrap_after(self, n: usize) -> Self
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
impl Clone for FakeDevice
Source§fn clone(&self) -> FakeDevice
fn clone(&self) -> FakeDevice
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FakeDevice
impl Debug for FakeDevice
Source§impl HardwareProvider for FakeDevice
impl HardwareProvider for FakeDevice
Source§fn kind(&self) -> HardwareKind
fn kind(&self) -> HardwareKind
Source§fn probe(&self) -> HardwareProbe
fn probe(&self) -> HardwareProbe
Source§fn custody(&self) -> KeyCustody
fn custody(&self) -> KeyCustody
Source§fn wrap_key(&self, content_key: &ContentKey) -> Result<Vec<u8>>
fn wrap_key(&self, content_key: &ContentKey) -> Result<Vec<u8>>
content_key to the hardware wrapping key. Read moreSource§fn unwrap_key(&self, wrapped: &[u8]) -> Result<ContentKey>
fn unwrap_key(&self, wrapped: &[u8]) -> Result<ContentKey>
Auto Trait Implementations§
impl !RefUnwindSafe for FakeDevice
impl !UnwindSafe for FakeDevice
impl Freeze for FakeDevice
impl Send for FakeDevice
impl Sync for FakeDevice
impl Unpin for FakeDevice
impl UnsafeUnpin for FakeDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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