public ConnectResponse(bool opened, string version, bool encrypted, EncryptionData encryptionData) { Opened = opened; Version = version; IsEncryted = encrypted; EncryptionData = encryptionData; }
void IClientConnector.SetEncrypton(EncryptionData encryptionData) { OnSetEncryption(encryptionData); }
protected virtual void OnSetEncryption(EncryptionData encryptionData) { }
public void SetEncrypton(EncryptionData encryptionData) { lock (channelLock) { var key = Encoding.Unicode.GetBytes(encryptionData.Key); var iv = Encoding.Unicode.GetBytes(encryptionData.IV); var readHash = SelectHashAlgorithm(encryptionData.HashAlgorithm, key, iv, FileAccess.Read); var writeHash = SelectHashAlgorithm(encryptionData.HashAlgorithm, key, iv, FileAccess.Write); InputStream = new CryptoStream(InputStream, readHash, CryptoStreamMode.Read); OutputStream = new CryptoStream(OutputStream, writeHash, CryptoStreamMode.Write); } }