No more limited to 16 readers

pcsc-lite and my CCID driver are no longer limited to 16 readers. See New version of pcsc-lite: 2.5.0 and New version of libccid: 1.8.0.

History

Since the first version of pcsc-lite (in 2002 according to git history) the maximum number of readers has been set to 16. This number is defined by the PCSCLITE_MAX_READERS_CONTEXTS constant.

Since pcsc-lite was limited to 16 readers it was obvious to also limit the number of devices supported by the CCID driver to 16.

This limitation is problematic for some use cases. While it is possible to change the value of PCSCLITE_MAX_READERS_CONTEXTS and rebuild both pcsc-lite and the driver, this has side effects. See Fedora, flatpak and pcsc-lite for more information.

Changes

The request has been around since at least 2018. See https://salsa.debian.org/rousseau/CCID/-/work_items/4 and https://salsa.debian.org/rousseau/PCSC/-/work_items/4.

I had already calculated the amount of RAM that could be saved by using a list instead of a fixed-size array:

You can now use as many readers as you want.

In fact, no. There is still a limit of 256 readers due to the naming scheme used by pcsc-lite for readers. Readers will go from 00 to FF. See What is in a PC/SC reader name?.

Backward compatibility

In version 2.4.1 of pcsc-lite I introduced the ability to mix different versions of the internal communication protocol between the PC/SC daemon (pcscd) and the PC/SC library (libpcsclite). See pcsc-lite backward & forward compatible with itself.

In order to remove the limitation of the reader number, I had to update this internal communication protocol again. However, I tried to make it smart so that an old libpcsclite can communicate with a recent pcscd or vice versa. The application will still only recognise up to 16 readers, but at least it should work.

Conclusion

I hope you will benefit from this change:

  • Less RAM consumed when only 1 reader is used.

  • The possibility of using more than 16 readers.