Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support x64 #3193

Open
wants to merge 1 commit into
base: v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added shadowsocks-csharp/Data/libcrypto-3-x64.dll.gz
Binary file not shown.
Binary file added shadowsocks-csharp/Data/libsscrypto64.dll.gz
Binary file not shown.
21 changes: 20 additions & 1 deletion shadowsocks-csharp/Encryption/MbedTLS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,32 @@ public static class MbedTLS
{
private static Logger logger = LogManager.GetCurrentClassLogger();

#if AMD64
private const string DPDLLNAME = "libcrypto-3-x64.dll";
private const string DLLNAME = "libsscrypto64.dll";
#else
private const string DLLNAME = "libsscrypto.dll";
#endif

public const int MBEDTLS_ENCRYPT = 1;
public const int MBEDTLS_DECRYPT = 0;

static MbedTLS()
{
string dllPath = Utils.GetTempPath(DLLNAME);
#if AMD64
string dpDllPath = Utils.GetTempPath(DPDLLNAME);

#endif
try
{
#if AMD64
FileManager.UncompressFile(dpDllPath, Resources.libcrypto_3_x64_dll);
FileManager.UncompressFile(dllPath, Resources.libsscrypto64_dll);
#else
FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll);
#endif

}
catch (IOException)
{
Expand All @@ -31,13 +46,17 @@ static MbedTLS()
{
logger.LogUsefulException(e);
}
#if AMD64
LoadLibrary(dpDllPath);

#endif
LoadLibrary(dllPath);
}

public static byte[] MD5(byte[] input)
{
byte[] output = new byte[16];
if (md5_ret(input, (uint) input.Length, output) != 0)
if (md5_ret(input, (uint)input.Length, output) != 0)
throw new System.Exception("mbedtls: MD5 failure");
return output;
}
Expand Down
19 changes: 19 additions & 0 deletions shadowsocks-csharp/Encryption/OpenSSL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ public static class OpenSSL
{
private static Logger logger = LogManager.GetCurrentClassLogger();

#if AMD64
private const string DPDLLNAME = "libcrypto-3-x64.dll";
private const string DLLNAME = "libsscrypto64.dll";
#else
private const string DLLNAME = "libsscrypto.dll";
#endif

public const int OPENSSL_ENCRYPT = 1;
public const int OPENSSL_DECRYPT = 0;
Expand All @@ -28,9 +33,19 @@ public static class OpenSSL
static OpenSSL()
{
string dllPath = Utils.GetTempPath(DLLNAME);
#if AMD64
string dpDllPath = Utils.GetTempPath(DPDLLNAME);

#endif
try
{
#if AMD64
FileManager.UncompressFile(dpDllPath, Resources.libcrypto_3_x64_dll);
FileManager.UncompressFile(dllPath, Resources.libsscrypto64_dll);
#else
FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll);
#endif

}
catch (IOException)
{
Expand All @@ -39,6 +54,10 @@ static OpenSSL()
{
logger.LogUsefulException(e);
}
#if AMD64
LoadLibrary(dpDllPath);

#endif
LoadLibrary(dllPath);
}

Expand Down
19 changes: 19 additions & 0 deletions shadowsocks-csharp/Encryption/Sodium.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ public static class Sodium
{
private static Logger logger = LogManager.GetCurrentClassLogger();

#if AMD64
private const string DPDLLNAME = "libcrypto-3-x64.dll";
private const string DLLNAME = "libsscrypto64.dll";
#else
private const string DLLNAME = "libsscrypto.dll";
#endif

private static bool _initialized = false;
private static readonly object _initLock = new object();
Expand All @@ -22,9 +27,19 @@ public static class Sodium
static Sodium()
{
string dllPath = Utils.GetTempPath(DLLNAME);
#if AMD64
string dpDllPath = Utils.GetTempPath(DPDLLNAME);

#endif
try
{
#if AMD64
FileManager.UncompressFile(dpDllPath, Resources.libcrypto_3_x64_dll);
FileManager.UncompressFile(dllPath, Resources.libsscrypto64_dll);
#else
FileManager.UncompressFile(dllPath, Resources.libsscrypto_dll);
#endif

}
catch (IOException)
{
Expand All @@ -33,6 +48,10 @@ static Sodium()
{
logger.LogUsefulException(e);
}
#if AMD64
LoadLibrary(dpDllPath);

#endif
LoadLibrary(dllPath);

lock (_initLock)
Expand Down
84 changes: 52 additions & 32 deletions shadowsocks-csharp/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions shadowsocks-csharp/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
<data name="i18n_csv" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Data\i18n.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="libcrypto_3_x64_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Data\libcrypto-3-x64.dll.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="libsscrypto64_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Data\libsscrypto64.dll.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="libsscrypto_dll" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Data\libsscrypto.dll.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand Down
Loading