Pārlūkot izejas kodu

Remove this qualifier.

drieseng 9 gadi atpakaļ
vecāks
revīzija
06b5128916
26 mainītis faili ar 969 papildinājumiem un 997 dzēšanām
  1. 1 1
      src/Renci.SshNet/MessageEventArgs.cs
  2. 12 12
      src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs
  3. 23 23
      src/Renci.SshNet/Security/Cryptography/Ciphers/Arc4Cipher.cs
  4. 30 34
      src/Renci.SshNet/Security/Cryptography/Ciphers/BlowfishCipher.cs
  5. 58 61
      src/Renci.SshNet/Security/Cryptography/Ciphers/CastCipher.cs
  6. 4 4
      src/Renci.SshNet/Security/Cryptography/Ciphers/CipherMode.cs
  7. 22 27
      src/Renci.SshNet/Security/Cryptography/Ciphers/DesCipher.cs
  8. 18 19
      src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/CbcCipherMode.cs
  9. 21 21
      src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/CfbCipherMode.cs
  10. 21 21
      src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/CtrCipherMode.cs
  11. 21 23
      src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/OfbCipherMode.cs
  12. 16 16
      src/Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs
  13. 469 468
      src/Renci.SshNet/Security/Cryptography/Ciphers/SerpentCipher.cs
  14. 33 38
      src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs
  15. 30 33
      src/Renci.SshNet/Security/Cryptography/Ciphers/TwofishCipher.cs
  16. 27 27
      src/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs
  17. 24 24
      src/Renci.SshNet/Security/Cryptography/DsaKey.cs
  18. 10 16
      src/Renci.SshNet/Security/Cryptography/RsaDigitalSignature.cs
  19. 35 35
      src/Renci.SshNet/Security/Cryptography/RsaKey.cs
  20. 1 1
      src/Renci.SshNet/Security/Cryptography/SymmetricCipher.cs
  21. 16 16
      src/Renci.SshNet/Security/GroupExchangeHashData.cs
  22. 1 1
      src/Renci.SshNet/Security/HostAlgorithm.cs
  23. 44 44
      src/Renci.SshNet/Security/KeyExchange.cs
  24. 17 17
      src/Renci.SshNet/Security/KeyExchangeDiffieHellman.cs
  25. 1 1
      src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeShaBase.cs
  26. 14 14
      src/Renci.SshNet/Security/KeyHostAlgorithm.cs

+ 1 - 1
src/Renci.SshNet/MessageEventArgs.cs

@@ -23,7 +23,7 @@ namespace Renci.SshNet
             if (message == null)
                 throw new ArgumentNullException("message");
 
-            this.Message = message;
+            Message = message;
         }
     }
 }

+ 12 - 12
src/Renci.SshNet/Security/Cryptography/Ciphers/AesCipher.cs

@@ -603,18 +603,18 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                 throw new IndexOutOfRangeException("output buffer too short");
             }
 
-            if (this._encryptionKey == null)
+            if (_encryptionKey == null)
             {
-                this._encryptionKey = this.GenerateWorkingKey(true, this.Key);
+                _encryptionKey = GenerateWorkingKey(true, Key);
             }
 
-            this.UnPackBlock(inputBuffer, inputOffset);
+            UnPackBlock(inputBuffer, inputOffset);
 
-            this.EncryptBlock(this._encryptionKey);
+            EncryptBlock(_encryptionKey);
 
-            this.PackBlock(outputBuffer, outputOffset);
+            PackBlock(outputBuffer, outputOffset);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         /// <summary>
@@ -648,18 +648,18 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                 throw new IndexOutOfRangeException("output buffer too short");
             }
 
-            if (this._decryptionKey == null)
+            if (_decryptionKey == null)
             {
-                this._decryptionKey = this.GenerateWorkingKey(false, this.Key);
+                _decryptionKey = GenerateWorkingKey(false, Key);
             }
 
-            this.UnPackBlock(inputBuffer, inputOffset);
+            UnPackBlock(inputBuffer, inputOffset);
 
-            this.DecryptBlock(this._decryptionKey);
+            DecryptBlock(_decryptionKey);
 
-            this.PackBlock(outputBuffer, outputOffset);
+            PackBlock(outputBuffer, outputOffset);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         private uint[] GenerateWorkingKey(bool isEncryption, byte[] key)

+ 23 - 23
src/Renci.SshNet/Security/Cryptography/Ciphers/Arc4Cipher.cs

@@ -40,14 +40,14 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         public Arc4Cipher(byte[] key, bool dischargeFirstBytes)
             : base(key)
         {
-            this._workingKey = key;
-            SetKey(this._workingKey);
+            _workingKey = key;
+            SetKey(_workingKey);
             //   The first 1536 bytes of keystream
             //   generated by the cipher MUST be discarded, and the first byte of the
             //   first encrypted packet MUST be encrypted using the 1537th byte of
             //   keystream.
             if (dischargeFirstBytes)
-                this.Encrypt(new byte[1536]);
+                Encrypt(new byte[1536]);
         }
 
         /// <summary>
@@ -63,7 +63,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// </returns>
         public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            return this.ProcessBytes(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+            return ProcessBytes(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
         }
 
         /// <summary>
@@ -79,7 +79,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            return this.ProcessBytes(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+            return ProcessBytes(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
         }
 
         /// <summary>
@@ -94,7 +94,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         public override byte[] Encrypt(byte[] input, int offset, int length)
         {
             var output = new byte[length];
-            this.ProcessBytes(input, offset, length, output, 0);
+            ProcessBytes(input, offset, length, output, 0);
             return output;
         }
 
@@ -108,7 +108,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         public override byte[] Decrypt(byte[] input)
         {
             var output = new byte[input.Length];
-            this.ProcessBytes(input, 0, input.Length, output, 0);
+            ProcessBytes(input, 0, input.Length, output, 0);
             return output;
         }
 
@@ -126,36 +126,36 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
             for (int i = 0; i < inputCount; i++)
             {
-                this._x = (this._x + 1) & 0xff;
-                this._y = (this._engineState[this._x] + this._y) & 0xff;
+                _x = (_x + 1) & 0xff;
+                _y = (_engineState[_x] + _y) & 0xff;
 
                 // swap
-                byte tmp = this._engineState[this._x];
-                this._engineState[this._x] = this._engineState[this._y];
-                this._engineState[this._y] = tmp;
+                byte tmp = _engineState[_x];
+                _engineState[_x] = _engineState[_y];
+                _engineState[_y] = tmp;
 
                 // xor
-                outputBuffer[i + outputOffset] = (byte)(inputBuffer[i + inputOffset] ^ this._engineState[(this._engineState[this._x] + this._engineState[this._y]) & 0xff]);
+                outputBuffer[i + outputOffset] = (byte)(inputBuffer[i + inputOffset] ^ _engineState[(_engineState[_x] + _engineState[_y]) & 0xff]);
             }
             return inputCount;
         }
 
         private void SetKey(byte[] keyBytes)
         {
-            this._workingKey = keyBytes;
+            _workingKey = keyBytes;
 
-            this._x = 0;
-            this._y = 0;
+            _x = 0;
+            _y = 0;
 
-            if (this._engineState == null)
+            if (_engineState == null)
             {
-                this._engineState = new byte[STATE_LENGTH];
+                _engineState = new byte[STATE_LENGTH];
             }
 
             // reset the state of the engine
             for (var i = 0; i < STATE_LENGTH; i++)
             {
-                this._engineState[i] = (byte) i;
+                _engineState[i] = (byte) i;
             }
 
             int i1 = 0;
@@ -163,11 +163,11 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
             for (var i = 0; i < STATE_LENGTH; i++)
             {
-                i2 = ((keyBytes[i1] & 0xff) + this._engineState[i] + i2) & 0xff;
+                i2 = ((keyBytes[i1] & 0xff) + _engineState[i] + i2) & 0xff;
                 // do the byte-swap inline
-                byte tmp = this._engineState[i];
-                this._engineState[i] = this._engineState[i2];
-                this._engineState[i2] = tmp;
+                byte tmp = _engineState[i];
+                _engineState[i] = _engineState[i2];
+                _engineState[i2] = tmp;
                 i1 = (i1 + 1) % keyBytes.Length;
             }
         }

+ 30 - 34
src/Renci.SshNet/Security/Cryptography/Ciphers/BlowfishCipher.cs

@@ -320,17 +320,13 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 			if (keySize < 1 || keySize > 448)
 				throw new ArgumentException(string.Format("KeySize '{0}' is not valid for this algorithm.", keySize));
 
-			this._s0 = new uint[_sboxSk];
+			_s0 = new uint[_sboxSk];
+			_s1 = new uint[_sboxSk];
+			_s2 = new uint[_sboxSk];
+			_s3 = new uint[_sboxSk];
+			_p = new uint[_pSize];
 
-			this._s1 = new uint[_sboxSk];
-
-			this._s2 = new uint[_sboxSk];
-
-			this._s3 = new uint[_sboxSk];
-
-			this._p = new uint[_pSize];
-
-			this.SetKey(key);
+			SetKey(key);
 		}
 
 		/// <summary>
@@ -346,26 +342,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 		/// </returns>
 		public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
 		{
-			if (inputCount != this.BlockSize)
+			if (inputCount != BlockSize)
 				throw new ArgumentException("inputCount");
 
 			uint xl = BigEndianToUInt32(inputBuffer, inputOffset);
 			uint xr = BigEndianToUInt32(inputBuffer, inputOffset + 4);
 
-			xl ^= this._p[0];
+			xl ^= _p[0];
 
 			for (int i = 1; i < _rounds; i += 2)
 			{
-				xr ^= F(xl) ^ this._p[i];
-				xl ^= F(xr) ^ this._p[i + 1];
+				xr ^= F(xl) ^ _p[i];
+				xl ^= F(xr) ^ _p[i + 1];
 			}
 
-			xr ^= this._p[_rounds + 1];
+			xr ^= _p[_rounds + 1];
 
 			UInt32ToBigEndian(xr, outputBuffer, outputOffset);
 			UInt32ToBigEndian(xl, outputBuffer, outputOffset + 4);
 
-			return this.BlockSize;
+			return BlockSize;
 		}
 
 		/// <summary>
@@ -381,31 +377,31 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 		/// </returns>
 		public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
 		{
-			if (inputCount != this.BlockSize)
+			if (inputCount != BlockSize)
 				throw new ArgumentException("inputCount");
 
 			uint xl = BigEndianToUInt32(inputBuffer, inputOffset);
 			uint xr = BigEndianToUInt32(inputBuffer, inputOffset + 4);
 
-			xl ^= this._p[_rounds + 1];
+			xl ^= _p[_rounds + 1];
 
 			for (int i = _rounds; i > 0; i -= 2)
 			{
-				xr ^= F(xl) ^ this._p[i];
-				xl ^= F(xr) ^ this._p[i - 1];
+				xr ^= F(xl) ^ _p[i];
+				xl ^= F(xr) ^ _p[i - 1];
 			}
 
-			xr ^= this._p[0];
+			xr ^= _p[0];
 
 			UInt32ToBigEndian(xr, outputBuffer, outputOffset);
 			UInt32ToBigEndian(xl, outputBuffer, outputOffset + 4);
 
-			return this.BlockSize;
+			return BlockSize;
 		}
 
 		private uint F(uint x)
 		{
-			return (((this._s0[x >> 24] + this._s1[(x >> 16) & 0xff]) ^ this._s2[(x >> 8) & 0xff]) + this._s3[x & 0xff]);
+			return (((_s0[x >> 24] + _s1[(x >> 16) & 0xff]) ^ _s2[(x >> 8) & 0xff]) + _s3[x & 0xff]);
 		}
 
 		private void SetKey(byte[] key)
@@ -419,12 +415,12 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 			* Initialise the S-boxes and the P-array, with a fixed string
 			* This string contains the hexadecimal digits of pi (3.141...)
 			*/
-			Buffer.BlockCopy(KS0, 0, this._s0, 0, _sboxSk * sizeof(uint));
-			Buffer.BlockCopy(KS1, 0, this._s1, 0, _sboxSk * sizeof(uint));
-			Buffer.BlockCopy(KS2, 0, this._s2, 0, _sboxSk * sizeof(uint));
-			Buffer.BlockCopy(KS3, 0, this._s3, 0, _sboxSk * sizeof(uint));
+			Buffer.BlockCopy(KS0, 0, _s0, 0, _sboxSk * sizeof(uint));
+			Buffer.BlockCopy(KS1, 0, _s1, 0, _sboxSk * sizeof(uint));
+			Buffer.BlockCopy(KS2, 0, _s2, 0, _sboxSk * sizeof(uint));
+			Buffer.BlockCopy(KS3, 0, _s3, 0, _sboxSk * sizeof(uint));
 
-			Buffer.BlockCopy(KP, 0, this._p, 0, _pSize * sizeof(uint));
+			Buffer.BlockCopy(KP, 0, _p, 0, _pSize * sizeof(uint));
 
 			/*
 			* (2)
@@ -452,7 +448,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 					}
 				}
 				// XOR the newly created 32 bit chunk onto the P-array
-				this._p[i] ^= data;
+				_p[i] ^= data;
 			}
 
 			/*
@@ -476,11 +472,11 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 			* continuously changing Blowfish algorithm
 			*/
 
-			ProcessTable(0, 0, this._p);
-			ProcessTable(this._p[_pSize - 2], this._p[_pSize - 1], this._s0);
-			ProcessTable(this._s0[_sboxSk - 2], this._s0[_sboxSk - 1], this._s1);
-			ProcessTable(this._s1[_sboxSk - 2], this._s1[_sboxSk - 1], this._s2);
-			ProcessTable(this._s2[_sboxSk - 2], this._s2[_sboxSk - 1], this._s3);
+			ProcessTable(0, 0, _p);
+			ProcessTable(_p[_pSize - 2], _p[_pSize - 1], _s0);
+			ProcessTable(_s0[_sboxSk - 2], _s0[_sboxSk - 1], _s1);
+			ProcessTable(_s1[_sboxSk - 2], _s1[_sboxSk - 1], _s2);
+			ProcessTable(_s2[_sboxSk - 2], _s2[_sboxSk - 1], _s3);
 		}
 
 		/// <summary>

+ 58 - 61
src/Renci.SshNet/Security/Cryptography/Ciphers/CastCipher.cs

@@ -39,7 +39,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             if (!(keySize >= 40 && keySize <= 128 && keySize % 8 == 0))
                 throw new ArgumentException(string.Format("KeySize '{0}' is not valid for this algorithm.", keySize));
 
-            this.SetKey(key);
+            SetKey(key);
         }
 
         /// <summary>
@@ -63,13 +63,13 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             uint R0 = BigEndianToUInt32(inputBuffer, inputOffset + 4);
 
             uint[] result = new uint[2];
-            this.CastEncipher(L0, R0, result);
+            CastEncipher(L0, R0, result);
 
             // now stuff them into the destination block
             UInt32ToBigEndian(result[0], outputBuffer, outputOffset);
             UInt32ToBigEndian(result[1], outputBuffer, outputOffset + 4);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         /// <summary>
@@ -92,13 +92,13 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             uint R16 = BigEndianToUInt32(inputBuffer, inputOffset + 4);
 
             uint[] result = new uint[2];
-            this.CastDecipher(L16, R16, result);
+            CastDecipher(L16, R16, result);
 
             // now stuff them into the destination block
             UInt32ToBigEndian(result[0], outputBuffer, outputOffset);
             UInt32ToBigEndian(result[1], outputBuffer, outputOffset + 4);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         #region Static Definition Tables
@@ -403,14 +403,11 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
             if (key.Length < 11)
             {
-                this._rounds = RED_ROUNDS;
+                _rounds = RED_ROUNDS;
             }
 
-            int[] z = new int[16];
-            int[] x = new int[16];
-
-            uint z03, z47, z8B, zCF;
-            uint x03, x47, x8B, xCF;
+            var z = new int[16];
+            var x = new int[16];
 
             /* copy the key into x */
             for (int i = 0; i < key.Length; i++)
@@ -423,24 +420,24 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             * bytes from the input key I've already chosen the
             * correct int.
             */
-            x03 = IntsTo32bits(x, 0x0);
-            x47 = IntsTo32bits(x, 0x4);
-            x8B = IntsTo32bits(x, 0x8);
-            xCF = IntsTo32bits(x, 0xC);
+            var x03 = IntsTo32bits(x, 0x0);
+            var x47 = IntsTo32bits(x, 0x4);
+            var x8B = IntsTo32bits(x, 0x8);
+            var xCF = IntsTo32bits(x, 0xC);
 
-            z03 = x03 ^ S5[x[0xD]] ^ S6[x[0xF]] ^ S7[x[0xC]] ^ S8[x[0xE]] ^ S7[x[0x8]];
+            var z03 = x03 ^ S5[x[0xD]] ^ S6[x[0xF]] ^ S7[x[0xC]] ^ S8[x[0xE]] ^ S7[x[0x8]];
 
             Bits32ToInts(z03, z, 0x0);
-            z47 = x8B ^ S5[z[0x0]] ^ S6[z[0x2]] ^ S7[z[0x1]] ^ S8[z[0x3]] ^ S8[x[0xA]];
+            var z47 = x8B ^ S5[z[0x0]] ^ S6[z[0x2]] ^ S7[z[0x1]] ^ S8[z[0x3]] ^ S8[x[0xA]];
             Bits32ToInts(z47, z, 0x4);
-            z8B = xCF ^ S5[z[0x7]] ^ S6[z[0x6]] ^ S7[z[0x5]] ^ S8[z[0x4]] ^ S5[x[0x9]];
+            var z8B = xCF ^ S5[z[0x7]] ^ S6[z[0x6]] ^ S7[z[0x5]] ^ S8[z[0x4]] ^ S5[x[0x9]];
             Bits32ToInts(z8B, z, 0x8);
-            zCF = x47 ^ S5[z[0xA]] ^ S6[z[0x9]] ^ S7[z[0xB]] ^ S8[z[0x8]] ^ S6[x[0xB]];
+            var zCF = x47 ^ S5[z[0xA]] ^ S6[z[0x9]] ^ S7[z[0xB]] ^ S8[z[0x8]] ^ S6[x[0xB]];
             Bits32ToInts(zCF, z, 0xC);
-            this._km[1] = S5[z[0x8]] ^ S6[z[0x9]] ^ S7[z[0x7]] ^ S8[z[0x6]] ^ S5[z[0x2]];
-            this._km[2] = S5[z[0xA]] ^ S6[z[0xB]] ^ S7[z[0x5]] ^ S8[z[0x4]] ^ S6[z[0x6]];
-            this._km[3] = S5[z[0xC]] ^ S6[z[0xD]] ^ S7[z[0x3]] ^ S8[z[0x2]] ^ S7[z[0x9]];
-            this._km[4] = S5[z[0xE]] ^ S6[z[0xF]] ^ S7[z[0x1]] ^ S8[z[0x0]] ^ S8[z[0xC]];
+            _km[1] = S5[z[0x8]] ^ S6[z[0x9]] ^ S7[z[0x7]] ^ S8[z[0x6]] ^ S5[z[0x2]];
+            _km[2] = S5[z[0xA]] ^ S6[z[0xB]] ^ S7[z[0x5]] ^ S8[z[0x4]] ^ S6[z[0x6]];
+            _km[3] = S5[z[0xC]] ^ S6[z[0xD]] ^ S7[z[0x3]] ^ S8[z[0x2]] ^ S7[z[0x9]];
+            _km[4] = S5[z[0xE]] ^ S6[z[0xF]] ^ S7[z[0x1]] ^ S8[z[0x0]] ^ S8[z[0xC]];
 
             z03 = IntsTo32bits(z, 0x0);
             z47 = IntsTo32bits(z, 0x4);
@@ -454,10 +451,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(x8B, x, 0x8);
             xCF = zCF ^ S5[x[0xA]] ^ S6[x[0x9]] ^ S7[x[0xB]] ^ S8[x[0x8]] ^ S6[z[0x3]];
             Bits32ToInts(xCF, x, 0xC);
-            this._km[5] = S5[x[0x3]] ^ S6[x[0x2]] ^ S7[x[0xC]] ^ S8[x[0xD]] ^ S5[x[0x8]];
-            this._km[6] = S5[x[0x1]] ^ S6[x[0x0]] ^ S7[x[0xE]] ^ S8[x[0xF]] ^ S6[x[0xD]];
-            this._km[7] = S5[x[0x7]] ^ S6[x[0x6]] ^ S7[x[0x8]] ^ S8[x[0x9]] ^ S7[x[0x3]];
-            this._km[8] = S5[x[0x5]] ^ S6[x[0x4]] ^ S7[x[0xA]] ^ S8[x[0xB]] ^ S8[x[0x7]];
+            _km[5] = S5[x[0x3]] ^ S6[x[0x2]] ^ S7[x[0xC]] ^ S8[x[0xD]] ^ S5[x[0x8]];
+            _km[6] = S5[x[0x1]] ^ S6[x[0x0]] ^ S7[x[0xE]] ^ S8[x[0xF]] ^ S6[x[0xD]];
+            _km[7] = S5[x[0x7]] ^ S6[x[0x6]] ^ S7[x[0x8]] ^ S8[x[0x9]] ^ S7[x[0x3]];
+            _km[8] = S5[x[0x5]] ^ S6[x[0x4]] ^ S7[x[0xA]] ^ S8[x[0xB]] ^ S8[x[0x7]];
 
             x03 = IntsTo32bits(x, 0x0);
             x47 = IntsTo32bits(x, 0x4);
@@ -471,10 +468,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(z8B, z, 0x8);
             zCF = x47 ^ S5[z[0xA]] ^ S6[z[0x9]] ^ S7[z[0xB]] ^ S8[z[0x8]] ^ S6[x[0xB]];
             Bits32ToInts(zCF, z, 0xC);
-            this._km[9] = S5[z[0x3]] ^ S6[z[0x2]] ^ S7[z[0xC]] ^ S8[z[0xD]] ^ S5[z[0x9]];
-            this._km[10] = S5[z[0x1]] ^ S6[z[0x0]] ^ S7[z[0xE]] ^ S8[z[0xF]] ^ S6[z[0xc]];
-            this._km[11] = S5[z[0x7]] ^ S6[z[0x6]] ^ S7[z[0x8]] ^ S8[z[0x9]] ^ S7[z[0x2]];
-            this._km[12] = S5[z[0x5]] ^ S6[z[0x4]] ^ S7[z[0xA]] ^ S8[z[0xB]] ^ S8[z[0x6]];
+            _km[9] = S5[z[0x3]] ^ S6[z[0x2]] ^ S7[z[0xC]] ^ S8[z[0xD]] ^ S5[z[0x9]];
+            _km[10] = S5[z[0x1]] ^ S6[z[0x0]] ^ S7[z[0xE]] ^ S8[z[0xF]] ^ S6[z[0xc]];
+            _km[11] = S5[z[0x7]] ^ S6[z[0x6]] ^ S7[z[0x8]] ^ S8[z[0x9]] ^ S7[z[0x2]];
+            _km[12] = S5[z[0x5]] ^ S6[z[0x4]] ^ S7[z[0xA]] ^ S8[z[0xB]] ^ S8[z[0x6]];
 
             z03 = IntsTo32bits(z, 0x0);
             z47 = IntsTo32bits(z, 0x4);
@@ -488,10 +485,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(x8B, x, 0x8);
             xCF = zCF ^ S5[x[0xA]] ^ S6[x[0x9]] ^ S7[x[0xB]] ^ S8[x[0x8]] ^ S6[z[0x3]];
             Bits32ToInts(xCF, x, 0xC);
-            this._km[13] = S5[x[0x8]] ^ S6[x[0x9]] ^ S7[x[0x7]] ^ S8[x[0x6]] ^ S5[x[0x3]];
-            this._km[14] = S5[x[0xA]] ^ S6[x[0xB]] ^ S7[x[0x5]] ^ S8[x[0x4]] ^ S6[x[0x7]];
-            this._km[15] = S5[x[0xC]] ^ S6[x[0xD]] ^ S7[x[0x3]] ^ S8[x[0x2]] ^ S7[x[0x8]];
-            this._km[16] = S5[x[0xE]] ^ S6[x[0xF]] ^ S7[x[0x1]] ^ S8[x[0x0]] ^ S8[x[0xD]];
+            _km[13] = S5[x[0x8]] ^ S6[x[0x9]] ^ S7[x[0x7]] ^ S8[x[0x6]] ^ S5[x[0x3]];
+            _km[14] = S5[x[0xA]] ^ S6[x[0xB]] ^ S7[x[0x5]] ^ S8[x[0x4]] ^ S6[x[0x7]];
+            _km[15] = S5[x[0xC]] ^ S6[x[0xD]] ^ S7[x[0x3]] ^ S8[x[0x2]] ^ S7[x[0x8]];
+            _km[16] = S5[x[0xE]] ^ S6[x[0xF]] ^ S7[x[0x1]] ^ S8[x[0x0]] ^ S8[x[0xD]];
 
             x03 = IntsTo32bits(x, 0x0);
             x47 = IntsTo32bits(x, 0x4);
@@ -505,10 +502,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(z8B, z, 0x8);
             zCF = x47 ^ S5[z[0xA]] ^ S6[z[0x9]] ^ S7[z[0xB]] ^ S8[z[0x8]] ^ S6[x[0xB]];
             Bits32ToInts(zCF, z, 0xC);
-            this._kr[1] = (int)((S5[z[0x8]] ^ S6[z[0x9]] ^ S7[z[0x7]] ^ S8[z[0x6]] ^ S5[z[0x2]]) & 0x1f);
-            this._kr[2] = (int)((S5[z[0xA]] ^ S6[z[0xB]] ^ S7[z[0x5]] ^ S8[z[0x4]] ^ S6[z[0x6]]) & 0x1f);
-            this._kr[3] = (int)((S5[z[0xC]] ^ S6[z[0xD]] ^ S7[z[0x3]] ^ S8[z[0x2]] ^ S7[z[0x9]]) & 0x1f);
-            this._kr[4] = (int)((S5[z[0xE]] ^ S6[z[0xF]] ^ S7[z[0x1]] ^ S8[z[0x0]] ^ S8[z[0xC]]) & 0x1f);
+            _kr[1] = (int)((S5[z[0x8]] ^ S6[z[0x9]] ^ S7[z[0x7]] ^ S8[z[0x6]] ^ S5[z[0x2]]) & 0x1f);
+            _kr[2] = (int)((S5[z[0xA]] ^ S6[z[0xB]] ^ S7[z[0x5]] ^ S8[z[0x4]] ^ S6[z[0x6]]) & 0x1f);
+            _kr[3] = (int)((S5[z[0xC]] ^ S6[z[0xD]] ^ S7[z[0x3]] ^ S8[z[0x2]] ^ S7[z[0x9]]) & 0x1f);
+            _kr[4] = (int)((S5[z[0xE]] ^ S6[z[0xF]] ^ S7[z[0x1]] ^ S8[z[0x0]] ^ S8[z[0xC]]) & 0x1f);
 
             z03 = IntsTo32bits(z, 0x0);
             z47 = IntsTo32bits(z, 0x4);
@@ -522,10 +519,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(x8B, x, 0x8);
             xCF = zCF ^ S5[x[0xA]] ^ S6[x[0x9]] ^ S7[x[0xB]] ^ S8[x[0x8]] ^ S6[z[0x3]];
             Bits32ToInts(xCF, x, 0xC);
-            this._kr[5] = (int)((S5[x[0x3]] ^ S6[x[0x2]] ^ S7[x[0xC]] ^ S8[x[0xD]] ^ S5[x[0x8]]) & 0x1f);
-            this._kr[6] = (int)((S5[x[0x1]] ^ S6[x[0x0]] ^ S7[x[0xE]] ^ S8[x[0xF]] ^ S6[x[0xD]]) & 0x1f);
-            this._kr[7] = (int)((S5[x[0x7]] ^ S6[x[0x6]] ^ S7[x[0x8]] ^ S8[x[0x9]] ^ S7[x[0x3]]) & 0x1f);
-            this._kr[8] = (int)((S5[x[0x5]] ^ S6[x[0x4]] ^ S7[x[0xA]] ^ S8[x[0xB]] ^ S8[x[0x7]]) & 0x1f);
+            _kr[5] = (int)((S5[x[0x3]] ^ S6[x[0x2]] ^ S7[x[0xC]] ^ S8[x[0xD]] ^ S5[x[0x8]]) & 0x1f);
+            _kr[6] = (int)((S5[x[0x1]] ^ S6[x[0x0]] ^ S7[x[0xE]] ^ S8[x[0xF]] ^ S6[x[0xD]]) & 0x1f);
+            _kr[7] = (int)((S5[x[0x7]] ^ S6[x[0x6]] ^ S7[x[0x8]] ^ S8[x[0x9]] ^ S7[x[0x3]]) & 0x1f);
+            _kr[8] = (int)((S5[x[0x5]] ^ S6[x[0x4]] ^ S7[x[0xA]] ^ S8[x[0xB]] ^ S8[x[0x7]]) & 0x1f);
 
             x03 = IntsTo32bits(x, 0x0);
             x47 = IntsTo32bits(x, 0x4);
@@ -539,10 +536,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(z8B, z, 0x8);
             zCF = x47 ^ S5[z[0xA]] ^ S6[z[0x9]] ^ S7[z[0xB]] ^ S8[z[0x8]] ^ S6[x[0xB]];
             Bits32ToInts(zCF, z, 0xC);
-            this._kr[9] = (int)((S5[z[0x3]] ^ S6[z[0x2]] ^ S7[z[0xC]] ^ S8[z[0xD]] ^ S5[z[0x9]]) & 0x1f);
-            this._kr[10] = (int)((S5[z[0x1]] ^ S6[z[0x0]] ^ S7[z[0xE]] ^ S8[z[0xF]] ^ S6[z[0xc]]) & 0x1f);
-            this._kr[11] = (int)((S5[z[0x7]] ^ S6[z[0x6]] ^ S7[z[0x8]] ^ S8[z[0x9]] ^ S7[z[0x2]]) & 0x1f);
-            this._kr[12] = (int)((S5[z[0x5]] ^ S6[z[0x4]] ^ S7[z[0xA]] ^ S8[z[0xB]] ^ S8[z[0x6]]) & 0x1f);
+            _kr[9] = (int)((S5[z[0x3]] ^ S6[z[0x2]] ^ S7[z[0xC]] ^ S8[z[0xD]] ^ S5[z[0x9]]) & 0x1f);
+            _kr[10] = (int)((S5[z[0x1]] ^ S6[z[0x0]] ^ S7[z[0xE]] ^ S8[z[0xF]] ^ S6[z[0xc]]) & 0x1f);
+            _kr[11] = (int)((S5[z[0x7]] ^ S6[z[0x6]] ^ S7[z[0x8]] ^ S8[z[0x9]] ^ S7[z[0x2]]) & 0x1f);
+            _kr[12] = (int)((S5[z[0x5]] ^ S6[z[0x4]] ^ S7[z[0xA]] ^ S8[z[0xB]] ^ S8[z[0x6]]) & 0x1f);
 
             z03 = IntsTo32bits(z, 0x0);
             z47 = IntsTo32bits(z, 0x4);
@@ -556,10 +553,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToInts(x8B, x, 0x8);
             xCF = zCF ^ S5[x[0xA]] ^ S6[x[0x9]] ^ S7[x[0xB]] ^ S8[x[0x8]] ^ S6[z[0x3]];
             Bits32ToInts(xCF, x, 0xC);
-            this._kr[13] = (int)((S5[x[0x8]] ^ S6[x[0x9]] ^ S7[x[0x7]] ^ S8[x[0x6]] ^ S5[x[0x3]]) & 0x1f);
-            this._kr[14] = (int)((S5[x[0xA]] ^ S6[x[0xB]] ^ S7[x[0x5]] ^ S8[x[0x4]] ^ S6[x[0x7]]) & 0x1f);
-            this._kr[15] = (int)((S5[x[0xC]] ^ S6[x[0xD]] ^ S7[x[0x3]] ^ S8[x[0x2]] ^ S7[x[0x8]]) & 0x1f);
-            this._kr[16] = (int)((S5[x[0xE]] ^ S6[x[0xF]] ^ S7[x[0x1]] ^ S8[x[0x0]] ^ S8[x[0xD]]) & 0x1f);
+            _kr[13] = (int)((S5[x[0x8]] ^ S6[x[0x9]] ^ S7[x[0x7]] ^ S8[x[0x6]] ^ S5[x[0x3]]) & 0x1f);
+            _kr[14] = (int)((S5[x[0xA]] ^ S6[x[0xB]] ^ S7[x[0x5]] ^ S8[x[0x4]] ^ S6[x[0x7]]) & 0x1f);
+            _kr[15] = (int)((S5[x[0xC]] ^ S6[x[0xD]] ^ S7[x[0x3]] ^ S8[x[0x2]] ^ S7[x[0x8]]) & 0x1f);
+            _kr[16] = (int)((S5[x[0xE]] ^ S6[x[0xF]] ^ S7[x[0x1]] ^ S8[x[0x0]] ^ S8[x[0xD]]) & 0x1f);
         }
 
         /// <summary>
@@ -612,8 +609,8 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// <param name="result">The result.</param>
         private void CastEncipher(uint L0, uint R0, uint[] result)
         {
-            uint Lp = L0;        // the previous value, equiv to L[i-1]
-            uint Rp = R0;        // equivalent to R[i-1]
+            var Lp = L0;        // the previous value, equiv to L[i-1]
+            var Rp = R0;        // equivalent to R[i-1]
 
             /*
             * numbering consistent with paper to make
@@ -621,7 +618,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             */
             uint Li = L0, Ri = R0;
 
-            for (int i = 1; i <= this._rounds; i++)
+            for (int i = 1; i <= _rounds; i++)
             {
                 Lp = Li;
                 Rp = Ri;
@@ -635,21 +632,21 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                     case 10:
                     case 13:
                     case 16:
-                        Ri = Lp ^ F1(Rp, this._km[i], this._kr[i]);
+                        Ri = Lp ^ F1(Rp, _km[i], _kr[i]);
                         break;
                     case 2:
                     case 5:
                     case 8:
                     case 11:
                     case 14:
-                        Ri = Lp ^ F2(Rp, this._km[i], this._kr[i]);
+                        Ri = Lp ^ F2(Rp, _km[i], _kr[i]);
                         break;
                     case 3:
                     case 6:
                     case 9:
                     case 12:
                     case 15:
-                        Ri = Lp ^ F3(Rp, this._km[i], this._kr[i]);
+                        Ri = Lp ^ F3(Rp, _km[i], _kr[i]);
                         break;
                 }
             }
@@ -669,7 +666,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             */
             uint Li = L16, Ri = R16;
 
-            for (int i = this._rounds; i > 0; i--)
+            for (int i = _rounds; i > 0; i--)
             {
                 Lp = Li;
                 Rp = Ri;
@@ -683,21 +680,21 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                     case 10:
                     case 13:
                     case 16:
-                        Ri = Lp ^ F1(Rp, this._km[i], this._kr[i]);
+                        Ri = Lp ^ F1(Rp, _km[i], _kr[i]);
                         break;
                     case 2:
                     case 5:
                     case 8:
                     case 11:
                     case 14:
-                        Ri = Lp ^ F2(Rp, this._km[i], this._kr[i]);
+                        Ri = Lp ^ F2(Rp, _km[i], _kr[i]);
                         break;
                     case 3:
                     case 6:
                     case 9:
                     case 12:
                     case 15:
-                        Ri = Lp ^ F3(Rp, this._km[i], this._kr[i]);
+                        Ri = Lp ^ F3(Rp, _km[i], _kr[i]);
                         break;
                 }
             }

+ 4 - 4
src/Renci.SshNet/Security/Cryptography/Ciphers/CipherMode.cs

@@ -28,7 +28,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// <param name="iv">The iv.</param>
         protected CipherMode(byte[] iv)
         {
-            this.IV = iv;
+            IV = iv;
         }
 
         /// <summary>
@@ -37,9 +37,9 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// <param name="cipher">The cipher.</param>
         internal void Init(BlockCipher cipher)
         {
-            this.Cipher = cipher;
-            this._blockSize = cipher.BlockSize;
-            this.IV = this.IV.Take(this._blockSize).ToArray();
+            Cipher = cipher;
+            _blockSize = cipher.BlockSize;
+            IV = IV.Take(_blockSize).ToArray();
         }
 
         /// <summary>

+ 22 - 27
src/Renci.SshNet/Security/Cryptography/Ciphers/DesCipher.cs

@@ -240,20 +240,20 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 		/// </returns>
 		public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
 		{
-			if ((inputOffset + this.BlockSize) > inputBuffer.Length)
+			if ((inputOffset + BlockSize) > inputBuffer.Length)
 				throw new IndexOutOfRangeException("input buffer too short");
 
-			if ((outputOffset + this.BlockSize) > outputBuffer.Length)
+			if ((outputOffset + BlockSize) > outputBuffer.Length)
 				throw new IndexOutOfRangeException("output buffer too short");
 
-			if (this._encryptionKey == null)
+			if (_encryptionKey == null)
 			{
-				this._encryptionKey = GenerateWorkingKey(true, this.Key);
+				_encryptionKey = GenerateWorkingKey(true, Key);
 			}
 
-			DesFunc(this._encryptionKey, inputBuffer, inputOffset, outputBuffer, outputOffset);
+			DesFunc(_encryptionKey, inputBuffer, inputOffset, outputBuffer, outputOffset);
 
-			return this.BlockSize;
+			return BlockSize;
 		}
 
 		/// <summary>
@@ -269,20 +269,20 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 		/// </returns>
 		public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
 		{
-			if ((inputOffset + this.BlockSize) > inputBuffer.Length)
+			if ((inputOffset + BlockSize) > inputBuffer.Length)
 				throw new IndexOutOfRangeException("input buffer too short");
 
-			if ((outputOffset + this.BlockSize) > outputBuffer.Length)
+			if ((outputOffset + BlockSize) > outputBuffer.Length)
 				throw new IndexOutOfRangeException("output buffer too short");
 
-			if (this._decryptionKey == null)
+			if (_decryptionKey == null)
 			{
-				this._decryptionKey = GenerateWorkingKey(false, this.Key);
+				_decryptionKey = GenerateWorkingKey(false, Key);
 			}
 
-			DesFunc(this._decryptionKey, inputBuffer, inputOffset, outputBuffer, outputOffset);
+			DesFunc(_decryptionKey, inputBuffer, inputOffset, outputBuffer, outputOffset);
 
-			return this.BlockSize;
+			return BlockSize;
 		}
 
         /// <summary>
@@ -293,7 +293,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// <returns>Generated working key.</returns>
 		protected int[] GenerateWorkingKey(bool encrypting, byte[] key)
 		{
-			this.ValidateKey();
+			ValidateKey();
 
 			int[] newKey = new int[32];
 			bool[] pc1m = new bool[56];
@@ -308,7 +308,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
 			for (int i = 0; i < 16; i++)
 			{
-				int l, m, n;
+				int l, m;
 
 				if (encrypting)
 				{
@@ -319,7 +319,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 					m = (15 - i) << 1;
 				}
 
-				n = m + 1;
+				var n = m + 1;
 				newKey[m] = newKey[n] = 0;
 
 				for (int j = 0; j < 28; j++)
@@ -367,10 +367,8 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 			//
 			for (int i = 0; i != 32; i += 2)
 			{
-				int i1, i2;
-
-				i1 = newKey[i];
-				i2 = newKey[i + 1];
+			    var i1 = newKey[i];
+				var i2 = newKey[i + 1];
 
 				newKey[i] = (int)  ((uint)((i1 & 0x00fc0000) << 6) |
 									(uint)((i1 & 0x00000fc0) << 10) |
@@ -391,9 +389,9 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 		/// </summary>
 		protected virtual void ValidateKey()
 		{
-			var keySize = this.Key.Length * 8;
+			var keySize = Key.Length * 8;
 			
-			if (!(keySize == 64))
+			if (keySize != 64)
 				throw new ArgumentException(string.Format("KeySize '{0}' is not valid for this algorithm.", keySize));
 		}
 
@@ -409,9 +407,8 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 		{
 			uint left = BigEndianToUInt32(input, inOff);
 			uint right = BigEndianToUInt32(input, inOff + 4);
-			uint work;
 
-			work = ((left >> 4) ^ right) & 0x0f0f0f0f;
+		    var work = ((left >> 4) ^ right) & 0x0f0f0f0f;
 			right ^= work;
 			left ^= (work << 4);
 			work = ((left >> 16) ^ right) & 0x0000ffff;
@@ -431,11 +428,9 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
 			for (int round = 0; round < 8; round++)
 			{
-				uint fval;
-
-				work = (right << 28) | (right >> 4);
+			    work = (right << 28) | (right >> 4);
 				work ^= (uint)wKey[round * 4 + 0];
-				fval = SP7[work & 0x3f];
+				var fval = SP7[work & 0x3f];
 				fval |= SP5[(work >> 8) & 0x3f];
 				fval |= SP3[(work >> 16) & 0x3f];
 				fval |= SP1[(work >> 24) & 0x3f];

+ 18 - 19
src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/CbcCipherMode.cs

@@ -30,26 +30,25 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                this.IV[i] ^= inputBuffer[inputOffset + i];
+                IV[i] ^= inputBuffer[inputOffset + i];
             }
 
-            this.Cipher.EncryptBlock(this.IV, 0, inputCount, outputBuffer, outputOffset);
+            Cipher.EncryptBlock(IV, 0, inputCount, outputBuffer, outputOffset);
 
-            Buffer.BlockCopy(outputBuffer, outputOffset, this.IV, 0, this.IV.Length);
+            Buffer.BlockCopy(outputBuffer, outputOffset, IV, 0, IV.Length);
 
-
-            return this._blockSize;
+            return _blockSize;
         }
 
         /// <summary>
@@ -65,25 +64,25 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+            Cipher.DecryptBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] ^= this.IV[i];
+                outputBuffer[outputOffset + i] ^= IV[i];
             }
 
-            Buffer.BlockCopy(inputBuffer, inputOffset, this.IV, 0, this.IV.Length);
+            Buffer.BlockCopy(inputBuffer, inputOffset, IV, 0, IV.Length);
 
-            return this._blockSize;
+            return _blockSize;
         }
     }
 }

+ 21 - 21
src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/CfbCipherMode.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         public CfbCipherMode(byte[] iv)
             : base(iv)
         {
-            this._ivOutput = new byte[iv.Length];
+            _ivOutput = new byte[iv.Length];
         }
 
         /// <summary>
@@ -33,26 +33,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.EncryptBlock(this.IV, 0, this.IV.Length, this._ivOutput, 0);
+            Cipher.EncryptBlock(IV, 0, IV.Length, _ivOutput, 0);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] = (byte)(this._ivOutput[i] ^ inputBuffer[inputOffset + i]);
+                outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
             }
 
-            Buffer.BlockCopy(this.IV, this._blockSize, this.IV, 0, this.IV.Length - this._blockSize);
-            Buffer.BlockCopy(outputBuffer, outputOffset, this.IV, this.IV.Length - this._blockSize, this._blockSize);
+            Buffer.BlockCopy(IV, _blockSize, IV, 0, IV.Length - _blockSize);
+            Buffer.BlockCopy(outputBuffer, outputOffset, IV, IV.Length - _blockSize, _blockSize);
 
-            return this._blockSize;
+            return _blockSize;
         }
 
         /// <summary>
@@ -68,26 +68,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.EncryptBlock(this.IV, 0, this.IV.Length, this._ivOutput, 0);
+            Cipher.EncryptBlock(IV, 0, IV.Length, _ivOutput, 0);
 
-            Buffer.BlockCopy(this.IV, this._blockSize, this.IV, 0, this.IV.Length - this._blockSize);
-            Buffer.BlockCopy(inputBuffer, inputOffset, this.IV, this.IV.Length - this._blockSize, this._blockSize);
+            Buffer.BlockCopy(IV, _blockSize, IV, 0, IV.Length - _blockSize);
+            Buffer.BlockCopy(inputBuffer, inputOffset, IV, IV.Length - _blockSize, _blockSize);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] = (byte)(this._ivOutput[i] ^ inputBuffer[inputOffset + i]);
+                outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
             }
 
-            return this._blockSize;
+            return _blockSize;
         }
     }
 }

+ 21 - 21
src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/CtrCipherMode.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         public CtrCipherMode(byte[] iv)
             : base(iv)
         {
-            this._ivOutput = new byte[iv.Length];
+            _ivOutput = new byte[iv.Length];
         }
 
         /// <summary>
@@ -33,26 +33,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.EncryptBlock(this.IV, 0, this.IV.Length, this._ivOutput, 0);
+            Cipher.EncryptBlock(IV, 0, IV.Length, _ivOutput, 0);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] = (byte)(this._ivOutput[i] ^ inputBuffer[inputOffset + i]);
+                outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
             }
 
-            int j = this.IV.Length;
-            while (--j >= 0 && ++this.IV[j] == 0) ;
+            int j = IV.Length;
+            while (--j >= 0 && ++IV[j] == 0) ;
 
-            return this._blockSize;
+            return _blockSize;
         }
 
         /// <summary>
@@ -68,26 +68,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.EncryptBlock(this.IV, 0, this.IV.Length, this._ivOutput, 0);
+            Cipher.EncryptBlock(IV, 0, IV.Length, _ivOutput, 0);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] = (byte)(this._ivOutput[i] ^ inputBuffer[inputOffset + i]);
+                outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
             }
 
-            int j = this.IV.Length;
-            while (--j >= 0 && ++this.IV[j] == 0) ;
+            int j = IV.Length;
+            while (--j >= 0 && ++IV[j] == 0) ;
 
-            return this._blockSize;
+            return _blockSize;
         }
     }
 }

+ 21 - 23
src/Renci.SshNet/Security/Cryptography/Ciphers/Modes/OfbCipherMode.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         public OfbCipherMode(byte[] iv)
             : base(iv)
         {
-            this._ivOutput = new byte[iv.Length];
+            _ivOutput = new byte[iv.Length];
         }
 
         /// <summary>
@@ -33,26 +33,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.EncryptBlock(this.IV, 0, this.IV.Length, this._ivOutput, 0);
+            Cipher.EncryptBlock(IV, 0, IV.Length, _ivOutput, 0);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] = (byte)(this._ivOutput[i] ^ inputBuffer[inputOffset + i]);
+                outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
             }
 
-            Buffer.BlockCopy(this.IV, this._blockSize, this.IV, 0, this.IV.Length - this._blockSize);
-            Buffer.BlockCopy(outputBuffer, outputOffset, this.IV, this.IV.Length - this._blockSize, this._blockSize);
+            Buffer.BlockCopy(IV, _blockSize, IV, 0, IV.Length - _blockSize);
+            Buffer.BlockCopy(outputBuffer, outputOffset, IV, IV.Length - _blockSize, _blockSize);
 
-            return this._blockSize;
+            return _blockSize;
         }
 
         /// <summary>
@@ -68,28 +68,26 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers.Modes
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if (inputBuffer.Length - inputOffset < this._blockSize)
+            if (inputBuffer.Length - inputOffset < _blockSize)
                 throw new ArgumentException("Invalid input buffer");
 
-            if (outputBuffer.Length - outputOffset < this._blockSize)
+            if (outputBuffer.Length - outputOffset < _blockSize)
                 throw new ArgumentException("Invalid output buffer");
 
-            if (inputCount != this._blockSize)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", this._blockSize));
+            if (inputCount != _blockSize)
+                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "inputCount must be {0}.", _blockSize));
 
-            this.Cipher.EncryptBlock(this.IV, 0, this.IV.Length, this._ivOutput, 0);
+            Cipher.EncryptBlock(IV, 0, IV.Length, _ivOutput, 0);
 
-            for (int i = 0; i < this._blockSize; i++)
+            for (int i = 0; i < _blockSize; i++)
             {
-                outputBuffer[outputOffset + i] = (byte)(this._ivOutput[i] ^ inputBuffer[inputOffset + i]);
+                outputBuffer[outputOffset + i] = (byte)(_ivOutput[i] ^ inputBuffer[inputOffset + i]);
             }
 
-            Buffer.BlockCopy(this.IV, this._blockSize, this.IV, 0, this.IV.Length - this._blockSize);
-            Buffer.BlockCopy(outputBuffer, outputOffset, this.IV, this.IV.Length - this._blockSize, this._blockSize);
+            Buffer.BlockCopy(IV, _blockSize, IV, 0, IV.Length - _blockSize);
+            Buffer.BlockCopy(outputBuffer, outputOffset, IV, IV.Length - _blockSize, _blockSize);
 
-            return this._blockSize;
+            return _blockSize;
         }
-
-
     }
 }

+ 16 - 16
src/Renci.SshNet/Security/Cryptography/Ciphers/RsaCipher.cs

@@ -25,8 +25,8 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             if (key == null)
                 throw new ArgumentNullException("key");
 
-            this._key = key;
-            this._isPrivate = !this._key.D.IsZero;
+            _key = key;
+            _isPrivate = !_key.D.IsZero;
         }
 
         /// <summary>
@@ -39,7 +39,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         public override byte[] Encrypt(byte[] data, int offset, int length)
         {
             //  Calculate signature
-            var bitLength = this._key.Modulus.BitLength;
+            var bitLength = _key.Modulus.BitLength;
 
             var paddedBlock = new byte[bitLength / 8 + (bitLength % 8 > 0 ? 1 : 0) - 1];
 
@@ -51,7 +51,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
             Buffer.BlockCopy(data, offset, paddedBlock, paddedBlock.Length - length, length);
 
-            return this.Transform(paddedBlock);
+            return Transform(paddedBlock);
         }
 
         /// <summary>
@@ -65,7 +65,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// <exception cref="NotSupportedException">Thrown when decrypted block type is not supported.</exception>
         public override byte[] Decrypt(byte[] data)
         {
-            var paddedBlock = this.Transform(data);
+            var paddedBlock = Transform(data);
 
             if (paddedBlock[0] != 1 && paddedBlock[0] != 2)
                 throw new NotSupportedException("Only block type 01 or 02 are supported.");
@@ -99,13 +99,13 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
             BigInteger result;
 
-            if (this._isPrivate)
+            if (_isPrivate)
             {
                 BigInteger random = BigInteger.One;
 
-                var max = this._key.Modulus - 1;
+                var max = _key.Modulus - 1;
                 
-                var bitLength = this._key.Modulus.BitLength;
+                var bitLength = _key.Modulus.BitLength;
 
                 if (max < BigInteger.One)
                     throw new SshException("Invalid RSA key.");
@@ -115,25 +115,25 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                     random = BigInteger.Random(bitLength);
                 }
 
-                BigInteger blindedInput = BigInteger.PositiveMod((BigInteger.ModPow(random, this._key.Exponent, this._key.Modulus) * input), this._key.Modulus);
+                BigInteger blindedInput = BigInteger.PositiveMod((BigInteger.ModPow(random, _key.Exponent, _key.Modulus) * input), _key.Modulus);
 
                 // mP = ((input Mod p) ^ dP)) Mod p
-                var mP = BigInteger.ModPow((blindedInput % this._key.P), this._key.DP, this._key.P);
+                var mP = BigInteger.ModPow((blindedInput % _key.P), _key.DP, _key.P);
 
                 // mQ = ((input Mod q) ^ dQ)) Mod q
-                var mQ = BigInteger.ModPow((blindedInput % this._key.Q), this._key.DQ, this._key.Q);
+                var mQ = BigInteger.ModPow((blindedInput % _key.Q), _key.DQ, _key.Q);
 
-                var h = BigInteger.PositiveMod(((mP - mQ) * this._key.InverseQ), this._key.P);
+                var h = BigInteger.PositiveMod(((mP - mQ) * _key.InverseQ), _key.P);
 
-                var m = h * this._key.Q + mQ;
+                var m = h * _key.Q + mQ;
 
-                BigInteger rInv = BigInteger.ModInverse(random, this._key.Modulus);
+                BigInteger rInv = BigInteger.ModInverse(random, _key.Modulus);
 
-                result = BigInteger.PositiveMod((m * rInv), this._key.Modulus);
+                result = BigInteger.PositiveMod((m * rInv), _key.Modulus);
             }
             else
             {
-                result = BigInteger.ModPow(input, this._key.Exponent, this._key.Modulus);
+                result = BigInteger.ModPow(input, _key.Exponent, _key.Modulus);
             }
 
 #if TUNING

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 469 - 468
src/Renci.SshNet/Security/Cryptography/Ciphers/SerpentCipher.cs


+ 33 - 38
src/Renci.SshNet/Security/Cryptography/Ciphers/TripleDesCipher.cs

@@ -8,15 +8,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
     public sealed class TripleDesCipher : DesCipher
     {
         private int[] _encryptionKey1;
-
         private int[] _encryptionKey2;
-
         private int[] _encryptionKey3;
-
         private int[] _decryptionKey1;
-
         private int[] _decryptionKey2;
-
         private int[] _decryptionKey3;
 
         /// <summary>
@@ -44,44 +39,44 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// </returns>
         public override int EncryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if ((inputOffset + this.BlockSize) > inputBuffer.Length)
+            if ((inputOffset + BlockSize) > inputBuffer.Length)
                 throw new IndexOutOfRangeException("input buffer too short");
 
-            if ((outputOffset + this.BlockSize) > outputBuffer.Length)
+            if ((outputOffset + BlockSize) > outputBuffer.Length)
                 throw new IndexOutOfRangeException("output buffer too short");
 
-            if (this._encryptionKey1 == null || this._encryptionKey2 == null || this._encryptionKey3 == null)
+            if (_encryptionKey1 == null || _encryptionKey2 == null || _encryptionKey3 == null)
             {
                 var part1 = new byte[8];
                 var part2 = new byte[8];
 
-                Buffer.BlockCopy(this.Key, 0, part1, 0, 8);
-                Buffer.BlockCopy(this.Key, 8, part2, 0, 8);
+                Buffer.BlockCopy(Key, 0, part1, 0, 8);
+                Buffer.BlockCopy(Key, 8, part2, 0, 8);
 
-                this._encryptionKey1 = this.GenerateWorkingKey(true, part1);
+                _encryptionKey1 = GenerateWorkingKey(true, part1);
 
-                this._encryptionKey2 = this.GenerateWorkingKey(false, part2);
+                _encryptionKey2 = GenerateWorkingKey(false, part2);
 
-                if (this.Key.Length == 24)
+                if (Key.Length == 24)
                 {
                     var part3 = new byte[8];
-                    Buffer.BlockCopy(this.Key, 16, part3, 0, 8);
+                    Buffer.BlockCopy(Key, 16, part3, 0, 8);
 
-                    this._encryptionKey3 = this.GenerateWorkingKey(true, part3);
+                    _encryptionKey3 = GenerateWorkingKey(true, part3);
                 }
                 else
                 {
-                    this._encryptionKey3 = this._encryptionKey1;
+                    _encryptionKey3 = _encryptionKey1;
                 }
             }
 
-            byte[] temp = new byte[this.BlockSize];
+            byte[] temp = new byte[BlockSize];
 
-            DesCipher.DesFunc(this._encryptionKey1, inputBuffer, inputOffset, temp, 0);
-            DesCipher.DesFunc(this._encryptionKey2, temp, 0, temp, 0);
-            DesCipher.DesFunc(this._encryptionKey3, temp, 0, outputBuffer, outputOffset);
+            DesFunc(_encryptionKey1, inputBuffer, inputOffset, temp, 0);
+            DesFunc(_encryptionKey2, temp, 0, temp, 0);
+            DesFunc(_encryptionKey3, temp, 0, outputBuffer, outputOffset);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         /// <summary>
@@ -97,43 +92,43 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            if ((inputOffset + this.BlockSize) > inputBuffer.Length)
+            if ((inputOffset + BlockSize) > inputBuffer.Length)
                 throw new IndexOutOfRangeException("input buffer too short");
 
-            if ((outputOffset + this.BlockSize) > outputBuffer.Length)
+            if ((outputOffset + BlockSize) > outputBuffer.Length)
                 throw new IndexOutOfRangeException("output buffer too short");
 
-            if (this._decryptionKey1 == null || this._decryptionKey2 == null || this._decryptionKey3 == null)
+            if (_decryptionKey1 == null || _decryptionKey2 == null || _decryptionKey3 == null)
             {
                 var part1 = new byte[8];
                 var part2 = new byte[8];
 
-                Buffer.BlockCopy(this.Key, 0, part1, 0, 8);
-                Buffer.BlockCopy(this.Key, 8, part2, 0, 8);
+                Buffer.BlockCopy(Key, 0, part1, 0, 8);
+                Buffer.BlockCopy(Key, 8, part2, 0, 8);
 
-                this._decryptionKey1 = this.GenerateWorkingKey(false, part1);
-                this._decryptionKey2 = this.GenerateWorkingKey(true, part2);
+                _decryptionKey1 = GenerateWorkingKey(false, part1);
+                _decryptionKey2 = GenerateWorkingKey(true, part2);
 
-                if (this.Key.Length == 24)
+                if (Key.Length == 24)
                 {
                     var part3 = new byte[8];
-                    Buffer.BlockCopy(this.Key, 16, part3, 0, 8);
+                    Buffer.BlockCopy(Key, 16, part3, 0, 8);
 
-                    this._decryptionKey3 = this.GenerateWorkingKey(false, part3);
+                    _decryptionKey3 = GenerateWorkingKey(false, part3);
                 }
                 else
                 {
-                    this._decryptionKey3 = this._decryptionKey1;
+                    _decryptionKey3 = _decryptionKey1;
                 }
             }
 
-            byte[] temp = new byte[this.BlockSize];
+            byte[] temp = new byte[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);
+            DesFunc(_decryptionKey3, inputBuffer, inputOffset, temp, 0);
+            DesFunc(_decryptionKey2, temp, 0, temp, 0);
+            DesFunc(_decryptionKey1, temp, 0, outputBuffer, outputOffset);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         /// <summary>
@@ -141,7 +136,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// </summary>
         protected override void ValidateKey()
         {
-            var keySize = this.Key.Length * 8;
+            var keySize = Key.Length * 8;
 
             if (!(keySize == 128 || keySize == 128 + 64))
                 throw new ArgumentException(string.Format("KeySize '{0}' is not valid for this algorithm.", keySize));

+ 30 - 33
src/Renci.SshNet/Security/Cryptography/Ciphers/TwofishCipher.cs

@@ -26,14 +26,13 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             //  TODO:   Refactor this algorithm
 
             // calculate the MDS matrix
-            int[] m1 = new int[2];
-            int[] mX = new int[2];
-            int[] mY = new int[2];
-            int j;
+            var m1 = new int[2];
+            var mX = new int[2];
+            var mY = new int[2];
 
-            for (int i = 0; i < MAX_KEY_BITS; i++)
+            for (var i = 0; i < MAX_KEY_BITS; i++)
             {
-                j = P[0 + i] & 0xff;
+                var j = P[0 + i] & 0xff;
                 m1[0] = j;
                 mX[0] = Mx_X(j) & 0xff;
                 mY[0] = Mx_Y(j) & 0xff;
@@ -52,8 +51,8 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                 gMDS3[i] = mX[P_30] | m1[P_30] << 8 | mY[P_30] << 16 | mX[P_30] << 24;
             }
 
-            this.k64Cnt = key.Length / 8; // pre-padded ?
-            this.SetKey(key);
+            k64Cnt = key.Length / 8; // pre-padded ?
+            SetKey(key);
         }
 
         /// <summary>
@@ -96,7 +95,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToBytes(x0 ^ gSubKeys[OUTPUT_WHITEN + 2], outputBuffer, outputOffset + 8);
             Bits32ToBytes(x1 ^ gSubKeys[OUTPUT_WHITEN + 3], outputBuffer, outputOffset + 12);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         /// <summary>
@@ -112,17 +111,16 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
         /// </returns>
         public override int DecryptBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
         {
-            int x2 = BytesTo32Bits(inputBuffer, inputOffset) ^ gSubKeys[OUTPUT_WHITEN];
-            int x3 = BytesTo32Bits(inputBuffer, inputOffset + 4) ^ gSubKeys[OUTPUT_WHITEN + 1];
-            int x0 = BytesTo32Bits(inputBuffer, inputOffset + 8) ^ gSubKeys[OUTPUT_WHITEN + 2];
-            int x1 = BytesTo32Bits(inputBuffer, inputOffset + 12) ^ gSubKeys[OUTPUT_WHITEN + 3];
+            var x2 = BytesTo32Bits(inputBuffer, inputOffset) ^ gSubKeys[OUTPUT_WHITEN];
+            var x3 = BytesTo32Bits(inputBuffer, inputOffset + 4) ^ gSubKeys[OUTPUT_WHITEN + 1];
+            var x0 = BytesTo32Bits(inputBuffer, inputOffset + 8) ^ gSubKeys[OUTPUT_WHITEN + 2];
+            var x1 = BytesTo32Bits(inputBuffer, inputOffset + 12) ^ gSubKeys[OUTPUT_WHITEN + 3];
 
-            int k = ROUND_SUBKEYS + 2 * ROUNDS - 1;
-            int t0, t1;
-            for (int r = 0; r < ROUNDS; r += 2)
+            var k = ROUND_SUBKEYS + 2 * ROUNDS - 1;
+            for (var r = 0; r < ROUNDS; r += 2)
             {
-                t0 = Fe32_0(gSBox, x2);
-                t1 = Fe32_3(gSBox, x3);
+                var t0 = Fe32_0(gSBox, x2);
+                var t1 = Fe32_3(gSBox, x3);
                 x1 ^= t0 + 2 * t1 + gSubKeys[k--];
                 x0 = (x0 << 1 | (int)((uint)x0 >> 31)) ^ (t0 + t1 + gSubKeys[k--]);
                 x1 = (int)((uint)x1 >> 1) | x1 << 31;
@@ -139,7 +137,7 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             Bits32ToBytes(x2 ^ gSubKeys[INPUT_WHITEN + 2], outputBuffer, outputOffset + 8);
             Bits32ToBytes(x3 ^ gSubKeys[INPUT_WHITEN + 3], outputBuffer, outputOffset + 12);
 
-            return this.BlockSize;
+            return BlockSize;
         }
 
         #region Static Definition Tables
@@ -351,10 +349,10 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
 
         private void SetKey(byte[] key)
         {
-            int[] k32e = new int[MAX_KEY_BITS / 64]; // 4
-            int[] k32o = new int[MAX_KEY_BITS / 64]; // 4
+            var k32e = new int[MAX_KEY_BITS / 64]; // 4
+            var k32o = new int[MAX_KEY_BITS / 64]; // 4
 
-            int[] sBoxKeys = new int[MAX_KEY_BITS / 64]; // 4
+            var sBoxKeys = new int[MAX_KEY_BITS / 64]; // 4
             gSubKeys = new int[TOTAL_SUBKEYS];
 
             if (k64Cnt < 1)
@@ -383,12 +381,11 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
                 sBoxKeys[k64Cnt - 1 - i] = RS_MDS_Encode(k32e[i], k32o[i]);
             }
 
-            int q, A, B;
             for (int i = 0; i < TOTAL_SUBKEYS / 2; i++)
             {
-                q = i * SK_STEP;
-                A = F32(q, k32e);
-                B = F32(q + SK_BUMP, k32o);
+                var q = i * SK_STEP;
+                var A = F32(q, k32e);
+                var B = F32(q + SK_BUMP, k32o);
                 B = B << 8 | (int)((uint)B >> 24);
                 A += B;
                 gSubKeys[i * 2] = A;
@@ -399,15 +396,15 @@ namespace Renci.SshNet.Security.Cryptography.Ciphers
             /*
             * fully expand the table for speed
             */
-            int k0 = sBoxKeys[0];
-            int k1 = sBoxKeys[1];
-            int k2 = sBoxKeys[2];
-            int k3 = sBoxKeys[3];
-            int b0, b1, b2, b3;
+            var k0 = sBoxKeys[0];
+            var k1 = sBoxKeys[1];
+            var k2 = sBoxKeys[2];
+            var k3 = sBoxKeys[3];
             gSBox = new int[4 * MAX_KEY_BITS];
-            for (int i = 0; i < MAX_KEY_BITS; i++)
+            for (var i = 0; i < MAX_KEY_BITS; i++)
             {
-                b0 = b1 = b2 = b3 = i;
+                int b1, b2, b3;
+                var b0 = b1 = b2 = b3 = i;
                 switch (k64Cnt & 3)
                 {
                     case 1:

+ 27 - 27
src/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs

@@ -24,9 +24,9 @@ namespace Renci.SshNet.Security.Cryptography
             if (key == null)
                 throw new ArgumentNullException("key");
 
-            this._key = key;
+            _key = key;
 
-            this._hash = HashAlgorithmFactory.CreateSHA1();
+            _hash = HashAlgorithmFactory.CreateSHA1();
         }
 
         /// <summary>
@@ -40,9 +40,9 @@ namespace Renci.SshNet.Security.Cryptography
         /// <exception cref="System.InvalidOperationException">Invalid signature.</exception>
         public override bool Verify(byte[] input, byte[] signature)
         {
-            var hashInput = this._hash.ComputeHash(input);
+            var hashInput = _hash.ComputeHash(input);
 
-            BigInteger hm = new BigInteger(hashInput.Reverse().Concat(new byte[] { 0 }).ToArray());
+            var hm = new BigInteger(hashInput.Reverse().Concat(new byte[] { 0 }).ToArray());
 
             if (signature.Length != 40)
                 throw new InvalidOperationException("Invalid signature.");
@@ -57,30 +57,30 @@ namespace Renci.SshNet.Security.Cryptography
                 sBytes[i] = signature[j + 20 - 1];
             }
 
-            BigInteger r = new BigInteger(rBytes);
-            BigInteger s = new BigInteger(sBytes);
+            var r = new BigInteger(rBytes);
+            var s = new BigInteger(sBytes);
 
             //  Reject the signature if 0 < r < q or 0 < s < q is not satisfied.
-            if (r <= 0 || r >= this._key.Q)
+            if (r <= 0 || r >= _key.Q)
                 return false;
 
-            if (s <= 0 || s >= this._key.Q)
+            if (s <= 0 || s >= _key.Q)
                 return false;
 
             //  Calculate w = s−1 mod q
-            BigInteger w = BigInteger.ModInverse(s, this._key.Q);
+            var w = BigInteger.ModInverse(s, _key.Q);
 
             //  Calculate u1 = H(m)·w mod q
-            BigInteger u1 = hm * w % this._key.Q;
+            var u1 = hm * w % _key.Q;
 
             //  Calculate u2 = r * w mod q
-            BigInteger u2 = r * w % this._key.Q;
+            var u2 = r * w % _key.Q;
 
-            u1 = BigInteger.ModPow(this._key.G, u1, this._key.P);
-            u2 = BigInteger.ModPow(this._key.Y, u2, this._key.P);
+            u1 = BigInteger.ModPow(_key.G, u1, _key.P);
+            u2 = BigInteger.ModPow(_key.Y, u2, _key.P);
 
             //  Calculate v = ((g pow u1 * y pow u2) mod p) mod q
-            BigInteger v = ((u1 * u2) % this._key.P) % this._key.Q;
+            var v = ((u1 * u2) % _key.P) % _key.Q;
 
             //  The signature is valid if v = r
             return v == r;
@@ -96,9 +96,9 @@ namespace Renci.SshNet.Security.Cryptography
         /// <exception cref="SshException">Invalid DSA key.</exception>
         public override byte[] Sign(byte[] input)
         {
-            var hashInput = this._hash.ComputeHash(input);
+            var hashInput = _hash.ComputeHash(input);
 
-            BigInteger m = new BigInteger(hashInput.Reverse().Concat(new byte[] { 0 }).ToArray());
+            var m = new BigInteger(hashInput.Reverse().Concat(new byte[] { 0 }).ToArray());
 
             BigInteger s;
             BigInteger r;
@@ -110,27 +110,27 @@ namespace Renci.SshNet.Security.Cryptography
                 do
                 {
                     //  Generate a random per-message value k where 0 < k < q
-                    var bitLength = this._key.Q.BitLength;
+                    var bitLength = _key.Q.BitLength;
 
-                    if (this._key.Q < BigInteger.Zero)
+                    if (_key.Q < BigInteger.Zero)
                         throw new SshException("Invalid DSA key.");
 
-                    while (k <= 0 || k >= this._key.Q)
+                    while (k <= 0 || k >= _key.Q)
                     {
                         k = BigInteger.Random(bitLength);
                     }
 
                     //  Calculate r = ((g pow k) mod p) mod q
-                    r = BigInteger.ModPow(this._key.G, k, this._key.P) % this._key.Q;
+                    r = BigInteger.ModPow(_key.G, k, _key.P) % _key.Q;
 
                     //      In the unlikely case that r = 0, start again with a different random k
                 } while (r.IsZero);
 
 
                 //  Calculate s = ((k pow −1)(H(m) + x*r)) mod q
-                k = (BigInteger.ModInverse(k, this._key.Q) * (m + this._key.X * r));
+                k = (BigInteger.ModInverse(k, _key.Q) * (m + _key.X * r));
 
-                s = k % this._key.Q;
+                s = k % _key.Q;
 
                 //  In the unlikely case that s = 0, start again with a different random k
             } while (s.IsZero);
@@ -170,22 +170,22 @@ namespace Renci.SshNet.Security.Cryptography
         protected virtual void Dispose(bool disposing)
         {
             // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
+            if (!_isDisposed)
             {
                 // If disposing equals true, dispose all managed
                 // and unmanaged ResourceMessages.
                 if (disposing)
                 {
                     // Dispose managed ResourceMessages.
-                    if (this._hash != null)
+                    if (_hash != null)
                     {
-                        this._hash.Dispose();
-                        this._hash = null;
+                        _hash.Dispose();
+                        _hash = null;
                     }
                 }
 
                 // Note disposing has been done.
-                this._isDisposed = true;
+                _isDisposed = true;
             }
         }
 

+ 24 - 24
src/Renci.SshNet/Security/Cryptography/DsaKey.cs

@@ -16,7 +16,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[0];
+                return _privateKey[0];
             }
         }
 
@@ -27,7 +27,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[1];
+                return _privateKey[1];
             }
         }
 
@@ -38,7 +38,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[2];
+                return _privateKey[2];
             }
         }
 
@@ -49,7 +49,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[3];
+                return _privateKey[3];
             }
         }
 
@@ -60,7 +60,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[4];
+                return _privateKey[4];
             }
         }
 
@@ -74,7 +74,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this.P.BitLength;
+                return P.BitLength;
             }
         }
 
@@ -86,11 +86,11 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._digitalSignature == null)
+                if (_digitalSignature == null)
                 {
-                    this._digitalSignature = new DsaDigitalSignature(this);
+                    _digitalSignature = new DsaDigitalSignature(this);
                 }
-                return this._digitalSignature;
+                return _digitalSignature;
             }
         }
 
@@ -104,14 +104,14 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return new BigInteger[] { this.P, this.Q, this.G, this.Y };
+                return new[] { P, Q, G, Y };
             }
             set
             {
                 if (value.Length != 4)
                     throw new InvalidOperationException("Invalid public key.");
 
-                this._privateKey = value;
+                _privateKey = value;
             }
         }
 
@@ -120,7 +120,7 @@ namespace Renci.SshNet.Security
         /// </summary>
         public DsaKey()
         {
-            this._privateKey = new BigInteger[5];
+            _privateKey = new BigInteger[5];
         }
 
         /// <summary>
@@ -130,7 +130,7 @@ namespace Renci.SshNet.Security
         public DsaKey(byte[] data)
             : base(data)
         {
-            if (this._privateKey.Length != 5)
+            if (_privateKey.Length != 5)
                 throw new InvalidOperationException("Invalid private key.");
         }
 
@@ -144,12 +144,12 @@ namespace Renci.SshNet.Security
         /// <param name="x">The x.</param>
         public DsaKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y, BigInteger x)
         {
-            this._privateKey = new BigInteger[5];
-            this._privateKey[0] = p;
-            this._privateKey[1] = q;
-            this._privateKey[2] = g;
-            this._privateKey[3] = y;
-            this._privateKey[4] = x;
+            _privateKey = new BigInteger[5];
+            _privateKey[0] = p;
+            _privateKey[1] = q;
+            _privateKey[2] = g;
+            _privateKey[3] = y;
+            _privateKey[4] = x;
         }
 
         #region IDisposable Members
@@ -173,22 +173,22 @@ namespace Renci.SshNet.Security
         protected virtual void Dispose(bool disposing)
         {
             // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
+            if (!_isDisposed)
             {
                 // If disposing equals true, dispose all managed
                 // and unmanaged ResourceMessages.
                 if (disposing)
                 {
                     // Dispose managed ResourceMessages.
-                    if (this._digitalSignature != null)
+                    if (_digitalSignature != null)
                     {
-                        this._digitalSignature.Dispose();
-                        this._digitalSignature = null;
+                        _digitalSignature.Dispose();
+                        _digitalSignature = null;
                     }
                 }
 
                 // Note disposing has been done.
-                this._isDisposed = true;
+                _isDisposed = true;
             }
         }
 

+ 10 - 16
src/Renci.SshNet/Security/Cryptography/RsaDigitalSignature.cs

@@ -19,7 +19,7 @@ namespace Renci.SshNet.Security.Cryptography
         public RsaDigitalSignature(RsaKey rsaKey)
             : base(new ObjectIdentifier(1, 3, 14, 3, 2, 26), new RsaCipher(rsaKey))
         {
-            this._hash = HashAlgorithmFactory.CreateSHA1();
+            _hash = HashAlgorithmFactory.CreateSHA1();
         }
 
         /// <summary>
@@ -31,7 +31,7 @@ namespace Renci.SshNet.Security.Cryptography
         /// </returns>
         protected override byte[] Hash(byte[] input)
         {
-            return this._hash.ComputeHash(input);
+            return _hash.ComputeHash(input);
         }
 
         #region IDisposable Members
@@ -44,7 +44,6 @@ namespace Renci.SshNet.Security.Cryptography
         public void Dispose()
         {
             Dispose(true);
-
             GC.SuppressFinalize(this);
         }
 
@@ -54,23 +53,18 @@ namespace Renci.SshNet.Security.Cryptography
         /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged ResourceMessages.</param>
         protected virtual void Dispose(bool disposing)
         {
-            // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
+            if (_isDisposed)
+                return;
+
+            if (disposing)
             {
-                // If disposing equals true, dispose all managed
-                // and unmanaged ResourceMessages.
-                if (disposing)
+                if (_hash != null)
                 {
-                    // Dispose managed ResourceMessages.
-                    if (this._hash != null)
-                    {
-                        this._hash.Dispose();
-                        this._hash = null;
-                    }
+                    _hash.Dispose();
+                    _hash = null;
                 }
 
-                // Note disposing has been done.
-                this._isDisposed = true;
+                _isDisposed = true;
             }
         }
 

+ 35 - 35
src/Renci.SshNet/Security/Cryptography/RsaKey.cs

@@ -16,7 +16,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[0];
+                return _privateKey[0];
             }
         }
 
@@ -27,7 +27,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this._privateKey[1];
+                return _privateKey[1];
             }
         }
 
@@ -38,8 +38,8 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._privateKey.Length > 2)
-                    return this._privateKey[2];
+                if (_privateKey.Length > 2)
+                    return _privateKey[2];
                 return BigInteger.Zero;
             }
         }
@@ -51,8 +51,8 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._privateKey.Length > 3)
-                    return this._privateKey[3];
+                if (_privateKey.Length > 3)
+                    return _privateKey[3];
                 return BigInteger.Zero;
             }
         }
@@ -64,8 +64,8 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._privateKey.Length > 4)
-                    return this._privateKey[4];
+                if (_privateKey.Length > 4)
+                    return _privateKey[4];
                 return BigInteger.Zero;
             }
         }
@@ -77,8 +77,8 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._privateKey.Length > 5)
-                    return this._privateKey[5];
+                if (_privateKey.Length > 5)
+                    return _privateKey[5];
                 return BigInteger.Zero;
             }
         }
@@ -90,8 +90,8 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._privateKey.Length > 6)
-                    return this._privateKey[6];
+                if (_privateKey.Length > 6)
+                    return _privateKey[6];
                 return BigInteger.Zero;
             }
         }
@@ -103,8 +103,8 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._privateKey.Length > 7)
-                    return this._privateKey[7];
+                if (_privateKey.Length > 7)
+                    return _privateKey[7];
                 return BigInteger.Zero;
             }
         }
@@ -119,7 +119,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return this.Modulus.BitLength;
+                return Modulus.BitLength;
             }
         }
 
@@ -131,11 +131,11 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._digitalSignature == null)
+                if (_digitalSignature == null)
                 {
-                    this._digitalSignature = new RsaDigitalSignature(this);
+                    _digitalSignature = new RsaDigitalSignature(this);
                 }
-                return this._digitalSignature;
+                return _digitalSignature;
             }
         }
 
@@ -149,14 +149,14 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return new BigInteger[] { this.Exponent, this.Modulus };
+                return new[] { Exponent, Modulus };
             }
             set
             {
                 if (value.Length != 2)
                     throw new InvalidOperationException("Invalid private key.");
 
-                this._privateKey = new BigInteger[] { value[1], value[0] };
+                _privateKey = new[] { value[1], value[0] };
             }
         }
 
@@ -175,7 +175,7 @@ namespace Renci.SshNet.Security
         public RsaKey(byte[] data)
             : base(data)
         {
-            if (this._privateKey.Length != 8)
+            if (_privateKey.Length != 8)
                 throw new InvalidOperationException("Invalid private key.");
         }
 
@@ -190,15 +190,15 @@ namespace Renci.SshNet.Security
         /// <param name="inverseQ">The inverse Q.</param>
         public RsaKey(BigInteger modulus, BigInteger exponent, BigInteger d, BigInteger p, BigInteger q, BigInteger inverseQ)
         {
-            this._privateKey = new BigInteger[8];
-            this._privateKey[0] = modulus;
-            this._privateKey[1] = exponent;
-            this._privateKey[2] = d;
-            this._privateKey[3] = p;
-            this._privateKey[4] = q;
-            this._privateKey[5] = PrimeExponent(d, p);
-            this._privateKey[6] = PrimeExponent(d, q);
-            this._privateKey[7] = inverseQ;
+            _privateKey = new BigInteger[8];
+            _privateKey[0] = modulus;
+            _privateKey[1] = exponent;
+            _privateKey[2] = d;
+            _privateKey[3] = p;
+            _privateKey[4] = q;
+            _privateKey[5] = PrimeExponent(d, p);
+            _privateKey[6] = PrimeExponent(d, q);
+            _privateKey[7] = inverseQ;
         }
 
         private static BigInteger PrimeExponent(BigInteger privateExponent, BigInteger prime)
@@ -228,22 +228,22 @@ namespace Renci.SshNet.Security
         protected virtual void Dispose(bool disposing)
         {
             // Check to see if Dispose has already been called.
-            if (!this._isDisposed)
+            if (!_isDisposed)
             {
                 // If disposing equals true, dispose all managed
                 // and unmanaged ResourceMessages.
                 if (disposing)
                 {
                     // Dispose managed ResourceMessages.
-                    if (this._digitalSignature != null)
+                    if (_digitalSignature != null)
                     {
-                        this._digitalSignature.Dispose();
-                        this._digitalSignature = null;
+                        _digitalSignature.Dispose();
+                        _digitalSignature = null;
                     }
                 }
 
                 // Note disposing has been done.
-                this._isDisposed = true;
+                _isDisposed = true;
             }
         }
 

+ 1 - 1
src/Renci.SshNet/Security/Cryptography/SymmetricCipher.cs

@@ -22,7 +22,7 @@ namespace Renci.SshNet.Security.Cryptography
             if (key == null)
                 throw new ArgumentNullException("key");
 
-            this.Key = key;
+            Key = key;
         }
 
         /// <summary>

+ 16 - 16
src/Renci.SshNet/Security/GroupExchangeHashData.cs

@@ -41,11 +41,11 @@ namespace Renci.SshNet.Security
 
         public byte[] HostKey { get; set; }
 
-        public UInt32 MinimumGroupSize { get; set; }
+        public uint MinimumGroupSize { get; set; }
 
-        public UInt32 PreferredGroupSize { get; set; }
+        public uint PreferredGroupSize { get; set; }
 
-        public UInt32 MaximumGroupSize { get; set; }
+        public uint MaximumGroupSize { get; set; }
 
 #if TUNING
         public BigInteger Prime
@@ -148,15 +148,15 @@ namespace Renci.SshNet.Security
             WriteBinaryString(_clientVersion);
             WriteBinaryString(_serverVersion);
 #else
-            this.Write(this.ClientVersion);
-            this.Write(this.ServerVersion);
+            Write(ClientVersion);
+            Write(ServerVersion);
 #endif
-            this.WriteBinaryString(this.ClientPayload);
-            this.WriteBinaryString(this.ServerPayload);
-            this.WriteBinaryString(this.HostKey);
-            this.Write(this.MinimumGroupSize);
-            this.Write(this.PreferredGroupSize);
-            this.Write(this.MaximumGroupSize);
+            WriteBinaryString(ClientPayload);
+            WriteBinaryString(ServerPayload);
+            WriteBinaryString(HostKey);
+            Write(MinimumGroupSize);
+            Write(PreferredGroupSize);
+            Write(MaximumGroupSize);
 #if TUNING
             WriteBinaryString(_prime);
             WriteBinaryString(_subGroup);
@@ -164,11 +164,11 @@ namespace Renci.SshNet.Security
             WriteBinaryString(_serverExchangeValue);
             WriteBinaryString(_sharedKey);
 #else
-            this.Write(this.Prime);
-            this.Write(this.SubGroup);
-            this.Write(this.ClientExchangeValue);
-            this.Write(this.ServerExchangeValue);
-            this.Write(this.SharedKey);
+            Write(Prime);
+            Write(SubGroup);
+            Write(ClientExchangeValue);
+            Write(ServerExchangeValue);
+            Write(SharedKey);
 #endif
         }
     }

+ 1 - 1
src/Renci.SshNet/Security/HostAlgorithm.cs

@@ -21,7 +21,7 @@
         /// <param name="name">The host key name.</param>
         protected HostAlgorithm(string name)
         {
-            this.Name = name;
+            Name = name;
         }
 
         /// <summary>

+ 44 - 44
src/Renci.SshNet/Security/KeyExchange.cs

@@ -48,11 +48,11 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                if (this._exchangeHash == null)
+                if (_exchangeHash == null)
                 {
-                    this._exchangeHash = this.CalculateHash();
+                    _exchangeHash = CalculateHash();
                 }
-                return this._exchangeHash;
+                return _exchangeHash;
             }
         }
 
@@ -68,9 +68,9 @@ namespace Renci.SshNet.Security
         /// <param name="message">Key exchange init message.</param>
         public virtual void Start(Session session, KeyExchangeInitMessage message)
         {
-            this.Session = session;
+            Session = session;
 
-            this.SendMessage(session.ClientInitMessage);
+            SendMessage(session.ClientInitMessage);
 
             //  Determine encryption algorithm
             var clientEncryptionAlgorithmName = (from b in session.ConnectionInfo.Encryptions.Keys
@@ -145,12 +145,12 @@ namespace Renci.SshNet.Security
 
             session.ConnectionInfo.CurrentServerCompressionAlgorithm = decompressionAlgorithmName;
 
-            this._clientCipherInfo = session.ConnectionInfo.Encryptions[clientEncryptionAlgorithmName];
-            this._serverCipherInfo = session.ConnectionInfo.Encryptions[serverDecryptionAlgorithmName];
-            this._clientHashInfo = session.ConnectionInfo.HmacAlgorithms[clientHmacAlgorithmName];
-            this._serverHashInfo = session.ConnectionInfo.HmacAlgorithms[serverHmacAlgorithmName];
-            this._compressionType = session.ConnectionInfo.CompressionAlgorithms[compressionAlgorithmName];
-            this._decompressionType = session.ConnectionInfo.CompressionAlgorithms[decompressionAlgorithmName];
+            _clientCipherInfo = session.ConnectionInfo.Encryptions[clientEncryptionAlgorithmName];
+            _serverCipherInfo = session.ConnectionInfo.Encryptions[serverDecryptionAlgorithmName];
+            _clientHashInfo = session.ConnectionInfo.HmacAlgorithms[clientHmacAlgorithmName];
+            _serverHashInfo = session.ConnectionInfo.HmacAlgorithms[serverHmacAlgorithmName];
+            _compressionType = session.ConnectionInfo.CompressionAlgorithms[compressionAlgorithmName];
+            _decompressionType = session.ConnectionInfo.CompressionAlgorithms[decompressionAlgorithmName];
         }
 
         /// <summary>
@@ -159,9 +159,9 @@ namespace Renci.SshNet.Security
         public virtual void Finish()
         {
             //  Validate hash
-            if (this.ValidateExchangeHash())
+            if (ValidateExchangeHash())
             {
-                this.SendMessage(new NewKeysMessage());
+                SendMessage(new NewKeysMessage());
             }
             else
             {
@@ -176,18 +176,18 @@ namespace Renci.SshNet.Security
         public Cipher CreateServerCipher()
         {
             //  Resolve Session ID
-            var sessionId = this.Session.SessionId ?? this.ExchangeHash;
+            var sessionId = Session.SessionId ?? ExchangeHash;
 
             //  Calculate server to client initial IV
-            var serverVector = this.Hash(this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, 'B', sessionId));
+            var serverVector = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'B', sessionId));
 
             //  Calculate server to client encryption
-            var serverKey = this.Hash(this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, 'D', sessionId));
+            var serverKey = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'D', sessionId));
 
-            serverKey = this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, serverKey, this._serverCipherInfo.KeySize / 8);
+            serverKey = GenerateSessionKey(SharedKey, ExchangeHash, serverKey, _serverCipherInfo.KeySize / 8);
             
             //  Create server cipher
-            return this._serverCipherInfo.Cipher(serverKey, serverVector);
+            return _serverCipherInfo.Cipher(serverKey, serverVector);
         }
 
         /// <summary>
@@ -197,18 +197,18 @@ namespace Renci.SshNet.Security
         public Cipher CreateClientCipher()
         {
             //  Resolve Session ID
-            var sessionId = this.Session.SessionId ?? this.ExchangeHash;
+            var sessionId = Session.SessionId ?? ExchangeHash;
 
             //  Calculate client to server initial IV
-            var clientVector = this.Hash(this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, 'A', sessionId));
+            var clientVector = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'A', sessionId));
 
             //  Calculate client to server encryption
-            var clientKey = this.Hash(this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, 'C', sessionId));
+            var clientKey = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'C', sessionId));
 
-            clientKey = this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, clientKey, this._clientCipherInfo.KeySize / 8);
+            clientKey = GenerateSessionKey(SharedKey, ExchangeHash, clientKey, _clientCipherInfo.KeySize / 8);
 
             //  Create client cipher
-            return this._clientCipherInfo.Cipher(clientKey, clientVector);
+            return _clientCipherInfo.Cipher(clientKey, clientVector);
         }
 
         /// <summary>
@@ -218,14 +218,14 @@ namespace Renci.SshNet.Security
         public HashAlgorithm CreateServerHash()
         {
             //  Resolve Session ID
-            var sessionId = this.Session.SessionId ?? this.ExchangeHash;
+            var sessionId = Session.SessionId ?? ExchangeHash;
 
-            var serverKey = this.Hash(this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, 'F', sessionId));
+            var serverKey = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'F', sessionId));
 
-            serverKey = this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, serverKey, this._serverHashInfo.KeySize / 8);
+            serverKey = GenerateSessionKey(SharedKey, ExchangeHash, serverKey, _serverHashInfo.KeySize / 8);
 
             //return serverHMac;
-            return this._serverHashInfo.HashAlgorithm(serverKey);
+            return _serverHashInfo.HashAlgorithm(serverKey);
         }
 
         /// <summary>
@@ -235,14 +235,14 @@ namespace Renci.SshNet.Security
         public HashAlgorithm CreateClientHash()
         {
             //  Resolve Session ID
-            var sessionId = this.Session.SessionId ?? this.ExchangeHash;
+            var sessionId = Session.SessionId ?? ExchangeHash;
 
-            var clientKey = this.Hash(this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, 'E', sessionId));
+            var clientKey = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'E', sessionId));
             
-            clientKey = this.GenerateSessionKey(this.SharedKey, this.ExchangeHash, clientKey, this._clientHashInfo.KeySize / 8);
+            clientKey = GenerateSessionKey(SharedKey, ExchangeHash, clientKey, _clientHashInfo.KeySize / 8);
 
             //return clientHMac;
-            return this._clientHashInfo.HashAlgorithm(clientKey);
+            return _clientHashInfo.HashAlgorithm(clientKey);
         }
 
         /// <summary>
@@ -251,12 +251,12 @@ namespace Renci.SshNet.Security
         /// <returns>Compression method.</returns>
         public Compressor CreateCompressor()
         {
-            if (this._compressionType == null)
+            if (_compressionType == null)
                 return null;
 
-            var compressor = this._compressionType.CreateInstance<Compressor>();
+            var compressor = _compressionType.CreateInstance<Compressor>();
 
-            compressor.Init(this.Session);
+            compressor.Init(Session);
 
             return compressor;
         }
@@ -267,12 +267,12 @@ namespace Renci.SshNet.Security
         /// <returns>Compression method.</returns>
         public Compressor CreateDecompressor()
         {
-            if (this._compressionType == null)
+            if (_compressionType == null)
                 return null;
 
-            var decompressor = this._decompressionType.CreateInstance<Compressor>();
+            var decompressor = _decompressionType.CreateInstance<Compressor>();
 
-            decompressor.Init(this.Session);
+            decompressor.Init(Session);
 
             return decompressor;
         }
@@ -330,7 +330,7 @@ namespace Renci.SshNet.Security
         /// <param name="message">The message.</param>
         protected void SendMessage(Message message)
         {
-            this.Session.SendMessage(message);
+            Session.SendMessage(message);
         }
 
         /// <summary>
@@ -346,7 +346,7 @@ namespace Renci.SshNet.Security
             var result = new List<byte>(key);
             while (size > result.Count)
             {
-                result.AddRange(this.Hash(new _SessionKeyAdjustment
+                result.AddRange(Hash(new _SessionKeyAdjustment
                 {
                     SharedKey = sharedKey,
                     ExcahngeHash = exchangeHash,
@@ -427,9 +427,9 @@ namespace Renci.SshNet.Security
 #else
                 this.Write(this.SharedKey);
 #endif
-                this.Write(this.ExchangeHash);
-                this.Write((byte)this.Char);
-                this.Write(this.SessionId);
+                Write(ExchangeHash);
+                Write((byte)Char);
+                Write(SessionId);
             }
         }
 
@@ -482,8 +482,8 @@ namespace Renci.SshNet.Security
 #else
                 this.Write(this.SharedKey);
 #endif
-                this.Write(this.ExcahngeHash);
-                this.Write(this.Key);
+                Write(ExcahngeHash);
+                Write(Key);
             }
         }
 

+ 17 - 17
src/Renci.SshNet/Security/KeyExchangeDiffieHellman.cs

@@ -63,20 +63,20 @@ namespace Renci.SshNet.Security
         /// </returns>
         protected override bool ValidateExchangeHash()
         {
-            var exchangeHash = this.CalculateHash();
+            var exchangeHash = CalculateHash();
 
-            var length = (uint)(this._hostKey[0] << 24 | this._hostKey[1] << 16 | this._hostKey[2] << 8 | this._hostKey[3]);
+            var length = (uint)(_hostKey[0] << 24 | _hostKey[1] << 16 | _hostKey[2] << 8 | _hostKey[3]);
 
-            var algorithmName = Encoding.UTF8.GetString(this._hostKey, 4, (int)length);
+            var algorithmName = Encoding.UTF8.GetString(_hostKey, 4, (int)length);
 
-            var key = this.Session.ConnectionInfo.HostKeyAlgorithms[algorithmName](this._hostKey);
+            var key = Session.ConnectionInfo.HostKeyAlgorithms[algorithmName](_hostKey);
 
-            this.Session.ConnectionInfo.CurrentHostKeyAlgorithm = algorithmName;
+            Session.ConnectionInfo.CurrentHostKeyAlgorithm = algorithmName;
 
-            if (this.CanTrustHostKey(key))
+            if (CanTrustHostKey(key))
             {
 
-                return key.VerifySignature(exchangeHash, this._signature);
+                return key.VerifySignature(exchangeHash, _signature);
             }
             return false;
         }
@@ -99,21 +99,21 @@ namespace Renci.SshNet.Security
         /// </summary>
         protected void PopulateClientExchangeValue()
         {
-            if (this._group.IsZero)
+            if (_group.IsZero)
                 throw new ArgumentNullException("_group");
 
-            if (this._prime.IsZero)
+            if (_prime.IsZero)
                 throw new ArgumentNullException("_prime");
 
-            var bitLength = this._prime.BitLength;
+            var bitLength = _prime.BitLength;
 
             do
             {
-                this._randomValue = BigInteger.Random(bitLength);
+                _randomValue = BigInteger.Random(bitLength);
 
-                this._clientExchangeValue = BigInteger.ModPow(this._group, this._randomValue, this._prime);
+                _clientExchangeValue = BigInteger.ModPow(_group, _randomValue, _prime);
 
-            } while (this._clientExchangeValue < 1 || this._clientExchangeValue > ((this._prime - 1)));
+            } while (_clientExchangeValue < 1 || _clientExchangeValue > ((_prime - 1)));
         }
 
         /// <summary>
@@ -124,10 +124,10 @@ namespace Renci.SshNet.Security
         /// <param name="signature">The signature.</param>
         protected virtual void HandleServerDhReply(byte[] hostKey, BigInteger serverExchangeValue, byte[] signature)
         {
-            this._serverExchangeValue = serverExchangeValue;
-            this._hostKey = hostKey;
-            this.SharedKey = BigInteger.ModPow(serverExchangeValue, this._randomValue, this._prime);
-            this._signature = signature;
+            _serverExchangeValue = serverExchangeValue;
+            _hostKey = hostKey;
+            SharedKey = BigInteger.ModPow(serverExchangeValue, _randomValue, _prime);
+            _signature = signature;
         }
     }
 }

+ 1 - 1
src/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeShaBase.cs

@@ -34,7 +34,7 @@ namespace Renci.SshNet.Security
                     SharedKey = SharedKey,
                 }.GetBytes();
 
-            return this.Hash(hashData);
+            return Hash(hashData);
         }
 
         /// <summary>

+ 14 - 14
src/Renci.SshNet/Security/KeyHostAlgorithm.cs

@@ -20,7 +20,7 @@ namespace Renci.SshNet.Security
         {
             get
             {
-                return new SshKeyData(this.Name, this.Key.Public).GetBytes();
+                return new SshKeyData(Name, Key.Public).GetBytes();
             }
         }
 
@@ -32,7 +32,7 @@ namespace Renci.SshNet.Security
         public KeyHostAlgorithm(string name, Key key)
             : base(name)
         {
-            this.Key = key;
+            Key = key;
         }
 
         /// <summary>
@@ -44,11 +44,11 @@ namespace Renci.SshNet.Security
         public KeyHostAlgorithm(string name, Key key, byte[] data)
             : base(name)
         {
-            this.Key = key;
+            Key = key;
 
             var sshKey = new SshKeyData();
             sshKey.Load(data);
-            this.Key.Public = sshKey.Keys;
+            Key.Public = sshKey.Keys;
         }
 
         /// <summary>
@@ -60,7 +60,7 @@ namespace Renci.SshNet.Security
         /// </returns>
         public override byte[] Sign(byte[] data)
         {
-            return new SignatureKeyData(this.Name, this.Key.Sign(data)).GetBytes();
+            return new SignatureKeyData(Name, Key.Sign(data)).GetBytes();
         }
 
         /// <summary>
@@ -76,7 +76,7 @@ namespace Renci.SshNet.Security
             var signatureData = new SignatureKeyData();
             signatureData.Load(signature);
 
-            return this.Key.VerifySignature(data, signatureData.Signature);
+            return Key.VerifySignature(data, signatureData.Signature);
         }
 
         private class SshKeyData : SshData
@@ -144,8 +144,8 @@ namespace Renci.SshNet.Security
 
             public SshKeyData(string name, params BigInteger[] keys)
             {
-                this.Name = name;
-                this.Keys = keys;
+                Name = name;
+                Keys = keys;
             }
 
             protected override void LoadData()
@@ -157,7 +157,7 @@ namespace Renci.SshNet.Security
                 this.Name = this.ReadString();
                 var keys = new List<BigInteger>();
 #endif
-                while (!this.IsEndOfData)
+                while (!IsEndOfData)
                 {
 #if TUNING
                     _keys.Add(ReadBinary());
@@ -241,11 +241,11 @@ namespace Renci.SshNet.Security
             public SignatureKeyData(string name, byte[] signature)
             {
 #if TUNING
-                this.AlgorithmName = Utf8.GetBytes(name);
+                AlgorithmName = Utf8.GetBytes(name);
 #else
                 this.AlgorithmName = name;
 #endif
-                this.Signature = signature;
+                Signature = signature;
             }
 
             /// <summary>
@@ -254,8 +254,8 @@ namespace Renci.SshNet.Security
             protected override void LoadData()
             {
 #if TUNING
-                this.AlgorithmName = this.ReadBinary();
-                this.Signature = this.ReadBinary();
+                AlgorithmName = ReadBinary();
+                Signature = ReadBinary();
 #else
                 this.AlgorithmName = this.ReadString();
                 this.Signature = this.ReadBinaryString();
@@ -272,7 +272,7 @@ namespace Renci.SshNet.Security
 #else
                 this.Write(this.AlgorithmName);
 #endif
-                this.WriteBinaryString(this.Signature);
+                WriteBinaryString(Signature);
             }
         }
     }

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels