Skip to main content

ClientHandshake

Struct ClientHandshake 

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

Client (app) side of the handshake, between the challenge and the server proof

The dev runtime calls start, sends the returned challenge as a WebSocket text message, waits for the server’s text reply, and passes it to finish. Only after finish succeeds does the app send its proof and then anything identifying the process.

§Example

use whisker_dev_protocol::{ClientHandshake, Error, ServerHandshake};

let (client, challenge) = ClientHandshake::start("app secret")?;
// A server from another session holds a different secret.
let (_server, proof) = ServerHandshake::respond("other secret", &challenge)?;
assert!(matches!(client.finish(&proof), Err(Error::InvalidServerProof)));

Implementations§

Source§

impl ClientHandshake

Source

pub fn start(secret: &str) -> Result<(Self, String), Error>

Begin a handshake and return the challenge text to send

Fails with Error::MissingSecret for an empty secret and with Error::Random if no nonce can be generated.

Source

pub fn finish(self, server_proof: &str) -> Result<(Session, String), Error>

Verify the server’s proof and return the session plus the client proof to send

Fails with Error::InvalidServerProof when the server does not hold the same secret, which is what an app left over from a previous whisker run session observes.

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.