[Pcsclite-muscle] Bug in reconnecting to a card.

Ludovic Rousseau ludovic.rousseau
Fri Sep 23 06:15:43 PDT 2016


2016-09-23 14:49 GMT+02:00 Abraham Macias Paredes <amacias at solutia-it.es>:

> Hi again,
>
>  After some tests I think that a second ?Connect? invalidates the
> transactions (Python test attached).
>
>
>
> Or maybe there are a couple of seconds of timeout before invalidating the
> transactions and allowing the connection (because when you run the test you
> can notice a couple of seconds of delay before the second ?connect?).
>
>
>
> The output of the test in my Windows 10 is:
>
>
>
> c:\Python27>python.exe test.py
>
> Context established!
>
> PCSC Readers: ['Dell Smart Card Reader Keyboard 0']
>
> Using reader: Dell Smart Card Reader Keyboard 0
>
> Connected with active protocol 1
>
> Start transaction
>
> Connect again
>
> Connected with active protocol 1
>
> Start transaction (card 2)
>
> End transaction (card 2)
>
> End transaction in the first connection
>
> Exception: failed to end a transaction: Se ha reiniciado la tarjeta
> inteligente, por lo que no es v?lida ninguna informaci?n de estado
> compartido.
>
> Released context.
>
> press Enter to continue
>
>
>
> Best regards!
>

On pcsc-lite your sample output is:

$ python test.py
Context established!
PCSC Readers: ['Gemalto PC Twin Reader (70D7E2EE) 00 00']
Using reader: Gemalto PC Twin Reader (70D7E2EE) 00 00
Connected with active protocol 1
Start transaction
Connect again
and the execution is blocked here.

The second SCardConnect() blocks because a transaction is ongoing.


I guess it "works" on Windows because the card is reset and the transaction
is aborted after 5 seconds.
The second SCardConnect() will block, link with pcsc-lite, but will
continue after a 5 seconds delay.

https://msdn.microsoft.com/de-de
/library/windows/desktop/aa379469%28v=vs.85%29.aspx
" If a transaction is held on the card for more than five seconds with no
operations happening on that card, then the card is reset. Calling any of
the Smart Card and Reader Access Functions
<https://msdn.microsoft.com/de-de/library/windows/desktop/aa380141%28v=vs.85%29.aspx>
or Direct Card Access Functions
<https://msdn.microsoft.com/de-de/library/windows/desktop/aa375369%28v=vs.85%29.aspx>
on the card that is transacted results in the timer being reset to continue
allowing the transaction to be used. "

pcsc-lite does not implement this card reset after 5 seconds of no-use. I
don't think that is a good idea.

Bye

-- 
 Dr. Ludovic Rousseau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pcsclite-muscle/attachments/20160923/5b01bbda/attachment-0001.html>



More information about the pcsclite-muscle mailing list