From d24548a04f4701dfe9f3e07d6305b5ba3b7a56f8 Mon Sep 17 00:00:00 2001 From: Gang Zhuo Date: Fri, 16 Oct 2015 04:36:31 -0400 Subject: [PATCH] rm rc4 and table --- shadowsocks-csharp/Encryption/EncryptorFactory.cs | 6 +- shadowsocks-csharp/Encryption/PolarSSLEncryptor.cs | 1 - shadowsocks-csharp/Encryption/TableEncryptor.cs | 106 --------------------- shadowsocks-csharp/View/ConfigForm.Designer.cs | 4 +- shadowsocks-csharp/shadowsocks-csharp.csproj | 1 - 5 files changed, 2 insertions(+), 116 deletions(-) delete mode 100644 shadowsocks-csharp/Encryption/TableEncryptor.cs diff --git a/shadowsocks-csharp/Encryption/EncryptorFactory.cs b/shadowsocks-csharp/Encryption/EncryptorFactory.cs index f0e2d284..b9cda1a7 100644 --- a/shadowsocks-csharp/Encryption/EncryptorFactory.cs +++ b/shadowsocks-csharp/Encryption/EncryptorFactory.cs @@ -13,10 +13,6 @@ namespace Shadowsocks.Encryption static EncryptorFactory() { _registeredEncryptors = new Dictionary(); - foreach (string method in TableEncryptor.SupportedCiphers()) - { - _registeredEncryptors.Add(method, typeof(TableEncryptor)); - } foreach (string method in PolarSSLEncryptor.SupportedCiphers()) { _registeredEncryptors.Add(method, typeof(PolarSSLEncryptor)); @@ -31,7 +27,7 @@ namespace Shadowsocks.Encryption { if (string.IsNullOrEmpty(method)) { - method = "table"; + method = "aes-256-cfb"; } method = method.ToLowerInvariant(); Type t = _registeredEncryptors[method]; diff --git a/shadowsocks-csharp/Encryption/PolarSSLEncryptor.cs b/shadowsocks-csharp/Encryption/PolarSSLEncryptor.cs index 3b3331f9..a40a12a1 100755 --- a/shadowsocks-csharp/Encryption/PolarSSLEncryptor.cs +++ b/shadowsocks-csharp/Encryption/PolarSSLEncryptor.cs @@ -26,7 +26,6 @@ namespace Shadowsocks.Encryption {"aes-128-cfb", new int[]{16, 16, CIPHER_AES, PolarSSL.AES_CTX_SIZE}}, {"aes-192-cfb", new int[]{24, 16, CIPHER_AES, PolarSSL.AES_CTX_SIZE}}, {"aes-256-cfb", new int[]{32, 16, CIPHER_AES, PolarSSL.AES_CTX_SIZE}}, - {"rc4", new int[]{16, 0, CIPHER_RC4, PolarSSL.ARC4_CTX_SIZE}}, {"rc4-md5", new int[]{16, 16, CIPHER_RC4, PolarSSL.ARC4_CTX_SIZE}}, }; diff --git a/shadowsocks-csharp/Encryption/TableEncryptor.cs b/shadowsocks-csharp/Encryption/TableEncryptor.cs deleted file mode 100644 index 4b6c8fe3..00000000 --- a/shadowsocks-csharp/Encryption/TableEncryptor.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Shadowsocks.Encryption -{ - public class TableEncryptor - : EncryptorBase - { - public TableEncryptor(string method, string password, bool onetimeauth, bool isudp) - : base(method, password, onetimeauth, isudp) - { - byte[] hash = GetPasswordHash(); - // TODO endian - ulong a = BitConverter.ToUInt64(hash, 0); - for (int i = 0; i < 256; i++) - { - _encryptTable[i] = (byte)i; - } - for (int i = 1; i < 1024; i++) - { - _encryptTable = MergeSort(_encryptTable, a, i); - } - for (int i = 0; i < 256; i++) - { - _decryptTable[_encryptTable[i]] = (byte)i; - } - } - - public static List SupportedCiphers() - { - return new List(new string[]{"table"}); - } - - public override void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength) - { - byte[] result = new byte[length]; - for (int i = 0; i < length; i++) - { - outbuf[i] = _encryptTable[buf[i]]; - } - outlength = length; - } - - public override void Decrypt(byte[] buf, int length, byte[] outbuf, out int outlength) - { - byte[] result = new byte[length]; - for (int i = 0; i < length; i++) - { - outbuf[i] = _decryptTable[buf[i]]; - } - outlength = length; - } - - private readonly byte[] _encryptTable = new byte[256]; - private readonly byte[] _decryptTable = new byte[256]; - - private static long Compare(byte x, byte y, ulong a, int i) - { - return (long)(a % (ulong)(x + i)) - (long)(a % (ulong)(y + i)); - } - - private byte[] MergeSort(byte[] array, ulong a, int j) - { - if (array.Length == 1) - { - return array; - } - int middle = array.Length / 2; - byte[] left = new byte[middle]; - for (int i = 0; i < middle; i++) - { - left[i] = array[i]; - } - byte[] right = new byte[array.Length - middle]; - for (int i = 0; i < array.Length - middle; i++) - { - right[i] = array[i + middle]; - } - left = MergeSort(left, a, j); - right = MergeSort(right, a, j); - - int leftptr = 0; - int rightptr = 0; - - byte[] sorted = new byte[array.Length]; - for (int k = 0; k < array.Length; k++) - { - if (rightptr == right.Length || ((leftptr < left.Length) && (Compare(left[leftptr], right[rightptr], a, j) <= 0))) - { - sorted[k] = left[leftptr]; - leftptr++; - } - else if (leftptr == left.Length || ((rightptr < right.Length) && (Compare(right[rightptr], left[leftptr], a, j)) <= 0)) - { - sorted[k] = right[rightptr]; - rightptr++; - } - } - return sorted; - } - - public override void Dispose() - { - } - } -} diff --git a/shadowsocks-csharp/View/ConfigForm.Designer.cs b/shadowsocks-csharp/View/ConfigForm.Designer.cs index 8c5334d0..306a92ec 100755 --- a/shadowsocks-csharp/View/ConfigForm.Designer.cs +++ b/shadowsocks-csharp/View/ConfigForm.Designer.cs @@ -198,14 +198,12 @@ this.EncryptionSelect.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.EncryptionSelect.ItemHeight = 12; this.EncryptionSelect.Items.AddRange(new object[] { - "table", "rc4-md5", "salsa20", "chacha20", "aes-256-cfb", "aes-192-cfb", - "aes-128-cfb", - "rc4"}); + "aes-128-cfb"}); this.EncryptionSelect.Location = new System.Drawing.Point(83, 87); this.EncryptionSelect.Name = "EncryptionSelect"; this.EncryptionSelect.Size = new System.Drawing.Size(160, 20); diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index 423268d8..bfe37140 100644 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -188,7 +188,6 @@ -