Browse Source

Refactor key exchange and add new KeyExchangeDiffieHellmanGroupSha1 base class for easy extenstion to new new groups
Add new StatusCodes to SFTP for possible future support

olegkap_cp 13 years ago
parent
commit
086936aa6b

+ 4 - 1
Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj

@@ -618,6 +618,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -799,7 +802,7 @@
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
+      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 4 - 1
Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj

@@ -591,6 +591,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -768,7 +771,7 @@
       <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
         <SilverlightProjectProperties />
       </FlavorProperties>
-      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
+      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 4 - 1
Renci.SshClient/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj

@@ -597,6 +597,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -774,7 +777,7 @@
       <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
         <SilverlightProjectProperties />
       </FlavorProperties>
-      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
+      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 4 - 1
Renci.SshClient/Renci.SshNet.WindowsPhone/Renci.SshNet.WindowsPhone.csproj

@@ -589,6 +589,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -764,7 +767,7 @@
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
+      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 4 - 1
Renci.SshClient/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj

@@ -632,6 +632,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -807,7 +810,7 @@
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
+      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 1 - 0
Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj

@@ -131,6 +131,7 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="ConnectionInfo.cs" />
+    <Compile Include="Security\KeyExchangeDiffieHellmanGroupSha1.cs" />
     <Compile Include="SftpClient.NET.cs" />
     <Compile Include="KeyboardInteractiveAuthenticationMethod.cs">
       <SubType>Code</SubType>

+ 7 - 106
Renci.SshClient/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroup14Sha1.cs

@@ -12,7 +12,7 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents "diffie-hellman-group14-sha1" algorithm implementation.
     /// </summary>
-    internal class KeyExchangeDiffieHellmanGroup14Sha1 : KeyExchangeDiffieHellman
+    internal class KeyExchangeDiffieHellmanGroup14Sha1 : KeyExchangeDiffieHellmanGroupSha1
     {
         /// <summary>
         /// Gets algorithm name.
@@ -22,113 +22,14 @@ namespace Renci.SshNet.Security
             get { return "diffie-hellman-group14-sha1"; }
         }
 
-        /// <summary>
-        /// Calculates key exchange hash value.
-        /// </summary>
-        /// <returns>
-        /// Key exchange hash.
-        /// </returns>
-        protected override byte[] CalculateHash()
-        {
-            var hashData = new _ExchangeHashData
-            {
-                ClientVersion = this.Session.ClientVersion,
-                ServerVersion = this.Session.ServerVersion,
-                ClientPayload = this._clientPayload,
-                ServerPayload = this._serverPayload,
-                HostKey = this._hostKey,
-                ClientExchangeValue = this._clientExchangeValue,
-                ServerExchangeValue = this._serverExchangeValue,
-                SharedKey = this.SharedKey,
-            }.GetBytes();
-
-            return this.Hash(hashData);
-        }
-
-        /// <summary>
-        /// Starts key exchange algorithm
-        /// </summary>
-        /// <param name="session">The session.</param>
-        /// <param name="message">Key exchange init message.</param>
-        public override void Start(Session session, KeyExchangeInitMessage message)
-        {
-            base.Start(session, message);
-
-            this.Session.RegisterMessage("SSH_MSG_KEXDH_REPLY");
-
-            this.Session.MessageReceived += Session_MessageReceived;
-
-            BigInteger prime;
-            var secondOkleyGroup = "00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF";
-            BigInteger.TryParse(secondOkleyGroup, System.Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out prime);
-
-            this._prime = prime;
-
-            this._group = new BigInteger(new byte[] { 2 });
-
-            this.PopulateClientExchangeValue();
-
-            this.SendMessage(new KeyExchangeDhInitMessage(this._clientExchangeValue));
-        }
-
-        /// <summary>
-        /// Finishes key exchange algorithm.
-        /// </summary>
-        public override void Finish()
+        public override BigInteger GroupPrime
         {
-            base.Finish();
-
-            this.Session.MessageReceived -= Session_MessageReceived;
-        }
-
-        private void Session_MessageReceived(object sender, MessageEventArgs<Message> e)
-        {
-            var message = e.Message as KeyExchangeDhReplyMessage;
-            if (message != null)
-            {
-                //  Unregister message once received
-                this.Session.UnRegisterMessage("SSH_MSG_KEXDH_REPLY");
-
-                this.HandleServerDhReply(message.HostKey, message.F, message.Signature);
-
-                //  When SSH_MSG_KEXDH_REPLY received key exchange is completed
-                this.Finish();
-            }
-        }
-
-        private class _ExchangeHashData : SshData
-        {
-            public string ServerVersion { get; set; }
-
-            public string ClientVersion { get; set; }
-
-            public byte[] ClientPayload { get; set; }
-
-            public byte[] ServerPayload { get; set; }
-
-            public byte[] HostKey { get; set; }
-
-            public BigInteger ClientExchangeValue { get; set; }
-
-            public BigInteger ServerExchangeValue { get; set; }
-
-            public BigInteger SharedKey { get; set; }
-
-            protected override void LoadData()
-            {
-                throw new System.NotImplementedException();
-            }
-
-            protected override void SaveData()
+            get
             {
-                this.Write(this.ClientVersion);
-                this.Write(this.ServerVersion);
-                this.WriteBinaryString(this.ClientPayload);
-                this.WriteBinaryString(this.ServerPayload);
-                this.WriteBinaryString(this.HostKey);
-                this.Write(this.ClientExchangeValue);
-                this.Write(this.ServerExchangeValue);
-                this.Write(this.SharedKey);
+                BigInteger prime;
+                var secondOkleyGroup = "00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF";
+                BigInteger.TryParse(secondOkleyGroup, System.Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out prime);
+                return prime;
             }
         }
     }

+ 7 - 107
Renci.SshClient/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroup1Sha1.cs

@@ -12,7 +12,7 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents "diffie-hellman-group1-sha1" algorithm implementation.
     /// </summary>
-    public class KeyExchangeDiffieHellmanGroup1Sha1 : KeyExchangeDiffieHellman
+    public class KeyExchangeDiffieHellmanGroup1Sha1 : KeyExchangeDiffieHellmanGroupSha1
     {
         /// <summary>
         /// Gets algorithm name.
@@ -22,114 +22,14 @@ namespace Renci.SshNet.Security
             get { return "diffie-hellman-group1-sha1"; }
         }
 
-        /// <summary>
-        /// Calculates key exchange hash value.
-        /// </summary>
-        /// <returns>
-        /// Key exchange hash.
-        /// </returns>
-        protected override byte[] CalculateHash()
-        {
-            var hashData = new _ExchangeHashData
-            {
-                ClientVersion = this.Session.ClientVersion,
-                ServerVersion = this.Session.ServerVersion,
-                ClientPayload = this._clientPayload,
-                ServerPayload = this._serverPayload,
-                HostKey = this._hostKey,
-                ClientExchangeValue = this._clientExchangeValue,
-                ServerExchangeValue = this._serverExchangeValue,
-                SharedKey = this.SharedKey,
-            }.GetBytes();
-
-            return this.Hash(hashData);
-        }
-
-        /// <summary>
-        /// Starts key exchange algorithm
-        /// </summary>
-        /// <param name="session">The session.</param>
-        /// <param name="message">Key exchange init message.</param>
-        public override void Start(Session session, KeyExchangeInitMessage message)
-        {
-            base.Start(session, message);
-
-            this.Session.RegisterMessage("SSH_MSG_KEXDH_REPLY");
-
-            this.Session.MessageReceived += Session_MessageReceived;
-
-            BigInteger prime;
-            var secondOkleyGroup = @"00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF";
-            BigInteger.TryParse(secondOkleyGroup, System.Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out prime);
-
-            this._prime = prime;
-
-            this._group = new BigInteger(new byte[] { 2 });
-
-            this.PopulateClientExchangeValue();
-
-            this.SendMessage(new KeyExchangeDhInitMessage(this._clientExchangeValue));
-
-        }
-
-        /// <summary>
-        /// Finishes key exchange algorithm.
-        /// </summary>
-        public override void Finish()
+        public override BigInteger GroupPrime
         {
-            base.Finish();
-
-            this.Session.MessageReceived -= Session_MessageReceived;
-        }
-
-        private void Session_MessageReceived(object sender, MessageEventArgs<Message> e)
-        {
-            var message = e.Message as KeyExchangeDhReplyMessage;
-            if (message != null)
-            {
-                //  Unregister message once received
-                this.Session.UnRegisterMessage("SSH_MSG_KEXDH_REPLY");
-
-                this.HandleServerDhReply(message.HostKey, message.F, message.Signature);
-
-                //  When SSH_MSG_KEXDH_REPLY received key exchange is completed
-                this.Finish();
-            }
-        }
-
-        private class _ExchangeHashData : SshData
-        {
-            public string ServerVersion { get; set; }
-
-            public string ClientVersion { get; set; }
-
-            public byte[] ClientPayload { get; set; }
-
-            public byte[] ServerPayload { get; set; }
-
-            public byte[] HostKey { get; set; }
-
-            public BigInteger ClientExchangeValue { get; set; }
-
-            public BigInteger ServerExchangeValue { get; set; }
-
-            public BigInteger SharedKey { get; set; }
-
-            protected override void LoadData()
-            {
-                throw new System.NotImplementedException();
-            }
-
-            protected override void SaveData()
+            get
             {
-                this.Write(this.ClientVersion);
-                this.Write(this.ServerVersion);
-                this.WriteBinaryString(this.ClientPayload);
-                this.WriteBinaryString(this.ServerPayload);
-                this.WriteBinaryString(this.HostKey);
-                this.Write(this.ClientExchangeValue);
-                this.Write(this.ServerExchangeValue);
-                this.Write(this.SharedKey);
+                BigInteger prime;
+                var secondOkleyGroup = @"00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF";
+                BigInteger.TryParse(secondOkleyGroup, System.Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out prime);
+                return prime;
             }
         }
     }

+ 126 - 0
Renci.SshClient/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupSha1.cs

@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using Renci.SshNet.Common;
+using Renci.SshNet.Messages;
+using Renci.SshNet.Messages.Transport;
+using System.Globalization;
+
+namespace Renci.SshNet.Security
+{
+    /// <summary>
+    /// Represents "diffie-hellman-group1-sha1" algorithm implementation.
+    /// </summary>
+    public abstract class KeyExchangeDiffieHellmanGroupSha1 : KeyExchangeDiffieHellman
+    {
+        public abstract BigInteger GroupPrime { get; }
+
+        /// <summary>
+        /// Calculates key exchange hash value.
+        /// </summary>
+        /// <returns>
+        /// Key exchange hash.
+        /// </returns>
+        protected override byte[] CalculateHash()
+        {
+            var hashData = new _ExchangeHashData
+            {
+                ClientVersion = this.Session.ClientVersion,
+                ServerVersion = this.Session.ServerVersion,
+                ClientPayload = this._clientPayload,
+                ServerPayload = this._serverPayload,
+                HostKey = this._hostKey,
+                ClientExchangeValue = this._clientExchangeValue,
+                ServerExchangeValue = this._serverExchangeValue,
+                SharedKey = this.SharedKey,
+            }.GetBytes();
+
+            return this.Hash(hashData);
+        }
+
+        /// <summary>
+        /// Starts key exchange algorithm
+        /// </summary>
+        /// <param name="session">The session.</param>
+        /// <param name="message">Key exchange init message.</param>
+        public override void Start(Session session, KeyExchangeInitMessage message)
+        {
+            base.Start(session, message);
+
+            this.Session.RegisterMessage("SSH_MSG_KEXDH_REPLY");
+
+            this.Session.MessageReceived += Session_MessageReceived;
+
+            this._prime = this.GroupPrime;
+
+            this._group = new BigInteger(new byte[] { 2 });
+
+            this.PopulateClientExchangeValue();
+
+            this.SendMessage(new KeyExchangeDhInitMessage(this._clientExchangeValue));
+
+        }
+
+        /// <summary>
+        /// Finishes key exchange algorithm.
+        /// </summary>
+        public override void Finish()
+        {
+            base.Finish();
+
+            this.Session.MessageReceived -= Session_MessageReceived;
+        }
+
+        private void Session_MessageReceived(object sender, MessageEventArgs<Message> e)
+        {
+            var message = e.Message as KeyExchangeDhReplyMessage;
+            if (message != null)
+            {
+                //  Unregister message once received
+                this.Session.UnRegisterMessage("SSH_MSG_KEXDH_REPLY");
+
+                this.HandleServerDhReply(message.HostKey, message.F, message.Signature);
+
+                //  When SSH_MSG_KEXDH_REPLY received key exchange is completed
+                this.Finish();
+            }
+        }
+
+        private class _ExchangeHashData : SshData
+        {
+            public string ServerVersion { get; set; }
+
+            public string ClientVersion { get; set; }
+
+            public byte[] ClientPayload { get; set; }
+
+            public byte[] ServerPayload { get; set; }
+
+            public byte[] HostKey { get; set; }
+
+            public BigInteger ClientExchangeValue { get; set; }
+
+            public BigInteger ServerExchangeValue { get; set; }
+
+            public BigInteger SharedKey { get; set; }
+
+            protected override void LoadData()
+            {
+                throw new System.NotImplementedException();
+            }
+
+            protected override void SaveData()
+            {
+                this.Write(this.ClientVersion);
+                this.Write(this.ServerVersion);
+                this.WriteBinaryString(this.ClientPayload);
+                this.WriteBinaryString(this.ServerPayload);
+                this.WriteBinaryString(this.HostKey);
+                this.Write(this.ClientExchangeValue);
+                this.Write(this.ServerExchangeValue);
+                this.Write(this.SharedKey);
+            }
+        }
+    }
+}

+ 92 - 0
Renci.SshClient/Renci.SshNet/Sftp/StatusCodes.cs

@@ -39,5 +39,97 @@ namespace Renci.SshNet.Sftp
         /// SSH_FX_OP_UNSUPPORTED
         /// </summary>
         OperationUnsupported = 8,
+        /// <summary>
+        /// SSH_FX_INVALID_HANDLE
+        /// </summary>
+        InvalidHandle = 9,
+        /// <summary>
+        /// SSH_FX_NO_SUCH_PATH
+        /// </summary>
+        NoSuchPath = 10,
+        /// <summary>
+        /// SSH_FX_FILE_ALREADY_EXISTS
+        /// </summary>
+        FileAlreadyExists = 11,
+        /// <summary>
+        /// SSH_FX_WRITE_PROTECT
+        /// </summary>
+        WriteProtect = 12,
+        /// <summary>
+        /// SSH_FX_NO_MEDIA
+        /// </summary>
+        NoMedia = 13,
+        /// <summary>
+        /// SSH_FX_NO_SPACE_ON_FILESYSTEM
+        /// </summary>
+        NoSpaceOnFilesystem = 14,
+        /// <summary>
+        /// SSH_FX_QUOTA_EXCEEDED
+        /// </summary>
+        QuotaExceeded = 15,
+        /// <summary>
+        /// SSH_FX_UNKNOWN_PRINCIPAL
+        /// </summary>
+        UnknownPrincipal = 16,
+        /// <summary>
+        /// SSH_FX_LOCK_CONFLICT
+        /// </summary>
+        LockConflict = 17,
+        /// <summary>
+        /// SSH_FX_DIR_NOT_EMPTY
+        /// </summary>
+        DirNotEmpty = 18,
+        /// <summary>
+        /// SSH_FX_NOT_A_DIRECTORY
+        /// </summary>
+        NotDirectory = 19,
+        /// <summary>
+        /// SSH_FX_INVALID_FILENAME
+        /// </summary>
+        InvalidFilename = 20,
+        /// <summary>
+        /// SSH_FX_LINK_LOOP
+        /// </summary>
+        LinkLoop = 21,
+        /// <summary>
+        /// SSH_FX_CANNOT_DELETE
+        /// </summary>
+        CannotDelete = 22,
+        /// <summary>
+        /// SSH_FX_INVALID_PARAMETER
+        /// </summary>
+        InvalidParameter = 23,
+        /// <summary>
+        /// SSH_FX_FILE_IS_A_DIRECTORY
+        /// </summary>
+        FileIsADirectory = 24,
+        /// <summary>
+        /// SSH_FX_BYTE_RANGE_LOCK_CONFLICT
+        /// </summary>
+        ByteRangeLockConflict = 25,
+        /// <summary>
+        /// SSH_FX_BYTE_RANGE_LOCK_REFUSED
+        /// </summary>
+        ByteRangeLockRefused = 26,
+        /// <summary>
+        /// SSH_FX_DELETE_PENDING
+        /// </summary>
+        DeletePending = 27,
+        /// <summary>
+        /// SSH_FX_FILE_CORRUPT
+        /// </summary>
+        FileCorrupt = 28,
+        /// <summary>
+        /// SSH_FX_OWNER_INVALID
+        /// </summary>
+        OwnerInvalid = 29,
+        /// <summary>
+        /// SSH_FX_GROUP_INVALID
+        /// </summary>
+        GroupInvalid = 30,
+        /// <summary>
+        /// SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK
+        /// </summary>
+        NoMatchingByteRangeLock = 31,
     }
 }