static EncryptorFactory() { _registeredEncryptors = new Dictionary <string, Type>(); foreach (string method in MbedTLSEncryptor.SupportedCiphers()) { _registeredEncryptors.Add(method, typeof(MbedTLSEncryptor)); } foreach (string method in SodiumEncryptor.SupportedCiphers()) { _registeredEncryptors.Add(method, typeof(SodiumEncryptor)); } }
static EncryptorFactory() { _registeredEncryptors = new Dictionary <string, Type>(); _registeredEncryptorNames = new List <string>(); foreach (string method in NoneEncryptor.SupportedCiphers()) { if (!_registeredEncryptorNames.Contains(method)) { _registeredEncryptorNames.Add(method); _registeredEncryptors.Add(method, typeof(NoneEncryptor)); } } { foreach (string method in MbedTLSEncryptor.SupportedCiphers()) { if (!_registeredEncryptorNames.Contains(method)) { _registeredEncryptorNames.Add(method); _registeredEncryptors.Add(method, typeof(MbedTLSEncryptor)); } } } if (LibcryptoEncryptor.isSupport()) { LibcryptoEncryptor.InitAviable(); foreach (string method in LibcryptoEncryptor.SupportedCiphers()) { if (!_registeredEncryptorNames.Contains(method)) { _registeredEncryptorNames.Add(method); _registeredEncryptors.Add(method, typeof(LibcryptoEncryptor)); } } } foreach (string method in SodiumEncryptor.SupportedCiphers()) { if (!_registeredEncryptorNames.Contains(method)) { _registeredEncryptorNames.Add(method); _registeredEncryptors.Add(method, typeof(SodiumEncryptor)); } } }
private void RunSingleRC4EncryptionThread() { try { for (int i = 0; i < 100; i++) { var random = new Random(); IEncryptor encryptor; IEncryptor decryptor; encryptor = new MbedTLSEncryptor("rc4-md5", "barfoo!", false, false); decryptor = new MbedTLSEncryptor("rc4-md5", "barfoo!", false, false); RunEncryptionRound(encryptor, decryptor); } } catch { encryptionFailed = true; throw; } }
private void RunSingleMbedTLSEncryptionThread() { try { for (int i = 0; i < 100; i++) { IEncryptor encryptor; IEncryptor decryptor; encryptor = new MbedTLSEncryptor("aes-256-cfb", "barfoo!", false, false); decryptor = new MbedTLSEncryptor("aes-256-cfb", "barfoo!", false, false); RunEncryptionRound(encryptor, decryptor); } } catch { encryptionFailed = true; throw; } }