Crate snow[][src]

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 Session, which is main state machine you will want to interact with.

Examples

See examples/simple.rs for a more complete TCP client/server example.

let mut initiator = snow::Builder::new("Noise_NN_25519_ChaChaPoly_BLAKE2s".parse().unwrap())
    .build_initiator()?;
let mut responder = snow::Builder::new("Noise_NN_25519_ChaChaPoly_BLAKE2s".parse().unwrap())
    .build_responder()?;
 
let mut read_buf = [0u8; 65535];
let mut first_msg = [0u8; 65535];
let mut second_msg = [0u8; 65535];

// initiator writes first handshake message
let len = initiator.write_message(&[], &mut first_msg)?;

// responder reads the message...
responder.read_message(&first_msg[..len], &mut read_buf)?;
 
// responder writes second (final) handshake message
let len = responder.write_message(&[], &mut second_msg)?;
 
// responder reads the message...
initiator.read_message(&second_msg[..len], &mut read_buf)?;

// complete handshake, and transition the state machines into transport mode
let initiator = initiator.into_transport_mode();
let responder = responder.into_transport_mode();
This example is not tested
let noise = snow::Builder::new("Noise_NN_ChaChaPoly_BLAKE2s".parse().unwrap())
    .build_initiator()
    .unwrap();

Re-exports

pub use resolvers::CryptoResolver;
pub use resolvers::FallbackResolver;
pub use resolvers::default::DefaultResolver;
pub use resolvers::ring::RingResolver;
pub use resolvers::hacl_star::HaclStarResolver;

Modules

params

All structures related to Noise parameter definitions (cryptographic primitive choices, protocol patterns/names)

resolvers

The wrappers around the default collection of cryptography and entropy providers.

types

The traits for cryptographic implementations that can be used by Noise.

Macros

bail

Exits a function early with an error.

copy_slices

Structs

Builder

The default pure-rust crypto implementation resolver. Generates a Session and also validate that all the prerequisites for the given parameters are satisfied.

Enums

InitStage

The various stages of initialization used to help identify the specific cause of an Init error.

Prerequisite

A prerequisite that may be missing.

Session

A state machine for the entire Noise session.

SnowError

All errors in snow will return a SnowError enum.

StateProblem

Specific errors in the state machine.