[Bug 60497] New: crypt32: PFXImportCertStore() fails for a PFX with an empty password created by BouncyCastle (MAC verification failed)
http://bugs.winehq.org/show_bug.cgi?id=60497 Bug ID: 60497 Summary: crypt32: PFXImportCertStore() fails for a PFX with an empty password created by BouncyCastle (MAC verification failed) Product: Wine Version: 11.19 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: crypt32 Assignee: wine-bugs@list.winehq.org Reporter: mailtomendoza@gmail.com Target Milestone: --- Distribution: --- PFXImportCertStore() with an empty password fails for PKCS#12 files written by BouncyCastle (C#, Pkcs12Store.Save() with an empty password; seen with BouncyCastle.Crypto 1.8): GnuTLS error: The Message Authentication Code verification failed. The same files import on Windows. In my case, SALTO ProAccess Space 6.14 stores such PFX files (per-device certificates, EC keys) and loads them with X509Certificate2 in .NET Framework 4.8. That works on Windows and fails under Wine. Cause: for an empty password BouncyCastle computes the MAC over a zero-length password, instead of a single BMPString null character (00 00). open_cert_store() always passes "" to gnutls_pkcs12_verify_mac(), which GnuTLS turns into 00 00, so the MAC check fails. gnutls_pkcs12_verify_mac(p12, NULL) succeeds. Windows accepts both encodings of an empty password, and OpenSSL also accepts these files with an empty password. Reproducer (attached): pfxcheck.c (plain C, mingw-w64: x86_64-w64-mingw32-gcc pfxcheck.c -lcrypt32) and bc-empty.pfx (throwaway RSA test certificate, CN=test, empty password, written with pfxgen.cs/BouncyCastle): wine pfxcheck.exe bc-empty.pfx Wine 11.19: PFXImportCertStore(""): FAILED with the patch: PFXImportCertStore(""): OK, cert 1, private key: yes The same file re-saved with the password "test" imports fine on unpatched Wine, so this concerns only the empty-password case. (Unpatched Wine also leaves the last error unset on this failure; that is bug 60234.) A suggested patch is attached (tested on Wine 11.19, applies to master too): if the MAC check fails and the password is empty, retry gnutls_pkcs12_verify_mac() with NULL, and if that succeeds use NULL for the bag decryption too. 32- and 64-bit tested; crypt32 conformance tests unchanged. For builds with the old WoW64 layout, the i386-unix crypt32.so needs it as well. Not done yet: a conformance test (a small BouncyCastle-style PFX with a zero-length-password MAC embedded in tests/store.c or tests/main.c would do 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.
http://bugs.winehq.org/show_bug.cgi?id=60497 --- Comment #1 from mailtomendoza@gmail.com --- Created attachment 82350 --> http://bugs.winehq.org/attachment.cgi?id=82350 Suggested patch (tested on Wine 11.19, not upstream-ready) -- 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=60497 --- Comment #2 from mailtomendoza@gmail.com --- Created attachment 82351 --> http://bugs.winehq.org/attachment.cgi?id=82351 pfxcheck.c - reproducer (mingw-w64, -lcrypt32) -- 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=60497 --- Comment #3 from mailtomendoza@gmail.com --- Created attachment 82352 --> http://bugs.winehq.org/attachment.cgi?id=82352 bc-empty.pfx - BouncyCastle PFX, RSA test cert, empty password -- 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=60497 --- Comment #4 from mailtomendoza@gmail.com --- Created attachment 82353 --> http://bugs.winehq.org/attachment.cgi?id=82353 pfxgen.cs - how the test PFX files were generated (BouncyCastle C#) -- 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