Skip to main content

Vault

Struct Vault 

Source
pub struct Vault<S = AgentClient> { /* private fields */ }
Expand description

High-level lockbox helper that integrates open operations with a key cache.

Vault wraps a ContentKeyStore. Creating or opening a lockbox stores the resulting content key in that store. open_lockbox then reopens the lockbox from the cached key without requiring the original password or contact private key.

Implementations§

Source§

impl<S> Vault<S>

Source

pub fn new(store: S) -> Vault<S>

Creates a vault around a custom content-key store.

Source

pub fn store(&self) -> &S

Returns the content-key store used by this vault.

Source§

impl<S> Vault<S>
where S: ContentKeyStore,

Source

pub fn create_lockbox_with_password( &self, path: impl AsRef<Path>, password: &SecureString, ) -> Result<Lockbox, Error>

Creates a password-protected lockbox and caches its content key.

Source

pub fn open_lockbox_with_password( &self, path: impl AsRef<Path>, password: &SecureString, ) -> Result<Lockbox, Error>

Opens a password-protected lockbox and caches its content key.

Source

pub fn open_lockbox_with_password_for_duration( &self, path: impl AsRef<Path>, password: &SecureString, ttl_seconds: u64, ) -> Result<Lockbox, Error>

Opens a password-protected lockbox and caches its content key for the requested number of seconds.

Source

pub fn cache_lockbox_password_for_duration( &self, path: impl AsRef<Path>, password: &SecureString, ttl_seconds: u64, ) -> Result<(), Error>

Refreshes a password-protected lockbox’s cached content key for a requested number of seconds without reopening the lockbox payload.

Source

pub fn create_lockbox( &self, path: impl AsRef<Path>, protection: LockboxProtection<'_>, ) -> Result<Lockbox, Error>

Creates a lockbox with the supplied protection mode.

Content-key and password modes cache the opened content key after the file is created. Contact-public-key mode creates the file but cannot cache a content key because no private material is available.

Source

pub fn create_lockbox_with_signing_key( &self, path: impl AsRef<Path>, protection: LockboxProtection<'_>, signing_key: &OwnerSigningKeyPair, ) -> Result<Lockbox, Error>

Creates a lockbox using an owner signing key loaded by the caller.

This variant lets interactive callers reuse an already-open encrypted vault instead of requiring its passphrase to also be available through process environment or platform secret-store state. Private signing material remains owned by OwnerSigningKeyPair, whose serialized private key is held in secure, zeroizing memory.

Source

pub fn open_lockbox(&self, path: impl AsRef<Path>) -> Result<Lockbox, Error>

Opens a lockbox using only a content key already present in the store.

This fails if the key store has no cached key for the lockbox id.

Source

pub fn open_lockbox_read_only( &self, path: impl AsRef<Path>, ) -> Result<Lockbox<ReadOnly>, Error>

Opens a cached lockbox for read-only metadata access without loading or requesting an owner-signing key.

Source

pub fn open_lockbox_with( &self, path: impl AsRef<Path>, open: LockboxOpen<'_>, ) -> Result<Lockbox, Error>

Opens a lockbox with explicit open material and caches its content key.

Password and contact-key-pair opens may fall back to a key-directory backup stored in the default VaultDirectory when the embedded key directory cannot be read. That fallback requires LOCKBOX_VAULT_PASSWORD to be set so the default vault directory can be opened.

Source

pub fn open_lockbox_with_signing_key( &self, path: impl AsRef<Path>, open: LockboxOpen<'_>, signing_key: &OwnerSigningKeyPair, ) -> Result<Lockbox, Error>

Opens a lockbox using explicit open material and an owner signing key loaded by the caller, then caches its content key.

Source

pub fn open_lockbox_with_for_duration( &self, path: impl AsRef<Path>, open: LockboxOpen<'_>, ttl_seconds: u64, ) -> Result<Lockbox, Error>

Opens a lockbox with explicit open material and caches its content key for the requested number of seconds.

Source

pub fn open_lockbox_with_for_duration_and_signing_key( &self, path: impl AsRef<Path>, open: LockboxOpen<'_>, ttl_seconds: u64, signing_key: &OwnerSigningKeyPair, ) -> Result<Lockbox, Error>

Opens a lockbox for a requested duration using an owner signing key loaded by the caller.

Source

pub fn close_lockbox(&self, path: impl AsRef<Path>) -> Result<(), Error>

Removes this lockbox’s cached content key from the store.

Source

pub fn close_all(&self) -> Result<(), Error>

Removes every cached content key from the store.

Trait Implementations§

Source§

impl<S> Clone for Vault<S>
where S: Clone,

Source§

fn clone(&self) -> Vault<S>

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<S> Debug for Vault<S>
where S: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Vault<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Vault<S>
where S: RefUnwindSafe,

§

impl<S> Send for Vault<S>
where S: Send,

§

impl<S> Sync for Vault<S>
where S: Sync,

§

impl<S> Unpin for Vault<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Vault<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Vault<S>
where S: UnwindSafe,

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