Skip to content

Key exchange is slow when size of group is more than 1024 bits #304

Closed
@ignas-sakalauskas-cko

Description

@ignas-sakalauskas-cko

Hello,

I am using .Net Core 2.0 and running local WinSCP SSH server.

Code to replicate the issue below.

using (var client = new SftpClient(host, username, password))
{
   var start = DateTime.Now;
   client.Connect();
   Console.WriteLine($"Time elapsed: {DateTime.Now.Subtract(start).Seconds} s");
}

And the result is Time elapsed: 5 s

SSH clients like WinSCP or FileZilla connect to the server instantly.

After digging into SSH.NET code seems like _prime.BitLength is 8192, hence BigInteger.ModPow runs while loop 8191 times, twice during Connect().

Please advise.

Thanks,
Ignas

UPDATE.
Tested several remote servers, and results were very different.
localhost: "hmac-sha1" time: 5s
test.rebex.net: "hmac-sha2-256" time: 1s
demo.wftpserver.com: "hmac-sha1" time: 2-3s

Using a different local server seems to work as expected, Connect() takes under 500 ms.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions