Skip to main content

Spake2pProver

Struct Spake2pProver 

Source
pub struct Spake2pProver { /* private fields */ }
Available on crate feature rustcrypto only.
Expand description

The prover: a commissioner that knows the passcode (§3.10).

Implementations§

Source§

impl Spake2pProver

Source

pub fn new( passcode: u32, salt: &[u8], iterations: u32, random: &[u8; 32], ) -> Result<Self>

Starts an exchange from a passcode and the PBKDF parameters the device announced.

random must be 32 octets of cryptographically secure randomness — the ephemeral scalar x. A predictable x hands the session key to anyone watching.

Source

pub fn from_parts(w0: &[u8; 32], w1: &[u8; 32], x: &[u8; 32]) -> Result<Self>

Starts an exchange from w0 and w1 directly.

Spake2pProver::new derives those from a passcode, which is what a commissioner reading a QR code does. This takes them ready-made — for a commissioner whose PBKDF ran somewhere else, and for checking this implementation against the published SPAKE2+ test vectors, which state w0 and w1 rather than a passcode.

Source

pub const fn pa(&self) -> &[u8; 65]

pA, to send to the commissionee.

Source

pub fn finish( &self, pb: &[u8; 65], context: &[u8], ) -> Result<(Confirmation, Confirmation, SharedSecret)>

Given the commissionee’s pB, derives the keys and the confirmations.

Returns (cA to send, cB to expect, Ke). The caller must compare the peer’s cB against the returned one with ct_eq, and abandon the session if it differs: that comparison is the only thing standing between a correct passcode and a wrong one.

Source

pub fn finish_with_identities( &self, pb: &[u8; 65], context: &[u8], prover_identity: &[u8], verifier_identity: &[u8], ) -> Result<(Confirmation, Confirmation, SharedSecret)>

Spake2pProver::finish with explicit SPAKE2+ identities.

Matter uses neither identity, so Spake2pProver::finish is what a Matter commissioner calls. This exists because SPAKE2+ itself has them, and because the specification’s own published test vectors exercise all four combinations — being able to run those is the difference between “our two halves agree” and “our arithmetic is right”.

Trait Implementations§

Source§

impl Debug for Spake2pProver

Source§

fn fmt(&self, f: &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> 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 = !

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.