pbatard / libwdi

Windows Driver Installer library for USB devices
GNU General Public License v3.0
1.87k stars 466 forks source link

Can't create self signed cert, invalid algorithm due to CryptoPro CSP #129

Closed Forst closed 6 years ago

Forst commented 6 years ago

Hello!

I am unable to install the WinUSB (or any other, in fact) driver for my RTL-SDR stick. My wild guess is that the latest Windows 10 update removed some obsolete ciphers/hashes/whatever, as it's complaining about an invalid algorithm:

libwdi:warning [CreateSelfSignedCert] could not create self signed certificate: [#80090008] Указан неправильный алгоритм.
libwdi:warning [wdi_prepare_driver] could not sign cat file

(translates as "Invalid algorithm specified")

Full log attached below.


Zadig 2.3.701
Windows 10 64-bit (Build 17134)
ini file 'zadig.ini' not found - default parameters will be used
default driver set to 'WinUSB'
0 devices found.
5 devices found.
libwdi:debug [wdi_create_list] Hardware ID: USB\VID_203A&PID_FFF9&REV_0100&MI_00
libwdi:debug [wdi_create_list] Compatible ID: USB\Class_0e&SubClass_03&Prot_00
libwdi:debug [wdi_create_list] Driver version: 10.0.17134.1
libwdi:debug [wdi_create_list] usbvideo USB device (0): USB\VID_203A&PID_FFF9&MI_00\6&3B2622F3&0&0000
libwdi:debug [wdi_create_list] Device description: 'FaceTime HD Camera (Built-in) (Interface 0)'
libwdi:debug [wdi_create_list] Hardware ID: USB\VID_0BDA&PID_2838&REV_0100&MI_00
libwdi:debug [wdi_create_list] Compatible ID: USB\Class_ff&SubClass_ff&Prot_ff
libwdi:debug [wdi_create_list] Upper filter: RTL2832UBDA
libwdi:debug [wdi_create_list] Driver version: 64.1.802.2010
libwdi:debug [wdi_create_list] RTL2832UUSB USB device (3): USB\VID_0BDA&PID_2838&MI_00\6&38A180A5&0&0000
libwdi:debug [wdi_create_list] Device description: 'Bulk-In, Interface (Interface 0)'
libwdi:debug [wdi_create_list] Hardware ID: USB\VID_203A&PID_FFFC&REV_0100&MI_00
libwdi:debug [wdi_create_list] Compatible ID: USB\Class_03&SubClass_00&Prot_02
libwdi:debug [wdi_create_list] Driver version: 10.0.17134.1
libwdi:debug [wdi_create_list] HidUsb USB device (5): USB\VID_203A&PID_FFFC&MI_00\6&100686D9&0&0000
libwdi:debug [wdi_create_list] Device description: 'Absolute Coordinate Interface (Interface 0)'
libwdi:debug [wdi_create_list] Hardware ID: USB\VID_0BDA&PID_2838&REV_0100&MI_01
libwdi:debug [wdi_create_list] Compatible ID: USB\Class_ff&SubClass_ff&Prot_ff
libwdi:debug [wdi_create_list] Driver version: 8664.1.818.2009
libwdi:debug [wdi_create_list] RTL2832U_IRHID USB device (7): USB\VID_0BDA&PID_2838&MI_01\6&38A180A5&0&0001
libwdi:debug [wdi_create_list] Device description: 'Bulk-In, Interface (Interface 1)'
libwdi:debug [wdi_create_list] Hardware ID: USB\VID_203A&PID_FFFC&REV_0100&MI_01
libwdi:debug [wdi_create_list] Compatible ID: USB\Class_03&SubClass_00&Prot_02
libwdi:debug [wdi_create_list] Driver version: 10.0.17134.1
libwdi:debug [wdi_create_list] HidUsb USB device (9): USB\VID_203A&PID_FFFC&MI_01\6&100686D9&0&0001
libwdi:debug [wdi_create_list] Device description: 'Relative Coordinate Interface (Interface 1)'
Using inf name: Bulk-In_Interface_(Interface_0).inf
Successfully extracted driver files.
Installing driver. Please wait...
libwdi:info [extract_binaries] successfully extracted driver files to C:\Users\Foster Snowhill\usb_driver
libwdi:info [wdi_prepare_driver] successfully created 'C:\Users\Foster Snowhill\usb_driver\Bulk-In_Interface_(Interface_0).inf'
libwdi:info [wdi_prepare_driver] Creating and self-signing a .cat file...
libwdi:debug [AddFileHash] 'wdfcoinstaller01011.dll': PE type
libwdi:info [ScanDirAndHash] added hash for 'C:\Users\Foster Snowhill\usb_driver\amd64\wdfcoinstaller01011.dll'
libwdi:debug [AddFileHash] 'winusbcoinstaller2.dll': PE type
libwdi:info [ScanDirAndHash] added hash for 'C:\Users\Foster Snowhill\usb_driver\amd64\winusbcoinstaller2.dll'
libwdi:debug [AddFileHash] 'bulk-in_interface_(interface_0).inf': INF type
libwdi:info [ScanDirAndHash] added hash for 'C:\Users\Foster Snowhill\usb_driver\bulk-in_interface_(interface_0).inf'
libwdi:debug [AddFileHash] 'wdfcoinstaller01011.dll': PE type
libwdi:info [ScanDirAndHash] added hash for 'C:\Users\Foster Snowhill\usb_driver\x86\wdfcoinstaller01011.dll'
libwdi:debug [AddFileHash] 'winusbcoinstaller2.dll': PE type
libwdi:info [ScanDirAndHash] added hash for 'C:\Users\Foster Snowhill\usb_driver\x86\winusbcoinstaller2.dll'
libwdi:info [CreateCat] successfully created file 'C:\Users\Foster Snowhill\usb_driver\Bulk-In_Interface_(Interface_0).cat'
libwdi:debug [CreateSelfSignedCert] set Enhanced Key Usage, URL and CPS
libwdi:debug [CreateSelfSignedCert] acquired existing key container
libwdi:debug [CreateSelfSignedCert] generated new keypair
libwdi:warning [CreateSelfSignedCert] could not create self signed certificate: [#80090008] Указан неправильный алгоритм.
libwdi:warning [wdi_prepare_driver] could not sign cat file
libwdi:debug [wdi_install_driver] using progress bar mode
libwdi:debug [installer process] got parameter Bulk-In_Interface_(Interface_0).inf
libwdi:debug [process_message] got request for device_id
libwdi:debug [installer process] got device_id: 'USB\VID_0BDA&PID_2838&MI_00\6&38A180A5&0&0000'
libwdi:debug [process_message] got request for hardware_id
libwdi:debug [installer process] got hardware_id: 'USB\VID_0BDA&PID_2838&REV_0100&MI_00'
libwdi:debug [installer process] got user_sid: 'S-1-5-21-4007036018-4238844075-2969377040-1001'
libwdi:debug [installer process] using syslog 'C:\WINDOWS\inf\setupapi.dev.log'
libwdi:debug [installer process] syslog reader thread started
libwdi:debug [installer process] successfully disabled the system restore point creation setting
libwdi:debug [process_message] switching timeout to infinite
libwdi:debug [installer process] Installing driver for USB\VID_0BDA&PID_2838&REV_0100&MI_00 - please wait...
libwdi:debug [syslog] <Garbled data>
libwdi:debug [syslog] [Boot Session: 2018/05/26 22:00:01.493]
libwdi:debug [syslog] >>>  [Device Install (UpdateDriverForPlugAndPlayDevices) - USB\VID_0BDA&PID_2838&REV_0100&MI_00]
libwdi:debug [syslog] >>>  Section start 2018/05/26 22:00:46.445
libwdi:debug [syslog]       cmd: "C:\Users\Foster Snowhill\usb_driver\installer_x64.exe" "Bulk-In_Interface_(Interface_0).inf"
libwdi:debug [syslog]      ndv: INF path: C:\Users\Foster Snowhill\usb_driver\Bulk-In_Interface_(Interface_0).inf
libwdi:debug [syslog]      ndv: Install flags: 0x00000001
libwdi:debug [syslog]      ndv: {Update Device Driver - USB\VID_0BDA&PID_2838&MI_00\6&38A180A5&0&0000}
libwdi:debug [syslog]      ndv:      Search options: 0x00000080
libwdi:debug [syslog]      ndv:      Searching single INF 'C:\Users\Foster Snowhill\usb_driver\Bulk-In_Interface_(Interface_0).inf'
libwdi:debug [syslog]      dvi:      {Build Driver List} 22:00:46.455
libwdi:debug [syslog]      dvi:           Searching for hardware ID(s):
libwdi:debug [syslog]      dvi:                usb\vid_0bda&pid_2838&rev_0100&mi_00
libwdi:debug [syslog]      dvi:                usb\vid_0bda&pid_2838&mi_00
libwdi:debug [syslog]      dvi:           Searching for compatible ID(s):
libwdi:debug [syslog]      dvi:                usb\class_ff&subclass_ff&prot_ff
libwdi:debug [syslog]      dvi:                usb\class_ff&subclass_ff
libwdi:debug [syslog]      dvi:                usb\class_ff
libwdi:debug [syslog]      sig:           {_VERIFY_FILE_SIGNATURE} 22:00:46.460
libwdi:debug [syslog]      sig:                Key      = bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                FilePath = c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                Catalog  = c:\users\foster snowhill\usb_driver\Bulk-In_Interface_(Interface_0).cat
libwdi:debug [syslog] !    sig:                Verifying file against specific (valid) catalog failed.
libwdi:debug [syslog] !    sig:                Error 0x800b0100: No signature was present in the subject.
libwdi:debug [syslog]      sig:           {_VERIFY_FILE_SIGNATURE exit(0x800b0100)} 22:00:46.499
libwdi:debug [syslog]      sig:           {_VERIFY_FILE_SIGNATURE} 22:00:46.500
libwdi:debug [syslog]      sig:                Key      = bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                FilePath = c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                Catalog  = c:\users\foster snowhill\usb_driver\Bulk-In_Interface_(Interface_0).cat
libwdi:debug [syslog] !    sig:                Verifying file against specific Authenticode(tm) catalog failed.
libwdi:debug [syslog] !    sig:                Error 0x800b0100: No signature was present in the subject.
libwdi:debug [syslog]      sig:           {_VERIFY_FILE_SIGNATURE exit(0x800b0100)} 22:00:46.502
libwdi:debug [syslog]      dvi:           Created Driver Node:
libwdi:debug [syslog]      dvi:                HardwareID   - USB\VID_0BDA&PID_2838&MI_00
libwdi:debug [syslog]      dvi:                InfName      - c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      dvi:                DevDesc      - Bulk-In, Interface (Interface 0)
libwdi:debug [syslog]      dvi:                Section      - USB_Install
libwdi:debug [syslog]      dvi:                Rank         - 0x80ff0001
libwdi:debug [syslog]      dvi:                Signer Score - Not digitally signed
libwdi:debug [syslog]      dvi:                DrvDate      - 02/10/2017
libwdi:debug [syslog]      dvi:                Version      - 6.1.7600.16385
libwdi:debug [syslog]      dvi:      {Build Driver List - exit(0x00000000)} 22:00:46.506
libwdi:debug [syslog]      dvi:      {DIF_SELECTBESTCOMPATDRV} 22:00:46.506
libwdi:debug [syslog]      dvi:           Default installer: Enter 22:00:46.507
libwdi:debug [syslog]      dvi:                {Select Best Driver}
libwdi:debug [syslog]      dvi:                     Class GUID of device changed to: {88bae032-5a81-49f0-bc3d-a4ff138216d6}.
libwdi:debug [syslog]      dvi:                     Selected Driver:
libwdi:debug [syslog]      dvi:                          Description - Bulk-In, Interface (Interface 0)
libwdi:debug [syslog]      dvi:                          InfFile     - c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      dvi:                          Section     - USB_Install
libwdi:debug [syslog]      dvi:                {Select Best Driver - exit(0x00000000)}
libwdi:debug [syslog]      dvi:           Default installer: Exit
libwdi:debug [syslog]      dvi:      {DIF_SELECTBESTCOMPATDRV - exit(0x00000000)} 22:00:46.509
libwdi:debug [syslog]      ndv:      Force Installing Driver:
libwdi:debug [syslog]      ndv:           Inf Name       - bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      ndv:           Driver Date    - 02/10/2017
libwdi:debug [syslog]      ndv:           Driver Version - 6.1.7600.16385
libwdi:debug [syslog]      sto:      {Setup Import Driver Package: c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf} 22:00:46.511
libwdi:debug [syslog]      inf:           Provider: libwdi
libwdi:debug [syslog]      inf:           Class GUID: {88bae032-5a81-49f0-bc3d-a4ff138216d6}
libwdi:debug [syslog]      inf:           Driver Version: 02/10/2017,6.1.7600.16385
libwdi:debug [syslog]      inf:           Catalog File: Bulk-In_Interface_(Interface_0).cat
libwdi:debug [syslog]      sto:           {Copy Driver Package: c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf} 22:00:46.515
libwdi:debug [syslog]      sto:                Driver Package = c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sto:                Flags          = 0x00000007
libwdi:debug [syslog]      sto:                Destination    = C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}
libwdi:debug [syslog]      sto:                Copying driver package files to 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}'.
libwdi:debug [syslog]      flq:                Copying 'c:\users\foster snowhill\usb_driver\amd64\WdfCoInstaller01011.dll' to 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\amd64\WdfCoInstaller01011.dll'.
libwdi:debug [syslog]      flq:                Copying 'c:\users\foster snowhill\usb_driver\amd64\WinUSBCoInstaller2.dll' to 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\amd64\WinUSBCoInstaller2.dll'.
libwdi:debug [syslog]      flq:                Copying 'c:\users\foster snowhill\usb_driver\Bulk-In_Interface_(Interface_0).cat' to 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\Bulk-In_Interface_(Interface_0).cat'.
libwdi:debug [syslog]      flq:                Copying 'c:\users\foster snowhill\usb_driver\bulk-in_interface_(interface_0).inf' to 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\bulk-in_interface_(interface_0).inf'.
libwdi:debug [syslog]      sto:           {Copy Driver Package: exit(0x00000000)} 22:00:46.532
libwdi:debug [syslog]      pol:           {Driver package policy check} 22:00:46.712
libwdi:debug [syslog]      pol:           {Driver package policy check - exit(0x00000000)} 22:00:46.712
libwdi:debug [syslog]      sto:           {Stage Driver Package: C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\bulk-in_interface_(interface_0).inf} 22:00:46.713
libwdi:debug [syslog]      inf:                {Query Configurability: C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\bulk-in_interface_(interface_0).inf} 22:00:46.717
libwdi:debug [syslog]      inf:                     Driver package uses WDF.
libwdi:debug [syslog]      inf:                     Driver package 'bulk-in_interface_(interface_0).inf' is configurable.
libwdi:debug [syslog]      inf:                {Query Configurability: exit(0x00000000)} 22:00:46.725
libwdi:debug [syslog]      flq:                Copying 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\amd64\WdfCoInstaller01011.dll' to 'C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\amd64\WdfCoInstaller01011.dll'.
libwdi:debug [syslog]      flq:                Copying 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\amd64\WinUSBCoInstaller2.dll' to 'C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\amd64\WinUSBCoInstaller2.dll'.
libwdi:debug [syslog]      flq:                Copying 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\Bulk-In_Interface_(Interface_0).cat' to 'C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\Bulk-In_Interface_(Interface_0).cat'.
libwdi:debug [syslog]      flq:                Copying 'C:\Users\FOSTER~1\AppData\Local\Temp\{84496e4b-b0b6-6b4d-8d6c-f415d218aafd}\bulk-in_interface_(interface_0).inf' to 'C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\bulk-in_interface_(interface_0).inf'.
libwdi:debug [syslog]      sto:                {DRIVERSTORE IMPORT VALIDATE} 22:00:46.746
libwdi:debug [syslog]      sig:                     {_VERIFY_FILE_SIGNATURE} 22:00:46.804
libwdi:debug [syslog]      sig:                          Key      = bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                          FilePath = C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                          Catalog  = C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\Bulk-In_Interface_(Interface_0).cat
libwdi:debug [syslog] !    sig:                          Verifying file against specific (valid) catalog failed.
libwdi:debug [syslog] !    sig:                          Error 0x800b0100: No signature was present in the subject.
libwdi:debug [syslog]      sig:                     {_VERIFY_FILE_SIGNATURE exit(0x800b0100)} 22:00:46.808
libwdi:debug [syslog]      sig:                     {_VERIFY_FILE_SIGNATURE} 22:00:46.809
libwdi:debug [syslog]      sig:                          Key      = bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                          FilePath = C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\bulk-in_interface_(interface_0).inf
libwdi:debug [syslog]      sig:                          Catalog  = C:\WINDOWS\System32\DriverStore\Temp\{3907f1fd-a0ec-324c-a171-72defa276b69}\Bulk-In_Interface_(Interface_0).cat
libwdi:debug [syslog] !    sig:                          Verifying file against specific Authenticode(tm) catalog failed.
libwdi:debug [syslog] !    sig:                          Error 0x800b0100: No signature was present in the subject.
libwdi:debug [syslog]      sig:                     {_VERIFY_FILE_SIGNATURE exit(0x800b0100)} 22:00:46.811
libwdi:debug [syslog] !!!  sig:                     Driver package catalog file does not contain a signature, and Code Integrity is enforced.
libwdi:debug [syslog] !!!  sig:                     Driver package failed signature validation. Error = 0xE0000247
libwdi:debug [syslog]      sto:                {DRIVERSTORE IMPORT VALIDATE: exit(0xe0000247)} 22:00:46.812
libwdi:debug [syslog] !!!  sig:                Driver package failed signature verification. Error = 0xE0000247
libwdi:debug [syslog] !!!  sto:                Failed to import driver package into Driver Store. Error = 0xE0000247
libwdi:debug [syslog]      sto:           {Stage Driver Package: exit(0xe0000247)} 22:00:46.815
libwdi:debug [syslog]      sto:      {Setup Import Driver Package - exit (0xe0000247)} 22:00:46.821
libwdi:debug [process_message] switching timeout back to finite
libwdi:debug [installer process] operation cancelled by the user
libwdi:debug [process_message] installer process completed
Driver Installation: Cancelled by User
pbatard commented 6 years ago

Thanks for the report.

Despite many people (including myself) using the latest fully patched Windows 10, you are the only person reporting this, so I logically have to suspect that this has to do more with something that is specific to your environment, as opposed to something that Microsoft may have broken for everybody.

For one thing, I certainly cannot replicate this issue.

From the error you are getting (Invalid algorithm specified), and from the code in CreateSelfSignedCert(), the only possibility I see is that, somehow, your Windows configuration disabled the use of SHA-256 RSA implementation (szOID_RSA_SHA256RSA), as this is the only way I see where you would get Unknown/Invalid cryptographic algorithm as an error.

I know that, for instance, Local Group Policy settings can disable the use of some cryptographic algorithms, though that should be for obsolete or potentially vulnerable ones, which SHA-256 isn't.

What happens if you try on a different Windows 10 platform?

Forst commented 6 years ago

I succeeded in reproducing this issue on a new installation of Windows 10. The problem is caused by CryptoPro CSP – a crypto provider implementing support for Russian cryptographic algorithms. Trying it with CSP version 5.0.10874.

If my understanding is correct, Windows can have multiple crypto providers installed and can choose whichever one it needs. Zadig perhaps picks the first available one, which happens to be CryptoPro?

pbatard commented 6 years ago

If my understanding is correct, Windows can have multiple crypto providers installed and can choose whichever one it needs.

Which is already what we do. We explicitly request PROV_RSA_FULL which is the RSA provider, and should still provide the szOID_RSA_SHA256RSA algorithm that we need.

The fact that this fails seems to indicate that CryptoPro CSP is actually trying to replace the RSA provider, instead of installing itself as an additional provider, which, if true, is very bad practice and suspicious...

For the record, this is the part where we select the Cryptographic Service Provider, so we are most certainly expecting to have properly selected the RSA version, rather than an additional provider, if this call succeed (which it does).

Which means that, if after we explicitly told Windows we wanted to use the RSA CSP for our PKI needs, Windows tells us that szOID_RSA_SHA256RSA is unavailable, it logically means that your CryptoPro CSP has altered the RSA provider, which is not something it should ever do if it is meant to coexist with existing providers, and again, sounds exceedingly suspicious...

At this stage, considering that the problem is external to libwdi/Zadig and that I am certainly not planning to go out of my way to add support for non native CSP, especially if they prevent native CSP from being used, I will simply close this issue. If you are unhappy with that, I will kindly request that you alter the PKI code yourself to use your CSP, and recompile your own version.

Forst commented 6 years ago

Thank you very much for a thorough explanation!

It is indeed trying to reimplement RSA and ECDSA if you tell it to, however it's not the default option, that might explain why nobody encountered this issue before.

For the record, in case anyone else gets hit by this. What one has to do is to uncheck "Support for RSA/ECDSA cryptoproviders" in Add/remove programs for CryptoPro CSP, which removes relevant broken components and thus fixes the problem.