aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2007-01-14 14:37:57 +0000
committerhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2007-01-14 14:37:57 +0000
commitc34c6a084c97bc2cf250ebd00d99f4e57da0a220 (patch)
treed262d9be25df17dd1559227bee7d06425a6061e8
parent0d21b554e548447560504d985cc6babfd80875fc (diff)
Fix size determination in building blocks
Create tcos 3.0 class git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@163 f711b948-2313-0410-aaa9-d29f33439f0b
-rw-r--r--cards/building_blocks.py10
-rw-r--r--cards/tcos_card.py12
2 files changed, 17 insertions, 5 deletions
diff --git a/cards/building_blocks.py b/cards/building_blocks.py
index 6f765b1..d16c1d7 100644
--- a/cards/building_blocks.py
+++ b/cards/building_blocks.py
@@ -38,10 +38,10 @@ class Card_with_ls:
response_DF = {}
response_EF = {}
for DF in dirs:
- response_DF[DF] = self.select_file(0x01, 0x00, DF)
+ response_DF[DF] = self.select_file(0x01, self.SELECT_P2, DF)
self.select_file(0x03, 0x00, "")
for EF in files:
- response_EF[EF] = self.select_file(0x02, 0x00, EF)
+ response_EF[EF] = self.select_file(0x02, self.SELECT_P2, EF)
self.sw_changed = False
@@ -57,7 +57,11 @@ class Card_with_ls:
for FID in files:
name = " " + utils.hexdump(FID, short=True) + " "
type = "EF"
- size = self._str_to_long(self._find_recursive(self.LS_L_SIZE_TAG, response_EF[FID].data))
+ v = self._find_recursive(self.LS_L_SIZE_TAG, response_EF[FID].data)
+ if v:
+ size = self._str_to_long(v)
+ else:
+ size = "n/a"
print self._ls_l_template % locals()
else:
print "\n".join( ["[%s]" % utils.hexdump(a, short=True) for a in dirs]
diff --git a/cards/tcos_card.py b/cards/tcos_card.py
index b5259a4..760a67a 100644
--- a/cards/tcos_card.py
+++ b/cards/tcos_card.py
@@ -434,13 +434,12 @@ class TCOS_Security_Environment(object):
self.keys[keyref] = keyvalue
class TCOS_Card(ISO_7816_4_Card,building_blocks.Card_with_80_aa):
- DRIVER_NAME = "TCOS"
+ DRIVER_NAME = "TCOS 2.0"
APDU_DELETE_FILE = C_APDU(cla=0x80,ins=0xe4)
SELECT_P2 = 0x04
ATRS = [
("3bba96008131865d0064........31809000..", None),
- ("3bbf96008131fe5d0064........31c073f701d00090007d", None), # TCOS 3.0, FIXME: Create new class?
]
file_status_descriptions = (
@@ -674,3 +673,12 @@ class TCOS_Card(ISO_7816_4_Card,building_blocks.Card_with_80_aa):
"set_key": cmd_set_key,
}
+class TCOS_3_Card(TCOS_Card):
+ DRIVER_NAME = "TCOS 3.0"
+ APDU_DELETE_FILE = C_APDU(cla=0x80,ins=0xe4)
+ SELECT_P2 = 0x04
+ LS_L_SIZE_TAG = 0x80
+
+ ATRS = [
+ ("3bbf96008131fe5d0064........31c073f701d00090007d", None),
+ ]