-
Notifications
You must be signed in to change notification settings - Fork 589
wincng: add ECDSA support for host and user authentication #1315
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
@willco007 and @vszakats, would you mind taking another look? Thanks! |
@jpassing Would you mind investigating the failures here? Thanks. |
Yes, sorry for the delay. Added the missing declarations. I don't have a linux/mingw64 setup locally. so I have to rely on the CI build to check whether it's ok now. |
Would it be possible to trigger the CI again? I hope my last commits fixed the remaining build issues. |
Thanks! Unfortunatelty some tests failed because of issues unrelated to this PR:
Could you trigger it once again, please? |
More intermittent
Let's wait a few hours and try again? |
@jpassing The intermittent issue was the xz backdoor most probably. It should be okay now. |
3f9b340
to
bb2e9c0
Compare
7e20de5
to
ceabf6a
Compare
There is a what looks like a crash happening while running tests in job The job fails consistently: |
Yes... I was able to reproduce the crash on 8.1 and it looks like an access violation, possibly caused by a double-free. I'll have a closer look at why this is happening.
|
The last commit fixed the crash and tests on Windows Server 2012 are now failing with
It's quite possible that CNG on Windows Server 2012 doesn't support all required feature yet, but I'll have to verify that. |
The problematic line of code is the call to
The documentation for
But the documentation doesn't distinguish between RSA and ECC, and it's possible that ECC support was added later. Interestingly, the .NET runtime guards calls with a Windows Server 2012 R2 and Windows 8.1 are both out of support, so I figure it might be okay if WinCNG/ECDSA doesn't work on these platforms? If so, is there any established pattern that I could use to ensure we skip respective tests when executed on these Windows versions? |
|
||
*signature = NULL; | ||
*signature_length = (size_t) | ||
_wincng_ecdsa_algorithms[curve].point_length * 2; |
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.
Would it be useful to check for a possible overflow?
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.
_wincng_ecdsa_algorithms[curve].point_length
is a constant, so I'd say that an overflow check is uneccessary.
It's fine to not support it on these versions (do we have any other choice?). But, we don't have a pattern to skip tests based on runtime availability of algos yet. Also, we don't have plumbing for Windows version detection — this can lead into a rabbit whole, also with manifests, so I'd be happy to avoid it. Do I understand correctly that This reminds of these earlier commit dealing with a similar scenario (with version detection briefly introduced, then solved differently): Do I understand correctly that:
/cc @mback2k |
Yes, exactly. So it's not that ECDSA isn't supported at all on older Windows versions, it's just that this particular function/flag combination doesn't seem to be implemented.
I think it's the same issue: IIUC, with RSA, the solution was to attempt to use The issue with ECDSA is that we don't have an alternate method to fall back to... or at least I'm not aware of one. I agree that checking Windows versions tends to be complex and/or unreliable, so I'd rather avoid that -- at least within the library. Testing in advance if What might work is the following:
Wdyt? |
For tests the Thinking of downstream code trying to use libssh2 though, I'm not sure this would be workable without breaking those when run in an unfit (pre-10) Windows env. Those apps either need to keep ECDSA disabled from the get go or fallback to something else automatically. This brings back to a reliable / fast / manifest-less (end-user apps may not have manifests, nor do our tests), feature or Windows 10 detection on init. Could Or perhaps There is Another option is to enable this only when building for Win10 or higher based on |
That's a good point. I'm sure we could do a Windows version check somehow, but I worry that it would be a high-impact change: All places that currently use
Guarding the feature by a If
That would also block |
That'd be harsh indeed. It means it's not enough to do this once in
Good idea, we can go with it. The mingw-w64 equivalent for the MSVC linker option above seems to be: I propose using the names |
* Null out `secret` when the function fails to avoid an AV on Win2012/8.1 * Update other functions to consistently set out-parameters to NULL
Disable WinCNG ECDSA support by default to maintain backward compatibility for projects that target versions below Windows 10.
d27a486
to
58346c6
Compare
Thanks @jpassing for the great work. Merged now. |
Thanks a lot for your help and fixing the build scripts, @vszakats! |
) The WinCNG backend currently only supports DSA and RSA. This PR adds ECDSA support for host and user authentication. * Disable WinCNG ECDSA support by default to maintain backward compatibility for projects that target versions below Windows 10. * Add cmake option `ENABLE_ECDSA_WINCNG` to guard ECDSA support. * Update AppVeyor job matrix to only enable ECDSA on Server 2016+
- add `./configure` option `--enable-ecdsa-wincng` - add WinCNG autotools jobs to GHA. - enable WinCNG ECDSA in some GHA jobs (both CMake and autotools). Follow-up to 3e72343 libssh2#1315 Closes libssh2#1368
The WinCNG backend currently only supports DSA and RSA. This PR adds
ECDSA support for host and user authentication.
I'd appreciate if someone could take a look.