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!
De: Pcsclite-muscle
[mailto:pcsclite-muscle-bounces+amacias=solutia-it...@lists.alioth.debian.org]
En nombre de Abraham Macias Paredes
Enviado el: viernes, 23 de septiembre de 2016 13:31
Para: 'Talks about MUSCLE' <[email protected]>
Asunto: Re: [Pcsclite-muscle] Bug in reconnecting to a card.
Hi,
* Do you get the same behavior on Windows?
No, in Windows seems that “disconnect” and “reconnect” ends all started
transactions.
* What should be the correct behavior of pcsc-lite?
I think that is logical to think that when you “reconnect” or “disconnect” a
card, all estarted transactions are ended.
Thank you and best regards!
De: Pcsclite-muscle
[mailto:pcsclite-muscle-bounces+amacias=solutia-it...@lists.alioth.debian.org]
En nombre de Ludovic Rousseau
Enviado el: viernes, 23 de septiembre de 2016 12:54
Para: Talks about MUSCLE <[email protected]
<mailto:[email protected]> >
Asunto: Re: [Pcsclite-muscle] Bug in reconnecting to a card.
2016-09-23 12:45 GMT+02:00 Abraham Macias Paredes <[email protected]
<mailto:[email protected]> >:
Hi PCSC lite Project people,
Hello,
I’m developing a software that nowadays is not stable (my software is buggy),
but I detected that a bug in my software causes a bug in pcsc-lite.
The “SCardReconnect” doesn’t check if the connection has a transaction opened.
So if you open a transtaction and reconnects the transaction is still opened.
And also you can open a new transaction.
Interesting.
Do you get the same behavior on Windows?
What should be the correct behavior of pcsc-lite?
Bye
--
Dr. Ludovic Rousseau
#! /usr/bin/env python
from smartcard.scard import *
import smartcard.util
SELECT = [0x00, 0xA4, 0x04, 0x00, 0x0A, 0xA0, 0x00, 0x00, 0x00, 0x62,
0x03, 0x01, 0x0C, 0x06, 0x01]
COMMAND = [0x00, 0x00, 0x00, 0x00]
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
raise Exception('Failed to establish context : ' +
SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
raise Exception('Failed to list readers: ' +
SCardGetErrorMessage(hresult))
print 'PCSC Readers:', readers
if len(readers) < 1:
raise Exception('No smart card readers')
reader = readers[0]
print "Using reader:", reader
try:
hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, reader,
SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
if hresult != SCARD_S_SUCCESS:
raise Exception('Unable to connect: ' +
SCardGetErrorMessage(hresult))
print 'Connected with active protocol', dwActiveProtocol
print "Start transaction"
hresult = SCardBeginTransaction(hcard)
if hresult != SCARD_S_SUCCESS:
raise error, 'failed to begin a transaction: ' +
SCardGetErrorMessage(hresult)
print "Connect again"
hresult, hcard2, dwActiveProtocol = SCardConnect(hcontext, reader,
SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
if hresult != SCARD_S_SUCCESS:
raise Exception('Unable to connect: ' +
SCardGetErrorMessage(hresult))
print 'Connected with active protocol', dwActiveProtocol
print "Start transaction (card 2)"
hresult = SCardBeginTransaction(hcard2)
if hresult != SCARD_S_SUCCESS:
raise error, 'failed to begin a transaction: ' +
SCardGetErrorMessage(hresult)
print 'End transaction (card 2)'
hresult = SCardEndTransaction(hcard2, SCARD_LEAVE_CARD)
if hresult != SCARD_S_SUCCESS:
raise error, 'failed to end a transaction: ' +
SCardGetErrorMessage(hresult)
print 'End transaction in the first connection'
hresult = SCardEndTransaction(hcard, SCARD_LEAVE_CARD)
if hresult != SCARD_S_SUCCESS:
raise error, 'failed to end a transaction: ' +
SCardGetErrorMessage(hresult)
except Exception, message:
print "Exception:", message
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
raise Exception('Failed to release context: ' +
SCardGetErrorMessage(hresult))
print 'Released context.'
except Exception, message:
print "Exception:", message
import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
_______________________________________________
Pcsclite-muscle mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle