diff --git a/test/App.config b/test/App.config
new file mode 100644
index 00000000..620550c5
--- /dev/null
+++ b/test/App.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/CryptographyTest.cs b/test/CryptographyTest.cs
index 68c2e3a8..a5b78bbd 100644
--- a/test/CryptographyTest.cs
+++ b/test/CryptographyTest.cs
@@ -31,7 +31,7 @@ namespace Shadowsocks.Test
{
RNG.Reload();
byte[] plain = new byte[16384];
- byte[] cipher = new byte[plain.Length + 16];
+ byte[] cipher = new byte[plain.Length + 100];// AEAD with IPv4 address type needs +100
byte[] plain2 = new byte[plain.Length + 16];
int outLen = 0;
int outLen2 = 0;
@@ -229,5 +229,93 @@ namespace Shadowsocks.Test
throw;
}
}
+
+ [TestMethod]
+ public void TestOpenSSLAEADEncryption()
+ {
+ encryptionFailed = false;
+ // run it once before the multi-threading test to initialize global tables
+ RunSingleOpenSSLAEADEncryptionThread();
+ List threads = new List();
+ for (int i = 0; i < 10; i++)
+ {
+ Thread t = new Thread(new ThreadStart(RunSingleOpenSSLAEADEncryptionThread));
+ threads.Add(t);
+ t.Start();
+ }
+ foreach (Thread t in threads)
+ {
+ t.Join();
+ }
+ RNG.Close();
+ Assert.IsFalse(encryptionFailed);
+ }
+
+ private void RunSingleOpenSSLAEADEncryptionThread()
+ {
+ try
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ var random = new Random();
+ IEncryptor encryptor;
+ IEncryptor decryptor;
+ encryptor = new Encryption.AEAD.AEADOpenSSLEncryptor("aes-256-gcm", "barfoo!");
+ encryptor.AddrBufLength = 1 + 4 + 2;// ADDR_ATYP_LEN + 4 + ADDR_PORT_LEN;
+ decryptor = new Encryption.AEAD.AEADOpenSSLEncryptor("aes-256-gcm", "barfoo!");
+ decryptor.AddrBufLength = 1 + 4 + 2;// ADDR_ATYP_LEN + 4 + ADDR_PORT_LEN;
+ RunEncryptionRound(encryptor, decryptor);
+ }
+ }
+ catch
+ {
+ encryptionFailed = true;
+ throw;
+ }
+ }
+
+ [TestMethod]
+ public void TestMBedTLSAEADEncryption()
+ {
+ encryptionFailed = false;
+ // run it once before the multi-threading test to initialize global tables
+ RunSingleMBedTLSAEADEncryptionThread();
+ List threads = new List();
+ for (int i = 0; i < 10; i++)
+ {
+ Thread t = new Thread(new ThreadStart(RunSingleMBedTLSAEADEncryptionThread));
+ threads.Add(t);
+ t.Start();
+ }
+ foreach (Thread t in threads)
+ {
+ t.Join();
+ }
+ RNG.Close();
+ Assert.IsFalse(encryptionFailed);
+ }
+
+ private void RunSingleMBedTLSAEADEncryptionThread()
+ {
+ try
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ var random = new Random();
+ IEncryptor encryptor;
+ IEncryptor decryptor;
+ encryptor = new Encryption.AEAD.AEADMbedTLSEncryptor("aes-256-gcm", "barfoo!");
+ encryptor.AddrBufLength = 1 + 4 + 2;// ADDR_ATYP_LEN + 4 + ADDR_PORT_LEN;
+ decryptor = new Encryption.AEAD.AEADMbedTLSEncryptor("aes-256-gcm", "barfoo!");
+ decryptor.AddrBufLength = 1 + 4 + 2;// ADDR_ATYP_LEN + 4 + ADDR_PORT_LEN;
+ RunEncryptionRound(encryptor, decryptor);
+ }
+ }
+ catch
+ {
+ encryptionFailed = true;
+ throw;
+ }
+ }
}
}
diff --git a/test/ShadowsocksTest.csproj b/test/ShadowsocksTest.csproj
index c21ab66b..e6a8885f 100644
--- a/test/ShadowsocksTest.csproj
+++ b/test/ShadowsocksTest.csproj
@@ -69,6 +69,7 @@
+