From 2cc37817d7fbc0f2f10cf09090f9ac06f6bbbc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henryk=20Pl=C3=B6tz?= Date: Fri, 15 Oct 2010 17:25:05 +0200 Subject: [PATCH] Move iso specific get response code to iso class --- cards/generic_card.py | 8 ++------ cards/iso_card.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cards/generic_card.py b/cards/generic_card.py index 93c5374..64d4bcb 100644 --- a/cards/generic_card.py +++ b/cards/generic_card.py @@ -149,12 +149,8 @@ class Card: if self.check_sw(result.sw, self.PURPOSE_GET_RESPONSE): ## Need to call GetResponse - gr_apdu = C_APDU(self.COMMAND_GET_RESPONSE, le = result.sw2, cla=apdu.cla) # FIXME - result = R_APDU(self._real_send(gr_apdu)) - elif self.check_sw(result.sw, self.PURPOSE_RETRY) and apdu.Le == 0: - ## Retry with correct Le - gr_apdu = C_APDU(apdu, le = result.sw2) - result = R_APDU(self._real_send(gr_apdu)) + gr_apdu = self.COMMAND_GET_RESPONSE + result = self._real_send(gr_apdu) return result diff --git a/cards/iso_card.py b/cards/iso_card.py index e4cca21..fa6085d 100644 --- a/cards/iso_card.py +++ b/cards/iso_card.py @@ -125,6 +125,20 @@ class ISO_Card(Card): return result + def _send_with_retry(self, apdu): + result = self._real_send(apdu) + + if self.check_sw(result.sw, self.PURPOSE_GET_RESPONSE): + ## Need to call GetResponse + gr_apdu = C_APDU(self.COMMAND_GET_RESPONSE, le = result.sw2, cla=apdu.cla) # FIXME + result = R_APDU(self._real_send(gr_apdu)) + elif self.check_sw(result.sw, self.PURPOSE_RETRY) and apdu.Le == 0: + ## Retry with correct Le + gr_apdu = C_APDU(apdu, le = result.sw2) + result = R_APDU(self._real_send(gr_apdu)) + + return result + def verify_pin(self, pin_number, pin_value):