LudovicRousseau / CCID

CCID driver
https://ccid.apdu.fr/
GNU Lesser General Public License v2.1
229 stars 79 forks source link

Add kapelse readers support in COMPOSITE_AS_MULTISLOT mode #118

Closed bmoraine closed 7 months ago

bmoraine commented 11 months ago

Hello,

Please find 2 patches regarding COMPOSITE_AS_MULTISLOT mode to simplify its implementation and to add support for Kapelse readers supports.

Best Regards

Baptiste Moraine

bmoraine commented 11 months ago

Build issue when --enable-strict --enable-composite-as-multislot used for configuration is now fixed by last commit

LudovicRousseau commented 10 months ago

Can you also give me the output of the following command for each kapelse readers please

lsusb -d 2947: -v | grep 'bInterfaceClass\|idVendor\|idProduct'

I need to know what other interfaces are present and in which position.

For example the Gemalto Prox DU reader has 2 CCID interfaces and 1 HID interface. The HID interface is in the first position so max_num_interfaces is not the same as the number of "slots" as you suggested in your patch. The code you removed looked like a duplication but was not exactly the same.

bmoraine commented 10 months ago

Please find below the output of the command : lsusb -d 2947: -v | grep 'bInterfaceClass\|idVendor\|idProduct'

  1. For Kap&Link2
  1. For KAP-eCV :

$ lsusb -d 2947: -v | grep 'bInterfaceClass|idVendor|idProduct' idVendor 0x2947 idProduct 0x0112 bInterfaceClass 11 Chip/SmartCard bInterfaceClass 3 Human Interface Device bInterfaceClass 2 Communications bInterfaceClass 10 CDC Data

  1. For all others Kapelse readers there are as many CCID interfaces as USB interfaces as for Kap&Link : $ lsusb -d 2947: -v | grep 'bInterfaceClass|idVendor|idProduct' idVendor 0x2947 idProduct 0x0101 bInterfaceClass 11 Chip/SmartCard bInterfaceClass 11 Chip/SmartCard
bmoraine commented 10 months ago

It's unclear for me. Do you want me to submit Kapelse reader suport in COMPOSITE_AS_MULTISLOT mode patch in this -debug repo? If yes, via a pull request?

LudovicRousseau commented 10 months ago

I made modifications to your first patch in the CCID-debug repo. You now have to define 2 values: max_interface_number and num_CCID_interfaces.

Since the CCID interfaces on the kapelse readers are in the first interfaces num_CCID_interfaces should contain the number of CCID interfaces (easy) and max_interface_number should be num_CCID_interfaces -1 because it starts at 0.

Yes, I ask you to propose a Pull Request on this repo to add support of kapelse readers. I do not have any of the kapelse readers so I can't test the code myself. I don't want to publish untested code.

bmoraine commented 10 months ago

For information, I have created a Pull Request as recommended : https://github.com/LudovicRousseau/CCID-debug/pull/1

LudovicRousseau commented 10 months ago

Good. have you checked your patches works fine on macOS with your readers?

bmoraine commented 10 months ago

No, I tested only on linux using "./configure --enable-strict --enable-composite-as-multislot " before compiling and installing driver.

In my understanding, driver should behave the same as on macos.

LudovicRousseau commented 10 months ago

I was expecting an answer like that :-) I asked because your patch does not correctly set (I think) the max_interface_number value. pcsc-lite on GNU/Linux does support composite devices. So you can't check your code on Linux.

You have to use macOS to test your changes work fine on macOS.

Please also test connecting 2 Kapelse readers and check all the CCID interfaces are visible using pcsctest. The CCID driver has code to reset static_interface value when all the CCID interfaces have been used, so the driver is ready to connect another "composite-as-multislot" reader. https://github.com/LudovicRousseau/CCID/blob/master/src/ccid_usb.c#L732

LudovicRousseau commented 10 months ago

@bmoraine you can also send me Kapelse sample readers so I can make tests on my side. Contact me by private email.

bmoraine commented 10 months ago

@LudovicRousseau I will test Kapelse readers on macOS Sonoma and ,in the same time, send you some readers.

Regarding ccid driver generatioin on macos, I always slightly modified ccid driver source in SmartcardCCID : https://github.com/apple-oss-distributions/SmartcardCCID/ and never update the entire ccid driver source files.

In my undestanding, Apple applies patches on top of cdid driver and use specific parameters when configuring ccid project according : https://github.com/apple-oss-distributions/SmartcardCCID/blob/main/ccid/Makefile. I assume that if I replace ccid tar.gz with the content of CCID-debug and I execute the makefile, it should be OK. Do you confirm?

LudovicRousseau commented 10 months ago

I assume that if I replace ccid tar.gz with the content of CCID-debug and I execute the makefile, it should be OK. Do you confirm?

I also assume it should work. I never used the Apple process to build my CCID driver on macOS, so you are the expert on this point.

bmoraine commented 10 months ago

What is your process to build CCID driver on macOS?

LudovicRousseau commented 10 months ago

https://ccid.apdu.fr/#MacOSX

LudovicRousseau commented 7 months ago

Fixed in 73d9d3a9bd9e2905912a76d7e4615a9729d83fc2 and later patches