LudovicRousseau / PCSC

pcsc-lite: PC/SC implementation
https://pcsclite.apdu.fr/
Other
270 stars 109 forks source link

limit 16 reader #13

Open catafestaxx opened 8 years ago

catafestaxx commented 8 years ago

as it does to remove the 16 reader limit must use 24 pc a reader would like to help me?

LudovicRousseau commented 8 years ago

See https://github.com/LudovicRousseau/PCSC/issues/8

LudovicRousseau commented 7 years ago

I is a known "limitation". I created a bug (in 2012) at https://alioth.debian.org/tracker/index.php?func=detail&aid=313579&group_id=30105&atid=410088 and will implement it "when I have time".

Contact me if you want to sponsor this development.

LudovicRousseau commented 6 years ago

Since the PCSC project moved from alioth to salsa, the bug is now at https://salsa.debian.org/rousseau/PCSC/issues/4

avassdal commented 4 years ago

I would become a sponsor for this if i know that this limitation could be removed asap

LudovicRousseau commented 4 years ago

@avassdal please contact me on my email ludovic.rousseau at free.fr

tatulea commented 4 years ago

Is there any update on this? :)

LudovicRousseau commented 4 years ago

@tatulea do you want to be a sponsor? I have no news from @avassdal

crypteo commented 1 year ago

Hi,

I'm using pyscard on Ubuntu 22 and need to support more than 16 readers So I followed #8.

I re-compiled pcsclite and ccid latest version, and made sure everything was working fine with the default limit. Then I re-compiled after changing 16 for 24 in both src/ccid_ifdhandler.h and src/PCSC/pcsclite.h.in. But only 8 cards are visible and they don't even work.

Is there anything else I'm supposed to do ?

aroth-fastprotect commented 1 year ago

For a project of ours we patched the pcscd to increase the limit with the following two patches: pcscd-max-readers.patch.txt ccid-max-readers.patch.txt

We have it working with up to 14 readers.

crypteo commented 1 year ago

This is exactly what I did. I checked the debug log of pcscd and all the cards seems to be detected properly. Could this be a problem with the python interface ? I'm using a external script going like this :

from smartcard.System import readers
class sCard():
    def __init__(self, card):
        r = readers()
        reader = r[card]
        self.card = card
        self.conn = reader.createConnection()
        self.conn.connect(CardConnection.T1_protocol)

Trying again, I got this error when calling readers() :

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9b in position 0: invalid start byte

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/tcaapp/query.py", line 438, in <module>
    main()
  File "/opt/tcaapp/query.py", line 361, in handle_client
    scObj = sCard(card)
  File "/opt/tcaapp/query.py", line 49, in __init__
    r = readers()
  File "/usr/local/lib/python3.10/dist-packages/smartcard/System.py", line 41, in readers
    return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
  File "/usr/local/lib/python3.10/dist-packages/smartcard/reader/ReaderFactory.py", line 58, in readers
    zreaders += fm(groups)
  File "/usr/local/lib/python3.10/dist-packages/smartcard/pcsc/PCSCReader.py", line 114, in readers
    pcsc_readers = __PCSCreaders__(hcontext, groups)
  File "/usr/local/lib/python3.10/dist-packages/smartcard/pcsc/PCSCReader.py", line 43, in __PCSCreaders__
    hresult, readers = SCardListReaders(hcontext, groups)
  File "/usr/local/lib/python3.10/dist-packages/smartcard/scard/scard.py", line 686, in SCardListReaders
    return _scard.SCardListReaders(hcontext, readergroups)
SystemError: <built-in function SCardListReaders> returned a result with an exception set
LudovicRousseau commented 1 year ago

Do you see all the readers when using pcsc_scan? https://blog.apdu.fr/posts/2014/03/level-1-smart-card-support-on-gnulinux/

Can you copy/paste here the output of pcsc_scan?

crypteo commented 1 year ago

Nothing much from pcsc_scan with the compiled version

Compiled with 24 :

PC/SC device scanner
V 1.7.0 (c) 2001-2022, Ludovic Rousseau <ludovic.rousseau@free.fr>
Using reader plug'n play mechanism
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... found one
Scanning present readers...
Waiting for the first reader... SCardGetStatusChange: Unknown error: 0x00000034

With the working pcsc compiled with 16 :

PC/SC device scanner
V 1.7.0 (c) 2001-2022, Ludovic Rousseau <ludovic.rousseau@free.fr>
Scanning present readers...
0: Alcor Micro AU9540 00 00
1: Alcor Micro AU9540 01 00
2: Generic Smart Card Reader Interface [Smart Card Reader Interface] (20070818000000000) 02 00
3: Generic Smart Card Reader Interface [Smart Card Reader Interface] (20070818000000000) 03 00
4: Alcor Micro AU9540 04 00
5: Alcor Micro AU9540 05 00
6: Alcor Micro AU9540 06 00
7: Alcor Micro AU9540 07 00
8: Alcor Micro AU9540 08 00
9: Generic Smart Card Reader Interface [Smart Card Reader Interface] (20070818000000000) 09 00
10: Alcor Micro AU9540 0A 00
11: Alcor Micro AU9540 0B 00
12: Alcor Micro AU9540 0C 00
13: Alcor Micro AU9540 0D 00
14: Alcor Micro AU9540 0E 00
15: Generic Smart Card Reader Interface [Smart Card Reader Interface] (20070818000000000) 0F 00
SCardGetStatusChange: Invalid parameter given.
LudovicRousseau commented 1 year ago

@crypteo it looks like you use 2 sides (pcscd and libpcsclite) with different values of  PCSCLITE_MAX_READERS_CONTEXTS. My guess if that you have 2 different libpcsclite.so.1 files in your system. Maybe one in /usr/lib/ and the other in /usr/local/lib/ or something like that.

In the case with 16 it is also NOT working correctly. You should not have the error "SCardGetStatusChange: Invalid parameter given."

crypteo commented 1 year ago

Indeed, even though I removed all the original packages, there was still lib files left. I should have double checked it. After removing manually, I had to rebuild everything. And seems to work now :) Thank for your help.

LudovicRousseau commented 1 year ago

I just discover that Windows limit is at 10 readers. And it looks like it is not possible to have more. Or course you can't change a value in the source code and rebuild Windows :-) Limitation of 10 smartcard readers in Windows Server 2012 R2, Windows 8, and later