mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 17:25:51 +00:00
94397d47ed
* Implement OpenSSH strict key exchange extension * The pseudo-algorithm is only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored if they are present in subsequent SSH2_MSG_KEXINIT packets. * Only send strict kex pseudo algorithm for the first kex. Strictly disable non-kex massages in strict kex mode. * Unit tests for strict kex * More unit tests * More unit tests * Correct file name * Update SessionTest_ConnectingBase.cs * More unit tests * Delete SessionTest_Connecting_ServerSendsMaxIgnoreMessagesBeforeKexInit.cs * Add a comment about throwing exception when inbound sequence number is about to wrap during init kex. * Delete SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_NoStrictKex.cs * Fix build * Update test/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com>
60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
using Renci.SshNet.Connection;
|
|
|
|
namespace Renci.SshNet.Tests.Classes
|
|
{
|
|
[TestClass]
|
|
public class SessionTest_Connecting_ServerIdentificationReceived : SessionTest_ConnectingBase
|
|
{
|
|
protected override void SetupData()
|
|
{
|
|
base.SetupData();
|
|
|
|
Session.ServerIdentificationReceived += (s, e) =>
|
|
{
|
|
if ((e.SshIdentification.SoftwareVersion.StartsWith("OpenSSH_6.5", System.StringComparison.Ordinal) || e.SshIdentification.SoftwareVersion.StartsWith("OpenSSH_6.6", System.StringComparison.Ordinal))
|
|
&& !e.SshIdentification.SoftwareVersion.StartsWith("OpenSSH_6.6.1", System.StringComparison.Ordinal))
|
|
{
|
|
_ = ConnectionInfo.KeyExchangeAlgorithms.Remove("curve25519-sha256");
|
|
_ = ConnectionInfo.KeyExchangeAlgorithms.Remove("curve25519-sha256@libssh.org");
|
|
}
|
|
};
|
|
}
|
|
|
|
[TestMethod]
|
|
[DataRow("OpenSSH_6.5")]
|
|
[DataRow("OpenSSH_6.5p1")]
|
|
[DataRow("OpenSSH_6.5 PKIX")]
|
|
[DataRow("OpenSSH_6.6")]
|
|
[DataRow("OpenSSH_6.6p1")]
|
|
[DataRow("OpenSSH_6.6 PKIX")]
|
|
public void ShouldExcludeCurve25519KexWhenServerIs(string softwareVersion)
|
|
{
|
|
ServerIdentification = new SshIdentification("2.0", softwareVersion);
|
|
|
|
Session.Connect();
|
|
|
|
Assert.IsFalse(ConnectionInfo.KeyExchangeAlgorithms.ContainsKey("curve25519-sha256"));
|
|
Assert.IsFalse(ConnectionInfo.KeyExchangeAlgorithms.ContainsKey("curve25519-sha256@libssh.org"));
|
|
}
|
|
|
|
[TestMethod]
|
|
[DataRow("OpenSSH_6.6.1")]
|
|
[DataRow("OpenSSH_6.6.1p1")]
|
|
[DataRow("OpenSSH_6.6.1 PKIX")]
|
|
[DataRow("OpenSSH_6.7")]
|
|
[DataRow("OpenSSH_6.7p1")]
|
|
[DataRow("OpenSSH_6.7 PKIX")]
|
|
public void ShouldIncludeCurve25519KexWhenServerIs(string softwareVersion)
|
|
{
|
|
ServerIdentification = new SshIdentification("2.0", softwareVersion);
|
|
|
|
Session.Connect();
|
|
|
|
Assert.IsTrue(ConnectionInfo.KeyExchangeAlgorithms.ContainsKey("curve25519-sha256"));
|
|
Assert.IsTrue(ConnectionInfo.KeyExchangeAlgorithms.ContainsKey("curve25519-sha256@libssh.org"));
|
|
}
|
|
}
|
|
}
|