-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
RSAOpenSsl seems to allow inconsistent values to ImportParameters #29515
Comments
Given that this isn't new in 3.0 I'm moving to Future (PRs while 3.0 is still open are still welcome). |
@bartonjs One way to address this is with |
Well, sort of. The problem is (last I checked) RSA_check_key directly checks the members of a default-engine software key. If it's possible to change the engine used by If that is always hard-coded to be the default engine, no worries. (And if we can determine that the engine isn't default, but we can forcibly use the software engine as a temporary engine during import, that's fine, too) |
@bartonjs Yes, that is the case. Someone could do I think we have three choices.
I can do either 1 or 2, two feels like more work to me but perhaps more "correct" since one might reject parameters that the engine is otherwise fine with using. As an aside, |
(1) seems like the easiest short term general solution (a temporary default-engine key to import and check, then if that passes import into the provided key). |
@bartonjs I pushed up some changes at master...vcsjones:fix-37595. This is not complete (more tests, etc), but wanted to check a few things before I continue.
Sorry for the big wall of questions, thanks for bearing with me. |
|
@bartonjs to summarize some things I learned..
Given all of that..
|
For both this issue and 33278, we might need to dual-import into Windows; once for parameter consistency and once for real... I'm not sure if exporting the key calls (internally) NCryptFinalizeKey, meaning that you can't import and then change properties (like the export policy) that can't be altered after finalize... of course, that only matters for the publicly CNG types (RSACng, ECDsaCng)... the ephemeral key opaque types from RSA.Create() or ECDsa.Create() can do the fast path, since there's no way to get the NCRYPT_KEY_HANDLE back. |
@bartonjs question: Does CNG support public exponents larger than UInt32.MaxValue? As far as I can tell, "Microsoft Software Key Storage Provider" will not accept an E larger than that, but I am not sure if that is a limitation of that particular CNG provider and other CNG providers could handle more, or if CNG imposes a real upper bound on it. |
Yep. https://github.com/dotnet/corefx/blob/d3911035f2ba3eb5c44310342cc1d654e42aa316/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs#L1558 is the key I habitually use for testing that. I feel like they broke it at some point in Win10 (brought back the 32-bit limit from CAPI because of a perf improvement), but then made it work again (but the limit now might be a 64-bit value for E). |
@bartonjs thinking about where to take this issue next, the original issue from the title was addressed by dotnet/corefx#38884. There are a number of other platform inconsistencies. I'm not sure if you want to open new issues for those, or make this one a bit more generic, "Inconsistent validation of RSA parameters at import time across platforms" or something.
|
@vcsjones I guess it depends on if you are wanting to tackle them or we're leaving them as open issues. If you're wanting to provide fixes, I'm fine using this issue as an uber-issue for making parameter import consistent across platforms (or breaking it up into smaller issues, whichever makes you happier). If we're leaving it as open, it probably makes more sense to open specific issues. (Ideally with a "this type of problem, for example [some parameters]", but perhaps just a "this type of problem... parameter generation left as an exercise to the reader".) |
Yes, just been a little slow organizing things. Leaving it as a single issue appeals to my sense of laziness, so I'll just use this issue. |
When the Modulus and Exponent are from one key, and the private parameters are from a key of a completely different size, the import shouldn't succeed, but does.
The key is in an obviously inconsistent state at that point, maybe it's deferring the check to first use... but we should lift it up to fail the import (and have parity with the other OSes).
The text was updated successfully, but these errors were encountered: