private void HandleSpecificPacket(KexInit packet) { m_Logger.LogDebug("Received KexInit"); if (m_PendingExchangeContext == null) { m_Logger.LogDebug("Trigger re-exchange from client"); m_PendingExchangeContext = new ExchangeContext(); Send(m_KexInitServerToClient); } m_KexInitClientToServer = packet; m_PendingExchangeContext.KexAlgorithm = packet.PickKexAlgorithm(); m_PendingExchangeContext.HostKeyAlgorithm = packet.PickHostKeyAlgorithm(); m_PendingExchangeContext.CipherClientToServer = packet.PickCipherClientToServer(); m_PendingExchangeContext.CipherServerToClient = packet.PickCipherServerToClient(); m_PendingExchangeContext.MACAlgorithmClientToServer = packet.PickMACAlgorithmClientToServer(); m_PendingExchangeContext.MACAlgorithmServerToClient = packet.PickMACAlgorithmServerToClient(); m_PendingExchangeContext.CompressionClientToServer = packet.PickCompressionAlgorithmClientToServer(); m_PendingExchangeContext.CompressionServerToClient = packet.PickCompressionAlgorithmServerToClient(); m_Logger.LogDebug($"Selected KexAlgorithm: {m_PendingExchangeContext.KexAlgorithm.Name}"); m_Logger.LogDebug($"Selected HostKeyAlgorithm: {m_PendingExchangeContext.HostKeyAlgorithm.Name}"); m_Logger.LogDebug($"Selected CipherClientToServer: {m_PendingExchangeContext.CipherClientToServer.Name}"); m_Logger.LogDebug($"Selected CipherServerToClient: {m_PendingExchangeContext.CipherServerToClient.Name}"); m_Logger.LogDebug($"Selected MACAlgorithmClientToServer: {m_PendingExchangeContext.MACAlgorithmClientToServer.Name}"); m_Logger.LogDebug($"Selected MACAlgorithmServerToClient: {m_PendingExchangeContext.MACAlgorithmServerToClient.Name}"); m_Logger.LogDebug($"Selected CompressionClientToServer: {m_PendingExchangeContext.CompressionClientToServer.Name}"); m_Logger.LogDebug($"Selected CompressionServerToClient: {m_PendingExchangeContext.CompressionServerToClient.Name}"); }
private void HandleSpecificPacket(NewKeys packet) { m_Logger.LogDebug("Received NewKeys"); m_ActiveExchangeContext = m_PendingExchangeContext; m_PendingExchangeContext = null; // Reset re-exchange values m_TotalBytesTransferred = 0; m_KeyTimeout = DateTime.UtcNow.AddHours(1); }
private void ConsiderReExchange() { const long OneGB = (1024 * 1024 * 1024); if ((m_TotalBytesTransferred > OneGB) || (m_KeyTimeout < DateTime.UtcNow)) { // Time to get new keys! m_TotalBytesTransferred = 0; m_KeyTimeout = DateTime.UtcNow.AddHours(1); m_Logger.LogDebug("Trigger re-exchange from server"); m_PendingExchangeContext = new ExchangeContext(); Send(m_KexInitServerToClient); } }