From 5c535899dbe89c51d10d2d1d7cda62d8b92dce49 Mon Sep 17 00:00:00 2001 From: olegkap_cp Date: Thu, 30 Dec 2010 19:58:16 +0000 Subject: [PATCH] Change sequence of sending NEW_KEYS message, some servers would hang during key negotiation stage --- Renci.SshClient/Renci.SshClient/Security/KeyExchange.cs | 8 +------- .../Renci.SshClient/Security/KeyExchangeDiffieHellman.cs | 3 +++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Renci.SshClient/Renci.SshClient/Security/KeyExchange.cs b/Renci.SshClient/Renci.SshClient/Security/KeyExchange.cs index 186b7e38..dca31dab 100644 --- a/Renci.SshClient/Renci.SshClient/Security/KeyExchange.cs +++ b/Renci.SshClient/Renci.SshClient/Security/KeyExchange.cs @@ -177,13 +177,7 @@ namespace Renci.SshClient.Security public virtual void Finish() { // Validate hash - var validated = this.ValidateExchangeHash(); - - if (validated) - { - this.SendMessage(new NewKeysMessage()); - } - else + if (!this.ValidateExchangeHash()) { throw new SshConnectionException("Key exchange negotiation failed.", DisconnectReasons.KeyExchangeFailed); } diff --git a/Renci.SshClient/Renci.SshClient/Security/KeyExchangeDiffieHellman.cs b/Renci.SshClient/Renci.SshClient/Security/KeyExchangeDiffieHellman.cs index 3bd9df97..1d806d81 100644 --- a/Renci.SshClient/Renci.SshClient/Security/KeyExchangeDiffieHellman.cs +++ b/Renci.SshClient/Renci.SshClient/Security/KeyExchangeDiffieHellman.cs @@ -138,6 +138,9 @@ namespace Renci.SshClient.Security this._hostKey = hostKey; this.SharedKey = System.Numerics.BigInteger.ModPow(serverExchangeValue, this._randomValue, this._prime); this._signature = signature; + + // Whare DH reply received key exchange is completed + this.SendMessage(new NewKeysMessage()); } } }