API change: more information in the APPLICATIONS dictionary

git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@161 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
hploetz 2007-01-14 13:46:30 +00:00
parent b4a825c461
commit 07de9a478d
4 changed files with 40 additions and 4 deletions

View File

@ -299,7 +299,7 @@ class Cyberflex_Card(Java_Card):
APPLICATIONS = dict(Java_Card.APPLICATIONS)
APPLICATIONS.update( {
"card_manager": DEFAULT_CARD_MANAGER_AID
DEFAULT_CARD_MANAGER_AID: ("card_manager", ),
} )
COMMANDS = dict(Java_Card.COMMANDS)

View File

@ -29,6 +29,23 @@ class Card:
}
## For the format of this dictionary of dictionaries see TLV_utils.tags
TLV_OBJECTS = {}
## Format: "AID (binary)": ("name", [optional: description, {more information}])
APPLICATIONS = {
## The following are from 0341a.pdf: BSI-DSZ-CC-0341-2006
"\xD2\x76\x00\x00\x66\x01": ("DF_SIG", "Signature application", {"fid": "\xAB\x00"}),
"\xD2\x76\x00\x00\x25\x5A\x41\x02": ("ZA_MF_NEU", "Zusatzanwendungen", {"fid": "\xA7\x00"}),
"\xD2\x76\x00\x00\x25\x45\x43\x02\x00": ("DF_EC_CASH_NEU", "ec-Cash", {"fid": "\xA1\x00"}),
"\xD2\x76\x00\x00\x25\x45\x50\x02\x00": ("DF_BOERSE_NEU", "Geldkarte", {"fid": "\xA2\x00"}),
"\xD2\x76\x00\x00\x25\x47\x41\x01\x00": ("DF_GA_MAESTRO", "GA-Maestro", {"fid": "\xAC\x00"}),
"\xD2\x76\x00\x00\x25\x54\x44\x01\x00": ("DF_TAN", "TAN-Anwendung", {"fid": "\xAC\x02"}),
"\xD2\x76\x00\x00\x25\x4D\x01\x02\x00": ("DF_MARKTPLATZ_NEU", "Marktplatz", {"fid": "\xB0\x01"}),
"\xD2\x76\x00\x00\x25\x46\x53\x02\x00": ("DF_FAHRSCHEIN_NEU", "Fahrschein", {"fid": "\xB0\x00"}),
"\xD2\x76\x00\x00\x25\x48\x42\x02\x00": ("DF_BANKING_20" , "HBCI", {"fid": "\xA6\x00"}),
"\xD2\x76\x00\x00\x25\x4E\x50\x01\x00": ("DF_NOTEPAD", "Notepad", {"fid": "\xA6\x10"}),
}
APPLICATIONS["\xA0\x00\x00\x00\x59\x50\x41\x43\x45\x01\x00"] = APPLICATIONS["\xD2\x76\x00\x00\x25\x45\x50\x02\x00"]
APPLICATIONS["\xA0\x00\x00\x00\x04\x30\x60"] = APPLICATIONS["\xD2\x76\x00\x00\x25\x47\x41\x01\x00"]
def __init__(self, card = None, reader = None):
if card is None:
@ -74,10 +91,24 @@ class Card:
end = lastlen
print TLV_utils.decode(self.last_result.data[start:end], tags=self.TLV_OBJECTS)
_SHOW_APPLICATIONS_FORMAT_STRING = "%(aid)-50s %(name)-20s %(description)-30s"
def cmd_show_applications(self):
"Show the list of known (by the shell) applications"
print self._SHOW_APPLICATIONS_FORMAT_STRING % {"aid": "AID", "name": "Name", "description": "Description"}
foo = self.APPLICATIONS.items()
foo.sort()
for aid, info in foo:
print self._SHOW_APPLICATIONS_FORMAT_STRING % {
"aid": utils.hexdump(aid, short=True),
"name": info[0],
"description": len(info) > 1 and info[1] or ""
}
COMMANDS = {
"reset": cmd_reset,
"verify": cmd_verify,
"parse_tlv": cmd_parsetlv,
"show_applications": cmd_show_applications,
}
def _real_send(self, apdu):

View File

@ -6,7 +6,7 @@ class Java_Card(Card):
APDU_SELECT_APPLICATION = C_APDU(ins=0xa4,p1=0x04)
DRIVER_NAME = "Generic Java"
APPLICATIONS = {
"muscle": "\xa0\x00\x00\x00\x01\x01"
"\xa0\x00\x00\x00\x01\x01": ("muscle", "MUSCLE applet")
}
def __init__(self, card = None):
@ -22,8 +22,9 @@ class Java_Card(Card):
"""Select an application on the card.
application can be given either as hexadezimal aid or by symbolic name (if known)."""
if self.APPLICATIONS.has_key(application):
aid = self.APPLICATIONS[application]
s = [a for a,b in self.APPLICATIONS.items() if b[0].lower() == application.lower()]
if len(s) > 0:
aid = s[0]
else:
aid = binascii.a2b_hex("".join(application.split()))
result = self.select_application(aid)

View File

@ -15,6 +15,10 @@ class SECCOS_Card(ISO_7816_4_Card):
("3BFF1800FF8131FE45656311086602800011........0620..", None),
("3BFF9600FF8131FE4565631901500280000F........5012..", None),
]
APPLICATIONS = {
"\x52\x4F\x4F\x54": ("MF", "Master File ZKA-Chipkarte"),
}
def decode_sfi_path(value):
return " SFI: 0x%02x, path: %s" % (ord(value[0]) >> 3, utils.hexdump(value[1:], short=True))