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>
impl<'builder> Builder<'builder>
sourcepub fn with_resolver(params: NoiseParams, resolver: BoxedCryptoResolver) -> Self
pub fn with_resolver(params: NoiseParams, resolver: BoxedCryptoResolver) -> Self
Create a Builder with a custom crypto resolver.
sourcepub fn psk(self, location: u8, key: &'builder [u8]) -> Self
pub fn psk(self, location: u8, key: &'builder [u8]) -> Self
Specify a PSK (only used with NoisePSK
base parameter)
§Safety
This will overwrite the value provided in any previous call to this method. Please take care to ensure this is not a security risk. In future versions, multiple calls to the same builder method will be explicitly prohibited.
sourcepub fn local_private_key(self, key: &'builder [u8]) -> Self
pub fn local_private_key(self, key: &'builder [u8]) -> Self
Your static private key (can be generated with generate_keypair()
).
§Safety
This will overwrite the value provided in any previous call to this method. Please take care to ensure this is not a security risk. In future versions, multiple calls to the same builder method will be explicitly prohibited.
sourcepub fn prologue(self, key: &'builder [u8]) -> Self
pub fn prologue(self, key: &'builder [u8]) -> Self
Arbitrary data to be hashed in to the handshake hash value.
§Safety
This will overwrite the value provided in any previous call to this method. Please take care to ensure this is not a security risk. In future versions, multiple calls to the same builder method will be explicitly prohibited.
sourcepub fn remote_public_key(self, pub_key: &'builder [u8]) -> Self
pub fn remote_public_key(self, pub_key: &'builder [u8]) -> Self
The responder’s static public key.
§Safety
This will overwrite the value provided in any previous call to this method. Please take care to ensure this is not a security risk. In future versions, multiple calls to the same builder method will be explicitly prohibited.
sourcepub fn generate_keypair(&self) -> Result<Keypair, Error>
pub fn generate_keypair(&self) -> Result<Keypair, Error>
Generate a new asymmetric keypair (for use as a static key).
sourcepub fn build_initiator(self) -> Result<HandshakeState, Error>
pub fn build_initiator(self) -> Result<HandshakeState, Error>
Build a HandshakeState
for the side who will initiate the handshake (send the first message)
sourcepub fn build_responder(self) -> Result<HandshakeState, Error>
pub fn build_responder(self) -> Result<HandshakeState, Error>
Build a HandshakeState
for the side who will be responder (receive the first message)