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 new(params: NoiseParams) -> Builder<'builder>
pub fn new(params: NoiseParams) -> Builder<'builder>
Create a Builder with the default crypto resolver.
Sourcepub fn with_resolver(
params: NoiseParams,
resolver: Box<dyn CryptoResolver + Send>,
) -> Builder<'builder>
pub fn with_resolver( params: NoiseParams, resolver: Box<dyn CryptoResolver + Send>, ) -> Builder<'builder>
Create a Builder with a custom crypto resolver.
Sourcepub fn psk(self, location: u8, key: &'builder [u8]) -> Builder<'builder>
pub fn psk(self, location: u8, key: &'builder [u8]) -> Builder<'builder>
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]) -> Builder<'builder>
pub fn local_private_key(self, key: &'builder [u8]) -> Builder<'builder>
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]) -> Builder<'builder>
pub fn prologue(self, key: &'builder [u8]) -> Builder<'builder>
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]) -> Builder<'builder>
pub fn remote_public_key(self, pub_key: &'builder [u8]) -> Builder<'builder>
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)