diff --git a/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeDhReplyMessage.cs b/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeDhReplyMessage.cs
index 0a7b3a07..2539a79a 100644
--- a/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeDhReplyMessage.cs
+++ b/Renci.SshClient/Renci.SshClient/Messages/Transport/KeyExchangeDhReplyMessage.cs
@@ -33,9 +33,6 @@ namespace Renci.SshClient.Messages.Transport
this.HostKey = this.ReadString();
this.F = this.ReadBigInteger();
this.Signature = this.ReadString();
-
- // TODO: Determine which algorithms to use from signature
-
}
protected override void SaveData()
diff --git a/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj b/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj
index 88ccc930..f5d22c28 100644
--- a/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj
+++ b/Renci.SshClient/Renci.SshClient/Renci.SshClient.csproj
@@ -67,7 +67,7 @@
-
+
diff --git a/Renci.SshClient/Renci.SshClient/Security/CipherAES128.cs b/Renci.SshClient/Renci.SshClient/Security/CipherAES.cs
similarity index 80%
rename from Renci.SshClient/Renci.SshClient/Security/CipherAES128.cs
rename to Renci.SshClient/Renci.SshClient/Security/CipherAES.cs
index 534743cd..cfb0f602 100644
--- a/Renci.SshClient/Renci.SshClient/Security/CipherAES128.cs
+++ b/Renci.SshClient/Renci.SshClient/Security/CipherAES.cs
@@ -5,7 +5,7 @@ using System.Security.Cryptography;
namespace Renci.SshClient.Security
{
- internal class CipherAES128 : Cipher, IDisposable
+ internal abstract class CipherAES : Cipher, IDisposable
{
private SymmetricAlgorithm _algorithm;
@@ -34,9 +34,12 @@ namespace Renci.SshClient.Security
}
}
- public CipherAES128()
+ protected abstract int KeyBitsSize { get; }
+
+ public CipherAES()
{
this._algorithm = new System.Security.Cryptography.RijndaelManaged();
+ this._algorithm.KeySize = this.KeyBitsSize;
this._algorithm.Mode = System.Security.Cryptography.CipherMode.CBC;
this._algorithm.Padding = System.Security.Cryptography.PaddingMode.None;
}
@@ -111,7 +114,7 @@ namespace Renci.SshClient.Security
}
}
- ~CipherAES128()
+ ~CipherAES()
{
// Do not re-create Dispose clean-up code here.
// Calling Dispose(false) is optimal in terms of
@@ -121,4 +124,27 @@ namespace Renci.SshClient.Security
#endregion
}
+
+ internal class CipherAES128CBC : CipherAES
+ {
+ protected override int KeyBitsSize
+ {
+ get { return 128; }
+ }
+ }
+ internal class CipherAES192CBC : CipherAES
+ {
+ protected override int KeyBitsSize
+ {
+ get { return 192; }
+ }
+ }
+ internal class CipherAES256CBC : CipherAES
+ {
+ protected override int KeyBitsSize
+ {
+ get { return 256; }
+ }
+ }
+
}
diff --git a/Renci.SshClient/Renci.SshClient/Session.cs b/Renci.SshClient/Renci.SshClient/Session.cs
index f7726530..d3dc56c1 100644
--- a/Renci.SshClient/Renci.SshClient/Session.cs
+++ b/Renci.SshClient/Renci.SshClient/Session.cs
@@ -538,13 +538,16 @@ namespace Renci.SshClient
// Read rest of the packet data
int bytesToRead = (int)(packetLength - (blockSize - 4));
- if (this._keyExhcange.ServerCipher == null)
+ if (bytesToRead > 0)
{
- decryptedData.AddRange(this.Read(bytesToRead));
- }
- else
- {
- decryptedData.AddRange(this._keyExhcange.ServerCipher.Decrypt(this.Read(bytesToRead)));
+ if (this._keyExhcange.ServerCipher == null)
+ {
+ decryptedData.AddRange(this.Read(bytesToRead));
+ }
+ else
+ {
+ decryptedData.AddRange(this._keyExhcange.ServerCipher.Decrypt(this.Read(bytesToRead)));
+ }
}
var paddingLength = decryptedData[4];
diff --git a/Renci.SshClient/Renci.SshClient/Settings.cs b/Renci.SshClient/Renci.SshClient/Settings.cs
index 30ef36a8..4b040b00 100644
--- a/Renci.SshClient/Renci.SshClient/Settings.cs
+++ b/Renci.SshClient/Renci.SshClient/Settings.cs
@@ -31,7 +31,9 @@ namespace Renci.SshClient
Settings.Encryptions = new Dictionary>()
{
{"3des-cbc", () => { return new CipherTripleDES();}},
- //{"aes128-cbc", () => { return new CipherAES128();}}, // TODO: This cipher does not work
+ {"aes128-cbc", () => { return new CipherAES128CBC();}},
+ {"aes192-cbc", () => { return new CipherAES192CBC();}},
+ {"aes256-cbc", () => { return new CipherAES256CBC();}},
};
@@ -57,7 +59,7 @@ namespace Renci.SshClient
Settings.CompressionAlgorithms = new Dictionary>()
{
{"none", (session) => { return null;}},
- {"zlib", (session) => { return new CompressionZlibOpenSsh(session);}},
+ {"zlib", (session) => { return new CompressionZlib(session);}},
{"zlib@openssh.com", (session) => { return new CompressionZlibOpenSsh(session);}},
};