Skip to content

Commit

Permalink
proactive: Avoid clobbering the output of the command that triggered …
Browse files Browse the repository at this point in the history
…the FETCH

Change-Id: I2b794a5c5bc808b9703b4bc679c119341a0ed41c
  • Loading branch information
Christian Amsüss authored and laf0rge committed Aug 21, 2022
1 parent cab26c7 commit 98552ef
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pySim/transport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,18 @@ def send_apdu_checksw(self, pdu, sw="9000"):
sw : string (in hex) of status word (ex. "9000")
"""
rv = self.send_apdu(pdu)
last_sw = rv[1]

while sw == '9000' and sw_match(rv[1], '91xx'):
while sw == '9000' and sw_match(last_sw, '91xx'):
# It *was* successful after all -- the extra pieces FETCH handled
# need not concern the caller.
rv = (rv[0], '9000')
# proactive sim as per TS 102 221 Setion 7.4.2
rv = self.send_apdu_checksw('80120000' + rv[1][2:], sw)
print("FETCH: %s" % rv[0])
fetch_rv = self.send_apdu_checksw('80120000' + last_sw[2:], sw)
last_sw = fetch_rv[1]
print("FETCH: %s" % fetch_rv[0])
if self.proactive_handler:
self.proactive_handler.receive_fetch_raw(rv[0])
self.proactive_handler.receive_fetch_raw(fetch_rv[0])
if not sw_match(rv[1], sw):
raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)
return rv
Expand Down

0 comments on commit 98552ef

Please sign in to comment.