mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 10:09:17 +08:00
rc4-md5 should be with rc4
This commit is contained in:
@@ -17,7 +17,6 @@ default = [
|
||||
"cipher-des-cfb",
|
||||
"cipher-rc2-cfb",
|
||||
"cipher-rc4",
|
||||
"cipher-rc4-md5",
|
||||
]
|
||||
|
||||
cipher-aes-cfb = []
|
||||
@@ -30,7 +29,6 @@ cipher-des-cfb = []
|
||||
cipher-idea-cfb = []
|
||||
cipher-rc2-cfb = []
|
||||
cipher-rc4 = []
|
||||
cipher-rc4-md5 = []
|
||||
cipher-seed-cfb = []
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -90,7 +90,7 @@ pub const CIPHER_IDEA_CFB: &'static str = "idea-cfb";
|
||||
pub const CIPHER_RC2_CFB: &'static str = "rc2-cfb";
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
pub const CIPHER_RC4: &'static str = "rc4";
|
||||
#[cfg(feature="cipher-rc4-md5")]
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
pub const CIPHER_RC4_MD5: &'static str = "rc4-md5";
|
||||
#[cfg(feature="cipher-seed-cfb")]
|
||||
pub const CIPHER_SEED_CFB: &'static str = "seed-cfb";
|
||||
@@ -133,7 +133,7 @@ pub enum CipherType {
|
||||
#[cfg(feature="cipher-idea-cfb")] IdeaCfb,
|
||||
#[cfg(feature="cipher-rc2-cfb")] Rc2Cfb,
|
||||
#[cfg(feature="cipher-rc4")] Rc4,
|
||||
#[cfg(feature="cipher-rc4-md5")] Rc4Md5,
|
||||
#[cfg(feature="cipher-rc4")] Rc4Md5,
|
||||
#[cfg(feature="cipher-seed-cfb")] SeedCfb,
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ pub fn with_name(method: &str, key: &[u8]) -> Option<CipherVariant> {
|
||||
CIPHER_RC2_CFB => Some(OpenSSLCrypto(openssl::OpenSSLCipher::new(Rc2Cfb, key))),
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
CIPHER_RC4 => Some(OpenSSLCrypto(openssl::OpenSSLCipher::new(Rc4, key))),
|
||||
#[cfg(feature="cipher-rc4-md5")]
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
CIPHER_RC4_MD5 => Some(OpenSSLCrypto(openssl::OpenSSLCipher::new(Rc4Md5, key))),
|
||||
#[cfg(feature="cipher-seed-cfb")]
|
||||
CIPHER_SEED_CFB => Some(OpenSSLCrypto(openssl::OpenSSLCipher::new(SeedCfb, key))),
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
//! Cipher defined with Rust binding for libcrypto (OpenSSL)
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
extern crate libc;
|
||||
extern crate log;
|
||||
extern crate test;
|
||||
@@ -123,7 +125,7 @@ extern {
|
||||
fn EVP_rc2_cfb64() -> EVP_CIPHER;
|
||||
#[cfg(feature="cipher-seed-cfb")]
|
||||
fn EVP_seed_cfb128() -> EVP_CIPHER;
|
||||
#[cfg(any(feature="cipher-rc4", feature="cipher-rc4-md5"))]
|
||||
#[cfg(any(feature="cipher-rc4"))]
|
||||
fn EVP_rc4() -> EVP_CIPHER;
|
||||
|
||||
// MD
|
||||
@@ -372,7 +374,7 @@ impl OpenSSLCrypto {
|
||||
cipher::SeedCfb => { (EVP_seed_cfb128(), 16, 16) },
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
cipher::Rc4 => { (EVP_rc4(), 16, 16) },
|
||||
#[cfg(feature="cipher-rc4-md5")]
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
cipher::Rc4Md5 => { (EVP_rc4(), 16, 16) },
|
||||
|
||||
cipher::Unknown => { (ptr::null(), 0, 0) },
|
||||
@@ -494,6 +496,7 @@ impl Cipher for OpenSSLCipher {
|
||||
);
|
||||
|
||||
match self.cipher_type {
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
cipher::Rc4Md5 => {
|
||||
let mut md5_digest = OpenSSLDigest::new(digest::Md5);
|
||||
md5_digest.update(key.as_slice());
|
||||
@@ -532,6 +535,7 @@ impl Cipher for OpenSSLCipher {
|
||||
let (real_iv, data) = data.split_at(expected_iv_len);
|
||||
|
||||
let key = match self.cipher_type {
|
||||
#[cfg(feature="cipher-rc4")]
|
||||
cipher::Rc4Md5 => {
|
||||
let mut md5_digest = OpenSSLDigest::new(digest::Md5);
|
||||
md5_digest.update(pad_key.as_slice());
|
||||
|
||||
Reference in New Issue
Block a user