mifare desfire, miscellaneous

git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@250 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
hploetz 2007-11-14 12:42:46 +00:00
parent c02f68c8cf
commit 55a0b4d4a2
4 changed files with 67 additions and 5 deletions

View File

@ -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",

View File

@ -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,
}

View File

@ -14,6 +14,7 @@ class SECCOS_Card(ISO_7816_4_Card):
("3BFF1800FF8131FE45656311084302500010........0530..", None),
("3BFF1800FF8131FE45656311086602800011........0620..", None),
("3BFF9600FF8131FE4565631901500280000F........5012..", None),
("3BEF00FF8131FE45656311086602800011284004070620BC", None),
]
APPLICATIONS = {

View File

@ -26,6 +26,7 @@
# Passport issued Apr 07: 3b 89 80 01 00 64 04 15 01 02 00 90 00 ee
# corresponding fingerprint: 0:006404150102009000ee,P:6700,1,5AAAAAAA,08
0:4a434f5034315632324d,P,1,55555555
New Zealandic Passport
# These have a fixed 4-byte UID