Abstract out command class

henryk_github
Henryk Plötz 12 years ago
parent e343352675
commit 144efe1cf7
  1. 1
      cards/iso_card.py
  2. 7
      cyberflex-shell.py
  3. 5
      utils.py

@ -6,6 +6,7 @@ from utils import C_APDU, R_APDU
class ISO_Card(Card):
DRIVER_NAME = ["ISO"]
COMMAND_GET_RESPONSE = C_APDU(ins=0xc0)
COMMAND_CLASS = C_APDU
APDU_VERIFY_PIN = C_APDU(ins=0x20)

@ -230,10 +230,13 @@ class Cyberflex_Shell(Shell):
self.card.last_delta = None
def do_fancy_apdu(self, *args):
"Parse and transmit a fancy APDU"
"Parse and transmit a fancy command"
apdu = None
try:
apdu = utils.C_APDU.parse_fancy(*args)
if hasattr(self.card.COMMAND_CLASS, "parse_fancy"):
apdu = self.card.COMMAND_CLASS.parse_fancy(*args)
else:
apdu = self.card.COMMAND_CLASS(*args)
except ValueError:
raise NotImplementedError

@ -228,6 +228,11 @@ class Transmission_Frame(object):
# Stub for implementation in subclasses
# Semantics should be: c=a.append(b) <=> c.data == a.data + b.data and c.status == b.status
append = None
@classmethod
def parse_fancy(cls, *args):
argstring = "".join((" ".join(args)).split())
return cls(binascii.unhexlify(argstring))
class Command_Frame(Transmission_Frame):
pass

Loading…
Cancel
Save