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
60
61
62
63
64
65
66
extern crate byteorder;
extern crate hmac;
extern crate num_bigint;
extern crate rand;
extern crate sha2;

extern crate chacha;

#[macro_use]
extern crate cfg_if;

cfg_if! {
    if #[cfg(feature = "ser")]{
        #[macro_use]
        extern crate serde;
    }
}

mod cipher;

pub mod blobs;
mod dh_params;
mod messages;
pub mod srd;
mod srd_errors;

pub type Result<T> = std::result::Result<T, srd_errors::SrdError>;

pub use cipher::Cipher;
pub use srd::Srd;
pub use srd_errors::SrdError;

cfg_if! {
    if #[cfg(feature = "wasm")] {
        extern crate wasm_bindgen;
        pub use srd::SrdJsResult;
    }
    else {
        pub mod ffi;
    }
}

cfg_if! {
    if #[cfg(feature = "aes")] {
        extern crate aes256 as aes;
        extern crate block_modes;

    }
}

#[cfg(test)]
mod tests;

#[cfg(feature = "wasm")]
fn main() {}

//TODO Verify packet size before reading to send error instead of panicking
//TODO Markdown documentation
//TODO Reorder imports
//TODO Reorder traits method
//TODO Verify bignum/Diffie-Hellman optimization
//TODO Comment subsections inside methods
//TODO Create basic blobs described in specs
//TODO Fix webassembly. It will use WebCryptoAPI's javascript function using wasm-bindgen. Still not sure how to use the object oriented model.

// Note: Implementation runs way faster in release mode.