dexter has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/9575 )

Change subject: __init__: also fetch response bytes for USIMs automatically
......................................................................

__init__: also fetch response bytes for USIMs automatically

The method send_apdu() first transmits the APDU in the cards direction.
The card may indicate that there is a response available by responding
with SW1=9F, where SW2 is the number of bytes. send_apdu() will then
craft a get-response APDU to pickup the response bytes. This mechanism
works fine for SIM, but USIM uses SW1=61 to indicate the availability
of a response, so lets also sense on SW1=61 to support USIMs as well.

- Also check on SW1=61 to see if a response is available

Change-Id: Ied7fb78873a7c4109de471c7a5e9c3701ba0c7d5
Related: SYS#4245
---
M pySim/transport/__init__.py
1 file changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  dexter: Verified



diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 0a71117..9cd23d0 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -67,7 +67,13 @@
                """
                data, sw = self.send_apdu_raw(pdu)
 
-               if (sw is not None) and (sw[0:2] == '9f'):
+               # When whe have sent the first APDU, the SW may indicate that 
there are response bytes
+               # available. There are two SWs commonly used for this 9fxx 
(sim) and 61xx (usim), where
+               # xx is the number of response bytes available.
+               # See also:
+               # SW1=9F: 3GPP TS 51.011 9.4.1, Responses to commands which are 
correctly executed
+               # SW1=61: ISO/IEC 7816-4, Table 5 — General meaning of the 
interindustry values of SW1-SW2
+               if (sw is not None) and ((sw[0:2] == '9f') or (sw[0:2] == 
'61')):
                        pdu_gr = pdu[0:2] + 'c00000' + sw[2:4]
                        data, sw = self.send_apdu_raw(pdu_gr)


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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied7fb78873a7c4109de471c7a5e9c3701ba0c7d5
Gerrit-Change-Number: 9575
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: dexter <pma...@sysmocom.de>

Reply via email to