Bugfixes: nPA emulator is now working

git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@650 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
oepen
2011-12-08 15:37:40 +00:00
parent cb2da77b58
commit 46d3551fbf
2 changed files with 6 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ from pickle import loads, dumps
from virtualsmartcard.TLVutils import pack from virtualsmartcard.TLVutils import pack
from virtualsmartcard.utils import inttostring from virtualsmartcard.utils import inttostring
from virtualsmartcard.SmartcardFilesystem import MF, DF, TransparentStructureEF from virtualsmartcard.SmartcardFilesystem import MF, DF, TransparentStructureEF
from virtualsmartcard.ConstantDefinitions import FDB from virtualsmartcard.ConstantDefinitions import FDB, ALGO_MAPPING
from virtualsmartcard.CryptoUtils import protect_string, read_protected_string from virtualsmartcard.CryptoUtils import protect_string, read_protected_string
from virtualsmartcard.SmartcardSAM import SAM from virtualsmartcard.SmartcardSAM import SAM
from virtualsmartcard.cards.cryptoflex import CryptoflexSAM, CryptoflexMF from virtualsmartcard.cards.cryptoflex import CryptoflexSAM, CryptoflexMF
@@ -145,7 +145,7 @@ class CardGenerator(object):
from virtualsmartcard.SmartcardSAM import SAM from virtualsmartcard.SmartcardSAM import SAM
card_access = "\x31\x81\xb3\x30\x0d\x06\x08\x04\x00\x7f\x00\x07\x02\x02\x02\x02\x01\x02\x30\x12\x06\x0a\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x02\x02\x01\x02\x02\x01\x41\x30\x12\x06\x0a\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x02\x02\x01\x02\x02\x01\x45\x30\x12\x06\x0a\x04\x00\x7f\x00\x07\x02\x02\x04\x02\x02\x02\x01\x02\x02\x01\x0d\x30\x1c\x06\x09\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x30\x0c\x06\x07\x04\x00\x7f\x00\x07\x01\x02\x02\x01\x0d\x02\x01\x41\x30\x1c\x06\x09\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x30\x0c\x06\x07\x04\x00\x7f\x00\x07\x01\x02\x02\x01\x0d\x02\x01\x45\x30\x2a\x06\x08\x04\x00\x7f\x00\x07\x02\x02\x06\x16\x1e\x68\x74\x74\x70\x3a\x2f\x2f\x62\x73\x69\x2e\x62\x75\x6e\x64\x2e\x64\x65\x2f\x63\x69\x66\x2f\x6e\x70\x61\x2e\x78\x6d\x6c" card_access = "\x31\x81\xb3\x30\x0d\x06\x08\x04\x00\x7f\x00\x07\x02\x02\x02\x02\x01\x02\x30\x12\x06\x0a\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x02\x02\x01\x02\x02\x01\x41\x30\x12\x06\x0a\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x02\x02\x01\x02\x02\x01\x45\x30\x12\x06\x0a\x04\x00\x7f\x00\x07\x02\x02\x04\x02\x02\x02\x01\x02\x02\x01\x0d\x30\x1c\x06\x09\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x30\x0c\x06\x07\x04\x00\x7f\x00\x07\x01\x02\x02\x01\x0d\x02\x01\x41\x30\x1c\x06\x09\x04\x00\x7f\x00\x07\x02\x02\x03\x02\x30\x0c\x06\x07\x04\x00\x7f\x00\x07\x01\x02\x02\x01\x0d\x02\x01\x45\x30\x2a\x06\x08\x04\x00\x7f\x00\x07\x02\x02\x06\x16\x1e\x68\x74\x74\x70\x3a\x2f\x2f\x62\x73\x69\x2e\x62\x75\x6e\x64\x2e\x64\x65\x2f\x63\x69\x66\x2f\x6e\x70\x61\x2e\x78\x6d\x6c"
ALGO_MAPPING["\x04\x00\x7f\x00\x07\x02\x02\x04\x02\x02"] = "PACE"
self.mf = MF() self.mf = MF()
self.mf.append(TransparentStructureEF(parent=self.mf, fid=0x011c, shortfid=0x1c, data=card_access)) self.mf.append(TransparentStructureEF(parent=self.mf, fid=0x011c, shortfid=0x1c, data=card_access))
self.sam = nPA_SAM(self.mf) self.sam = nPA_SAM(self.mf)

View File

@@ -28,7 +28,7 @@ from chat import CHAT
class nPA_AT_CRT(ControlReferenceTemplate): class nPA_AT_CRT(ControlReferenceTemplate):
def __init__(self): def __init__(self):
ControlReferenceTemplate(CRT_TEMPLATE["AT"]) ControlReferenceTemplate.__init__(self, CRT_TEMPLATE["AT"])
def parse_SE_config(self, config): def parse_SE_config(self, config):
try: try:
@@ -36,7 +36,7 @@ class nPA_AT_CRT(ControlReferenceTemplate):
except SwError, e: except SwError, e:
structure = unpack(config) structure = unpack(config)
for tlv in structure: for tlv in structure:
tag, length, value = structure tag, length, value = tlv
if tag == 0x7f4c: if tag == 0x7f4c:
chat = CHAT(bertlv_pack([[tag, length, value]])) chat = CHAT(bertlv_pack([[tag, length, value]]))
print(chat) print(chat)
@@ -45,6 +45,8 @@ class nPA_AT_CRT(ControlReferenceTemplate):
else: else:
raise SwError(SW["ERR_REFNOTUSABLE"]) raise SwError(SW["ERR_REFNOTUSABLE"])
return 0x9000 , ""
class nPA_SAM(SAM): class nPA_SAM(SAM):
""" """
SAM for ICAO ePassport. Implements Basic access control and key derivation SAM for ICAO ePassport. Implements Basic access control and key derivation