diff options
author | Henryk Plötz <henryk@ploetzli.ch> | 2010-10-15 16:50:01 +0200 |
---|---|---|
committer | Henryk Plötz <henryk@ploetzli.ch> | 2010-10-15 17:08:08 +0200 |
commit | c53914f1aedf737ea9bd225bfd9ce62ebd9903c8 (patch) | |
tree | f89befdb02d452f554a55df3bbd6d6d29f53bc70 /cards/generic_card.py | |
parent | 9e8b7b0a82dc8e4fc8c07f26c87f4b706c679d6e (diff) |
Refactor, move apdu SW handling from generic card class to iso card class
Diffstat (limited to 'cards/generic_card.py')
-rw-r--r-- | cards/generic_card.py | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/cards/generic_card.py b/cards/generic_card.py index 94d8cc7..93c5374 100644 --- a/cards/generic_card.py +++ b/cards/generic_card.py @@ -88,9 +88,7 @@ class Card: self._i = 0 self.last_apdu = None - self.last_sw = None self.last_result = None - self.sw_changed = False self._last_start = None self.last_delta = None @@ -138,11 +136,9 @@ class Card: print ">> " + utils.hexdump(apdu_binary, indent = 3) result_binary = self.reader.transceive(apdu_binary) - result = R_APDU(result_binary) + result = apdu.RESPONSE_CLASS(result_binary) self.last_apdu = apdu - self.last_sw = result.sw - self.sw_changed = True if DEBUG: print "<< " + utils.hexdump(result_binary, indent = 3) @@ -238,29 +234,6 @@ class Card: return None match_statusword = staticmethod(match_statusword) - def decode_statusword(self): - if self.last_sw is None: - return "No command executed so far" - else: - retval = None - - matched_sw = self.match_statusword(self.STATUS_WORDS.keys(), self.last_sw) - if matched_sw is not None: - retval = self.STATUS_WORDS.get(matched_sw) - if isinstance(retval, str): - retval = retval % { "SW1": ord(self.last_sw[0]), - "SW2": ord(self.last_sw[1]) } - - elif callable(retval): - retval = retval( ord(self.last_sw[0]), - ord(self.last_sw[1]) ) - - if retval is None: - return "Unknown SW (SW %s)" % binascii.b2a_hex(self.last_sw) - else: - return "%s (SW %s)" % (retval, binascii.b2a_hex(self.last_sw)) - - def get_driver_name(self): if len(self.DRIVER_NAME) > 1: names = [e for e in self.DRIVER_NAME if e != _GENERIC_NAME] |