1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The `snow` crate is a straightforward, Hard To Fuck Up™ Noise Protocol implementation.
//!
//! Read the [Noise Protocol Framework Spec](http://noiseprotocol.org/noise.html) for more
//! information.
//!
//! The typical usage flow is to use `NoiseBuilder` 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.
//!
//! ```rust,ignore
//! let noise = NoiseBuilder::new("Noise_NN_ChaChaPoly_BLAKE2s".parse().unwrap())
//!                          .build_initiator()
//!                          .unwrap();
//!
//! let mut buf = [0u8; 65535];
//!
//! // write first handshake message
//! noise.write_message(&[0u8; 0], &mut buf).unwrap();
//!
//! // receive response message
//! let incoming = receive_message_from_the_mysterious_ether();
//! noise.read_message(&incoming, &mut buf).unwrap();
//!
//! // complete handshake, and transition the state machine into transport mode
//! let noise = noise.into_transport_mode();
//!
//! ```

#![cfg_attr(feature = "nightly", feature(try_from))]
#![recursion_limit = "1024"]

extern crate arrayvec;
extern crate byteorder;
#[macro_use] extern crate static_slice;
#[macro_use] extern crate error_chain;
#[cfg(feature = "ring-resolver")] extern crate ring;

mod error;
mod constants;
mod utils;
mod cipherstate;
mod symmetricstate;
mod handshakestate;
mod noise;
mod session;
mod transportstate;

pub mod params;
pub mod types;
pub mod wrappers;

pub use error::*;
pub use noise::{CryptoResolver, DefaultResolver};
pub use noise::NoiseBuilder;
pub use session::Session;

#[cfg(feature = "ring-resolver")] pub use wrappers::ring_wrapper::RingAcceleratedResolver;