mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 10:09:17 +08:00
Supports camellia-*-cfb
This commit is contained in:
@@ -32,11 +32,12 @@ path = "src/bin/ssdns.rs"
|
||||
lto = true
|
||||
|
||||
[features]
|
||||
default = ["sodium", "rc4", "aes-cfb", "aes-ctr"]
|
||||
default = ["sodium", "rc4", "aes-cfb", "aes-ctr", "camellia-cfb"]
|
||||
sodium = ["libsodium-ffi"]
|
||||
rc4 = ["openssl"]
|
||||
aes-cfb = ["openssl"]
|
||||
aes-ctr = ["openssl"]
|
||||
camellia-cfb = ["openssl"]
|
||||
single-threaded = []
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -10,6 +10,8 @@ use std::{
|
||||
use crate::crypto::digest::{self, Digest, DigestType};
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
#[cfg(feature = "openssl")]
|
||||
use openssl::nid::Nid;
|
||||
#[cfg(feature = "openssl")]
|
||||
use openssl::symm;
|
||||
use rand::{self, RngCore};
|
||||
use ring::aead::{AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305};
|
||||
@@ -107,6 +109,31 @@ const CIPHER_AES_192_CTR: &str = "aes-192-ctr";
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
const CIPHER_AES_256_CTR: &str = "aes-256-ctr";
|
||||
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_128_CFB: &str = "camellia-128-cfb";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_192_CFB: &str = "camellia-192-cfb";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_256_CFB: &str = "camellia-256-cfb";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_128_CFB_1: &str = "camellia-128-cfb1";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_192_CFB_1: &str = "camellia-192-cfb1";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_256_CFB_1: &str = "camellia-256-cfb1";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_128_CFB_8: &str = "camellia-128-cfb8";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_192_CFB_8: &str = "camellia-192-cfb8";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_256_CFB_8: &str = "camellia-256-cfb8";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_128_CFB_128: &str = "camellia-128-cfb128";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_192_CFB_128: &str = "camellia-192-cfb128";
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
const CIPHER_CAMELLIA_256_CFB_128: &str = "camellia-256-cfb128";
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
const CIPHER_RC4: &str = "rc4";
|
||||
#[cfg(feature = "rc4")]
|
||||
@@ -176,6 +203,31 @@ pub enum CipherType {
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
Aes256Ctr,
|
||||
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia128Cfb,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia192Cfb,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia256Cfb,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia128Cfb1,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia192Cfb1,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia256Cfb1,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia128Cfb8,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia192Cfb8,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia256Cfb8,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia128Cfb128,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia192Cfb128,
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
Camellia256Cfb128,
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
Rc4,
|
||||
#[cfg(feature = "rc4")]
|
||||
@@ -244,6 +296,55 @@ impl CipherType {
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes256Ctr => symm::Cipher::aes_256_ctr().key_len(),
|
||||
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB128)
|
||||
.expect("openssl doesn't support camellia-128-cfb")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb1 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB1)
|
||||
.expect("openssl doesn't support camellia-128-cfb1")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb8 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB8)
|
||||
.expect("openssl doesn't support camellia-128-cfb8")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB128)
|
||||
.expect("openssl doesn't support camellia-128-cfb128")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB128)
|
||||
.expect("openssl doesn't support camellia-192-cfb")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb1 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB1)
|
||||
.expect("openssl doesn't support camellia-192-cfb1")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb8 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB8)
|
||||
.expect("openssl doesn't support camellia-192-cfb8")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB128)
|
||||
.expect("openssl doesn't support camellia-192-cfb128")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB128)
|
||||
.expect("openssl doesn't support camellia-256-cfb")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb1 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB1)
|
||||
.expect("openssl doesn't support camellia-256-cfb1")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb8 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB8)
|
||||
.expect("openssl doesn't support camellia-256-cfb8")
|
||||
.key_len(),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB128)
|
||||
.expect("openssl doesn't support camellia-256-cfb128")
|
||||
.key_len(),
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
CipherType::Rc4 | CipherType::Rc4Md5 => symm::Cipher::rc4().key_len(),
|
||||
|
||||
@@ -350,6 +451,67 @@ impl CipherType {
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes256Ctr => symm::Cipher::aes_256_ctr().iv_len().expect("iv_len should not be None"),
|
||||
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB128)
|
||||
.expect("openssl doesn't support camellia-128-cfb")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb1 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB1)
|
||||
.expect("openssl doesn't support camellia-128-cfb1")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb8 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB8)
|
||||
.expect("openssl doesn't support camellia-128-cfb8")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB128)
|
||||
.expect("openssl doesn't support camellia-128-cfb128")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB128)
|
||||
.expect("openssl doesn't support camellia-192-cfb")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb1 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB1)
|
||||
.expect("openssl doesn't support camellia-192-cfb1")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb8 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB8)
|
||||
.expect("openssl doesn't support camellia-192-cfb8")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB128)
|
||||
.expect("openssl doesn't support camellia-192-cfb128")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB128)
|
||||
.expect("openssl doesn't support camellia-256-cfb")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb1 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB1)
|
||||
.expect("openssl doesn't support camellia-256-cfb1")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb8 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB8)
|
||||
.expect("openssl doesn't support camellia-256-cfb8")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB128)
|
||||
.expect("openssl doesn't support camellia-256-cfb128")
|
||||
.iv_len()
|
||||
.expect("iv_len should not be None"),
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
CipherType::Rc4 => symm::Cipher::rc4().iv_len().expect("iv_len should not be None"),
|
||||
#[cfg(feature = "rc4")]
|
||||
@@ -478,6 +640,31 @@ impl FromStr for CipherType {
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CIPHER_AES_256_CTR => Ok(CipherType::Aes256Ctr),
|
||||
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_128_CFB => Ok(CipherType::Camellia128Cfb),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_128_CFB_1 => Ok(CipherType::Camellia128Cfb1),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_128_CFB_8 => Ok(CipherType::Camellia128Cfb8),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_128_CFB_128 => Ok(CipherType::Camellia128Cfb128),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_192_CFB => Ok(CipherType::Camellia192Cfb),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_192_CFB_1 => Ok(CipherType::Camellia192Cfb1),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_192_CFB_8 => Ok(CipherType::Camellia192Cfb8),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_192_CFB_128 => Ok(CipherType::Camellia192Cfb128),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_256_CFB => Ok(CipherType::Camellia256Cfb),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_256_CFB_1 => Ok(CipherType::Camellia256Cfb1),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_256_CFB_8 => Ok(CipherType::Camellia256Cfb8),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CIPHER_CAMELLIA_256_CFB_128 => Ok(CipherType::Camellia256Cfb128),
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
CIPHER_RC4 => Ok(CipherType::Rc4),
|
||||
#[cfg(feature = "rc4")]
|
||||
@@ -548,6 +735,31 @@ impl Display for CipherType {
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes256Ctr => write!(f, "{}", CIPHER_AES_256_CTR),
|
||||
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb => write!(f, "{}", CIPHER_CAMELLIA_128_CFB),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb1 => write!(f, "{}", CIPHER_CAMELLIA_128_CFB_1),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb8 => write!(f, "{}", CIPHER_CAMELLIA_128_CFB_8),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb128 => write!(f, "{}", CIPHER_CAMELLIA_128_CFB_128),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb => write!(f, "{}", CIPHER_CAMELLIA_192_CFB),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb1 => write!(f, "{}", CIPHER_CAMELLIA_192_CFB_1),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb8 => write!(f, "{}", CIPHER_CAMELLIA_192_CFB_8),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb128 => write!(f, "{}", CIPHER_CAMELLIA_192_CFB_128),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb => write!(f, "{}", CIPHER_CAMELLIA_256_CFB),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb1 => write!(f, "{}", CIPHER_CAMELLIA_256_CFB_1),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb8 => write!(f, "{}", CIPHER_CAMELLIA_256_CFB_8),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb128 => write!(f, "{}", CIPHER_CAMELLIA_256_CFB_128),
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
CipherType::Rc4 => write!(f, "{}", CIPHER_RC4),
|
||||
#[cfg(feature = "rc4")]
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::crypto::{cipher, CipherResult, CipherType, StreamCipher};
|
||||
use crate::crypto::CryptoMode;
|
||||
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use openssl::nid::Nid;
|
||||
use openssl::symm;
|
||||
|
||||
/// Core cipher of OpenSSL
|
||||
@@ -18,37 +19,84 @@ pub struct OpenSSLCrypto {
|
||||
impl OpenSSLCrypto {
|
||||
/// Creates by type
|
||||
pub fn new(cipher_type: cipher::CipherType, key: &[u8], iv: &[u8], mode: CryptoMode) -> OpenSSLCrypto {
|
||||
let t = match cipher_type {
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes128Cfb => symm::Cipher::aes_128_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes128Cfb1 => symm::Cipher::aes_128_cfb1(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes128Cfb128 => symm::Cipher::aes_128_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes192Cfb => symm::Cipher::aes_192_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes192Cfb1 => symm::Cipher::aes_192_cfb1(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes192Cfb128 => symm::Cipher::aes_192_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes256Cfb => symm::Cipher::aes_256_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes256Cfb1 => symm::Cipher::aes_256_cfb1(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes256Cfb128 => symm::Cipher::aes_256_cfb128(),
|
||||
let t =
|
||||
match cipher_type {
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes128Cfb => symm::Cipher::aes_128_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes128Cfb1 => symm::Cipher::aes_128_cfb1(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes128Cfb128 => symm::Cipher::aes_128_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes192Cfb => symm::Cipher::aes_192_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes192Cfb1 => symm::Cipher::aes_192_cfb1(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes192Cfb128 => symm::Cipher::aes_192_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes256Cfb => symm::Cipher::aes_256_cfb128(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes256Cfb1 => symm::Cipher::aes_256_cfb1(),
|
||||
#[cfg(feature = "aes-cfb")]
|
||||
CipherType::Aes256Cfb128 => symm::Cipher::aes_256_cfb128(),
|
||||
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes128Ctr => symm::Cipher::aes_128_ctr(),
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes192Ctr => symm::Cipher::aes_192_ctr(),
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes256Ctr => symm::Cipher::aes_256_ctr(),
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes128Ctr => symm::Cipher::aes_128_ctr(),
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes192Ctr => symm::Cipher::aes_192_ctr(),
|
||||
#[cfg(feature = "aes-ctr")]
|
||||
CipherType::Aes256Ctr => symm::Cipher::aes_256_ctr(),
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
CipherType::Rc4 => symm::Cipher::rc4(),
|
||||
_ => panic!("Cipher type {:?} does not supported by OpenSSLCrypt yet", cipher_type),
|
||||
};
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB128).expect("openssl doesn't support camellia-128-cfb")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb1 => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB1).expect("openssl doesn't support camellia-128-cfb1")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb8 => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB8).expect("openssl doesn't support camellia-128-cfb8")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia128Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_128_CFB128)
|
||||
.expect("openssl doesn't support camellia-128-cfb128"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB128).expect("openssl doesn't support camellia-192-cfb")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb1 => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB1).expect("openssl doesn't support camellia-192-cfb1")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb8 => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB8).expect("openssl doesn't support camellia-192-cfb8")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia192Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_192_CFB128)
|
||||
.expect("openssl doesn't support camellia-192-cfb128"),
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB128).expect("openssl doesn't support camellia-256-cfb")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb1 => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB1).expect("openssl doesn't support camellia-256-cfb1")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb8 => {
|
||||
symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB8).expect("openssl doesn't support camellia-256-cfb8")
|
||||
}
|
||||
#[cfg(feature = "camellia-cfb")]
|
||||
CipherType::Camellia256Cfb128 => symm::Cipher::from_nid(Nid::CAMELLIA_256_CFB128)
|
||||
.expect("openssl doesn't support camellia-256-cfb128"),
|
||||
|
||||
#[cfg(feature = "rc4")]
|
||||
CipherType::Rc4 => symm::Cipher::rc4(),
|
||||
_ => panic!("Cipher type {:?} does not supported by OpenSSLCrypt yet", cipher_type),
|
||||
};
|
||||
|
||||
// Panic if error occurs
|
||||
let cipher = symm::Crypter::new(t, From::from(mode), key, Some(iv)).unwrap();
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
use crate::crypto::{
|
||||
digest::{self, Digest, DigestType},
|
||||
openssl::OpenSSLCrypto,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
CryptoMode,
|
||||
StreamCipher,
|
||||
CipherResult, CipherType, CryptoMode, StreamCipher,
|
||||
};
|
||||
|
||||
use bytes::{BufMut, BytesMut};
|
||||
|
||||
@@ -3,24 +3,13 @@
|
||||
use std::{mem, ptr};
|
||||
|
||||
use ring::aead::{
|
||||
open_in_place,
|
||||
seal_in_place,
|
||||
Aad,
|
||||
Nonce,
|
||||
OpeningKey,
|
||||
SealingKey,
|
||||
AES_128_GCM,
|
||||
AES_256_GCM,
|
||||
CHACHA20_POLY1305,
|
||||
open_in_place, seal_in_place, Aad, Nonce, OpeningKey, SealingKey, AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305,
|
||||
};
|
||||
|
||||
use crate::crypto::{
|
||||
aead::{increase_nonce, make_skey},
|
||||
cipher::Error,
|
||||
AeadDecryptor,
|
||||
AeadEncryptor,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
AeadDecryptor, AeadEncryptor, CipherResult, CipherType,
|
||||
};
|
||||
|
||||
use byte_string::ByteStr;
|
||||
|
||||
@@ -7,10 +7,7 @@ use miscreant::aead::{Aead, Aes128PmacSivAead, Aes256PmacSivAead};
|
||||
use crate::crypto::{
|
||||
aead::{increase_nonce, make_skey},
|
||||
cipher::Error,
|
||||
AeadDecryptor,
|
||||
AeadEncryptor,
|
||||
CipherResult,
|
||||
CipherType,
|
||||
AeadDecryptor, AeadEncryptor, CipherResult, CipherType,
|
||||
};
|
||||
|
||||
use byte_string::ByteStr;
|
||||
|
||||
@@ -4,9 +4,7 @@ use std::io::Cursor;
|
||||
|
||||
use crate::crypto::{
|
||||
digest::{self, Digest, DigestType},
|
||||
CipherResult,
|
||||
CryptoMode,
|
||||
StreamCipher,
|
||||
CipherResult, CryptoMode, StreamCipher,
|
||||
};
|
||||
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
|
||||
@@ -12,14 +12,7 @@ use tokio::net::TcpStream;
|
||||
use tokio_io::{io::flush, AsyncRead, AsyncWrite};
|
||||
|
||||
use crate::relay::socks5::{
|
||||
self,
|
||||
Address,
|
||||
Command,
|
||||
HandshakeRequest,
|
||||
HandshakeResponse,
|
||||
Reply,
|
||||
TcpRequestHeader,
|
||||
TcpResponseHeader,
|
||||
self, Address, Command, HandshakeRequest, HandshakeResponse, Reply, TcpRequestHeader, TcpResponseHeader,
|
||||
};
|
||||
|
||||
use crate::{config::ServerConfig, context::SharedContext};
|
||||
|
||||
@@ -11,9 +11,7 @@ use futures::{Async, Future, Poll};
|
||||
use tokio::timer::Delay;
|
||||
use tokio_io::{
|
||||
io::{copy, Copy},
|
||||
try_nb,
|
||||
AsyncRead,
|
||||
AsyncWrite,
|
||||
try_nb, AsyncRead, AsyncWrite,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
||||
@@ -9,9 +9,7 @@ use futures::{Async, Future, Poll};
|
||||
use tokio::timer::Delay;
|
||||
use tokio_io::{
|
||||
io::{copy, Copy},
|
||||
try_nb,
|
||||
AsyncRead,
|
||||
AsyncWrite,
|
||||
try_nb, AsyncRead, AsyncWrite,
|
||||
};
|
||||
|
||||
use super::BUFFER_SIZE;
|
||||
|
||||
@@ -14,9 +14,7 @@ use tokio::{self, net::UdpSocket};
|
||||
|
||||
use super::{
|
||||
crypto_io::{decrypt_payload, encrypt_payload},
|
||||
PacketStream,
|
||||
SendDgramRc,
|
||||
SharedUdpSocket,
|
||||
PacketStream, SendDgramRc, SharedUdpSocket,
|
||||
};
|
||||
use crate::{
|
||||
config::{ServerAddr, ServerConfig},
|
||||
|
||||
@@ -24,9 +24,7 @@ use crate::{
|
||||
|
||||
use super::{
|
||||
crypto_io::{decrypt_payload, encrypt_payload},
|
||||
PacketStream,
|
||||
SendDgramRc,
|
||||
MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
PacketStream, SendDgramRc, MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
};
|
||||
|
||||
/// Resolves server address to SocketAddr
|
||||
|
||||
@@ -38,8 +38,7 @@
|
||||
//! +-------+--------------+
|
||||
|
||||
use std::{
|
||||
io,
|
||||
mem,
|
||||
io, mem,
|
||||
net::SocketAddr,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
@@ -19,9 +19,7 @@ use crate::{
|
||||
|
||||
use super::{
|
||||
crypto_io::{decrypt_payload, encrypt_payload},
|
||||
PacketStream,
|
||||
SendDgramRc,
|
||||
MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
PacketStream, SendDgramRc, MAXIMUM_UDP_PAYLOAD_SIZE,
|
||||
};
|
||||
|
||||
fn resolve_remote_addr(
|
||||
|
||||
@@ -9,8 +9,7 @@ use dns_parser::{Builder, Packet, QueryClass, QueryType};
|
||||
use log::trace;
|
||||
use shadowsocks::{
|
||||
config::{Config, ConfigType},
|
||||
run_dns,
|
||||
run_server,
|
||||
run_dns, run_server,
|
||||
};
|
||||
use tokio::runtime::current_thread::Runtime;
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ use shadowsocks::{
|
||||
config::{Config, ConfigType, Mode, ServerConfig},
|
||||
crypto::CipherType,
|
||||
relay::{socks5::Address, tcprelay::client::Socks5Client},
|
||||
run_local,
|
||||
run_server,
|
||||
run_local, run_server,
|
||||
};
|
||||
|
||||
pub struct Socks5TestServer {
|
||||
|
||||
@@ -20,8 +20,7 @@ use shadowsocks::{
|
||||
socks5::{Address, UdpAssociateHeader},
|
||||
tcprelay::client::Socks5Client,
|
||||
},
|
||||
run_local,
|
||||
run_server,
|
||||
run_local, run_server,
|
||||
};
|
||||
|
||||
const SERVER_ADDR: &str = "127.0.0.1:8093";
|
||||
|
||||
Reference in New Issue
Block a user