laforge has uploaded this change for review. (
https://gerrit.osmocom.org/c/pysim/+/35215?usp=email )
Change subject: perform multiple GET RESPONSE cycles if more data is available
......................................................................
perform multiple GET RESPONSE cycles if more data is available
So far we implemented only one round of "Send the APDU, get SW=61xx,
call GET RESPONSE". This permitted us to receive only data up to 256
bytes.
Let's extend that to doing multiple rounds, concatenating the result.
This allows us to obtain arbitrary-length data from the card.
See Annex C.1 of ETSI TS 102 221 for examples showing multiple 61xx
iterations.
Change-Id: Ib17da655aa0b0eb203c29dc92690c81bd1300778
Closes: OS#6287
---
M pySim/transport/__init__.py
1 file changed, 23 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/15/35215/1
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index e90ced6..2ffb9c3 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -137,11 +137,12 @@
# xx is the number of response bytes available.
# See also:
if (sw is not None):
- if ((sw[0:2] == '9f') or (sw[0:2] == '61')):
+ while ((sw[0:2] == '9f') or (sw[0:2] == '61')):
# 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
pdu_gr = pdu[0:2] + 'c00000' + sw[2:4]
- data, sw = self.send_apdu_raw(pdu_gr)
+ d, sw = self.send_apdu_raw(pdu_gr)
+ data += d
if sw[0:2] == '6c':
# SW1=6C: ETSI TS 102 221 Table 7.1: Procedure byte coding
pdu_gr = pdu[0:8] + sw[2:4]
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/35215?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib17da655aa0b0eb203c29dc92690c81bd1300778
Gerrit-Change-Number: 35215
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange