@@ -10,7 +10,7 @@ namespace Shadowsocks.Encrypt | |||||
{ | { | ||||
public class PolarSSL | public class PolarSSL | ||||
{ | { | ||||
const string DLLNAME = "polarssl"; | |||||
const string DLLNAME = "libsscrypto"; | |||||
public const int AES_CTX_SIZE = 8 + 4 * 68; | public const int AES_CTX_SIZE = 8 + 4 * 68; | ||||
public const int AES_ENCRYPT = 1; | public const int AES_ENCRYPT = 1; | ||||
@@ -19,16 +19,19 @@ namespace Shadowsocks.Encrypt | |||||
static PolarSSL() | static PolarSSL() | ||||
{ | { | ||||
string tempPath = Path.GetTempPath(); | string tempPath = Path.GetTempPath(); | ||||
string dllPath = tempPath + "/polarssl.dll"; | |||||
string dllPath = tempPath + "/libsscrypto.dll"; | |||||
try | try | ||||
{ | { | ||||
FileManager.UncompressFile(dllPath, Resources.polarssl_dll); | |||||
FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll); | |||||
LoadLibrary(dllPath); | |||||
} | } | ||||
catch (IOException e) | |||||
catch (IOException) | |||||
{ | |||||
} | |||||
catch (Exception e) | |||||
{ | { | ||||
Console.WriteLine(e.ToString()); | Console.WriteLine(e.ToString()); | ||||
} | } | ||||
LoadLibrary(dllPath); | |||||
} | } | ||||
[DllImport("Kernel32.dll")] | [DllImport("Kernel32.dll")] | ||||
@@ -10,21 +10,24 @@ namespace Shadowsocks.Encrypt | |||||
{ | { | ||||
public class Sodium | public class Sodium | ||||
{ | { | ||||
const string DLLNAME = "libsodium"; | |||||
const string DLLNAME = "libsscrypto"; | |||||
static Sodium() | static Sodium() | ||||
{ | { | ||||
string tempPath = Path.GetTempPath(); | string tempPath = Path.GetTempPath(); | ||||
string dllPath = tempPath + "/libsodium.dll"; | |||||
string dllPath = tempPath + "/libsscrypto.dll"; | |||||
try | try | ||||
{ | { | ||||
FileManager.UncompressFile(dllPath, Resources.libsodium_dll); | |||||
FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll); | |||||
LoadLibrary(dllPath); | |||||
} | } | ||||
catch (IOException e) | |||||
catch (IOException) | |||||
{ | |||||
} | |||||
catch (Exception e) | |||||
{ | { | ||||
Console.WriteLine(e.ToString()); | Console.WriteLine(e.ToString()); | ||||
} | } | ||||
LoadLibrary(dllPath); | |||||
} | } | ||||
[DllImport("Kernel32.dll")] | [DllImport("Kernel32.dll")] | ||||
@@ -63,19 +63,9 @@ namespace Shadowsocks.Properties { | |||||
/// <summary> | /// <summary> | ||||
/// Looks up a localized resource of type System.Byte[]. | /// Looks up a localized resource of type System.Byte[]. | ||||
/// </summary> | /// </summary> | ||||
internal static byte[] libsodium_dll { | |||||
internal static byte[] libsscrypto_dll { | |||||
get { | get { | ||||
object obj = ResourceManager.GetObject("libsodium_dll", resourceCulture); | |||||
return ((byte[])(obj)); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// Looks up a localized resource of type System.Byte[]. | |||||
/// </summary> | |||||
internal static byte[] polarssl_dll { | |||||
get { | |||||
object obj = ResourceManager.GetObject("polarssl_dll", resourceCulture); | |||||
object obj = ResourceManager.GetObject("libsscrypto_dll", resourceCulture); | |||||
return ((byte[])(obj)); | return ((byte[])(obj)); | ||||
} | } | ||||
} | } | ||||
@@ -118,11 +118,8 @@ | |||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||||
</resheader> | </resheader> | ||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||||
<data name="libsodium_dll" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||||
<value>..\data\libsodium.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||||
</data> | |||||
<data name="polarssl_dll" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||||
<value>..\Data\polarssl.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||||
<data name="libsscrypto_dll" type="System.Resources.ResXFileRef, System.Windows.Forms"> | |||||
<value>..\data\libsscrypto.dll.gz;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||||
</data> | </data> | ||||
<data name="polipo_config" type="System.Resources.ResXFileRef, System.Windows.Forms"> | <data name="polipo_config" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||||
<value>..\Data\polipo_config.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value> | <value>..\Data\polipo_config.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312</value> | ||||
@@ -129,6 +129,7 @@ | |||||
<SubType>Designer</SubType> | <SubType>Designer</SubType> | ||||
</None> | </None> | ||||
<None Include="Data\libsodium.dll.gz" /> | <None Include="Data\libsodium.dll.gz" /> | ||||
<None Include="Data\libsscrypto.dll.gz" /> | |||||
<None Include="Data\polarssl.dll.gz" /> | <None Include="Data\polarssl.dll.gz" /> | ||||
<None Include="Data\polipo.exe.gz" /> | <None Include="Data\polipo.exe.gz" /> | ||||
<None Include="Properties\Settings.settings"> | <None Include="Properties\Settings.settings"> | ||||