Refine encryption(#655)
* Refine encryption - Add AES-CTR, blowfish and camellia ciphers aes-256-ctr aes-192-ctr aes-128-ctr bf-cfb camellia-128-cfb camellia-192-cfb camellia-256-cfb - Merge the previous PolarSSL and MbedTLS - Switch to MbedTLS's cipher layer functions - Add workaround to set cipher operation(encrypt/decrypt) Signed-off-by: Syrone Wong <wong.syrone@gmail.com> * Add function to get MbedTLS cipher context size and drop hard-coded ctx sizes Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
+8
-8
@@ -73,14 +73,14 @@ namespace test
|
||||
private static object locker = new object();
|
||||
|
||||
[TestMethod]
|
||||
public void TestPolarSSLEncryption()
|
||||
public void TestMbedTLSEncryption()
|
||||
{
|
||||
// run it once before the multi-threading test to initialize global tables
|
||||
RunSinglePolarSSLEncryptionThread();
|
||||
RunSingleMbedTLSEncryptionThread();
|
||||
List<Thread> threads = new List<Thread>();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Thread t = new Thread(new ThreadStart(RunSinglePolarSSLEncryptionThread));
|
||||
Thread t = new Thread(new ThreadStart(RunSingleMbedTLSEncryptionThread));
|
||||
threads.Add(t);
|
||||
t.Start();
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace test
|
||||
Assert.IsFalse(encryptionFailed);
|
||||
}
|
||||
|
||||
private void RunSinglePolarSSLEncryptionThread()
|
||||
private void RunSingleMbedTLSEncryptionThread()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -99,8 +99,8 @@ namespace test
|
||||
{
|
||||
IEncryptor encryptor;
|
||||
IEncryptor decryptor;
|
||||
encryptor = new PolarSSLEncryptor("aes-256-cfb", "barfoo!", false, false);
|
||||
decryptor = new PolarSSLEncryptor("aes-256-cfb", "barfoo!", false, false);
|
||||
encryptor = new MbedTLSEncryptor("aes-256-cfb", "barfoo!", false, false);
|
||||
decryptor = new MbedTLSEncryptor("aes-256-cfb", "barfoo!", false, false);
|
||||
RunEncryptionRound(encryptor, decryptor);
|
||||
}
|
||||
}
|
||||
@@ -139,8 +139,8 @@ namespace test
|
||||
var random = new Random();
|
||||
IEncryptor encryptor;
|
||||
IEncryptor decryptor;
|
||||
encryptor = new PolarSSLEncryptor("rc4-md5", "barfoo!", false, false);
|
||||
decryptor = new PolarSSLEncryptor("rc4-md5", "barfoo!", false, false);
|
||||
encryptor = new MbedTLSEncryptor("rc4-md5", "barfoo!", false, false);
|
||||
decryptor = new MbedTLSEncryptor("rc4-md5", "barfoo!", false, false);
|
||||
RunEncryptionRound(encryptor, decryptor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user