Exemple #1
0
        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}");
        }
Exemple #2
0
        private void HandleSpecificPacket(KexInit packet)
        {
            logger.LogDebug("Processing KexInit packet.");

            // TODO - handle re-exchange

            // Keep track of the client-to-server packet
            kexInitClientToServer = packet;

            // A little logging
            logger.LogDebug("   ...KEX algorithms: {0}", string.Join(",", packet.KexAlgorithms));
            logger.LogDebug("   ...host key algorithms: {0}", string.Join(",", packet.ServerHostKeyAlgorithms));
            logger.LogDebug("   ...ciphers ctos: {0}", string.Join(",", packet.EncryptionAlgorithmsClientToServer));
            logger.LogDebug("   ...ciphers stoc: {0}", string.Join(",", packet.EncryptionAlgorithmsServerToClient));
            logger.LogDebug("   ...MACs ctos: {0}", string.Join(",", packet.MacAlgorithmsClientToServer));
            logger.LogDebug("   ...MACs stoc: {0}", string.Join(",", packet.MacAlgorithmsServerToClient));
            logger.LogDebug("   ...compression ctos: {0}", string.Join(",", packet.CompressionAlgorithmsClientToServer));
            logger.LogDebug("   ...compression stoc: {0}", string.Join(",", packet.CompressionAlgorithmsServerToClient));

            // Pick algorithms
            pendingExchangeContext.KexAlgorithm               = KeyInfo.PickKexAlgorithm(packet.KexAlgorithms);
            pendingExchangeContext.HostKeyAlgorithm           = KeyInfo.PickHostKeyAlgorithm(packet.ServerHostKeyAlgorithms);
            pendingExchangeContext.CipherClientToServer       = KeyInfo.PickCipher(packet.EncryptionAlgorithmsClientToServer, "Client-To-Server");
            pendingExchangeContext.CipherServerToClient       = KeyInfo.PickCipher(packet.EncryptionAlgorithmsServerToClient, "Server-To-Client");
            pendingExchangeContext.MACAlgorithmClientToServer = KeyInfo.PickMACAlgorithm(packet.MacAlgorithmsClientToServer, "Client-To-Server");
            pendingExchangeContext.MACAlgorithmServerToClient = KeyInfo.PickMACAlgorithm(packet.MacAlgorithmsServerToClient, "Server-To-Client");
            pendingExchangeContext.CompressionClientToServer  = KeyInfo.PickCompression(packet.CompressionAlgorithmsClientToServer, "Client-To-Server");
            pendingExchangeContext.CompressionServerToClient  = KeyInfo.PickCompression(packet.CompressionAlgorithmsServerToClient, "Server-To-Client");
        }