Browse Source

Remove unnecessary call to InitKey.

tags/3.3
noisyfox Syrone Wong 9 years ago
parent
commit
4c5376ce0b
3 changed files with 3 additions and 7 deletions
  1. +3
    -5
      shadowsocks-csharp/Encryption/IVEncryptor.cs
  2. +0
    -1
      shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs
  3. +0
    -1
      shadowsocks-csharp/Encryption/SodiumEncryptor.cs

+ 3
- 5
shadowsocks-csharp/Encryption/IVEncryptor.cs View File

@@ -22,7 +22,7 @@ namespace Shadowsocks.Encryption
public const int CLEN_BYTES = 2; public const int CLEN_BYTES = 2;
public const int AUTH_BYTES = ONETIMEAUTH_BYTES + CLEN_BYTES; public const int AUTH_BYTES = ONETIMEAUTH_BYTES + CLEN_BYTES;
protected static byte[] tempbuf = new byte[MAX_INPUT_SIZE];
protected static readonly byte[] tempbuf = new byte[MAX_INPUT_SIZE];
protected Dictionary<string, Dictionary<string, int[]>> ciphers; protected Dictionary<string, Dictionary<string, int[]>> ciphers;
protected Dictionary<string, int[]> ciphersDetail; protected Dictionary<string, int[]> ciphersDetail;
@@ -51,7 +51,7 @@ namespace Shadowsocks.Encryption
protected abstract Dictionary<string, Dictionary<string, int[]>> getCiphers(); protected abstract Dictionary<string, Dictionary<string, int[]>> getCiphers();
protected void InitKey(string method, string password)
private void InitKey(string method, string password)
{ {
method = method.ToLower(); method = method.ToLower();
_method = method; _method = method;
@@ -71,13 +71,12 @@ namespace Shadowsocks.Encryption
{ {
byte[] passbuf = Encoding.UTF8.GetBytes(password); byte[] passbuf = Encoding.UTF8.GetBytes(password);
byte[] key = new byte[32]; byte[] key = new byte[32];
byte[] iv = new byte[16];
bytesToKey(passbuf, key); bytesToKey(passbuf, key);
return key; return key;
}); });
} }
protected void bytesToKey(byte[] password, byte[] key)
protected static void bytesToKey(byte[] password, byte[] key)
{ {
byte[] result = new byte[password.Length + 16]; byte[] result = new byte[password.Length + 16];
int i = 0; int i = 0;
@@ -239,7 +238,6 @@ namespace Shadowsocks.Encryption
{ {
randBytes(outbuf, ivLen); randBytes(outbuf, ivLen);
initCipher(outbuf, true); initCipher(outbuf, true);
outlength = length + ivLen;
reactBuffer(buf, ref length); reactBuffer(buf, ref length);
_encryptIVSent = true; _encryptIVSent = true;
lock (tempbuf) lock (tempbuf)


+ 0
- 1
shadowsocks-csharp/Encryption/MbedTLSEncryptor.cs View File

@@ -18,7 +18,6 @@ namespace Shadowsocks.Encryption
public MbedTLSEncryptor(string method, string password, bool onetimeauth, bool isudp) public MbedTLSEncryptor(string method, string password, bool onetimeauth, bool isudp)
: base(method, password, onetimeauth, isudp) : base(method, password, onetimeauth, isudp)
{ {
InitKey(method, password);
} }
private static Dictionary<string, Dictionary<string, int[]>> _ciphers = new Dictionary<string, Dictionary<string, int[]>> { private static Dictionary<string, Dictionary<string, int[]>> _ciphers = new Dictionary<string, Dictionary<string, int[]>> {


+ 0
- 1
shadowsocks-csharp/Encryption/SodiumEncryptor.cs View File

@@ -22,7 +22,6 @@ namespace Shadowsocks.Encryption
public SodiumEncryptor(string method, string password, bool onetimeauth, bool isudp) public SodiumEncryptor(string method, string password, bool onetimeauth, bool isudp)
: base(method, password, onetimeauth, isudp) : base(method, password, onetimeauth, isudp)
{ {
InitKey(method, password);
} }
private static Dictionary<string, Dictionary<string, int[]>> _ciphers = new Dictionary<string, Dictionary<string, int[]>> { private static Dictionary<string, Dictionary<string, int[]>> _ciphers = new Dictionary<string, Dictionary<string, int[]>> {


Loading…
Cancel
Save