-
-
Notifications
You must be signed in to change notification settings - Fork 960
Use BCL Curve25519 for Windows 10+ #1702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f5486b5
to
9d15116
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm otherwise
actually, it is not working on my win10 22H2 machine (connected aborted). develop branch works fine, using curve25519-sha256 |
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Based on your description, it does not throw exception when get the named curve. May related to agreement derivation. |
Right, see wireshark.zip. I see the bad capture (on this branch) is sending ECDH init with a key length of 65 bytes (containing 32 trailing zeroes), and the server closes the connection. The good capture (on develop) is sending with 32 byte key, and everything works fine |
this works diff --git a/src/Renci.SshNet/Security/KeyExchangeEC.BclImpl.cs b/src/Renci.SshNet/Security/KeyExchangeEC.BclImpl.cs
index 54757719..571614f6 100644
--- a/src/Renci.SshNet/Security/KeyExchangeEC.BclImpl.cs
+++ b/src/Renci.SshNet/Security/KeyExchangeEC.BclImpl.cs
@@ -23,17 +23,15 @@ public override byte[] GenerateClientECPoint()
var q = _clientECDH.PublicKey.ExportParameters().Q;
- return EncodeECPoint(q);
+ return q.X;
}
public override byte[] CalculateAgreement(byte[] serverECPoint)
{
- var q = DecodeECPoint(serverECPoint);
-
var parameters = new ECParameters
{
Curve = _curve,
- Q = q,
+ Q = new ECPoint { X = serverECPoint, Y = new byte[serverECPoint.Length] },
};
using var serverECDH = ECDiffieHellman.Create(parameters); |
That's really strange. Not sure why integration test passes. |
338e205
to
295b2b5
Compare
CI only tests Windows with .NET Framework, not Windows with .NET . I guess we should add that? |
Agreed. Unfortunately though, the tests still pass locally (on the earlier commit), so it seems like OpenSSH is more forgiving than this particular server. On a similar note, we will need to consider that #1619 is set to leave a netstandard-only path without any coverage. And in #1659 it will be difficult to tell whether the BouncyCastle fallback is in use, based on the BCL's somewhat opaque |
I am less concerned about those platforms and more concerned about being in a chain of dependencies where even a netcore app could be referencing the netstandard build. One of the highest listed "Used by" libraries on the SSH.NET page is netstandard only: https://www.nuget.org/packages/MongoDBMigrations/2.2.0#dependencies-body-tab |
NuGet would still pick the most appropriate .NET assembly in this case, I just double-checked this locally. If you have a net48 project targeting MongoDBMigrations, the published app will contain the net40 assembly of SSH.NET, not the netstandard2.0 assembly. If you target MongoDBMigrations from a net9.0 app, it would use netstandard2.0, but only because the SSH.NET version referenced by MongoDBMigrations doesn't even have targets for modern .NET . If you reference a newer version of SSH.NET in the app itself, it will also use the net9.0 assembly. |
492dac3
to
3269626
Compare
It fails if incorrectly implemented. See https://github.com/scott-xu/SSH.NET/actions/runs/18098643073/job/51495598766 |
Indeed, thanks. I think I must have run the net48 tests...
Indeed, thanks. I never realised that |
This reverts commit 3269626.
* CI: add Windows Integration Tests for .NET see #1702 (comment) * fix podman setup with Windows and .NET * debug * x * x * x * revert * Run Windows .NET tests in separate job so they run in parallel and we avoid the Common_CreateMoreChannelsThanMaxSessions test failure. * fix coverlet artifacts * fix missing PermitTTY in RemoteSshdConfig Reset this fixes a test failure in Common_CreateMoreChannelsThanMaxSessions when running the tests multiple times against the same SSH server instance. see #1704 (comment) * speed up Windows tests turns out this is caused by DNS resolution taking about 2 seconds on every new connection... * add windows integration tests to Publish needs: --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com> Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Beginning in Windows 10, CNG provides support for Curve25519.
See https://learn.microsoft.com/en-us/windows/win32/seccng/cng-named-elliptic-curves