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<'_>
impl Keyring<'_>
Sourcepub fn hand_over_keys(
&self,
request: &KeyRequest,
name: &str,
) -> Result<KeyHandover>
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<'_>
impl Keyring<'_>
Sourcepub fn sign_own_ssh(&self, ssh: &SshServer) -> Result<bool>
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<'_>
impl Keyring<'_>
Sourcepub fn join_request(
&self,
name: &str,
ssh: Option<SshServer>,
addresses: Vec<String>,
) -> Result<JoinRequest>
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.
Sourcepub fn admit(
&self,
request: &JoinRequest,
name: &str,
ssh: Option<SshServer>,
addresses: Vec<String>,
) -> Result<Admission>
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<'_>
impl Keyring<'_>
Sourcepub fn is_removed(&self) -> Result<bool>
pub fn is_removed(&self) -> Result<bool>
True once a revocation this device holds reaches it.
Source§impl Keyring<'_>
impl Keyring<'_>
pub fn recovery_state(&self) -> Result<RecoveryState>
Sourcepub fn add_recovery_phrase(&self, now_micros: i64) -> Result<RecoveryPhrase>
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<'_>
impl Keyring<'_>
Sourcepub fn removal_preview(
&self,
target: &str,
keep: &BTreeSet<String>,
) -> Result<Removal>
pub fn removal_preview( &self, target: &str, keep: &BTreeSet<String>, ) -> Result<Removal>
What removing target would revoke, keeping keep and this device.
Sourcepub fn remove_device(
&self,
target: &str,
keep: &BTreeSet<String>,
now_micros: i64,
) -> Result<Removal>
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.
Sourcepub fn open_lines(
&self,
peer: Option<&str>,
lines: &[String],
) -> Result<Vec<Vec<u8>>>
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.
Sourcepub fn snapshot_opening_key(
&self,
exporter: &str,
epoch: &Epoch,
) -> Result<SnapshotKey>
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§impl<'a> Keyring<'a>
impl<'a> Keyring<'a>
pub fn load(store: &'a SqliteStore, data_dir: &'a Path) -> Result<Self>
pub fn identity(&self) -> Option<&IdentityTag>
pub fn held_epochs(&self) -> Vec<Epoch>
Sourcepub fn handshake_for(
&self,
peer: &str,
declared: Option<&[Epoch]>,
) -> Result<HandshakeKeys>
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.
Sourcepub fn check_peer(&self, peer: &HandshakeKeys, peer_name: &str) -> Result<()>
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”.
Sourcepub fn accept(
&self,
peer: &str,
keys: &HandshakeKeys,
now_micros: i64,
) -> Result<()>
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.
Sourcepub fn sealer_for(
&self,
peer: &str,
declared: Option<&[Epoch]>,
) -> Result<EpochSealer>
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.
Sourcepub fn snapshot_key_for(
&self,
peer: &str,
declared: Option<&[Epoch]>,
) -> Result<SnapshotKey>
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.
Sourcepub fn snapshot_key(&self, epoch: &Epoch) -> Result<SnapshotKey>
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.
pub fn opener(&self) -> Result<EpochSealer>
Auto Trait Implementations§
impl<'a> Forget for Keyring<'a>
impl<'a> Freeze for Keyring<'a>
impl<'a> Move 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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