[Bug 60190] New: rsaenh: Wrong private exponent for RSA keys with public exponent 1
http://bugs.winehq.org/show_bug.cgi?id=60190 Bug ID: 60190 Summary: rsaenh: Wrong private exponent for RSA keys with public exponent 1 Product: Wine Version: 11.15 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: rsaenh Assignee: wine-bugs@list.winehq.org Reporter: Urias.Uhle@web.de Target Milestone: --- Distribution: --- Autodesk Fusion 360 renders a black 3D canvas since Wine 11.11 while its Qt interface works. The cause is not graphics related. This supersedes bug 60010, which I filed against win32u before the root cause was known. Fusion imports a 512 bit RSA private key whose public exponent is 1 through CryptImportKey. Before 11.11 libtomcrypt handled that key. Since d22453b rsaenh uses SymCrypt, which rejected it; 0cb249ce (!11182) made the import succeed again. The import succeeds now, but the derived private key is wrong. SymCryptRsakeyCalculatePrivateFields() in libs/symcrypt/lib/rsakey.c computes the private exponent with SymCryptIntExtendedGcd(), which derives the inverse as -((B1*Src1 - Gcd)/Src2) mod Src1. That does not hold for Src2 == 1, so the private exponent and both CRT exponents come out wrong. The public operation is correct, the private one is not, so Fusion's 3D subsystem never initialises. With e == 1 both RSA operations are the identity, m^1 mod n == m, so the private exponent has to be 1 as well. Setting piPrivExps[i] to 1 directly when au64PubExp[i] == 1, and skipping the gcd path, makes d, dp and dq come out as 1 and both operations become the identity again. I verified that on 11.14 and on current master, and ordinary RSA keys stay byte identical. test_pubexp() in dlls/rsaenh/tests/rsaenh.c only imports the key, which is why this was not caught. An encrypt and decrypt round trip with the same blob shows it. I am not opening a merge request, because I worked this out with LLM assistance and the WineHQ contributor policies ask contributors to refrain from that. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #1 from Urias.Uhle@web.de --- *** Bug 60010 has been marked as a duplicate of this bug. *** -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #2 from Urias.Uhle@web.de --- Created attachment 81875 --> http://bugs.winehq.org/attachment.cgi?id=81875 Set the private exponent to 1 for RSA keys with public exponent 1 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 Urias.Uhle@web.de changed: What |Removed |Added ---------------------------------------------------------------------------- Distribution|--- |Fedora -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #3 from Hans Leidekker <hans@meelstraat.net> --- Thanks. Can you attach a WINEDEBUG=+crypt trace from unpatched Wine? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #4 from Urias.Uhle@web.de --- Created attachment 81878 --> http://bugs.winehq.org/attachment.cgi?id=81878 Autodesk Fusion Log with WINEDEBUG=+crypt and wine-11.15 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #5 from Urias.Uhle@web.de --- Comment on attachment 81878 --> http://bugs.winehq.org/attachment.cgi?id=81878 Autodesk Fusion Log with WINEDEBUG=+crypt and wine-11.15 This is a .zip because the .log file was too large to upload. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #6 from Urias.Uhle@web.de --- Created attachment 81879 --> http://bugs.winehq.org/attachment.cgi?id=81879 claude: where the key appears in the `+crypt` trace -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #7 from Hans Leidekker <hans@meelstraat.net> --- I see the key being imported in this log but there's no sign of it being used to encrypt or decrypt anything. It seems unlikely that this is the cause of this bug. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=60190 --- Comment #8 from Urias.Uhle@web.de --- Created attachment 81908 --> http://bugs.winehq.org/attachment.cgi?id=81908 claude-key-usage-analysis Thanks for looking into it. I can't really judge this myself, I don't know this part of wine well enough. I've attached an md file with what my Claude session worked out from the trace. Short version: you're right that the key never reaches CryptEncrypt or CryptDecrypt, but every PRIVATEKEYBLOB import is followed by a SIMPLEBLOB import into the same provider with hPubKey pointing at the key that was just installed as the key exchange key, and import_symmetric_key() decrypts that block with it. So the private key operation is inside CryptImportKey, not in a separate call. Either way, patching this is what made the problem go away in Autodesk Fusion. If you need any more traces or a smaller one narrowed down to a single round trip, just say so and I'll record it. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla