فهرست منبع

Refactor and reorganize cipher code
Fix TripleDES cipher
Fix and add missing comments
Mark assembly as not CLR

olegkap_cp 14 سال پیش
والد
کامیت
7d8c9cf61e
41فایلهای تغییر یافته به همراه1170 افزوده شده و 2052 حذف شده
  1. 11 37
      Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj
  2. 3 3
      Renci.SshClient/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj
  3. 0 158
      Renci.SshClient/Renci.SshNet.Tests/Security/Cryptography/TestAes.cs
  4. 0 59
      Renci.SshClient/Renci.SshNet.Tests/Security/Cryptography/TestBlowfish.cs
  5. 0 35
      Renci.SshClient/Renci.SshNet.Tests/Security/Cryptography/TestCast.cs
  6. 73 13
      Renci.SshClient/Renci.SshNet.Tests/Security/TestCipher.cs
  7. 2 2
      Renci.SshClient/Renci.SshNet.Tests/SshClientTests/TestSshCommand.cs
  8. 5 2
      Renci.SshClient/Renci.SshNet/Common/ASCIIEncoding.cs
  9. 565 0
      Renci.SshClient/Renci.SshNet/Common/BigInteger.cs
  10. 1 1
      Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs
  11. 3 0
      Renci.SshClient/Renci.SshNet/Common/SemaphoreLight.cs
  12. 8 8
      Renci.SshClient/Renci.SshNet/ConnectionInfo.cs
  13. 1 1
      Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs
  14. 9 21
      Renci.SshClient/Renci.SshNet/PrivateKeyFile.cs
  15. 1 1
      Renci.SshClient/Renci.SshNet/Properties/AssemblyInfo.cs
  16. 5 29
      Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj
  17. 58 29
      Renci.SshClient/Renci.SshNet/Security/Cipher.cs
  18. 24 102
      Renci.SshClient/Renci.SshNet/Security/CipherAESCBC.cs
  19. 24 102
      Renci.SshClient/Renci.SshNet/Security/CipherAESCTR.cs
  20. 18 94
      Renci.SshClient/Renci.SshNet/Security/CipherBlowFish.cs
  21. 0 148
      Renci.SshClient/Renci.SshNet/Security/CipherCast.cs
  22. 94 0
      Renci.SshClient/Renci.SshNet/Security/CipherCastCbc.cs
  23. 0 146
      Renci.SshClient/Renci.SshNet/Security/CipherDES.cs
  24. 95 0
      Renci.SshClient/Renci.SshNet/Security/CipherDesCbc.cs
  25. 13 90
      Renci.SshClient/Renci.SshNet/Security/CipherSerpent.cs
  26. 0 145
      Renci.SshClient/Renci.SshNet/Security/CipherTripleDES.cs
  27. 94 0
      Renci.SshClient/Renci.SshNet/Security/CipherTripleDesCbc.cs
  28. 1 1
      Renci.SshClient/Renci.SshNet/Security/CryptoPublicKeyDss.cs
  29. 1 1
      Renci.SshClient/Renci.SshNet/Security/CryptoPublicKeyRsa.cs
  30. 0 119
      Renci.SshClient/Renci.SshNet/Security/Cryptography/Aes.cs
  31. 0 97
      Renci.SshClient/Renci.SshNet/Security/Cryptography/Blowfish.cs
  32. 0 90
      Renci.SshClient/Renci.SshNet/Security/Cryptography/Cast.cs
  33. 0 128
      Renci.SshClient/Renci.SshNet/Security/Cryptography/CipherTransform.cs
  34. 41 12
      Renci.SshClient/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs
  35. 0 90
      Renci.SshClient/Renci.SshNet/Security/Cryptography/Des.cs
  36. 0 122
      Renci.SshClient/Renci.SshNet/Security/Cryptography/Serpent.cs
  37. 0 22
      Renci.SshClient/Renci.SshNet/Security/Cryptography/TransformMode.cs
  38. 0 100
      Renci.SshClient/Renci.SshNet/Security/Cryptography/TripleDes.cs
  39. 0 24
      Renci.SshClient/Renci.SshNet/Session.cs
  40. 14 14
      Renci.SshClient/Renci.SshNet/SftpClient.cs
  41. 6 6
      Renci.SshClient/Renci.SshNet/SshClient.cs

+ 11 - 37
Renci.SshClient/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj

@@ -50,6 +50,7 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="mscorlib" />
     <Reference Include="System.Windows" />
     <Reference Include="system" />
@@ -395,35 +396,26 @@
     <Compile Include="..\Renci.SshNet\Security\Cipher.cs">
       <Link>Security\Cipher.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\CipherAESCBC.cs">
-      <Link>Security\CipherAESCBC.cs</Link>
+    <Compile Include="..\Renci.SshNet\Security\CipherAesCbc.cs">
+      <Link>Security\CipherAesCbc.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\CipherAESCTR.cs">
-      <Link>Security\CipherAESCTR.cs</Link>
+    <Compile Include="..\Renci.SshNet\Security\CipherAesCtr.cs">
+      <Link>Security\CipherAesCtr.cs</Link>
     </Compile>
     <Compile Include="..\Renci.SshNet\Security\CipherBlowfish.cs">
       <Link>Security\CipherBlowfish.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\CipherCast.cs">
-      <Link>Security\CipherCast.cs</Link>
+    <Compile Include="..\Renci.SshNet\Security\CipherCastCbc.cs">
+      <Link>Security\CipherCastCbc.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\CipherDES.cs">
-      <Link>Security\CipherDES.cs</Link>
+    <Compile Include="..\Renci.SshNet\Security\CipherDesCbc.cs">
+      <Link>Security\CipherDesCbc.cs</Link>
     </Compile>
     <Compile Include="..\Renci.SshNet\Security\CipherSerpent.cs">
       <Link>Security\CipherSerpent.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\CipherTripleDES.cs">
-      <Link>Security\CipherTripleDES.cs</Link>
-    </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\Aes.cs">
-      <Link>Security\Cryptography\Aes.cs</Link>
-    </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\Blowfish.cs">
-      <Link>Security\Cryptography\Blowfish.cs</Link>
-    </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\Cast.cs">
-      <Link>Security\Cryptography\Cast.cs</Link>
+    <Compile Include="..\Renci.SshNet\Security\CipherTripleDesCbc.cs">
+      <Link>Security\CipherTripleDesCbc.cs</Link>
     </Compile>
     <Compile Include="..\Renci.SshNet\Security\Cryptography\Ciphers\AesCipher.cs">
       <Link>Security\Cryptography\Ciphers\AesCipher.cs</Link>
@@ -449,12 +441,6 @@
     <Compile Include="..\Renci.SshNet\Security\Cryptography\Ciphers\TwofishCipher.cs">
       <Link>Security\Cryptography\Ciphers\TwofishCipher.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\CipherTransform.cs">
-      <Link>Security\Cryptography\CipherTransform.cs</Link>
-    </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\Des.cs">
-      <Link>Security\Cryptography\Des.cs</Link>
-    </Compile>
     <Compile Include="..\Renci.SshNet\Security\Cryptography\Modes\CbcMode.cs">
       <Link>Security\Cryptography\Modes\CbcMode.cs</Link>
     </Compile>
@@ -473,15 +459,6 @@
     <Compile Include="..\Renci.SshNet\Security\Cryptography\Modes\OfbMode.cs">
       <Link>Security\Cryptography\Modes\OfbMode.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\Serpent.cs">
-      <Link>Security\Cryptography\Serpent.cs</Link>
-    </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\TransformMode.cs">
-      <Link>Security\Cryptography\TransformMode.cs</Link>
-    </Compile>
-    <Compile Include="..\Renci.SshNet\Security\Cryptography\TripleDes.cs">
-      <Link>Security\Cryptography\TripleDes.cs</Link>
-    </Compile>
     <Compile Include="..\Renci.SshNet\Security\CryptoKey.cs">
       <Link>Security\CryptoKey.cs</Link>
     </Compile>
@@ -506,9 +483,6 @@
     <Compile Include="..\Renci.SshNet\Security\HMac.cs">
       <Link>Security\HMac.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\HMacMD5.cs">
-      <Link>Security\HMacMD5.cs</Link>
-    </Compile>
     <Compile Include="..\Renci.SshNet\Security\HMacSha1.cs">
       <Link>Security\HMacSha1.cs</Link>
     </Compile>

+ 3 - 3
Renci.SshClient/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj

@@ -54,9 +54,6 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ConnectionTest.cs" />
-    <Compile Include="Security\Cryptography\TestAes.cs" />
-    <Compile Include="Security\Cryptography\TestBlowfish.cs" />
-    <Compile Include="Security\Cryptography\TestCast.cs" />
     <Compile Include="Security\TestCipher.cs" />
     <Compile Include="Security\TestCryptoKey.cs" />
     <Compile Include="Security\TestHMac.cs" />
@@ -93,6 +90,9 @@
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Security\Cryptography\" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 0 - 158
Renci.SshClient/Renci.SshNet.Tests/Security/Cryptography/TestAes.cs

@@ -1,158 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Renci.SshNet.Tests.Security.Cryptography
-{
-    [TestClass]
-    public class TestAes
-    {
-        [TestMethod]
-        public void Test_AES_128_CBC_NoPadding()
-        {
-            var key = new byte[] { 0xfa, 0x49, 0x9d, 0xa5, 0x59, 0xc3, 0xcc, 0xa9, 0xc3, 0x0b, 0xcd, 0xba, 0x03, 0xbc, 0x97, 0xfc };
-            var iv = new byte[] { 0x3a, 0x3f, 0x51, 0xb1, 0xba, 0xc7, 0x60, 0x70, 0x52, 0xb4, 0x8d, 0x21, 0xac, 0x81, 0x27, 0xbb };
-            var input = new byte[] { 0xcc, 0xa8, 0x81, 0xf2, 0x94, 0xef, 0xcc, 0xfc, 0xc3, 0x49, 0x3c, 0xe5, 0xa3, 0x33, 0x35, 0x34, 0xd7, 0x9a, 0x60, 0xd8, 0x67, 0x5d, 0x51, 0x32, 0xe9, 0x2d, 0x53, 0xa5, 0x35, 0xaa, 0xfc, 0x42, 0xe3, 0x11, 0xed, 0x5b, 0x3a, 0xa4, 0x68, 0x4a, 0x73, 0x55, 0xed, 0x70, 0x8b, 0x7a, 0xcc, 0x1f, 0x7e, 0x58, 0x4a, 0x12, 0x20, 0x4f, 0x53, 0x6f, 0x56, 0x4f, 0x08, 0x66, 0x9b, 0x26, 0xc6, 0x18, 0x4d, 0xfa, 0x01, 0x92, 0x45, 0xda, 0xfa, 0x32, 0x32, 0x16, 0x65, 0x12, 0x70, 0xe0, 0xa6, 0x6f };
-            var correctEncoding = new byte[] { 0x3d, 0x7f, 0x38, 0x4e, 0x05, 0x72, 0xfa, 0x81, 0x64, 0x29, 0xa5, 0xa2, 0x72, 0x6f, 0x93, 0x9d, 0x7d, 0xd6, 0x12, 0x3d, 0xb9, 0xad, 0x7c, 0x61, 0xb1, 0xf3, 0xd0, 0xdb, 0xdb, 0xc0, 0x65, 0xe4, 0x58, 0x75, 0x70, 0x27, 0xdd, 0x65, 0x33, 0xe9, 0xf6, 0x1e, 0x4e, 0xb9, 0x15, 0x3c, 0x16, 0x7d, 0x3d, 0x6c, 0xde, 0x17, 0x0e, 0x85, 0xbc, 0x9c, 0x68, 0xec, 0xad, 0xc7, 0x45, 0x29, 0xf1, 0xf9, 0x22, 0x70, 0xd9, 0xe0, 0x62, 0x9f, 0x32, 0xf1, 0x71, 0xd6, 0x3e, 0x39, 0xa6, 0xdd, 0xf7, 0xca };
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Aes(128);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;
-            cipher.Padding = System.Security.Cryptography.PaddingMode.None;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-        [TestMethod]
-        public void Test_AES_192_CBC_NoPadding()
-        {
-            var key = new byte[] { 0xd8, 0xab, 0x36, 0x37, 0x10, 0x20, 0xec, 0x98, 0x90, 0x56, 0xc1, 0x9e, 0xbe, 0x6c, 0x32, 0xc5, 0x77, 0x73, 0x74, 0xee, 0xb5, 0x43, 0xd4, 0x18 };
-            var iv = new byte[] { 0x3a, 0x3f, 0x51, 0xb1, 0xba, 0xc7, 0x60, 0x70, 0x52, 0xb4, 0x8d, 0x21, 0xac, 0x81, 0x27, 0xbb };
-            var input = new byte[] { 0xcc, 0xa8, 0x81, 0xf2, 0x94, 0xef, 0xcc, 0xfc, 0xc3, 0x49, 0x3c, 0xe5, 0xa3, 0x33, 0x35, 0x34, 0xd7, 0x9a, 0x60, 0xd8, 0x67, 0x5d, 0x51, 0x32, 0xe9, 0x2d, 0x53, 0xa5, 0x35, 0xaa, 0xfc, 0x42, 0xe3, 0x11, 0xed, 0x5b, 0x3a, 0xa4, 0x68, 0x4a, 0x73, 0x55, 0xed, 0x70, 0x8b, 0x7a, 0xcc, 0x1f, 0x7e, 0x58, 0x4a, 0x12, 0x20, 0x4f, 0x53, 0x6f, 0x56, 0x4f, 0x08, 0x66, 0x9b, 0x26, 0xc6, 0x18, 0x4d, 0xfa, 0x01, 0x92, 0x45, 0xda, 0xfa, 0x32, 0x32, 0x16, 0x65, 0x12, 0x70, 0xe0, 0xa6, 0x6f };
-            var correctEncoding = new byte[] { 0xa6, 0x71, 0x7e, 0xd8, 0x88, 0xb6, 0xcb, 0x2e, 0x66, 0x6c, 0xed, 0x73, 0x28, 0x19, 0xa8, 0xec, 0x24, 0x66, 0xbe, 0x61, 0xa8, 0x05, 0x6a, 0x9b, 0xe5, 0x52, 0x12, 0xd8, 0x9f, 0xe0, 0x24, 0xbc, 0x91, 0x30, 0xaa, 0x1e, 0x35, 0x00, 0x5f, 0x1a, 0xbf, 0x8c, 0x33, 0xff, 0xc0, 0x3d, 0x93, 0x9f, 0x9b, 0xb6, 0x87, 0x63, 0x55, 0x34, 0xc1, 0xdf, 0xa8, 0x75, 0x9f, 0x41, 0x01, 0xc5, 0xda, 0xae, 0x1f, 0xda, 0x3d, 0x59, 0x78, 0x50, 0xee, 0xc5, 0x64, 0xcb, 0xde, 0x5c, 0xca, 0x67, 0xe1, 0x41 };
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Aes(192);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;
-            cipher.Padding = System.Security.Cryptography.PaddingMode.None;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-        [TestMethod]
-        public void Test_AES_256_CBC_NoPadding()
-        {
-            var key = new byte[] { 0x81, 0xb3, 0xd3, 0x28, 0x20, 0x0b, 0x27, 0x47, 0xdc, 0x46, 0x6e, 0xee, 0xbb, 0x48, 0xac, 0xc7, 0xee, 0x2e, 0x45, 0xec, 0xb8, 0xd6, 0x7e, 0xfb, 0x03, 0xc9, 0x9b, 0x74, 0x7b, 0x17, 0xf7, 0x0a };
-            var iv = new byte[] { 0x3a, 0x3f, 0x51, 0xb1, 0xba, 0xc7, 0x60, 0x70, 0x52, 0xb4, 0x8d, 0x21, 0xac, 0x81, 0x27, 0xbb };
-            var input = new byte[] { 0xcc, 0xa8, 0x81, 0xf2, 0x94, 0xef, 0xcc, 0xfc, 0xc3, 0x49, 0x3c, 0xe5, 0xa3, 0x33, 0x35, 0x34, 0xd7, 0x9a, 0x60, 0xd8, 0x67, 0x5d, 0x51, 0x32, 0xe9, 0x2d, 0x53, 0xa5, 0x35, 0xaa, 0xfc, 0x42, 0xe3, 0x11, 0xed, 0x5b, 0x3a, 0xa4, 0x68, 0x4a, 0x73, 0x55, 0xed, 0x70, 0x8b, 0x7a, 0xcc, 0x1f, 0x7e, 0x58, 0x4a, 0x12, 0x20, 0x4f, 0x53, 0x6f, 0x56, 0x4f, 0x08, 0x66, 0x9b, 0x26, 0xc6, 0x18, 0x4d, 0xfa, 0x01, 0x92, 0x45, 0xda, 0xfa, 0x32, 0x32, 0x16, 0x65, 0x12, 0x70, 0xe0, 0xa6, 0x6f };
-            var correctEncoding = new byte[] { 0xf8, 0x32, 0x01, 0x59, 0xe1, 0x38, 0xc3, 0x9e, 0x73, 0x13, 0x09, 0x0f, 0x01, 0x14, 0x1e, 0xfd, 0x70, 0x77, 0x96, 0xcb, 0xcc, 0x9d, 0x8e, 0x5c, 0xda, 0x10, 0x3c, 0x7d, 0x8f, 0x31, 0x01, 0x92, 0x50, 0x17, 0x11, 0x22, 0x46, 0xff, 0xf3, 0xef, 0x2d, 0xbd, 0xbf, 0xb1, 0xe0, 0x15, 0xcc, 0xf1, 0xf4, 0x59, 0x00, 0x82, 0x0e, 0x4b, 0xcc, 0x0a, 0xcc, 0x67, 0xd8, 0xec, 0x8c, 0xe6, 0x40, 0x86, 0xc6, 0x8b, 0xbb, 0xea, 0x2f, 0x98, 0x79, 0x28, 0x91, 0x6e, 0x87, 0x84, 0xdc, 0x3f, 0xa7, 0xf6};
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Aes(256);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;
-            cipher.Padding = System.Security.Cryptography.PaddingMode.None;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-        [TestMethod]
-        public void Test_AES_128_CFB_NoPadding()
-        {
-            var key = new byte[] { 0xfa, 0x49, 0x9d, 0xa5, 0x59, 0xc3, 0xcc, 0xa9, 0xc3, 0x0b, 0xcd, 0xba, 0x03, 0xbc, 0x97, 0xfc };
-            var iv = new byte[] { 0x3a, 0x3f, 0x51, 0xb1, 0xba, 0xc7, 0x60, 0x70, 0x52, 0xb4, 0x8d, 0x21, 0xac, 0x81, 0x27, 0xbb };
-            var input = new byte[] { 0xcc, 0xa8, 0x81, 0xf2, 0x94, 0xef, 0xcc, 0xfc, 0xc3, 0x49, 0x3c, 0xe5, 0xa3, 0x33, 0x35, 0x34, 0xd7, 0x9a, 0x60, 0xd8, 0x67, 0x5d, 0x51, 0x32, 0xe9, 0x2d, 0x53, 0xa5, 0x35, 0xaa, 0xfc, 0x42, 0xe3, 0x11, 0xed, 0x5b, 0x3a, 0xa4, 0x68, 0x4a, 0x73, 0x55, 0xed, 0x70, 0x8b, 0x7a, 0xcc, 0x1f, 0x7e, 0x58, 0x4a, 0x12, 0x20, 0x4f, 0x53, 0x6f, 0x56, 0x4f, 0x08, 0x66, 0x9b, 0x26, 0xc6, 0x18, 0x4d, 0xfa, 0x01, 0x92, 0x45, 0xda, 0xfa, 0x32, 0x32, 0x16, 0x65, 0x12, 0x70, 0xe0, 0xa6, 0x6f };
-            var correctEncoding = new byte[] { 0x4a, 0xd9, 0x19, 0xa4, 0x51, 0xf6, 0xdc, 0xf5, 0xfc, 0xa9, 0x6f, 0x07, 0xf2, 0xb9, 0x00, 0xbc, 0xa4, 0x44, 0x97, 0x49, 0x55, 0xce, 0xc7, 0xf4, 0xe6, 0x34, 0xf3, 0x05, 0x9a, 0x46, 0xbb, 0x58, 0x6c, 0x06, 0x99, 0xe0, 0x98, 0xfc, 0x79, 0x60, 0x73, 0xea, 0x9a, 0x7e, 0xab, 0x08, 0xbe, 0x59, 0x27, 0x72, 0x3c, 0x31, 0x36, 0xf2, 0x90, 0xb1, 0x53, 0x45, 0x9d, 0xf9, 0xf4, 0xec, 0x19, 0xae, 0x8b, 0xf5, 0x56, 0x4b, 0x59, 0x87, 0xec, 0x6f, 0x23, 0x86, 0x81, 0xeb, 0xca, 0x20, 0xe6, 0x5e};
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Aes(128);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CFB;
-            cipher.Padding = System.Security.Cryptography.PaddingMode.None;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-        [TestMethod]
-        public void Test_AES_192_CFB_NoPadding()
-        {
-            var key = new byte[] { 0xd8, 0xab, 0x36, 0x37, 0x10, 0x20, 0xec, 0x98, 0x90, 0x56, 0xc1, 0x9e, 0xbe, 0x6c, 0x32, 0xc5, 0x77, 0x73, 0x74, 0xee, 0xb5, 0x43, 0xd4, 0x18 };
-            var iv = new byte[] { 0x3a, 0x3f, 0x51, 0xb1, 0xba, 0xc7, 0x60, 0x70, 0x52, 0xb4, 0x8d, 0x21, 0xac, 0x81, 0x27, 0xbb };
-            var input = new byte[] { 0xcc, 0xa8, 0x81, 0xf2, 0x94, 0xef, 0xcc, 0xfc, 0xc3, 0x49, 0x3c, 0xe5, 0xa3, 0x33, 0x35, 0x34, 0xd7, 0x9a, 0x60, 0xd8, 0x67, 0x5d, 0x51, 0x32, 0xe9, 0x2d, 0x53, 0xa5, 0x35, 0xaa, 0xfc, 0x42, 0xe3, 0x11, 0xed, 0x5b, 0x3a, 0xa4, 0x68, 0x4a, 0x73, 0x55, 0xed, 0x70, 0x8b, 0x7a, 0xcc, 0x1f, 0x7e, 0x58, 0x4a, 0x12, 0x20, 0x4f, 0x53, 0x6f, 0x56, 0x4f, 0x08, 0x66, 0x9b, 0x26, 0xc6, 0x18, 0x4d, 0xfa, 0x01, 0x92, 0x45, 0xda, 0xfa, 0x32, 0x32, 0x16, 0x65, 0x12, 0x70, 0xe0, 0xa6, 0x6f };
-            var correctEncoding = new byte[] { 0xe4, 0x75, 0xc8, 0x82, 0x38, 0x62, 0x8c, 0x3a, 0x8c, 0xff, 0xcd, 0xf6, 0xc3, 0x55, 0xec, 0x12, 0xee, 0xb1, 0x11, 0x66, 0x10, 0x23, 0x99, 0x48, 0x51, 0x78, 0x14, 0x69, 0xbb, 0x11, 0xcf, 0x73, 0x67, 0xd6, 0x24, 0x0a, 0x1f, 0x89, 0x0a, 0x90, 0x86, 0xdc, 0x55, 0x65, 0x62, 0x06, 0x27, 0xbe, 0xbb, 0x7d, 0x67, 0x43, 0xa3, 0xd2, 0xa2, 0x65, 0x5e, 0x6b, 0x11, 0x33, 0xa1, 0x42, 0xf0, 0xa8, 0x13, 0x51, 0x83, 0xf5, 0x7d, 0x76, 0x66, 0xc4, 0xb5, 0x85, 0x06, 0x69, 0x21, 0x5b, 0x6e, 0xc3};
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Aes(128);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CFB;
-            cipher.Padding = System.Security.Cryptography.PaddingMode.None;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-        [TestMethod]
-        public void Test_AES_256_CFB_NoPadding()
-        {
-            var key = new byte[] { 0x81, 0xb3, 0xd3, 0x28, 0x20, 0x0b, 0x27, 0x47, 0xdc, 0x46, 0x6e, 0xee, 0xbb, 0x48, 0xac, 0xc7, 0xee, 0x2e, 0x45, 0xec, 0xb8, 0xd6, 0x7e, 0xfb, 0x03, 0xc9, 0x9b, 0x74, 0x7b, 0x17, 0xf7, 0x0a };             
-            var iv = new byte[] { 0x3a, 0x3f, 0x51, 0xb1, 0xba, 0xc7, 0x60, 0x70, 0x52, 0xb4, 0x8d, 0x21, 0xac, 0x81, 0x27, 0xbb };
-            var input = new byte[] { 0xcc, 0xa8, 0x81, 0xf2, 0x94, 0xef, 0xcc, 0xfc, 0xc3, 0x49, 0x3c, 0xe5, 0xa3, 0x33, 0x35, 0x34, 0xd7, 0x9a, 0x60, 0xd8, 0x67, 0x5d, 0x51, 0x32, 0xe9, 0x2d, 0x53, 0xa5, 0x35, 0xaa, 0xfc, 0x42, 0xe3, 0x11, 0xed, 0x5b, 0x3a, 0xa4, 0x68, 0x4a, 0x73, 0x55, 0xed, 0x70, 0x8b, 0x7a, 0xcc, 0x1f, 0x7e, 0x58, 0x4a, 0x12, 0x20, 0x4f, 0x53, 0x6f, 0x56, 0x4f, 0x08, 0x66, 0x9b, 0x26, 0xc6, 0x18, 0x4d, 0xfa, 0x01, 0x92, 0x45, 0xda, 0xfa, 0x32, 0x32, 0x16, 0x65, 0x12, 0x70, 0xe0, 0xa6, 0x6f };
-            var correctEncoding = new byte[] { 0xaf, 0x84, 0xc6, 0xf4, 0x6a, 0x6a, 0xe2, 0xce, 0x1d, 0x93, 0x3a, 0x03, 0x7f, 0x88, 0x3b, 0xf6, 0xec, 0xc7, 0x84, 0x7c, 0x01, 0xcd, 0x77, 0xdb, 0x60, 0xcb, 0xc7, 0xbe, 0x86, 0x69, 0xe3, 0xbc, 0x46, 0x6c, 0x73, 0xb8, 0xc3, 0x36, 0xbe, 0x0f, 0x2a, 0x15, 0xd5, 0x69, 0x10, 0xcd, 0x1f, 0x7c, 0xb8, 0x64, 0x53, 0xd2, 0xab, 0xfd, 0xf7, 0x3b, 0xde, 0xde, 0x3b, 0x12, 0x26, 0xc4, 0x7f, 0x9c, 0x30, 0xfe, 0x00, 0xbf, 0x4d, 0x0b, 0x5e, 0x3d, 0x34, 0xb9, 0x0c, 0x56, 0x7d, 0xb2, 0x4a, 0xcf};
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Aes(128);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CFB;
-            cipher.Padding = System.Security.Cryptography.PaddingMode.None;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-
-    }
-}

+ 0 - 59
Renci.SshClient/Renci.SshNet.Tests/Security/Cryptography/TestBlowfish.cs

@@ -1,59 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Renci.SshNet.Tests.Security.Cryptography
-{
-    [TestClass]
-    public class TestBlowfish
-    {
-        [TestMethod]
-        public void Test_Blowfish_CBC_NoPadding()
-        {
-            var key = new byte[] { 0xe0, 0xb1, 0xb3, 0xbc, 0xa7, 0xe2, 0x2b, 0xca, 0xf0, 0xc1, 0xc7, 0xaa, 0x93, 0x50, 0xb7, 0x72 };
-            var iv = new byte[] { 0x0b, 0x7c, 0xf1, 0x33, 0xe0, 0x4a, 0x64, 0x30, 0x37, 0x08, 0x83, 0xd3, 0x56, 0x04, 0x12, 0xd9, 0x88, 0xd0, 0x89, 0xf2, 0xe9, 0xd9, 0x25, 0xea, 0x81, 0x64, 0x5b, 0x03, 0xf2, 0xd3, 0xd5, 0x11 };
-            var input = new byte[] { 0x00, 0x00, 0x00, 0x1c, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x4c, 0x78, 0x42, 0xbb, 0x1a, 0x87, 0x5e, 0xba, 0xfc, 0x9e };
-            var correctEncoding = new byte[] { 0x42, 0x36, 0xf4, 0xe9, 0xfd, 0x47, 0x97, 0x43, 0x11, 0x0a, 0x52, 0xf6, 0x1e, 0x7b, 0x78, 0xc0, 0x34, 0x73, 0x58, 0xce, 0x0c, 0xd9, 0x20, 0x97, 0x76, 0x03, 0xb0, 0x2d, 0x4b, 0xce, 0x33, 0x8f };
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Blowfish();
-            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-        [TestMethod]
-        public void Test_Blowfish_128_CBC_NoPadding()
-        {
-            var key = new byte[] { 0xe0, 0xb1, 0xb3, 0xbc, 0xa7, 0xe2, 0x2b, 0xca, 0xf0, 0xc1, 0xc7, 0xaa, 0x93, 0x50, 0xb7, 0x72 };
-            var iv = new byte[] { 0x0b, 0x7c, 0xf1, 0x33, 0xe0, 0x4a, 0x64, 0x30, 0x37, 0x08, 0x83, 0xd3, 0x56, 0x04, 0x12, 0xd9, 0x88, 0xd0, 0x89, 0xf2, 0xe9, 0xd9, 0x25, 0xea, 0x81, 0x64, 0x5b, 0x03, 0xf2, 0xd3, 0xd5, 0x11 };
-            var input = new byte[] { 0x00, 0x00, 0x00, 0x1c, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0x4c, 0x78, 0x42, 0xbb, 0x1a, 0x87, 0x5e, 0xba, 0xfc, 0x9e };
-            var correctEncoding = new byte[] { 0x42, 0x36, 0xf4, 0xe9, 0xfd, 0x47, 0x97, 0x43, 0x11, 0x0a, 0x52, 0xf6, 0x1e, 0x7b, 0x78, 0xc0, 0x34, 0x73, 0x58, 0xce, 0x0c, 0xd9, 0x20, 0x97, 0x76, 0x03, 0xb0, 0x2d, 0x4b, 0xce, 0x33, 0x8f };
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Blowfish(128);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-
-    }
-}

+ 0 - 35
Renci.SshClient/Renci.SshNet.Tests/Security/Cryptography/TestCast.cs

@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Renci.SshNet.Tests.Security.Cryptography
-{
-    [TestClass]
-    public class TestCast
-    {
-        [TestMethod]
-        public void Test_Cast_128_CBC_NoPadding()
-        {
-            var key = new byte[] { 0xd3, 0x2b, 0x5e, 0x1e, 0xfe, 0x99, 0x02, 0xc2, 0x85, 0x85, 0x49, 0xb5, 0x29, 0x4a, 0x8c, 0x44 };
-            var iv = new byte[] { 0x76, 0xc2, 0xd7, 0x95, 0x80, 0x39, 0xd1, 0xb7 };
-            var input = new byte[] { 0x00, 0x00, 0x00, 0x1c, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x0c, 0x73, 0x73, 0x68, 0x2d, 0x75, 0x73, 0x65, 0x72, 0x61, 0x75, 0x74, 0x68, 0xc8, 0xdc, 0xcb, 0x70, 0xb0, 0x53, 0xfe, 0xd5, 0x80, 0xf7 };
-            var correctEncoding = new byte[] { 0x90, 0x1c, 0x5b, 0x18, 0xc1, 0xe2, 0xce, 0x96, 0xe4, 0x55, 0x13, 0xce, 0x1d, 0x84, 0xf8, 0xb0, 0xb3, 0x22, 0x73, 0x06, 0xf6, 0xf9, 0x4b, 0x06, 0xf9, 0x07, 0x38, 0x6e, 0xea, 0x0d, 0x6a, 0xb8 };
-
-            var encodedResult = new byte[input.Length];
-            var decodedResult = new byte[input.Length];
-
-            var cipher = new Renci.SshNet.Security.Cryptography.Cast(128);
-            cipher.Mode = System.Security.Cryptography.CipherMode.CBC;
-            var enc = cipher.CreateEncryptor(key, iv);
-            enc.TransformBlock(input, 0, input.Length, encodedResult, 0);
-
-            var dec = cipher.CreateDecryptor(key, iv);
-            dec.TransformBlock(encodedResult, 0, encodedResult.Length, decodedResult, 0);
-
-            Assert.IsTrue(encodedResult.IsEqualTo(correctEncoding));
-            Assert.IsTrue(decodedResult.IsEqualTo(input));
-        }
-    }
-}

+ 73 - 13
Renci.SshClient/Renci.SshNet.Tests/Security/TestCipher.cs

@@ -12,11 +12,11 @@ namespace Renci.SshNet.Tests.Security
     public class TestCipher
     {
         [TestMethod]
-        public void Test_Cipher_TripleDES_Connection()
+        public void Test_Cipher_TripleDESCBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
             connectionInfo.Encryptions.Clear();
-            connectionInfo.Encryptions.Add("3des-cbc", typeof(CipherTripleDES));
+            connectionInfo.Encryptions.Add("3des-cbc", typeof(CipherTripleDes192Cbc));
 
             using (var client = new SshClient(connectionInfo))
             {
@@ -26,11 +26,11 @@ namespace Renci.SshNet.Tests.Security
         }
 
         [TestMethod]
-        public void Test_Cipher_AES128CBC_Connection()
+        public void Test_Cipher_AEes128CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
             connectionInfo.Encryptions.Clear();
-            connectionInfo.Encryptions.Add("aes128-cbc", typeof(CipherAES128CBC));
+            connectionInfo.Encryptions.Add("aes128-cbc", typeof(CipherAes128Cbc));
 
             using (var client = new SshClient(connectionInfo))
             {
@@ -40,11 +40,11 @@ namespace Renci.SshNet.Tests.Security
         }
 
         [TestMethod]
-        public void Test_Cipher_AES192CBC_Connection()
+        public void Test_Cipher_Aes192CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
             connectionInfo.Encryptions.Clear();
-            connectionInfo.Encryptions.Add("aes192-cbc", typeof(CipherAES192CBC));
+            connectionInfo.Encryptions.Add("aes192-cbc", typeof(CipherAes192Cbc));
 
             using (var client = new SshClient(connectionInfo))
             {
@@ -54,11 +54,11 @@ namespace Renci.SshNet.Tests.Security
         }
 
         [TestMethod]
-        public void Test_Cipher_AES256CBC_Connection()
+        public void Test_Cipher_Aes256CBC_Connection()
         {
             var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
             connectionInfo.Encryptions.Clear();
-            connectionInfo.Encryptions.Add("aes256-cbc", typeof(CipherAES256CBC));
+            connectionInfo.Encryptions.Add("aes256-cbc", typeof(CipherAes256Cbc));
 
             using (var client = new SshClient(connectionInfo))
             {
@@ -68,13 +68,73 @@ namespace Renci.SshNet.Tests.Security
         }
 
         [TestMethod]
-        public void Test_Cipher_TripleDES_Algorithm()
+        public void Test_Cipher_Aes128CTR_Connection()
         {
-            //var cipher = new CipherTripleDES();
-            //cipher.Init();
-            //cipher.Encrypt();
-            //cipher.Decrypt();
+            var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
+            connectionInfo.Encryptions.Clear();
+            connectionInfo.Encryptions.Add("aes128-ctr", typeof(CipherAes128Ctr));
+
+            using (var client = new SshClient(connectionInfo))
+            {
+                client.Connect();
+                client.Disconnect();
+            }
+        }
+
+        [TestMethod]
+        public void Test_Cipher_Aes192CTR_Connection()
+        {
+            var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
+            connectionInfo.Encryptions.Clear();
+            connectionInfo.Encryptions.Add("aes192-ctr", typeof(CipherAes192Ctr));
+
+            using (var client = new SshClient(connectionInfo))
+            {
+                client.Connect();
+                client.Disconnect();
+            }
         }
 
+        [TestMethod]
+        public void Test_Cipher_Aes256CTR_Connection()
+        {
+            var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
+            connectionInfo.Encryptions.Clear();
+            connectionInfo.Encryptions.Add("aes256-ctr", typeof(CipherAes256Ctr));
+
+            using (var client = new SshClient(connectionInfo))
+            {
+                client.Connect();
+                client.Disconnect();
+            }
+        }
+
+        [TestMethod]
+        public void Test_Cipher_BlowfishCBC_Connection()
+        {
+            var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
+            connectionInfo.Encryptions.Clear();
+            connectionInfo.Encryptions.Add("blowfish-cbc", typeof(CipherBlowfish));
+
+            using (var client = new SshClient(connectionInfo))
+            {
+                client.Connect();
+                client.Disconnect();
+            }
+        }
+
+        [TestMethod]
+        public void Test_Cipher_Cast128CBC_Connection()
+        {
+            var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
+            connectionInfo.Encryptions.Clear();
+            connectionInfo.Encryptions.Add("cast128-cbc", typeof(CipherCast128Cbc));
+
+            using (var client = new SshClient(connectionInfo))
+            {
+                client.Connect();
+                client.Disconnect();
+            }
+        }
     }
 }

+ 2 - 2
Renci.SshClient/Renci.SshNet.Tests/SshClientTests/TestSshCommand.cs

@@ -64,7 +64,7 @@ namespace Renci.SshNet.Tests.SshClientTests
 			}
 		}
 
-		[TestMethod]
+		//[TestMethod]
 		public void Test_MultipleThread_10000_MultipleSessions()
 		{
 			using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
@@ -83,7 +83,7 @@ namespace Renci.SshNet.Tests.SshClientTests
 			}
 		}
 
-		[TestMethod]
+		//[TestMethod]
 		public void Test_MultipleThread_10000_MultipleConnections()
 		{
 			try

+ 5 - 2
Renci.SshClient/Renci.SshNet/Common/ASCIIEncoding.cs

@@ -23,6 +23,9 @@ using System.Text;
 
 namespace Renci.SshNet.Common
 {
+    /// <summary>
+    /// Represents an ASCII character encoding of Unicode characters.
+    /// </summary>
     public partial class ASCIIEncoding : Encoding
     {
         // Magic number used by Windows for "ASCII".
@@ -166,7 +169,7 @@ namespace Renci.SshNet.Common
         ///   <paramref name="s"/> is null.-or- <paramref name="bytes"/> is null. </exception>
         ///   
         /// <exception cref="T:System.ArgumentOutOfRangeException">
-        ///   <paramref name="charIndex"/> or <paramref name="charCount"/> or <paramref name="byteIndex"/> is less than zero.-or- <paramref name="charIndex"/> and <paramref name="charCount"/> do not denote a valid range in <paramref name="chars"/>.-or- <paramref name="byteIndex"/> is not a valid index in <paramref name="bytes"/>. </exception>
+        ///   <paramref name="charIndex"/> or <paramref name="charCount"/> or <paramref name="byteIndex"/> is less than zero.-or- <paramref name="charIndex"/> and <paramref name="charCount"/> do not denote a valid range in <paramref name="bytes"/>.-or- <paramref name="byteIndex"/> is not a valid index in <paramref name="bytes"/>. </exception>
         ///   
         /// <exception cref="T:System.ArgumentException">
         ///   <paramref name="bytes"/> does not have enough capacity from <paramref name="byteIndex"/> to the end of the array to accommodate the resulting bytes. </exception>
@@ -263,7 +266,7 @@ namespace Renci.SshNet.Common
         ///   <paramref name="bytes"/> is null.-or- <paramref name="chars"/> is null. </exception>
         ///   
         /// <exception cref="T:System.ArgumentOutOfRangeException">
-        ///   <paramref name="byteIndex"/> or <paramref name="byteCount"/> or <paramref name="charIndex"/> is less than zero.-or- <paramref name="byteindex"/> and <paramref name="byteCount"/> do not denote a valid range in <paramref name="bytes"/>.-or- <paramref name="charIndex"/> is not a valid index in <paramref name="chars"/>. </exception>
+        ///   <paramref name="byteIndex"/> or <paramref name="byteCount"/> or <paramref name="charIndex"/> is less than zero.-or- <paramref name="byteIndex"/> and <paramref name="byteCount"/> do not denote a valid range in <paramref name="bytes"/>.-or- <paramref name="charIndex"/> is not a valid index in <paramref name="chars"/>. </exception>
         ///   
         /// <exception cref="T:System.ArgumentException">
         ///   <paramref name="chars"/> does not have enough capacity from <paramref name="charIndex"/> to the end of the array to accommodate the resulting characters. </exception>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 565 - 0
Renci.SshClient/Renci.SshNet/Common/BigInteger.cs


+ 1 - 1
Renci.SshClient/Renci.SshNet/Common/ExceptionEventArgs.cs

@@ -6,7 +6,7 @@ using System.Text;
 namespace Renci.SshNet.Common
 {
     /// <summary>
-    /// Provides data for the <see cref="ErrorOccured"/> event.
+    /// Provides data for the ErrorOccured events.
     /// </summary>
     public class ExceptionEventArgs : EventArgs
     {

+ 3 - 0
Renci.SshClient/Renci.SshNet/Common/SemaphoreLight.cs

@@ -6,6 +6,9 @@ using System.Threading;
 
 namespace Renci.SshNet.Common
 {
+    /// <summary>
+    /// Light implementation of SemaphoreSlim.
+    /// </summary>
     public class SemaphoreLight
     {
         private object _lock = new object();

+ 8 - 8
Renci.SshClient/Renci.SshNet/ConnectionInfo.cs

@@ -132,10 +132,10 @@ namespace Renci.SshNet
 
             this.Encryptions = new Dictionary<string, Type>()
             {
-                {"3des-cbc", typeof(CipherTripleDES)},
-                {"aes128-cbc", typeof(CipherAES128CBC)},
-                {"aes192-cbc", typeof(CipherAES192CBC)},
-                {"aes256-cbc", typeof(CipherAES256CBC)},                
+                {"3des-cbc", typeof(CipherTripleDes192Cbc)},
+                {"aes128-cbc", typeof(CipherAes128Cbc)},
+                {"aes192-cbc", typeof(CipherAes192Cbc)},
+                {"aes256-cbc", typeof(CipherAes256Cbc)},                
                 {"blowfish-cbc", typeof(CipherBlowfish)},               
                 //{"twofish-cbc", typeof(...)},
                 //{"twofish192-cbc", typeof(...)},
@@ -148,11 +148,11 @@ namespace Renci.SshNet
                 //{"arcfour256", typeof(...)},
                 //{"arcfour", typeof(...)},
                 //{"idea-cbc", typeof(...)},
-                {"cast128-cbc", typeof(CipherCast)},
+                {"cast128-cbc", typeof(CipherCast128Cbc)},
                 //{"rijndael-cbc@lysator.liu.se", typeof(...)},                
-                {"aes128-ctr", typeof(CipherAES128CTR)},
-                {"aes192-ctr", typeof(CipherAES192CTR)},
-                {"aes256-ctr", typeof(CipherAES256CTR)},
+                {"aes128-ctr", typeof(CipherAes128Ctr)},
+                {"aes192-ctr", typeof(CipherAes192Ctr)},
+                {"aes256-ctr", typeof(CipherAes256Ctr)},
             };
 
             this.HmacAlgorithms = new Dictionary<string, Type>()

+ 1 - 1
Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs

@@ -76,7 +76,7 @@ namespace Renci.SshNet
 
         /// <summary>
         /// Releases unmanaged resources and performs other cleanup operations before the
-        /// <see cref="Channel"/> is reclaimed by garbage collection.
+        /// <see cref="ForwardedPortLocal"/> is reclaimed by garbage collection.
         /// </summary>
         ~ForwardedPortLocal()
         {

+ 9 - 21
Renci.SshClient/Renci.SshNet/PrivateKeyFile.cs

@@ -126,7 +126,7 @@ namespace Renci.SshNet
 
             if (!privateKeyMatch.Success)
             {
-                throw new InvalidDataException("Invalid private key file.");
+                throw new SshException("Invalid private key file.");
             }
 
             var keyName = privateKeyMatch.Result("${keyName}");
@@ -147,45 +147,33 @@ namespace Renci.SshNet
                 for (int i = 0; i < binarySalt.Length; i++)
                     binarySalt[i] = Convert.ToByte(salt.Substring(i * 2, 2), 16);
 
+                Cipher cipher = null;
                 switch (cipherName)
                 {
                     case "DES-EDE3-CBC":
-                        using (var cipher = new CipherTripleDES())
-                        {
-                            decryptedData = DecryptKey(cipher, binaryData, passPhrase, binarySalt);
-                        }
+                        cipher = new CipherTripleDes192Cbc();
                         break;
                     case "DES-CBC":
                         //  TODO:   Not tested
-                        using (var cipher = new CipherDES())
-                        {
-                            decryptedData = DecryptKey(cipher, binaryData, passPhrase, binarySalt);
-                        }
+                        cipher = new CipherDes64Cbc();
                         break;
                     case "AES-128-CBC":
                         //  TODO:   Not tested
-                        using (var cipher = new CipherAES128CBC())
-                        {
-                            decryptedData = DecryptKey(cipher, binaryData, passPhrase, binarySalt);
-                        }
+                        cipher = new CipherAes128Cbc();
                         break;
                     case "AES-192-CBC":
                         //  TODO:   Not tested
-                        using (var cipher = new CipherAES192CBC())
-                        {
-                            decryptedData = DecryptKey(cipher, binaryData, passPhrase, binarySalt);
-                        }
+                        cipher = new CipherAes192Cbc();
                         break;
                     case "AES-256-CBC":
                         //  TODO:   Not tested
-                        using (var cipher = new CipherAES256CBC())
-                        {
-                            decryptedData = DecryptKey(cipher, binaryData, passPhrase, binarySalt);
-                        }
+                        cipher = new CipherAes256Cbc();
                         break;
                     default:
                         throw new SshException(string.Format(CultureInfo.CurrentCulture, "Unknown private key cipher \"{0}\".", cipherName));
                 }
+
+                decryptedData = DecryptKey(cipher, binaryData, passPhrase, binarySalt);
             }
             else
             {

+ 1 - 1
Renci.SshClient/Renci.SshNet/Properties/AssemblyInfo.cs

@@ -35,5 +35,5 @@ using System;
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("0.1")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: CLSCompliant(true)]
+[assembly: CLSCompliant(false)]
 [assembly: InternalsVisibleTo("Renci.SshNet.Tests")]

+ 5 - 29
Renci.SshClient/Renci.SshNet/Renci.SshNet.csproj

@@ -109,49 +109,25 @@
     <Compile Include="Security\Cipher.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Security\CipherAESCBC.cs">
+    <Compile Include="Security\CipherAesCbc.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Security\CipherAESCTR.cs">
+    <Compile Include="Security\CipherAesCtr.cs">
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="Security\CipherBlowfish.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Security\CipherCast.cs">
+    <Compile Include="Security\CipherCastCbc.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Security\CipherDES.cs">
+    <Compile Include="Security\CipherDesCbc.cs">
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="Security\CipherSerpent.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="Security\CipherTripleDES.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\Aes.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\Blowfish.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\Cast.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\CipherTransform.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\Des.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\Serpent.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\TransformMode.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="Security\Cryptography\TripleDes.cs">
+    <Compile Include="Security\CipherTripleDesCbc.cs">
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="Security\CryptoKey.cs">

+ 58 - 29
Renci.SshClient/Renci.SshNet/Security/Cipher.cs

@@ -1,14 +1,19 @@
 using System.Collections.Generic;
 using System.Linq;
 using System;
+using Renci.SshNet.Security.Cryptography;
 
 namespace Renci.SshNet.Security
 {
     /// <summary>
     /// Represents the abstract base class from which all implementations of cipher must inherit.
     /// </summary>
-    public abstract class Cipher : Algorithm, IDisposable
+    public abstract class Cipher : Algorithm
     {
+        private ModeBase _encryptor;
+
+        private ModeBase _decryptor;
+
         /// <summary>
         /// Gets or sets the block size, in bits, of the cipher operation.
         /// </summary>
@@ -51,48 +56,72 @@ namespace Renci.SshNet.Security
         /// </summary>
         /// <param name="data">The data.</param>
         /// <returns>Encrypted data</returns>
-        public abstract byte[] Encrypt(byte[] data);
+        public byte[] Encrypt(byte[] data)
+        {
+            if (this._encryptor == null)
+            {
+                this._encryptor = this.CreateEncryptor();
+            }
+
+            var output = new byte[data.Length];
+
+            if (data.Length % this.BlockSize > 0)
+                throw new ArgumentException("data");
+
+            var writtenBytes = 0;
+            for (int i = 0; i < data.Length / this.BlockSize; i++)
+            {
+                writtenBytes += this._encryptor.EncryptBlock(data, i * this.BlockSize, this.BlockSize, output, i * this.BlockSize);
+            }
+
+            if (writtenBytes < data.Length)
+            {
+                throw new InvalidOperationException("Encryption error.");
+            }
+
+            return output;
+        }
 
         /// <summary>
         /// Decrypts the specified data.
         /// </summary>
         /// <param name="data">The data.</param>
         /// <returns>Decrypted data</returns>
-        public abstract byte[] Decrypt(byte[] data);
-        
-        #region IDisposable Members
-
-        /// <summary>
-        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
-        /// </summary>
-        public void Dispose()
+        public byte[] Decrypt(byte[] data)
         {
-            Dispose(true);
+            if (this._decryptor == null)
+            {
+                this._decryptor = this.CreateDecryptor();
+            }
+
+            var output = new byte[data.Length];
+
+            if (data.Length % this.BlockSize > 0)
+                throw new ArgumentException("data");
 
-            GC.SuppressFinalize(this);
+            var writtenBytes = 0;
+            for (int i = 0; i < data.Length / this.BlockSize; i++)
+            {
+                writtenBytes += this._decryptor.DecryptBlock(data, i * this.BlockSize, this.BlockSize, output, i * this.BlockSize);
+            }
+
+            if (writtenBytes < data.Length)
+            {
+                throw new InvalidOperationException("Encryption error.");
+            }
+            return output;
         }
 
         /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
+        /// Creates the encryptor.
         /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected virtual void Dispose(bool disposing)
-        {
-        }
+        /// <returns></returns>
+        protected abstract ModeBase CreateEncryptor();
 
         /// <summary>
-        /// Releases unmanaged resources and performs other cleanup operations before the
-        /// <see cref="Cipher"/> is reclaimed by garbage collection.
+        /// Creates the decryptor.
         /// </summary>
-        ~Cipher()
-        {
-            // Do not re-create Dispose clean-up code here.
-            // Calling Dispose(false) is optimal in terms of
-            // readability and maintainability.
-            Dispose(false);
-        }
-
-        #endregion
-
+        /// <returns></returns>
+        protected abstract ModeBase CreateDecryptor();
     }
 }

+ 24 - 102
Renci.SshClient/Renci.SshNet/Security/CipherAESCBC.cs

@@ -9,14 +9,9 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents base class for AES based encryption.
     /// </summary>
-    public abstract class CipherAESCBC : Cipher
+    public abstract class CipherAesCbc : Cipher
     {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
-
+        private readonly int _keySize;
         /// <summary>
         /// Gets or sets the key size, in bits, of the secret key used by the cipher.
         /// </summary>
@@ -27,7 +22,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.KeySize;
+                return this._keySize;
             }
         }
 
@@ -41,115 +36,42 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.BlockSize / 8;
+                return 16;
             }
         }
 
         /// <summary>
-        /// Gets the size of the key bits.
-        /// </summary>
-        /// <value>
-        /// The size of the key bits.
-        /// </value>
-        protected int KeyBitsSize { get; private set; }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAESCBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAesCbc"/> class.
         /// </summary>
         /// <param name="keyBitsSize">Size of the key bits.</param>
-        public CipherAESCBC(int keyBitsSize)
+        public CipherAesCbc(int keyBitsSize)
         {
-            this.KeyBitsSize = keyBitsSize;
-            this._algorithm = new System.Security.Cryptography.RijndaelManaged();
-            this._algorithm.KeySize = keyBitsSize;
-            this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
+            this._keySize = keyBitsSize;
         }
 
         /// <summary>
-        /// Encrypts the specified data.
+        /// Creates the encryptor.
         /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
         {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
+            return new CbcMode(new AesCipher(this.Key.Take(this._keySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
 
         /// <summary>
-        /// Decrypts the specified data.
+        /// Creates the decryptor.
         /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
         {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
+            return new CbcMode(new AesCipher(this.Key.Take(this._keySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
     }
 
     /// <summary>
     /// Represents AES 128 bit encryption.
     /// </summary>
-    public class CipherAES128CBC : CipherAESCBC
+    public class CipherAes128Cbc : CipherAesCbc
     {
         /// <summary>
         /// Gets algorithm name.
@@ -160,9 +82,9 @@ namespace Renci.SshNet.Security
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAES128CBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAes128Cbc"/> class.
         /// </summary>
-        public CipherAES128CBC()
+        public CipherAes128Cbc()
             : base(128)
         {
 
@@ -172,7 +94,7 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents AES 192 bit encryption.
     /// </summary>
-    public class CipherAES192CBC : CipherAESCBC
+    public class CipherAes192Cbc : CipherAesCbc
     {
         /// <summary>
         /// Gets algorithm name.
@@ -183,9 +105,9 @@ namespace Renci.SshNet.Security
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAES192CBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAes192Cbc"/> class.
         /// </summary>
-        public CipherAES192CBC()
+        public CipherAes192Cbc()
             : base(192)
         {
 
@@ -195,7 +117,7 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents AES 256 bit encryption.
     /// </summary>
-    public class CipherAES256CBC : CipherAESCBC
+    public class CipherAes256Cbc : CipherAesCbc
     {
         /// <summary>
         /// Gets algorithm name.
@@ -206,9 +128,9 @@ namespace Renci.SshNet.Security
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAES256CBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAes256Cbc"/> class.
         /// </summary>
-        public CipherAES256CBC()
+        public CipherAes256Cbc()
             : base(256)
         {
 

+ 24 - 102
Renci.SshClient/Renci.SshNet/Security/CipherAESCTR.cs

@@ -9,14 +9,9 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents base class for AES based encryption.
     /// </summary>
-    public abstract class CipherAESCTR : Cipher
+    public abstract class CipherAesCtr : Cipher
     {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
-
+        private readonly int _keySize;
         /// <summary>
         /// Gets or sets the key size, in bits, of the secret key used by the cipher.
         /// </summary>
@@ -27,7 +22,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.KeySize;
+                return this._keySize / 8;
             }
         }
 
@@ -41,115 +36,42 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.BlockSize / 8;
+                return 16;
             }
         }
 
         /// <summary>
-        /// Gets the size of the key bits.
-        /// </summary>
-        /// <value>
-        /// The size of the key bits.
-        /// </value>
-        protected int KeyBitsSize { get; private set; }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAESCBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAesCtr"/> class.
         /// </summary>
         /// <param name="keyBitsSize">Size of the key bits.</param>
-        public CipherAESCTR(int keyBitsSize)
+        public CipherAesCtr(int keyBitsSize)
         {
-            this.KeyBitsSize = keyBitsSize;
-            this._algorithm = new Cryptography.Aes(keyBitsSize);
-            this._algorithm.KeySize = keyBitsSize;
-            this._algorithm.Mode = (CipherMode)CipherModeEx.CTR;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
+            this._keySize = keyBitsSize;
         }
 
         /// <summary>
-        /// Encrypts the specified data.
+        /// Creates the encryptor.
         /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
         {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
+            return new CtrMode(new AesCipher(this.Key.Take(this._keySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
 
         /// <summary>
-        /// Decrypts the specified data.
+        /// Creates the decryptor.
         /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
         {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
+            return new CtrMode(new AesCipher(this.Key.Take(this._keySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
     }
 
     /// <summary>
     /// Represents AES 128 bit encryption.
     /// </summary>
-    public class CipherAES128CTR : CipherAESCTR
+    public class CipherAes128Ctr : CipherAesCtr
     {
         /// <summary>
         /// Gets algorithm name.
@@ -160,9 +82,9 @@ namespace Renci.SshNet.Security
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAES192CBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAes192Cbc"/> class.
         /// </summary>
-        public CipherAES128CTR()
+        public CipherAes128Ctr()
             : base(128)
         {
 
@@ -172,7 +94,7 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents AES 192 bit encryption.
     /// </summary>
-    public class CipherAES192CTR : CipherAESCTR
+    public class CipherAes192Ctr : CipherAesCtr
     {
         /// <summary>
         /// Gets algorithm name.
@@ -183,9 +105,9 @@ namespace Renci.SshNet.Security
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAES192CBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAes192Cbc"/> class.
         /// </summary>
-        public CipherAES192CTR()
+        public CipherAes192Ctr()
             : base(192)
         {
 
@@ -195,7 +117,7 @@ namespace Renci.SshNet.Security
     /// <summary>
     /// Represents AES 256 bit encryption.
     /// </summary>
-    public class CipherAES256CTR : CipherAESCTR
+    public class CipherAes256Ctr : CipherAesCtr
     {
         /// <summary>
         /// Gets algorithm name.
@@ -206,9 +128,9 @@ namespace Renci.SshNet.Security
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAES192CBC"/> class.
+        /// Initializes a new instance of the <see cref="CipherAes192Cbc"/> class.
         /// </summary>
-        public CipherAES256CTR()
+        public CipherAes256Ctr()
             : base(256)
         {
 

+ 18 - 94
Renci.SshClient/Renci.SshNet/Security/CipherBlowFish.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Security.Cryptography;
+using Renci.SshNet.Security.Cryptography;
 
 namespace Renci.SshNet.Security
 {
@@ -11,11 +12,13 @@ namespace Renci.SshNet.Security
     /// </summary>
     public class CipherBlowfish : Cipher
     {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
+        /// <summary>
+        /// Gets algorithm name.
+        /// </summary>
+        public override string Name
+        {
+            get { return "blowfish-cbc"; }
+        }
 
         /// <summary>
         /// Gets or sets the key size, in bits, of the secret key used by the cipher.
@@ -27,7 +30,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.KeySize;
+                return 16 * 8;
             }
         }
 
@@ -41,105 +44,26 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.BlockSize / 8;
+                return 8;
             }
         }
 
         /// <summary>
-        /// Gets algorithm name.
+        /// Creates the encryptor.
         /// </summary>
-        public override string Name
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
         {
-            get { return "blowfish-cbc"; }
+            return new CbcMode(new BlowfishCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
 
         /// <summary>
-        /// Initializes a new instance of the <see cref="CipherBlowfish"/> class.
+        /// Creates the decryptor.
         /// </summary>
-        public CipherBlowfish()
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
         {
-            this._algorithm = new Cryptography.Blowfish();
-            this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
-        }
-
-        /// <summary>
-        /// Encrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
-        {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
-        }
-
-        /// <summary>
-        /// Decrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
-        {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
+            return new CbcMode(new BlowfishCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
     }
 }

+ 0 - 148
Renci.SshClient/Renci.SshNet/Security/CipherCast.cs

@@ -1,148 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-
-namespace Renci.SshNet.Security
-{
-
-    /// <summary>
-    /// Represents base class for AES based encryption.
-    /// </summary>
-    public class CipherCast : Cipher
-    {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
-
-        /// <summary>
-        /// Gets or sets the key size, in bits, of the secret key used by the cipher.
-        /// </summary>
-        /// <value>
-        /// The key size, in bits.
-        /// </value>
-        public override int KeySize
-        {
-            get
-            {
-                return this._algorithm.KeySize;
-            }
-        }
-
-        /// <summary>
-        /// Gets or sets the block size, in bits, of the cipher operation.
-        /// </summary>
-        /// <value>
-        /// The block size, in bits.
-        /// </value>
-        public override int BlockSize
-        {
-            get
-            {
-                return this._algorithm.BlockSize / 8;
-            }
-        }
-
-        /// <summary>
-        /// Gets algorithm name.
-        /// </summary>
-        public override string Name
-        {
-            get { return "cast128-cbc"; }
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CipherAESCBC"/> class.
-        /// </summary>
-        public CipherCast()
-        {
-            this._algorithm = new Cryptography.Cast(128);
-            this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
-        }
-
-        /// <summary>
-        /// Encrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
-        {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
-        }
-
-        /// <summary>
-        /// Decrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
-        {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
-        }
-    }
-
-}

+ 94 - 0
Renci.SshClient/Renci.SshNet/Security/CipherCastCbc.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Security.Cryptography;
+using Renci.SshNet.Security.Cryptography;
+
+namespace Renci.SshNet.Security
+{
+    /// <summary>
+    /// Represents base class for CAST-CBC based encryption.
+    /// </summary>
+    public abstract class CipherCastCbc : Cipher
+    {
+        private readonly int _keySize;
+        /// <summary>
+        /// Gets or sets the key size, in bits, of the secret key used by the cipher.
+        /// </summary>
+        /// <value>
+        /// The key size, in bits.
+        /// </value>
+        public override int KeySize
+        {
+            get
+            {
+                return this._keySize;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the block size, in bits, of the cipher operation.
+        /// </summary>
+        /// <value>
+        /// The block size, in bits.
+        /// </value>
+        public override int BlockSize
+        {
+            get
+            {
+                return 8;
+            }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CipherCastCbc"/> class.
+        /// </summary>
+        /// <param name="keySize">Size of the key.</param>
+        public CipherCastCbc(int keySize)
+        {
+            this._keySize = keySize;
+        }
+
+        /// <summary>
+        /// Creates the encryptor.
+        /// </summary>
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
+        {
+            return new CbcMode(new CastCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
+        }
+
+        /// <summary>
+        /// Creates the decryptor.
+        /// </summary>
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
+        {
+            return new CbcMode(new CastCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
+        }
+    }
+
+    /// <summary>
+    /// Represents class for CAST 128 CBC based encryption.
+    /// </summary>
+    public class CipherCast128Cbc : CipherCastCbc
+    {
+        /// <summary>
+        /// Gets algorithm name.
+        /// </summary>
+        public override string Name
+        {
+            get { return "cast128-cbc"; }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CipherCast128Cbc"/> class.
+        /// </summary>
+        public CipherCast128Cbc()
+            : base(128)
+        {
+
+        }        
+    }
+}

+ 0 - 146
Renci.SshClient/Renci.SshNet/Security/CipherDES.cs

@@ -1,146 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-
-namespace Renci.SshNet.Security
-{
-    /// <summary>
-    /// Represents DES-CBC encryption.
-    /// </summary>
-    public class CipherDES : Cipher
-    {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
-
-        /// <summary>
-        /// Gets algorithm name.
-        /// </summary>
-        public override string Name
-        {
-            get { return "3des-cbc"; }
-        }
-
-        /// <summary>
-        /// Gets or sets the key size, in bits, of the secret key used by the cipher.
-        /// </summary>
-        /// <value>
-        /// The key size, in bits.
-        /// </value>
-        public override int KeySize
-        {
-            get
-            {
-                return this._algorithm.KeySize;
-            }
-        }
-
-        /// <summary>
-        /// Gets or sets the block size, in bits, of the cipher operation.
-        /// </summary>
-        /// <value>
-        /// The block size, in bits.
-        /// </value>
-        public override int BlockSize
-        {
-            get
-            {
-                return this._algorithm.BlockSize / 8;
-            }
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CipherDES"/> class.
-        /// </summary>
-        public CipherDES()
-        {
-            this._algorithm = new System.Security.Cryptography.DESCryptoServiceProvider();
-            this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
-        }
-
-        /// <summary>
-        /// Encrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
-        {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
-        }
-
-        /// <summary>
-        /// Decrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
-        {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
-        }
-    }
-}

+ 95 - 0
Renci.SshClient/Renci.SshNet/Security/CipherDesCbc.cs

@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Security.Cryptography;
+using Renci.SshNet.Security.Cryptography;
+
+namespace Renci.SshNet.Security
+{
+    /// <summary>
+    /// Represents base class for DES-CBC encryption.
+    /// </summary>
+    public abstract class CipherDesCbc : Cipher
+    {
+        private readonly int _keySize;
+        /// <summary>
+        /// Gets or sets the key size, in bits, of the secret key used by the cipher.
+        /// </summary>
+        /// <value>
+        /// The key size, in bits.
+        /// </value>
+        public override int KeySize
+        {
+            get
+            {
+                return 0;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the block size, in bits, of the cipher operation.
+        /// </summary>
+        /// <value>
+        /// The block size, in bits.
+        /// </value>
+        public override int BlockSize
+        {
+            get
+            {
+                return 8;
+            }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CipherDesCbc"/> class.
+        /// </summary>
+        /// <param name="keySize">Size of the key.</param>
+        public CipherDesCbc(int keySize)
+        {
+            this._keySize = keySize;
+        }
+
+        /// <summary>
+        /// Creates the encryptor.
+        /// </summary>
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
+        {
+            return new CbcMode(new DesCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
+        }
+
+        /// <summary>
+        /// Creates the decryptor.
+        /// </summary>
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
+        {
+            return new CbcMode(new DesCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
+        }
+    }
+
+    /// <summary>
+    /// Represents class for DES-64 CBC encryption.
+    /// </summary>
+    public class CipherDes64Cbc : CipherDesCbc
+    {
+        /// <summary>
+        /// Gets algorithm name.
+        /// </summary>
+        public override string Name
+        {
+            get { return "des-cbc"; }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CipherDesCbc"/> class.
+        /// </summary>
+        public CipherDes64Cbc()
+            : base(64)
+        {
+
+        }
+    }
+
+}

+ 13 - 90
Renci.SshClient/Renci.SshNet/Security/CipherSerpent.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Security.Cryptography;
+using Renci.SshNet.Security.Cryptography;
 
 namespace Renci.SshNet.Security
 {
@@ -11,12 +12,7 @@ namespace Renci.SshNet.Security
     /// </summary>
     public abstract class CipherSerpentCBC : Cipher
     {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
-
+        private readonly int _keySize;
         /// <summary>
         /// Gets or sets the key size, in bits, of the secret key used by the cipher.
         /// </summary>
@@ -27,7 +23,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.KeySize;
+                return this._keySize;
             }
         }
 
@@ -41,108 +37,35 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._algorithm.BlockSize / 8;
+                return 16;
             }
         }
 
-        /// <summary>
-        /// Gets the size of the key bits.
-        /// </summary>
-        /// <value>
-        /// The size of the key bits.
-        /// </value>
-        protected int KeyBitsSize { get; private set; }
-
         /// <summary>
         /// Initializes a new instance of the <see cref="CipherSerpentCBC"/> class.
         /// </summary>
         /// <param name="keyBitsSize">Size of the key bits.</param>
         public CipherSerpentCBC(int keyBitsSize)
         {
-            this.KeyBitsSize = keyBitsSize;
-            this._algorithm = new Cryptography.Serpent(keyBitsSize);
-            this._algorithm.KeySize = keyBitsSize;
-            this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
+            this._keySize = keyBitsSize;
         }
 
         /// <summary>
-        /// Encrypts the specified data.
+        /// Creates the encryptor.
         /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
         {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
+            return new CbcMode(new SerpentCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
 
         /// <summary>
-        /// Decrypts the specified data.
+        /// Creates the decryptor.
         /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
         {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
+            return new CbcMode(new SerpentCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
         }
     }
 

+ 0 - 145
Renci.SshClient/Renci.SshNet/Security/CipherTripleDES.cs

@@ -1,145 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Cryptography;
-
-namespace Renci.SshNet.Security
-{
-    /// <summary>
-    /// Represents Triple DES encryption.
-    /// </summary>
-    public class CipherTripleDES : Cipher
-    {
-        private SymmetricAlgorithm _algorithm;
-
-        private ICryptoTransform _encryptor;
-
-        private ICryptoTransform _decryptor;
-
-        /// <summary>
-        /// Gets algorithm name.
-        /// </summary>
-        public override string Name
-        {
-            get { return "3des-cbc"; }
-        }
-
-        /// <summary>
-        /// Gets or sets the key size, in bits, of the secret key used by the cipher.
-        /// </summary>
-        /// <value>
-        /// The key size, in bits.
-        /// </value>
-        public override int KeySize
-        {
-            get
-            {
-                return this._algorithm.KeySize;
-            }
-        }
-
-        /// <summary>
-        /// Gets or sets the block size, in bits, of the cipher operation.
-        /// </summary>
-        /// <value>
-        /// The block size, in bits.
-        /// </value>
-        public override int BlockSize
-        {
-            get
-            {
-                return this._algorithm.BlockSize / 8;
-            }
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CipherTripleDES"/> class.
-        /// </summary>
-        public CipherTripleDES()
-        {
-            this._algorithm = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
-            this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
-            this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
-        }
-
-        /// <summary>
-        /// Encrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Encrypted data
-        /// </returns>
-        public override byte[] Encrypt(byte[] data)
-        {
-            if (this._encryptor == null)
-            {
-                this._encryptor = this._algorithm.CreateEncryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._encryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
-        }
-
-        /// <summary>
-        /// Decrypts the specified data.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <returns>
-        /// Decrypted data
-        /// </returns>
-        public override byte[] Decrypt(byte[] data)
-        {
-            if (this._decryptor == null)
-            {
-                this._decryptor = this._algorithm.CreateDecryptor(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray());
-            }
-
-            var output = new byte[data.Length];
-            var writtenBytes = this._decryptor.TransformBlock(data, 0, data.Length, output, 0);
-
-            if (writtenBytes < data.Length)
-            {
-                throw new InvalidOperationException("Encryption error.");
-            }
-
-            return output;
-        }
-
-        private bool _isDisposed = false;
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources
-        /// </summary>
-        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected override void Dispose(bool disposing)
-        {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
-            {
-                // If disposing equals true, dispose all managed
-                // and unmanaged resources.
-                if (disposing)
-                {
-                    // Dispose managed resources.
-                    if (this._algorithm != null)
-                    {
-                        this._algorithm.Dispose();
-                        this._algorithm = null;
-                    }
-                }
-
-                // Note disposing has been done.
-                this._isDisposed = true;
-            }
-
-            base.Dispose(disposing);
-        }
-    }
-}

+ 94 - 0
Renci.SshClient/Renci.SshNet/Security/CipherTripleDesCbc.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using Renci.SshNet.Security.Cryptography;
+
+namespace Renci.SshNet.Security
+{
+    /// <summary>
+    /// Represents base class Triple DES encryption.
+    /// </summary>
+    public abstract class CipherTripleDesCbc : Cipher
+    {
+        private readonly int _keySize;
+        /// <summary>
+        /// Gets or sets the key size, in bits, of the secret key used by the cipher.
+        /// </summary>
+        /// <value>
+        /// The key size, in bits.
+        /// </value>
+        public override int KeySize
+        {
+            get
+            {
+                return this._keySize;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the block size, in bits, of the cipher operation.
+        /// </summary>
+        /// <value>
+        /// The block size, in bits.
+        /// </value>
+        public override int BlockSize
+        {
+            get
+            {
+                return 8;
+            }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CipherTripleDes192Cbc"/> class.
+        /// </summary>
+        /// <param name="keySize">Size of the key.</param>
+        public CipherTripleDesCbc(int keySize)
+        {
+            this._keySize = keySize;        
+        }
+
+        /// <summary>
+        /// Creates the encryptor.
+        /// </summary>
+        /// <returns></returns>
+        protected override ModeBase CreateEncryptor()
+        {
+            return new CbcMode(new TripleDesCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
+        }
+
+        /// <summary>
+        /// Creates the decryptor.
+        /// </summary>
+        /// <returns></returns>
+        protected override ModeBase CreateDecryptor()
+        {
+            return new CbcMode(new TripleDesCipher(this.Key.Take(this.KeySize / 8).ToArray(), this.Vector.Take(this.BlockSize).ToArray()));
+        }
+    }
+
+    /// <summary>
+    /// Represents class Triple DES 192 CBC encryption.
+    /// </summary>
+    public class CipherTripleDes192Cbc : CipherTripleDesCbc
+    {
+        /// <summary>
+        /// Gets algorithm name.
+        /// </summary>
+        public override string Name
+        {
+            get { return "3des-cbc"; }
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CipherTripleDes192Cbc"/> class.
+        /// </summary>
+        public CipherTripleDes192Cbc()
+            : base(192)
+        {
+
+        }
+        
+    }
+}

+ 1 - 1
Renci.SshClient/Renci.SshNet/Security/CryptoPublicKeyDss.cs

@@ -140,7 +140,7 @@ namespace Renci.SshNet.Security
                         j = i1 | i2 | i3 | i4;
 
                         tmp = new byte[j];
-                        Array.Copy(sig, i, tmp, 0, j);
+                        Array.Copy(sig, (int)i, tmp, 0, (int)j);
                         sig = tmp;
                     }
 

+ 1 - 1
Renci.SshClient/Renci.SshNet/Security/CryptoPublicKeyRsa.cs

@@ -125,7 +125,7 @@ namespace Renci.SshNet.Security
                         j = i1 | i2 | i3 | i4;
 
                         tmp = new byte[j];
-                        Array.Copy(sig, i, tmp, 0, j);
+                        Array.Copy(sig, (int)i, tmp, 0, (int)j);
                         sig = tmp;
                     }
 

+ 0 - 119
Renci.SshClient/Renci.SshNet/Security/Cryptography/Aes.cs

@@ -1,119 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    /// <summary>
-    /// Represents the class for the AES algorithm.
-    /// </summary>
-    public class Aes : SymmetricAlgorithm
-    {
-        private CipherMode _mode;
-        /// <summary>
-        /// Gets or sets the mode for operation of the symmetric algorithm.
-        /// </summary>
-        /// <returns>The mode for operation of the symmetric algorithm. The default is <see cref="F:System.Security.Cryptography.CipherMode.CBC"/>.</returns>
-        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The cipher mode is not one of the <see cref="T:System.Security.Cryptography.CipherMode"/> values. </exception>
-        public override CipherMode Mode
-        {
-            get
-            {
-                return this._mode;
-            }
-            set
-            {
-                this._mode = value;
-            }
-        }
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Aes"/> class.
-        /// </summary>
-        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The implementation of the class derived from the symmetric algorithm is not valid.</exception>
-        public Aes()
-            : this(256)
-        {
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Aes"/> class.
-        /// </summary>
-        /// <param name="keySize">Size of the key.</param>
-        public Aes(int keySize)
-        {
-            this.KeySizeValue = keySize;
-            this.BlockSizeValue = 128;
-            this.FeedbackSizeValue = BlockSizeValue;
-            this.LegalBlockSizesValue = new KeySizes[] { new KeySizes(128, 256, 64) };
-            this.LegalKeySizesValue = new KeySizes[] { new KeySizes(128, 256, 64) };
-        }
-
-        /// <summary>
-        /// Creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric decryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Decrypt, this.GetBlockCipher(new AesCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric encryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Encrypt, this.GetBlockCipher(new AesCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Generates a random initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateIV()
-        {
-            var random = new Random();
-            this.KeyValue = new byte[this.KeySizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        /// <summary>
-        /// Generates a random key (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateKey()
-        {
-            var random = new Random();
-            this.IVValue = new byte[this.BlockSizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        private ModeBase GetBlockCipher(CipherBase cipher)
-        {
-            switch (this.Mode)
-            {
-                case CipherMode.CBC:
-                    return new CbcMode(cipher);
-                case CipherMode.CFB:
-                    return new CfbMode(cipher);
-                case (CipherMode)CipherModeEx.CTR:
-                    return new CtrMode(cipher);
-                default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Mode '{0}' is not supported.", this.Mode));
-            }
-        }
-    }
-}

+ 0 - 97
Renci.SshClient/Renci.SshNet/Security/Cryptography/Blowfish.cs

@@ -1,97 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    /// <summary>
-    /// Represents the class for the Blowfish algorithm.
-    /// </summary>
-    public class Blowfish : SymmetricAlgorithm
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Blowfish"/> class.
-        /// </summary>
-        public Blowfish()
-            : this(16 * 8)
-        {
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Blowfish"/> class.
-        /// </summary>
-        /// <param name="keySize">Size of the key.</param>
-        public Blowfish(int keySize)
-        {
-            this.KeySizeValue = keySize;
-            this.BlockSizeValue = 8 * 8;
-            this.FeedbackSizeValue = BlockSizeValue;
-            this.LegalBlockSizesValue = new KeySizes[] { new KeySizes(64, 64, 0 ) };
-            this.LegalKeySizesValue = new KeySizes[] { new KeySizes(32, 448, 32) };
-        }
-
-        /// <summary>
-        /// Creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric decryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Decrypt, this.GetBlockCipher(new BlowfishCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric encryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Encrypt, this.GetBlockCipher(new BlowfishCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Generates a random initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateIV()
-        {
-            var random = new Random();
-            this.KeyValue = new byte[this.KeySizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        /// <summary>
-        /// Generates a random key (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateKey()
-        {
-            var random = new Random();
-            this.IVValue = new byte[this.BlockSizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        private ModeBase GetBlockCipher(CipherBase cipher)
-        {
-            switch (this.Mode)
-            {
-                case CipherMode.CBC:
-                    return new CbcMode(cipher);
-                default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Mode '{0}' is not supported.", this.Mode));
-            }
-        }
-    }
-}

+ 0 - 90
Renci.SshClient/Renci.SshNet/Security/Cryptography/Cast.cs

@@ -1,90 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    /// <summary>
-    /// Represents the class for the CAST algorithm.
-    /// </summary>
-    public class Cast : SymmetricAlgorithm
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Cast"/> class.
-        /// </summary>
-        /// <param name="keySize">Size of the key.</param>
-        public Cast(int keySize)
-        {
-            this.KeySizeValue = keySize;
-            this.BlockSizeValue = 64;
-            this.FeedbackSizeValue = BlockSizeValue;
-            this.LegalBlockSizesValue = new KeySizes[] { new KeySizes(64, 64, 0) };
-            this.LegalKeySizesValue = new KeySizes[] { new KeySizes(128, 256, 128) };
-        }
-
-        /// <summary>
-        /// Creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric decryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Decrypt, this.GetBlockCipher(new CastCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric encryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-            
-            return new CipherTransform(TransformMode.Encrypt, this.GetBlockCipher(new CastCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Generates a random initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateIV()
-        {
-            var random = new Random();
-            this.KeyValue = new byte[this.KeySizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        /// <summary>
-        /// Generates a random key (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateKey()
-        {
-            var random = new Random();
-            this.IVValue = new byte[this.BlockSizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        private ModeBase GetBlockCipher(CipherBase cipher)
-        {
-            switch (this.Mode)
-            {
-                case CipherMode.CBC:
-                    return new CbcMode(cipher);
-                default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Mode '{0}' is not supported.", this.Mode));
-            }
-        }
-    }
-
-}

+ 0 - 128
Renci.SshClient/Renci.SshNet/Security/Cryptography/CipherTransform.cs

@@ -1,128 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    /// <summary>
-    /// 
-    /// </summary>
-    internal class CipherTransform : ICryptoTransform
-    {
-        private readonly int _blockSize;
-
-        private readonly CipherBase _blockCipher;
-
-        /// <summary>
-        /// Gets the transform mode.
-        /// </summary>
-        public TransformMode TransformMode { get; private set; }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="CipherTransform"/> class.
-        /// </summary>
-        /// <param name="transformMode">The transform mode.</param>
-        /// <param name="blockCipher">The block cipher.</param>
-        public CipherTransform(TransformMode transformMode, CipherBase blockCipher)
-        {
-            this._blockCipher = blockCipher;
-
-            this._blockSize = blockCipher.BlockSize;
-
-            this.TransformMode = transformMode;
-        }
-
-        #region ICryptoTransform Members
-
-        /// <summary>
-        /// Gets a value indicating whether the current transform can be reused.
-        /// </summary>
-        /// <returns>true if the current transform can be reused; otherwise, false.</returns>
-        public bool CanReuseTransform
-        {
-            get { return true; }
-        }
-
-        /// <summary>
-        /// Gets a value indicating whether multiple blocks can be transformed.
-        /// </summary>
-        /// <returns>true if multiple blocks can be transformed; otherwise, false.</returns>
-        public bool CanTransformMultipleBlocks
-        {
-            get { return false; }
-        }
-
-        /// <summary>
-        /// Gets the input block size.
-        /// </summary>
-        /// <returns>The size of the input data blocks in bytes.</returns>
-        public int InputBlockSize
-        {
-            get { return this._blockSize; }
-        }
-
-        /// <summary>
-        /// Gets the output block size.
-        /// </summary>
-        /// <returns>The size of the output data blocks in bytes.</returns>
-        public int OutputBlockSize
-        {
-            get { return this._blockSize; }
-        }
-
-        /// <summary>
-        /// Transforms the specified region of the input byte array and copies the resulting transform to the specified region of the output byte array.
-        /// </summary>
-        /// <param name="inputBuffer">The input for which to compute the transform.</param>
-        /// <param name="inputOffset">The offset into the input byte array from which to begin using data.</param>
-        /// <param name="inputCount">The number of bytes in the input byte array to use as data.</param>
-        /// <param name="outputBuffer">The output to which to write the transform.</param>
-        /// <param name="outputOffset">The offset into the output byte array from which to begin writing data.</param>
-        /// <returns>
-        /// The number of bytes written.
-        /// </returns>
-        public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
-        {
-            if (inputCount % this._blockSize != 0)
-                throw new ArgumentException("Invalid  value.");
-
-            var length = 0;
-
-            for (int i = 0; i < inputCount / this._blockSize; i++)
-            {
-                switch (this.TransformMode)
-                {
-                    case TransformMode.Encrypt:
-                        length += this._blockCipher.EncryptBlock(inputBuffer, inputOffset + this._blockSize * i, this._blockSize, outputBuffer, outputOffset + this._blockSize * i);
-                        break;
-                    case TransformMode.Decrypt:
-                        length += this._blockCipher.DecryptBlock(inputBuffer, inputOffset + this._blockSize * i, this._blockSize, outputBuffer, outputOffset + this._blockSize * i);
-                        break;
-                    default:
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "TransformMode '{0}' is not supported.", this.TransformMode));
-                }
-            }
-
-            return length;
-        }
-
-        public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
-        {
-            throw new NotSupportedException("TransformFinalBlock is currently not supported.");
-        }
-
-        #endregion
-
-        #region IDisposable Members
-
-        public void Dispose()
-        {
-            throw new NotImplementedException();
-        }
-
-        #endregion
-    }
-}

+ 41 - 12
Renci.SshClient/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs

@@ -11,8 +11,13 @@ namespace Renci.SshNet.Security.Cryptography
     /// </summary>
     public class TripleDesCipher : DesCipher
     {
-        private byte[] _pass1;
-        private byte[] _pass2;
+        private readonly int[] _encryptionKey1;
+        private readonly int[] _encryptionKey2;
+        private readonly int[] _encryptionKey3;
+
+        private readonly int[] _decryptionKey1;
+        private readonly int[] _decryptionKey2;
+        private readonly int[] _decryptionKey3;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="TripleDesCipher"/> class.
@@ -22,6 +27,31 @@ namespace Renci.SshNet.Security.Cryptography
         public TripleDesCipher(byte[] key, byte[] iv)
             : base(key, iv)
         {
+            var part1 = new byte[8];
+            var part2 = new byte[8];
+
+            Array.Copy(key, 0, part1, 0, 8);
+            Array.Copy(key, 8, part2, 0, 8);
+
+            this._encryptionKey1 = GenerateWorkingKey(true, part1);
+            this._decryptionKey1 = GenerateWorkingKey(false, part1);
+
+            this._encryptionKey2 = GenerateWorkingKey(false, part2);
+            this._decryptionKey2 = GenerateWorkingKey(true, part2);
+
+            if (this.Key.Length == 24)
+            {
+                var part3 = new byte[8];
+                Array.Copy(key, 16, part3, 0, 8);
+
+                this._encryptionKey3 = GenerateWorkingKey(true, part3);
+                this._decryptionKey3 = GenerateWorkingKey(false, part3);
+            }
+            else
+            {
+                this._encryptionKey3 = this._encryptionKey1;
+                this._decryptionKey3 = this._decryptionKey1;
+            }
         }
 
         /// <summary>
@@ -43,14 +73,11 @@ namespace Renci.SshNet.Security.Cryptography
             if ((outputOffset + this.BlockSize) > outputBuffer.Length)
                 throw new IndexOutOfRangeException("output buffer too short");
 
-            if (this._pass1 == null)
-                this._pass1 = new byte[this.BlockSize];
-            if (this._pass2 == null)
-                this._pass2 = new byte[this.BlockSize];
+            byte[] temp = new byte[this.BlockSize];
 
-            DesCipher.DesFunc(this.EncryptionKey, inputBuffer, inputOffset, this._pass1, 0);
-            DesCipher.DesFunc(this.EncryptionKey, this._pass1, 0, this._pass2, 0);
-            DesCipher.DesFunc(this.EncryptionKey, this._pass2, 0, outputBuffer, outputOffset);
+            DesCipher.DesFunc(this._encryptionKey1, inputBuffer, inputOffset, temp, 0);
+            DesCipher.DesFunc(this._encryptionKey2, temp, 0, temp, 0);
+            DesCipher.DesFunc(this._encryptionKey3, temp, 0, outputBuffer, outputOffset);
 
             return this.BlockSize;
         }
@@ -74,9 +101,11 @@ namespace Renci.SshNet.Security.Cryptography
             if ((outputOffset + this.BlockSize) > outputBuffer.Length)
                 throw new IndexOutOfRangeException("output buffer too short");
 
-            DesCipher.DesFunc(this.DecryptionKey, inputBuffer, inputOffset, this._pass1, 0);
-            DesCipher.DesFunc(this.DecryptionKey, this._pass1, 0, this._pass2, 0);
-            DesCipher.DesFunc(this.DecryptionKey, this._pass2, 0, outputBuffer, outputOffset);
+            byte[] temp = new byte[this.BlockSize];
+
+            DesCipher.DesFunc(this._decryptionKey3, inputBuffer, inputOffset, temp, 0);
+            DesCipher.DesFunc(this._decryptionKey2, temp, 0, temp, 0);
+            DesCipher.DesFunc(this._decryptionKey1, temp, 0, outputBuffer, outputOffset);
 
             return this.BlockSize;
         }

+ 0 - 90
Renci.SshClient/Renci.SshNet/Security/Cryptography/Des.cs

@@ -1,90 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    //  TODO:   Des algorithm is not tested yet but fully implemented
-    /// <summary>
-    /// Represents the class for the DES algorithm.
-    /// </summary>
-    public class Des : SymmetricAlgorithm
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Des"/> class.
-        /// </summary>
-        public Des()
-        {
-            this.KeySizeValue = 64;
-            this.BlockSizeValue = 64;
-            this.FeedbackSizeValue = BlockSizeValue;
-            this.LegalBlockSizesValue = new KeySizes[] { new KeySizes(64, 64, 0) };
-            this.LegalKeySizesValue = new KeySizes[] { new KeySizes(64, 64, 0) };
-        }
-
-        /// <summary>
-        /// Creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric decryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-            
-            return new CipherTransform(TransformMode.Decrypt, this.GetBlockCipher(new DesCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric encryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-            
-            return new CipherTransform(TransformMode.Encrypt, this.GetBlockCipher(new DesCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Generates a random initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateIV()
-        {
-            var random = new Random();
-            this.KeyValue = new byte[this.KeySizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        /// <summary>
-        /// Generates a random key (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateKey()
-        {
-            var random = new Random();
-            this.IVValue = new byte[this.BlockSizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        private ModeBase GetBlockCipher(CipherBase cipher)
-        {
-            switch (this.Mode)
-            {
-                case CipherMode.CBC:
-                    return new CbcMode(cipher);
-                default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Mode '{0}' is not supported.", this.Mode));
-            }
-        }
-
-    }
-}

+ 0 - 122
Renci.SshClient/Renci.SshNet/Security/Cryptography/Serpent.cs

@@ -1,122 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    //  TODO:   Serpent algorithm is not tested yet but fully implemented
-    /// <summary>
-    /// Represents the class for the Serpent algorithm.
-    /// </summary>
-    public class Serpent : SymmetricAlgorithm
-    {
-        private CipherMode _mode;
-        /// <summary>
-        /// Gets or sets the mode for operation of the symmetric algorithm.
-        /// </summary>
-        /// <returns>The mode for operation of the symmetric algorithm. The default is <see cref="F:System.Security.Cryptography.CipherMode.CBC"/>.</returns>
-        ///   
-        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The cipher mode is not one of the <see cref="T:System.Security.Cryptography.CipherMode"/> values. </exception>
-        public override CipherMode Mode
-        {
-            get
-            {
-                return this._mode;
-            }
-            set
-            {
-                this._mode = value;
-            }
-        }
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Serpent"/> class.
-        /// </summary>
-        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The implementation of the class derived from the symmetric algorithm is not valid.</exception>
-        public Serpent()
-            : this(256)
-        {
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="Serpent"/> class.
-        /// </summary>
-        /// <param name="keySize">Size of the key.</param>
-        public Serpent(int keySize)
-        {
-            this.KeySizeValue = keySize;
-            this.BlockSizeValue = 128;
-            this.FeedbackSizeValue = BlockSizeValue;
-            this.LegalBlockSizesValue = new KeySizes[] { new KeySizes(128, 128, 0) };
-            this.LegalKeySizesValue = new KeySizes[] { new KeySizes(128, 256, 64) };
-        }
-
-        /// <summary>
-        /// Creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric decryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Decrypt, this.GetBlockCipher(new SerpentCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric encryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Encrypt, this.GetBlockCipher(new SerpentCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Generates a random initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateIV()
-        {
-            var random = new Random();
-            this.KeyValue = new byte[this.KeySizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        /// <summary>
-        /// Generates a random key (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateKey()
-        {
-            var random = new Random();
-            this.IVValue = new byte[this.BlockSizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        private ModeBase GetBlockCipher(CipherBase cipher)
-        {
-            switch (this.Mode)
-            {
-                case CipherMode.CBC:
-                    return new CbcMode(cipher);
-                case CipherMode.CFB:
-                    return new CfbMode(cipher);
-                case (CipherMode)CipherModeEx.CTR:
-                    return new CtrMode(cipher);
-                default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Mode '{0}' is not supported.", this.Mode));
-            }
-        }
-    }
-
-}

+ 0 - 22
Renci.SshClient/Renci.SshNet/Security/Cryptography/TransformMode.cs

@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    /// <summary>
-    /// Specifies transformation modes
-    /// </summary>
-    public enum TransformMode
-    {
-        /// <summary>
-        /// Specifies encryption mode
-        /// </summary>
-        Encrypt = 0,
-        /// <summary>
-        /// Specifies decryption mode
-        /// </summary>
-        Decrypt = 1
-    }
-}

+ 0 - 100
Renci.SshClient/Renci.SshNet/Security/Cryptography/TripleDes.cs

@@ -1,100 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Security.Cryptography;
-using System.Globalization;
-
-namespace Renci.SshNet.Security.Cryptography
-{
-    //  TODO:   TripleDes algorithm is not tested yet but fully implemented
-    /// <summary>
-    /// 
-    /// </summary>
-    public class TripleDes : SymmetricAlgorithm
-    {
-        /// <summary>
-        /// Initializes a new instance of the <see cref="TripleDes"/> class.
-        /// </summary>
-        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The implementation of the class derived from the symmetric algorithm is not valid.</exception>
-        public TripleDes()
-            : this(256)
-        {
-        }
-
-        /// <summary>
-        /// Initializes a new instance of the <see cref="TripleDes"/> class.
-        /// </summary>
-        /// <param name="keySize">Size of the key.</param>
-        public TripleDes(int keySize)
-        {
-            this.KeySizeValue = keySize;
-            this.BlockSizeValue = 128;
-            this.FeedbackSizeValue = BlockSizeValue;
-            this.LegalBlockSizesValue = new KeySizes[] { new KeySizes(128, 256, 64) };
-            this.LegalKeySizesValue = new KeySizes[] { new KeySizes(128, 256, 64) };
-        }
-
-        /// <summary>
-        /// Creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric decryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Decrypt, this.GetBlockCipher(new TripleDesCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/> property and initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>).
-        /// </summary>
-        /// <param name="rgbKey">The secret key to use for the symmetric algorithm.</param>
-        /// <param name="rgbIV">The initialization vector to use for the symmetric algorithm.</param>
-        /// <returns>
-        /// A symmetric encryptor object.
-        /// </returns>
-        public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
-        {
-            base.ValidKeySize(rgbKey.Length * 8);
-
-            return new CipherTransform(TransformMode.Encrypt, this.GetBlockCipher(new TripleDesCipher(rgbKey, rgbIV)));
-        }
-
-        /// <summary>
-        /// Generates a random initialization vector (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateIV()
-        {
-            var random = new Random();
-            this.KeyValue = new byte[this.KeySizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        /// <summary>
-        /// Generates a random key (<see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key"/>) to use for the algorithm.
-        /// </summary>
-        public override void GenerateKey()
-        {
-            var random = new Random();
-            this.IVValue = new byte[this.BlockSizeValue / 8];
-            random.NextBytes(this.KeyValue);
-        }
-
-        private ModeBase GetBlockCipher(CipherBase cipher)
-        {
-            switch (this.Mode)
-            {
-                case CipherMode.CBC:
-                    return new CbcMode(cipher);
-                default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Mode '{0}' is not supported.", this.Mode));
-            }
-        }
-
-    }
-}

+ 0 - 24
Renci.SshClient/Renci.SshNet/Session.cs

@@ -1112,18 +1112,6 @@ namespace Renci.SshNet
             }
 
             //  Dispose of old ciphers and hash algorithms
-            if (this._serverCipher != null)
-            {
-                this._serverCipher.Dispose();
-                this._serverCipher = null;
-            }
-
-            if (this._clientCipher != null)
-            {
-                this._clientCipher.Dispose();
-                this._clientCipher = null;
-            }
-
             if (this._serverMac != null)
             {
                 this._serverMac.Dispose();
@@ -1592,18 +1580,6 @@ namespace Renci.SshNet
                         this._keyExchangeCompletedWaitHandle = null;
                     }
 
-                    if (this._serverCipher != null)
-                    {
-                        this._serverCipher.Dispose();
-                        this._serverCipher = null;
-                    }
-
-                    if (this._clientCipher != null)
-                    {
-                        this._clientCipher.Dispose();
-                        this._clientCipher = null;
-                    }
-
                     if (this._serverMac != null)
                     {
                         this._serverMac.Dispose();

+ 14 - 14
Renci.SshClient/Renci.SshNet/SftpClient.cs

@@ -129,7 +129,7 @@ namespace Renci.SshNet
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="SftpPermissionDeniedException">Permission to change directory denied by remote host -or- a SSH command was denied by the server.</exception>
         /// <exception cref="SftpPathNotFoundException">The path in <paramref name="path"/> was not found on the remote host.</exception>
-        /// <exception cref="SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void ChangeDirectory(string path)
         {
             if (path == null)
@@ -150,7 +150,7 @@ namespace Renci.SshNet
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="SftpPermissionDeniedException">Permission to change permission on the path(s) was denied by the remote host -or- a SSH command was denied by the server.</exception>
         /// <exception cref="SftpPathNotFoundException">The path in <paramref name="path"/> was not found on the remote host.</exception>
-        /// <exception cref="SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void ChangePermissions(string path, short mode)
         {
             var file = this.Get(path);
@@ -165,7 +165,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to create the directory was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void CreateDirectory(string path)
         {
             if (string.IsNullOrWhiteSpace(path))
@@ -186,7 +186,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to delete the directory was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void DeleteDirectory(string path)
         {
             if (string.IsNullOrWhiteSpace(path))
@@ -207,7 +207,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to delete the file was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void DeleteFile(string path)
         {
             if (string.IsNullOrWhiteSpace(path))
@@ -229,7 +229,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentNullException"><paramref name="oldPath"/> or <paramref name="newPath"/> is null.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to rename the file was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void RenameFile(string oldPath, string newPath)
         {
             if (oldPath == null)
@@ -253,10 +253,10 @@ namespace Renci.SshNet
         /// </summary>
         /// <param name="path">The old path.</param>
         /// <param name="linkPath">The new path.</param>
-        /// <exception cref="ArgumentException"><paramref name="path"/> or <paramref name="linkedpath"/> is null or contains whitespace characters.</exception>
+        /// <exception cref="ArgumentException"><paramref name="path"/> or <paramref name="linkPath"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to create the symbolic link was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public void SymbolicLink(string path, string linkPath)
         {
             if (string.IsNullOrWhiteSpace(path))
@@ -283,7 +283,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to list the contents of the directory was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public IEnumerable<SftpFile> ListDirectory(string path)
         {
             return InternalListDirectory(path, null);
@@ -366,7 +366,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to perform the operation was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         public bool Exists(string path)
         {
             if (string.IsNullOrWhiteSpace(path))
@@ -405,7 +405,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to perform the operation was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         /// <remarks>Method calls made by this method to <paramref name="output"/>, may under certain conditions result in exceptions thrown by the stream.</remarks>
         public void DownloadFile(string path, Stream output)
         {
@@ -424,7 +424,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to perform the operation was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         /// <remarks>Method calls made by this method to <paramref name="output"/>, may under certain conditions result in exceptions thrown by the stream.</remarks>
         public IAsyncResult BeginDownloadFile(string path, Stream output, AsyncCallback asyncCallback, object state)
         {
@@ -481,7 +481,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to upload the file was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         /// <remarks>Method calls made by this method to <paramref name="input"/>, may under certain conditions result in exceptions thrown by the stream.</remarks>
         public void UploadFile(Stream input, string path)
         {
@@ -500,7 +500,7 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentException"><paramref name="path"/> is null or contains whitespace characters.</exception>
         /// <exception cref="SshConnectionException">Client is not connected.</exception>
         /// <exception cref="Renci.SshNet.Common.SftpPermissionDeniedException">Permission to list the contents of the directory was denied by the remote host -or- a SSH command was denied by the server.</exception>
-        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="SshException.Message"/> is the message from the remote host.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshException">A SSH error where <see cref="P:SshException.Message"/> is the message from the remote host.</exception>
         /// <remarks>Method calls made by this method to <paramref name="input"/>, may under certain conditions result in exceptions thrown by the stream.</remarks>
         public IAsyncResult BeginUploadFile(Stream input, string path, AsyncCallback asyncCallback, object state)
         {

+ 6 - 6
Renci.SshClient/Renci.SshNet/SshClient.cs

@@ -124,9 +124,9 @@ namespace Renci.SshNet
         /// <exception cref="ArgumentNullException"><paramref name="boundHost"/> or <paramref name="connectedHost"/> is null.</exception>
         /// <exception cref="ArgumentException"><paramref name="boundHost"/> or <paramref name="connectedHost"/> is invalid.</exception>
         /// <exception cref="ArgumentOutOfRangeException"><paramref name="boundPort"/> or <paramref name="connectedPort"/> is not within <see cref="System.Net.IPEndPoint.MinPort"/> and <see cref="System.Net.IPEndPoint.MaxPort"/>.</exception>
-        /// <exception cref="SshConnectionException">Client is not connected.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshConnectionException">Client is not connected.</exception>
         public T AddForwardedPort<T>(string boundHost, uint boundPort, string connectedHost, uint connectedPort) where T : ForwardedPort, new()
-        {
+        {            
             if (boundHost == null)
                 throw new ArgumentNullException("boundHost");
 
@@ -169,12 +169,12 @@ namespace Renci.SshNet
         /// <param name="connectedHost">The connected host.</param>
         /// <param name="connectedPort">The connected port.</param>
         /// <returns></returns>
-        /// <exception cref="ArgumentNullException"><paramref name="boundHost"/> or <paramref name="connectedHost"/> is null.</exception>
-        /// <exception cref="ArgumentException"><paramref name="boundHost"/> or <paramref name="connectedHost"/> is invalid.</exception>
+        /// <exception cref="ArgumentNullException"><paramref name="connectedHost"/> is null.</exception>
+        /// <exception cref="ArgumentException"><paramref name="boundPort"/>, <paramref name="connectedPort"/> or <paramref name="connectedHost"/> is invalid.</exception>
         /// <exception cref="ArgumentOutOfRangeException"><paramref name="boundPort"/> or <paramref name="connectedPort"/> is not within <see cref="System.Net.IPEndPoint.MinPort"/> and <see cref="System.Net.IPEndPoint.MaxPort"/>.</exception>
-        /// <exception cref="SshConnectionException">Client is not connected.</exception>
+        /// <exception cref="Renci.SshNet.Common.SshConnectionException">Client is not connected.</exception>
         public T AddForwardedPort<T>(uint boundPort, string connectedHost, uint connectedPort) where T : ForwardedPort, new()
-        {
+        {            
             return this.AddForwardedPort<T>("localhost", boundPort, connectedHost, connectedPort);
         }
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است