internal void FreeEncryptor(MbedEncryptor e) { if (e != null) { if (e.IsCipher) { encryptorPool.Add(e); } else { decryptorPool.Add(e); } } }
internal MbedEncryptor GetDecryptor(Server s) { MbedEncryptor decryptor; if (!decryptorPool.TryTake(out decryptor)) { //Not found decryptor = new MbedEncryptor(s.Method, false); } else if (decryptor.Method != s.Method) { //found but method not match decryptor.SetMethod(s.Method); } //found and method match, set key only decryptor.SetKey(s.Password); return(decryptor); }
internal MbedEncryptor GetEncryptor(Server s) { MbedEncryptor encryptor; if (!encryptorPool.TryTake(out encryptor)) { //Not found encryptor = new MbedEncryptor(s.Method, true); } else if (encryptor.Method != s.Method) { //found but method not match encryptor.SetMethod(s.Method); } //found and method match, set key and iv encryptor.SetKV(s.Password); return(encryptor); }