Skip to main content

Keyring

Struct Keyring 

Source
pub struct Keyring<'a> { /* private fields */ }
Expand description

This device’s sync identity: its device keys and the identity key epochs it can open.

Implementations§

Source§

impl Keyring<'_>

Source

pub fn hand_over_keys( &self, request: &KeyRequest, name: &str, ) -> Result<KeyHandover>

Every epoch this device holds, of its current identity and of every earlier one, wrapped for a device restoring a backup. A removed device still hands over: a thief’s revocation must not keep the user from restoring with keys from a device they hold.

Source§

impl Keyring<'_>

Source

pub fn sign_own_ssh(&self, ssh: &SshServer) -> Result<bool>

Puts this device’s sshd into its signed row, so every device of its identity can pin its host key and dial it, whichever device paired it. A field ssh lacks, or holds in a form unsafe for ssh, keeps its signed value. False when nothing changed or this device has no row.

Source§

impl Keyring<'_>

Source

pub fn join_request( &self, name: &str, ssh: Option<SshServer>, addresses: Vec<String>, ) -> Result<JoinRequest>

What this device sends a pairing device once the code is proven.

Source

pub fn admit( &self, request: &JoinRequest, name: &str, ssh: Option<SshServer>, addresses: Vec<String>, ) -> Result<Admission>

Signs the joining device’s first row into this identity and answers with every epoch wrapped for it, the device list, the revocations behind the epochs and this device’s recovery recipients.

Source§

impl Keyring<'_>

Source

pub fn is_removed(&self) -> Result<bool>

True once a revocation this device holds reaches it.

Source§

impl Keyring<'_>

Source

pub fn recovery_state(&self) -> Result<RecoveryState>

Source

pub fn add_recovery_phrase(&self, now_micros: i64) -> Result<RecoveryPhrase>

Makes a phrase for this identity, lists its fingerprint in this device’s signed row and then wraps every epoch this device holds to it, so a failed row write leaves no phrase trusted unseen. The phrase is returned once and never stored.

Source§

impl Keyring<'_>

Source

pub fn retire_recovery( &self, fingerprint: &str, now_micros: i64, ) -> Result<Retired>

Signs a retirement of the recovery phrase with fingerprint, mints the next epoch without wrapping it to that phrase, and deletes this device’s envelopes for it. Peers apply it from the handshake.

Source§

impl Keyring<'_>

Source

pub fn removal_preview( &self, target: &str, keep: &BTreeSet<String>, ) -> Result<Removal>

What removing target would revoke, keeping keep and this device.

Source

pub fn remove_device( &self, target: &str, keep: &BTreeSet<String>, now_micros: i64, ) -> Result<Removal>

Signs a revocation of target and of every device whose first row it signed, transitively, except keep and this device, then mints the next epoch for the devices that remain. Peers wrap it to each other in their handshakes, never to a revoked device.

Source

pub fn open_lines( &self, peer: Option<&str>, lines: &[String], ) -> Result<Vec<Vec<u8>>>

Opens wire lines from peer, refusing any under an epoch numbered below its floor. Once peer seals under an epoch a revocation caused, that epoch’s number becomes its floor, so a holder of an older epoch can’t pose as it. Without a peer the floor is the newest epoch a revocation caused here.

Source

pub fn snapshot_opening_key( &self, exporter: &str, epoch: &Epoch, ) -> Result<SnapshotKey>

The key to open a snapshot exporter sealed under epoch, refused under the floor and revocations open_lines applies to its frames.

Source

pub fn opened_snapshot(&self, exporter: &str, epoch: &Epoch) -> Result<()>

Raises exporter’s floor from a snapshot whose frames all opened, as open_lines does from frames.

Source§

impl Keyring<'_>

Source§

impl<'a> Keyring<'a>

Source

pub fn load(store: &'a SqliteStore, data_dir: &'a Path) -> Result<Self>

Source

pub fn identity(&self) -> Option<&IdentityTag>

Source

pub fn held_epochs(&self) -> Vec<Epoch>

Source

pub fn handshake_for( &self, peer: &str, declared: Option<&[Epoch]>, ) -> Result<HandshakeKeys>

What this device tells peer in its hello: its identity, the epochs it holds, the rows it holds and the epochs peer lacks, wrapped for it. declared is what peer said it holds in the hello being answered; without one, earlier hellos decide.

Source

pub fn check_peer(&self, peer: &HandshakeKeys, peer_name: &str) -> Result<()>

Refuses a peer that holds no identity key or another one, naming pairing as the fix. The text reaches the other side too, so it names both machines rather than saying “this device”.

Source

pub fn accept( &self, peer: &str, keys: &HandshakeKeys, now_micros: i64, ) -> Result<()>

Takes in what a peer’s hello carries: the rows and revocations it holds, the epochs it wrapped for this device, and which epochs it holds. A peer its own revocations reach is refused once they are stored.

Source

pub fn sealer_for( &self, peer: &str, declared: Option<&[Epoch]>, ) -> Result<EpochSealer>

Seals under the newest epoch peer holds: from its hello when one is at hand, otherwise from what earlier hellos showed.

Source

pub fn snapshot_key_for( &self, peer: &str, declared: Option<&[Epoch]>, ) -> Result<SnapshotKey>

The snapshot key for the newest epoch peer holds, chosen as sealer_for chooses the wire key.

Source

pub fn snapshot_key(&self, epoch: &Epoch) -> Result<SnapshotKey>

The snapshot key of an epoch this device holds, to open a snapshot sealed under it.

Source

pub fn opener(&self) -> Result<EpochSealer>

Auto Trait Implementations§

§

impl<'a> Freeze for Keyring<'a>

§

impl<'a> RefUnwindSafe for Keyring<'a>

§

impl<'a> Send for Keyring<'a>

§

impl<'a> Sync for Keyring<'a>

§

impl<'a> Unpin for Keyring<'a>

§

impl<'a> UnsafeUnpin for Keyring<'a>

§

impl<'a> UnwindSafe for Keyring<'a>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Fruit for T
where T: Send + Downcast,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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