Remove unnecessary call to InitKey.

This commit is contained in:
noisyfox
2016-09-03 08:57:31 +08:00
committed by Syrone Wong
parent 0266ad9d59
commit 4c5376ce0b
3 changed files with 3 additions and 7 deletions
+3 -5
View File
@@ -22,7 +22,7 @@ namespace Shadowsocks.Encryption
public const int CLEN_BYTES = 2;
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, int[]> ciphersDetail;
@@ -51,7 +51,7 @@ namespace Shadowsocks.Encryption
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;
@@ -71,13 +71,12 @@ namespace Shadowsocks.Encryption
{
byte[] passbuf = Encoding.UTF8.GetBytes(password);
byte[] key = new byte[32];
byte[] iv = new byte[16];
bytesToKey(passbuf, 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];
int i = 0;
@@ -239,7 +238,6 @@ namespace Shadowsocks.Encryption
{
randBytes(outbuf, ivLen);
initCipher(outbuf, true);
outlength = length + ivLen;
reactBuffer(buf, ref length);
_encryptIVSent = true;
lock (tempbuf)
@@ -18,7 +18,6 @@ namespace Shadowsocks.Encryption
public MbedTLSEncryptor(string method, string password, bool onetimeauth, bool isudp)
: base(method, password, onetimeauth, isudp)
{
InitKey(method, password);
}
private static Dictionary<string, Dictionary<string, int[]>> _ciphers = new Dictionary<string, Dictionary<string, int[]>> {
@@ -22,7 +22,6 @@ namespace Shadowsocks.Encryption
public SodiumEncryptor(string method, string password, bool onetimeauth, bool isudp)
: base(method, password, onetimeauth, isudp)
{
InitKey(method, password);
}
private static Dictionary<string, Dictionary<string, int[]>> _ciphers = new Dictionary<string, Dictionary<string, int[]>> {