Skip to main content

Pairing

Struct Pairing 

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

How a joiner pairs: build one, then join a channel.

Implementations§

Source§

impl Pairing

Source

pub fn invitation(inviter: PeerId, secret: [u8; 32]) -> Self

Pairs with an invitation: secret from the inviter, who is inviter. The joiner sends the secret only when the channel proved inviter’s key, so it must be confidential and authenticate the inviter (a TLS connection that pins it).

Source

pub fn pin(pin: Pin, role: PinRole) -> Self

Pairs with a PIN: the one the responder shows and a person typed here (PinRole::Typed), or this joiner’s own, which it shows with the slot the responder assigns (PinRole::Shown). The PAKE draws from the operating system’s generator unless random gives another.

Source

pub fn device(label: &str) -> Self

Pairs by the device flow: the responder issues a user code that this joiner shows, and pairs when its operator approves. label (at most 255 bytes, one line) is shown to the operator if the responder’s app chooses; it proves nothing.

The joiner must have verified the responder (a pin, or roots for the name dialled): join refuses a channel that is not Channel::verified unless allow_unverified is set.

Source

pub fn allow_unverified(self, allow: bool) -> Self

Lets the device flow run with a responder this joiner did not verify. A relaying attacker can then pair in place of both sides: the operator approves the attacker’s code, and this joiner trusts the attacker. Off by default.

Source

pub fn allows_unverified(&self) -> bool

Whether allow_unverified is set.

Source

pub fn random(self, random: Random) -> Self

The PAKE’s random source, instead of the operating system’s.

Source

pub fn mode(&self) -> Mode

The mode.

Source

pub fn inviter(&self) -> Option<PeerId>

The inviter’s id, for an invitation.

Source

pub fn join(self, channel: Channel) -> Result<PairingJoiner, PairingError>

Starts the exchange over channel; the first message is ready to transmit.

§Errors

PairingError::Unverified for an invitation whose channel did not prove the inviter’s key, and for the device flow over a channel that did not verify the responder unless allowed; PairingError::Local with Error::InvalidOptions for a device label longer than 255 bytes or with a control or bidirectional formatting character.

Trait Implementations§

Source§

impl Clone for Pairing

Source§

fn clone(&self) -> Self

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 Debug for Pairing

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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 = !

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.