Change in pysim[master]: transport/pcsc: explicitly specify T0 protocol

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Mar 1 19:22:04 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17279 )

Change subject: transport/pcsc: explicitly specify T0 protocol
......................................................................

transport/pcsc: explicitly specify T0 protocol

>From pyscard user's guide [1]:

   == Selecting the card communication protocol ==

   By defaults, the connect() method of the CardConnection object
   will try to connect using either the T=0 or T=1 protocol.
   To force a connection protocol, you can pass the required
   protocol to the connect() method.

This means that a PC/SC ifd handler may automatically choose T=1
as the highest protocol if the card indicates both in its ATR [2].

Since pySim only supports T=0, let's select it explicitly.

[1] https://pyscard.sourceforge.io/user-guide.html
[2] https://github.com/acshk/acsccid/issues/16#issuecomment-501101972

Change-Id: Ifed4574aab98a86c3ebbeb191f36a8282103e775
---
M pySim/transport/pcsc.py
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/transport/pcsc.py b/pySim/transport/pcsc.py
index 7fa922f..380c8fd 100644
--- a/pySim/transport/pcsc.py
+++ b/pySim/transport/pcsc.py
@@ -22,6 +22,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from smartcard.CardConnection import CardConnection
 from smartcard.CardRequest import CardRequest
 from smartcard.Exceptions import NoCardException, CardRequestTimeoutException
 from smartcard.System import readers
@@ -52,7 +53,10 @@
 
 	def connect(self):
 		try:
-			self._con.connect()
+			# Explicitly select T=0 communication protocol
+			self._con.connect(CardConnection.T0_protocol)
+		except CardConnectionException:
+			raise ProtocolError()
 		except NoCardException:
 			raise NoCardError()
 

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/17279
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifed4574aab98a86c3ebbeb191f36a8282103e775
Gerrit-Change-Number: 17279
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200301/ba938fdb/attachment.htm>


More information about the gerrit-log mailing list