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
//! Crypto methods for shadowsocks

use std::convert::From;

use openssl::symm;

pub use self::cipher::{CipherType, CipherCategory, CipherResult};
pub use self::stream::{StreamCipher, StreamCipherVariant, new_stream};
pub use self::aead::{AeadEncryptor, AeadDecryptor, new_aead_encryptor, new_aead_decryptor};

pub mod cipher;
pub mod openssl;
pub mod digest;
pub mod table;
pub mod rc4_md5;
pub mod crypto;
pub mod dummy;
pub mod aead;
pub mod stream;

/// Crypto mode, encrypt or decrypt
#[derive(Clone, Copy)]
pub enum CryptoMode {
    Encrypt,
    Decrypt,
}

impl From<CryptoMode> for symm::Mode {
    fn from(m: CryptoMode) -> symm::Mode {
        match m {
            CryptoMode::Encrypt => symm::Mode::Encrypt,
            CryptoMode::Decrypt => symm::Mode::Decrypt,
        }
    }
}