none
Generic USB CCID Driver for Windows RRS feed

  • Question

  • Hello Everyone,

    I'm currently attempting to develop a very simple USB CCID Smart Card Reader driver for windows and I'm somewhat lost!

    I have a USB device prototype which acts as a storage device and smart card reader combined.

    The device itself is automatically detected by Windows/Linux as a storage device and immediately accessible, to make it fully work under Linux I grabbed a sample from GitHub (USB CCID IFD Handler by Ludovic Rouseseau) and expanded it to provide the needed functionality as a smart card reader.

    Right now I'm trying to do the same under Windows, first I would like to know what this would be, is it a minidriver, a filter driver or a function driver?

    I started a new project and am simply trying to do anything with UMDF 2, the problem is that the samples provided are way too different from what I want to do to even start and the documentation seems extremely scarce.


    Basically this is what I want:

    • New USB device is plugged into the machine, if the Vendor and Product ID matches so we load our smart card driver
    • I override the original smart card calls and provide the correct response for whatever data is requested.


    I also tried to get an understanding on how this works from here [An UMDF Driver for a Virtual Smart Card Reader] but the example is done in UMDF 1 and trying to convert it to UMDF 2 when I have a really basic understanding on Windows Drivers seems like a really bad way to start digging into this topic.

    Could someone point me in the right direction?

    Thanks in advance!


    • Edited by Mywk Saturday, May 12, 2018 2:39 PM Grammar
    Wednesday, May 9, 2018 1:21 PM

Answers

  • You would need a kmdf filter driver that is a lower filter below the usb mass storage driver. That filter driver will enumerate a child device (and be a bus driver). You will the install your umdf virtual smart card driver on this child device. The smart card driver would send io down the stack to your bus driver and the bus driver would translate these requests to usb requests. Your best bet is to start with the toaster sample and merge the filter example with the static bus driver example. The kbdfiltr sample shows a filter that enumerates a child device as well (it enumerates a raw child, you should remove the raw part). You cannot use winusb in this scenario as that requires directl access to the endpoints which it can’t acquire as the usb mass storage driver owns them.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, May 9, 2018 5:06 PM

All replies

  • If you implement the CCID usb spec you get the inbox class driver. By far The simplest choice.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, May 9, 2018 2:33 PM
  • As I didn't fully understand what you meant I'll add some more details to my question.

    The device has a very limited chip and must be set as "Storage device" (disk drive on the Device manager tree).

    I'm simply looking for a way to add what I assume that would be a virtual smart card device when the PnP USB Drive is inserted.

    After a bit more of research it seems that I would need a "Filter Driver" that would attach to the device when it gets plugged in and the Vendor and Product ID matches, then somehow create a virtual smart card device which exposes the smart card functions, at that point I can just do what I want using WinUSB, is this correct?

    Thanks once again!


    • Edited by Mywk Saturday, May 12, 2018 2:36 PM Grammar
    Wednesday, May 9, 2018 3:00 PM
  • You would need a kmdf filter driver that is a lower filter below the usb mass storage driver. That filter driver will enumerate a child device (and be a bus driver). You will the install your umdf virtual smart card driver on this child device. The smart card driver would send io down the stack to your bus driver and the bus driver would translate these requests to usb requests. Your best bet is to start with the toaster sample and merge the filter example with the static bus driver example. The kbdfiltr sample shows a filter that enumerates a child device as well (it enumerates a raw child, you should remove the raw part). You cannot use winusb in this scenario as that requires directl access to the endpoints which it can’t acquire as the usb mass storage driver owns them.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, May 9, 2018 5:06 PM
  • I'm currently attempting to develop a very simple USB CCID Smartcard Reader driver for windows 

    So you see, in Windows, a simple driver requires some minimal level of cooperation from the hardware.

    If the hardware is simpler than this minimum, the driver part explodes and eats savings from the cheap hardware. In the best case, device could work with only in-box Windows drivers, bypassing custom driver development and its expenses (signing, certificates...)

    -- pa

    Wednesday, May 9, 2018 6:19 PM
  • I definitively understand what you mean, I'm enjoying this experience with Windows Drivers so far, it's a shame there's almost no Windows open source drivers, it's usually way easier to understand something when we have the chance of reading code that works (granted that most people will just copy and paste it without even attempting to understand it but that's another issue).

    For now I'm just reading the examples that Doron Holan suggested and trying to understand better this whole thing.

    • Edited by Mywk Saturday, May 12, 2018 2:33 PM Grammar
    Friday, May 11, 2018 9:33 AM
  • But is it possible to fix the device part? Today one can find quite a lot of microcontrollers with powerful USB interfaces. Examples are available. Make a proper multifunction (composite) device and Windows will do the rest. Win10 has in-box driver for USB CCID. 

    Development is only part of the work, consider testing and maintenance.

    -- pa

    Friday, May 11, 2018 5:26 PM
  • It seems I've been approaching this completely wrong and over-complicating everything in all the ways possible. As I started this topic I had zero knowledge on Windows Drivers, it has been 4 days of intensive research on this topic and there's still a lot to learn.


    As there is a Win10 CCID in-box driver, lets simplify:

    - Due to technical limitations the device can only be set as having one functionality so it will have to remain a Storage Device.

    - The device is a CCID compliant device and a storage device, however, before sending and receiving CCID commands, they need to be translated into SCSI commands.

    Considering that the device part cannot be changed for a better one, what would be the best way to implement this for Windows?

    Once again thanks a lot!

    • Edited by Mywk Saturday, May 12, 2018 2:41 PM Extra Info
    Friday, May 11, 2018 6:09 PM
  • before sending and receiving CCID commands, they need to be translated into SCSI commands.

    SPTI ?

    -- pa

    Tuesday, May 15, 2018 2:56 PM
  • That's exactly it!! So to summarize:

    - A UMDF driver that acts as a virtual smart card and and uses SPTI for the communication.
    - A KMDF lower filter driver that installs/uninstalls that UMDF driver when the device is plugged in or out.

    Thank you all for explaining everything so thoroughly!
    Wednesday, May 16, 2018 8:13 AM
  • Except that kernel mode drivers do not install any other drivers. They can create additional devices (PnP children or legacy) Installation of drivers for these new devices occurs somewhere else, and at unspecified time (usually in a few seconds, but can vary).

    Good luck.

    -- pa

     

    • Edited by Pavel A Wednesday, May 16, 2018 11:37 AM
    Wednesday, May 16, 2018 11:34 AM
  • I apologize in advance for bumping this topic, I was able to accomplish most of what I described above the way Doron Holan advised (bus lower filter that installs a virtual device on the child device).

    Regardless, I was wondering if this wouldn't be better using an Extension Device (I'm not looking for backwards compatibility here, minimum supported operative system should be Windows 10).
    I couldn't find much documentation on this but what's on the MS Docs is enough to get me started.

    According to the Docs, I just use the new driver and assuming the inf file is correct it uses the AddComponent directive to create a virtual child device without removing the default functionality of the device, is this correct?

    Tuesday, July 3, 2018 8:32 AM