Skip to main content

FfiDirectMasterKeyStore

Struct FfiDirectMasterKeyStore 

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

The application’s master key held directly by the platform key store.

The store keeps the material itself (a CNG key on Windows, a Keystore entry on Android) and the host side persists nothing of its own for it. Reading it back returns the same 32 bytes.

§The two forms, and how the host side picks one

FfiWrappedMasterKeyStore is the other form. There is no flag and no mode argument anywhere in this section: a caller that wants the wrapped form reaches for the other object, so a platform that implements only one form cannot silently answer for both. FfiDirectMasterKeyStore::backend reports what actually answered.

§The master key crosses this boundary as bytes, and as nothing else

FfiDirectMasterKeyStore::store takes 32 bytes, FfiDirectMasterKeyStore::load returns 32 bytes. The material is never formatted, never logged and never part of an error message; the host side should drop its copy as soon as it has handed the bytes over or built an FfiVault from them.

§Current state

Windows and Android have a backend. On every other platform FfiDirectMasterKeyStore::open still succeeds — the object is usable and reports "unavailable" — and every operation fails with the kind unsupported_platform. Nothing falls back to an in-process map.

Implementations§

Source§

impl FfiDirectMasterKeyStore

Source

pub fn open() -> Result<Arc<Self>, FfiError>

Opens the direct master key store of the current platform.

§Errors

A FfiError::Core error with the kind hardware_unavailable when no provider on this machine can hold master key material. A platform whose backend is not implemented yet still opens: the failures arrive from the operations below, with the kind unsupported_platform, so the host side can name the platform instead of reporting a machine that is out of order.

Source

pub fn backend(&self) -> String

The platform key store that holds the material, as a stable short name: "tpm", "android-keystore", "software", "secure-enclave" or "unavailable".

Reported truthfully, exactly as FfiPlatformKeys::backend does: asking for it opens no key handle, and a machine without a TPM says "software" rather than pretending. The host side can use it to tell the user before relying on the store.

Source

pub fn is_hardware_backed(&self) -> bool

Whether the material cannot leave hardware.

Consistent with FfiDirectMasterKeyStore::backend by construction: true exactly when that backend is a hardware one.

Source

pub fn store(&self, label: String, key: Vec<u8>) -> Result<(), FfiError>

Stores the 32-byte key under label, replacing what was stored there.

Replacing is deliberate: a recovery or a re-pairing legitimately replaces the master key, and refusing would leave the host side unable to follow its own vault files.

§Errors

FfiError::InputTooLong for a label over the boundary limit; the core’s master_key_wrong_length when key is not 32 bytes; key_not_exportable when the platform takes the material but will not hand it back, which is the case that wants FfiWrappedMasterKeyStore; otherwise a key store failure, reported as hardware_unavailable, unsupported_platform or device_error.

Source

pub fn load(&self, label: String) -> Result<Vec<u8>, FfiError>

Reads back the master key stored under label: the 32 bytes FfiDirectMasterKeyStore::store was given.

Never creates or replaces anything: a label that holds nothing fails instead.

§Errors

FfiError::InputTooLong for an oversized label, and otherwise a key store failure: a label that holds nothing is device_error today, an unusable platform is unsupported_platform, and invalid_master_key reports a store that returned something which is not master key material.

Source

pub fn delete(&self, label: String) -> Result<(), FfiError>

Deletes the master key stored under label.

§Warning

Every vault of that account becomes unreadable on this device unless the key exists elsewhere — a recovery key, another device. The host side has to ask the user first.

§Errors

FfiError::InputTooLong for an oversized label, and otherwise the same key store failures as FfiDirectMasterKeyStore::load.

Trait Implementations§

Source§

impl<UT> LiftRef<UT> for FfiDirectMasterKeyStore

Source§

impl<UT> LowerError<UT> for FfiDirectMasterKeyStore

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for FfiDirectMasterKeyStore

Source§

type ReturnType = <Arc<FfiDirectMasterKeyStore> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for FfiDirectMasterKeyStore

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self> ⓘ

Get a clone of the Arc<> using a “borrowed” handle. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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