Skip to main content

Keystore

Struct Keystore 

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

A handle to the key store.

Implementations§

Source§

impl Keystore

Source

pub fn connect(c: &Context) -> Result<Self>

Connects to the keystore.

To set the context’s home directory, you should usually instantiate a sequoia_dirs::Home object, and use the value returned by home.data_dir(sequoia_dirs::Component::Keystore).

Source

pub fn backends(&mut self) -> Result<Vec<Backend>>

Lists all backends.

Source

pub async fn backends_async(&mut self) -> Result<Vec<Backend>>

Lists all backends.

Source

pub fn find_keys( &mut self, ids: &[KeyHandle], ) -> Result<(Vec<Key>, Vec<KeyHandle>)>

Finds the specified keys.

As a key may reside on multiple devices, this may return multiple handles for a given key.

The second return value is the list of keys that were not found on the keystore.

Source

pub async fn find_keys_async( &mut self, ids: &[KeyHandle], ) -> Result<(Vec<Key>, Vec<KeyHandle>)>

Finds the specified keys.

As a key may reside on multiple devices, this may return multiple handles for a given key.

The second return value is the list of keys that were not found on the keystore.

Source

pub fn find_key(&mut self, id: KeyHandle) -> Result<Vec<Key>>

Finds the specified key.

As a key may reside on multiple devices, this may return multiple keys for a given id.

Source

pub async fn find_key_async(&mut self, id: KeyHandle) -> Result<Vec<Key>>

Finds the specified key.

As a key may reside on multiple devices, this may return multiple keys for a given id.

Source

pub fn decrypt( &mut self, pkesks: &[PKESK], ) -> Result<(usize, Fingerprint, Option<SymmetricAlgorithm>, SessionKey)>

Decrypts a PKESK.

The keystore tries to decrypt the PKESKs in an arbitrary order. When it succeeds in decrypting a PKESK, it stops and returns the decrypted session key. By not enforcing an order, the keystore is able to first try keys that are immediately available, and only try keys that need to be unlocked or connected to if that fails.

On success, this function returns the index of the PKESK that was decrypted, the fingerprint of the key that decrypted the PKESK, and the plaintext (the symmetric algorithm and the session key).

Source

pub async fn decrypt_async( &mut self, pkesks: &[PKESK], ) -> Result<(usize, Fingerprint, Option<SymmetricAlgorithm>, SessionKey)>

Decrypts a PKESK.

The keystore tries to decrypt the PKESKs in an arbitrary order. When it succeeds in decrypting a PKESK, it stops and returns the decrypted session key. By not enforcing an order, the keystore is able to first try keys that are immediately available, and only try keys that need to be unlocked or connected to if that fails.

On success, this function returns the index of the PKESK that was decrypted, the fingerprint of the key that decrypted the PKESK, and the plaintext (the symmetric algorithm and the session key).

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