Struct snow::Builder

source ·
pub struct Builder<'builder> { /* private fields */ }
Expand description

Generates a HandshakeState and also validates that all the prerequisites for the given parameters are satisfied.

Examples

let noise = Builder::new("Noise_XX_25519_ChaChaPoly_BLAKE2s".parse().unwrap())
    .local_private_key(&my_long_term_key)
    .remote_public_key(&their_pub_key)
    .prologue("noise is just swell".as_bytes())
    .build_initiator()
    .unwrap();

Implementations§

source§

impl<'builder> Builder<'builder>

source

pub fn new(params: NoiseParams) -> Self

Create a Builder with the default crypto resolver.

source

pub fn with_resolver(params: NoiseParams, resolver: BoxedCryptoResolver) -> Self

Create a Builder with a custom crypto resolver.

source

pub fn psk(self, location: u8, key: &'builder [u8]) -> Self

Specify a PSK (only used with NoisePSK base parameter)

source

pub fn local_private_key(self, key: &'builder [u8]) -> Self

Your static private key (can be generated with generate_keypair()).

source

pub fn prologue(self, key: &'builder [u8]) -> Self

Arbitrary data to be hashed in to the handshake hash value.

source

pub fn remote_public_key(self, pub_key: &'builder [u8]) -> Self

The responder’s static public key.

source

pub fn generate_keypair(&self) -> Result<Keypair, Error>

Generate a new asymmetric keypair (for use as a static key).

source

pub fn build_initiator(self) -> Result<HandshakeState, Error>

Build a HandshakeState for the side who will initiate the handshake (send the first message)

source

pub fn build_responder(self) -> Result<HandshakeState, Error>

Build a HandshakeState for the side who will be responder (receive the first message)

Auto Trait Implementations§

§

impl<'builder> !RefUnwindSafe for Builder<'builder>

§

impl<'builder> Send for Builder<'builder>

§

impl<'builder> !Sync for Builder<'builder>

§

impl<'builder> Unpin for Builder<'builder>

§

impl<'builder> !UnwindSafe for Builder<'builder>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.