From 46d3551fbfc122e58672bdcadb259cd362ec93d5 Mon Sep 17 00:00:00 2001 From: oepen Date: Thu, 8 Dec 2011 15:37:40 +0000 Subject: [PATCH] Bugfixes: nPA emulator is now working git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@650 96b47cad-a561-4643-ad3b-153ac7d7599c --- .../src/vpicc/virtualsmartcard/CardGenerator.py | 4 ++-- virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/CardGenerator.py b/virtualsmartcard/src/vpicc/virtualsmartcard/CardGenerator.py index d1a1622..097912a 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/CardGenerator.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/CardGenerator.py @@ -22,7 +22,7 @@ from pickle import loads, dumps from virtualsmartcard.TLVutils import pack from virtualsmartcard.utils import inttostring 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.SmartcardSAM import SAM from virtualsmartcard.cards.cryptoflex import CryptoflexSAM, CryptoflexMF @@ -145,7 +145,7 @@ class CardGenerator(object): 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" - + ALGO_MAPPING["\x04\x00\x7f\x00\x07\x02\x02\x04\x02\x02"] = "PACE" self.mf = MF() self.mf.append(TransparentStructureEF(parent=self.mf, fid=0x011c, shortfid=0x1c, data=card_access)) self.sam = nPA_SAM(self.mf) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py index 2a75f64..b5d8093 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py @@ -28,7 +28,7 @@ from chat import CHAT class nPA_AT_CRT(ControlReferenceTemplate): def __init__(self): - ControlReferenceTemplate(CRT_TEMPLATE["AT"]) + ControlReferenceTemplate.__init__(self, CRT_TEMPLATE["AT"]) def parse_SE_config(self, config): try: @@ -36,7 +36,7 @@ class nPA_AT_CRT(ControlReferenceTemplate): except SwError, e: structure = unpack(config) for tlv in structure: - tag, length, value = structure + tag, length, value = tlv if tag == 0x7f4c: chat = CHAT(bertlv_pack([[tag, length, value]])) print(chat) @@ -45,6 +45,8 @@ class nPA_AT_CRT(ControlReferenceTemplate): else: raise SwError(SW["ERR_REFNOTUSABLE"]) + return 0x9000 , "" + class nPA_SAM(SAM): """ SAM for ICAO ePassport. Implements Basic access control and key derivation