Trait sequoia_keystore_backend::Backend

source ·
pub trait Backend: Send {
    // Required methods
    fn id(&self) -> String;
    fn list<'a, 'async_trait>(
        &'a self,
    ) -> Pin<Box<dyn Future<Output = Box<dyn Iterator<Item = Box<dyn DeviceHandle + Send + Sync + 'a>> + Send + Sync + 'a>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait;
    fn find_device<'a, 'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn DeviceHandle + Send + Sync + 'a>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn find_key<'a, 'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn KeyHandle + Send + Sync + 'a>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn import<'a, 'life0, 'async_trait>(
        &'life0 self,
        cert: Cert,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(ImportStatus, Box<dyn KeyHandle + Send + Sync + 'a>)>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn scan<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

The backend interface for the sequoia key store.

This is the the interface that each device driver needs to implement.

Required Methods§

source

fn id(&self) -> String

Returns the backend’s identifier.

This should be an identifier that uniquely identifies the device driver, is human readable, and is stable across restarts.

source

fn list<'a, 'async_trait>( &'a self, ) -> Pin<Box<dyn Future<Output = Box<dyn Iterator<Item = Box<dyn DeviceHandle + Send + Sync + 'a>> + Send + Sync + 'a>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Lists all devices that are available or registered.

This does not actively perform a scan. It simply returns the devices that were available or registered as of the last scan.

In the terminology of DeviceHandle, it returns devices that are available or are registered.

source

fn find_device<'a, 'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn DeviceHandle + Send + Sync + 'a>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns a handle for the specified device.

id is a string as returned by DeviceHandle::id.

If the device is not available or not registered, then this should return Error::NotFound.

source

fn find_key<'a, 'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn KeyHandle + Send + Sync + 'a>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns a handle for the specified key.

id is a string as returned by KeyHandle::id.

If the key is not available or not registered, then this should return Error::NotFound.

source

fn import<'a, 'life0, 'async_trait>( &'life0 self, cert: Cert, ) -> Pin<Box<dyn Future<Output = Result<Vec<(ImportStatus, Box<dyn KeyHandle + Send + Sync + 'a>)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Imports the keys in the cert.

cert is a TSK. Any keys without secret key material are silently ignored.

Returns each key’s import status, and a capability to the key.

If the TSK doesn’t include any secret keys, then an empty list is returned.

Some backends require additional information to import a key. These backends should Error::ExternalImportRequired, and indicate how a user might import a key to this backend.

Provided Methods§

source

fn scan<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Causes the backend to look for devices.

This function should perform a lightweight scan. In particular, it should:

  • Read in the configuration of any devices that have been registered.

  • Look for locally connected devices with OpenPGP keys, e.g., smartcards, TPMs, etc.

This function should not search for devices that may take a long time to find. For instance, it should not scan the network, or prompt the user for a password. Instead, a separate utility should be used to discover and register those devices.

The backend should cache information about any devices that it finds in memory, but it should not register them.

This function should not initialize registered devices for use, e.g., the ssh tunnel needed to access a remote key should not be brought up.

In the terminology of DeviceHandle, this should look for devices that are available or registered.

Implementors§