Expand description
The snow
crate is a straightforward, Hard To Fuck Up™ Noise Protocol implementation.
Read the Noise Protocol Framework Spec for more information.
The typical usage flow is to use Builder
to construct a HandshakeState
, where you
will complete the handshake phase and convert into either a TransportState
or
StatelessTransportState
.
§Examples
See examples/simple.rs
for a more complete TCP client/server example with static keys.
static PATTERN: &'static str = "Noise_NN_25519_ChaChaPoly_BLAKE2s";
let mut initiator = snow::Builder::new(PATTERN.parse()?)
.build_initiator()?;
let mut responder = snow::Builder::new(PATTERN.parse()?)
.build_responder()?;
let (mut read_buf, mut first_msg, mut second_msg) =
([0u8; 1024], [0u8; 1024], [0u8; 1024]);
// -> e
let len = initiator.write_message(&[], &mut first_msg)?;
// responder processes the first message...
responder.read_message(&first_msg[..len], &mut read_buf)?;
// <- e, ee
let len = responder.write_message(&[], &mut second_msg)?;
// initiator processes the response...
initiator.read_message(&second_msg[..len], &mut read_buf)?;
// NN handshake complete, transition into transport mode.
let initiator = initiator.into_transport_mode();
let responder = responder.into_transport_mode();
Re-exports§
pub use crate::error::Error;
Modules§
- All error types used by Snow operations.
- All structures related to Noise parameter definitions (cryptographic primitive choices, protocol patterns/names)
- The wrappers around the default collection of cryptography and entropy providers.
- The traits for cryptographic implementations that can be used by Noise.
Structs§
- Generates a
HandshakeState
and also validates that all the prerequisites for the given parameters are satisfied. - A state machine encompassing the handshake phase of a Noise session.
- A keypair object returned by
Builder::generate_keypair()
- A state machine encompassing the transport phase of a Noise session, using the two
CipherState
s (for sending and receiving) that were spawned from theSymmetricState
’sSplit()
method, called after a handshake has been finished. - A state machine encompassing the transport phase of a Noise session, using the two
CipherState
s (for sending and receiving) that were spawned from theSymmetricState
’sSplit()
method, called after a handshake has been finished.