diff options
author | hploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b> | 2007-11-14 12:42:46 +0000 |
---|---|---|
committer | hploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b> | 2007-11-14 12:42:46 +0000 |
commit | 55a0b4d4a245de5ec6385f9fbf175bc799ba0813 (patch) | |
tree | 2a8a01c755c55116f280a58a3c2d11eb52c80b25 /cards | |
parent | c02f68c8cfeae7c3b5a78e4831d3f93804121ff9 (diff) |
mifare desfire, miscellaneous
git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@250 f711b948-2313-0410-aaa9-d29f33439f0b
Diffstat (limited to 'cards')
-rw-r--r-- | cards/passport_application.py | 15 | ||||
-rw-r--r-- | cards/rfid_card.py | 55 | ||||
-rw-r--r-- | cards/seccos_card.py | 1 |
3 files changed, 66 insertions, 5 deletions
diff --git a/cards/passport_application.py b/cards/passport_application.py index 7a9fb88..af81f68 100644 --- a/cards/passport_application.py +++ b/cards/passport_application.py @@ -326,11 +326,15 @@ class Passport_Application(Application): del _key, _a, _b def decode_version_number(value): - result = [] - while len(value) > 0: - v, value = value[:2], value[2:] - result.append(str(int(v))) - return " "+".".join(result) + #print "|||||||", value, "|", repr(value), "|" + try: + result = [] + while len(value) > 0: + v, value = value[:2], value[2:] + result.append(str(int(v))) + return " "+".".join(result) + except: + return "".join( ["|||||||", value, "|", repr(value), "|"] ) def decode_tag_list(value): result = [] @@ -439,6 +443,7 @@ class FAC: offset = offset+12 self.data = data[offset:offset_+self.length] + print len(self.data) FILE_EXTENSIONS = { 0: "jpg", diff --git a/cards/rfid_card.py b/cards/rfid_card.py index e209c91..9358136 100644 --- a/cards/rfid_card.py +++ b/cards/rfid_card.py @@ -16,6 +16,7 @@ class RFID_Card(Card): STOP_ATRS = [ # Mifare, handled below ("3b8f8001804f0ca000000306..000[1-3]00000000..", None), + ("3B8180018080", None), ] def get_uid(self): @@ -81,3 +82,57 @@ class Mifare_Ultralight_Card(Mifare_Card): # Ultralight ("3b8f8001804f0ca000000306..000300000000..", None), ] + +class Mifare_DESfire_Card(Mifare_Card): + DRIVER_NAME = ["Mifare DESfire"] + ATRS = [ + ("3B8180018080", None) + ] + + STATUS_WORDS = { + "\x91\x00": "Successful Operation", + "\x91\x0C": "No changes done to backup files, CommitTransaction/AbortTransaction not necessary", + "\x91\x0E": "Insufficient NV-Memory to complete command", + "\x91\x1C": "Command code not supported", + "\x91\x1E": "CRC or MAC does not match data. Padding bytes not valid", + "\x91\x40": "Invalid key number specified", + "\x91\x7E": "Length of command string invalid", + "\x91\x9D": "Current configuration / status does not allow the requested command", + "\x91\x9E": "Value of the parameter(s) invalid", + "\x91\xA0": "Requested AID not present on PICC", + "\x91\xA1": "Unrecoverable error within application, application will be disabled", + "\x91\xAE": "Current authentication status does not allow the requested command", + "\x91\xAF": "Additional data frame is expected to be sent", + "\x91\xBE": "Attempt to read/write data from/to beyond the file's/record's limits. Attempt to exceed the limits of a value file.", + "\x91\xC1": "Unrecoverable error within PICC, PICC will be disabled", + "\x91\xCA": "Previous Command was not fully completed. Not all Frames were requested or provided by the PCD", + "\x91\xCD": "PICC was disabled by an unrecoverable error", + "\x91\xCE": "Number of Applications limited to 28, no additional CreateApplication possible", + "\x91\xDE": "Creation of file/application failed because file/application with same number already exists", + "\x91\xEE": "Could not complete NV-write operation due to loss of power, internal backup/rollback mechanism activated", + "\x91\xF0": "Specified file number does not exist", + "\x91\xF1": "Unrecoverable error within file, file will be disabled", + } + + DEFAULT_CLA = 0x90 + + def wrap_native(self, native_command): + print repr(native_command) + if len(native_command) > 1: + apdu = utils.C_APDU(cla=self.DEFAULT_CLA, ins=native_command[0], data=native_command[1:], le=0) + elif len(native_command) == 1: + apdu = utils.C_APDU(cla=self.DEFAULT_CLA, ins=native_command[0], le=0) + else: + raise ValueError, "len(native_command) must be >= 1" + + result = self.send_apdu(apdu) + + return result.data, result.sw2 + + def cmd_wrap_native(self, *args): + data, returncode = self.wrap_native( binascii.a2b_hex( "".join("".join(args).split()) ) ) + print utils.hexdump(data) + + COMMANDS = { + "wrap": cmd_wrap_native, + } diff --git a/cards/seccos_card.py b/cards/seccos_card.py index 389c250..eda3cac 100644 --- a/cards/seccos_card.py +++ b/cards/seccos_card.py @@ -14,6 +14,7 @@ class SECCOS_Card(ISO_7816_4_Card): ("3BFF1800FF8131FE45656311084302500010........0530..", None), ("3BFF1800FF8131FE45656311086602800011........0620..", None), ("3BFF9600FF8131FE4565631901500280000F........5012..", None), + ("3BEF00FF8131FE45656311086602800011284004070620BC", None), ] APPLICATIONS = { |