From 6cd71ddd55b1e1cf861d8ad49f9477be424ddb3d Mon Sep 17 00:00:00 2001 From: oepen Date: Fri, 29 Jul 2011 09:08:46 +0000 Subject: [PATCH] Various Bugfixes with regard to parsing a MSE:SetAT. The whole SE and SAM system should really be rewritten. git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@444 96b47cad-a561-4643-ad3b-153ac7d7599c --- .../src/vpicc/virtualsmartcard/SEutils.py | 4 +-- .../vpicc/virtualsmartcard/SmartcardSAM.py | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py index 067bf80..76df631 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License along with # virtualsmartcard. If not, see . # -import virtualsmartcard.TLVutils +import TLVutils from time import time from random import seed, randint from virtualsmartcard.ConstantDefinitions import * @@ -51,7 +51,7 @@ class ControlReferenceTemplate: for object in structure: tag, length, value = object if tag == 0x80: - self.__set_algo(data) + self.__set_algo(value) elif tag in (0x81,0x82,0x83,0x84): self.__set_key(tag,length,value) elif tag in range(0x85, 0x93): diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py index d8fb437..215bf14 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py @@ -617,14 +617,16 @@ class Secure_Messaging(object): """ cmd = p1 & 0x0F - se = p1 & 0xF0 + se = p1 >> 4 if(cmd == 0x01): - if se == 0x01: #Set the right SE + if se & 0x01: #Secure messaging in command data field self.current_SE = self.CAPDU_SE - elif se == 0x02: + if se & 0x02: #Secure messaging in response data field self.current_SE = self.RAPDU_SE - else: - pass #FIXME + if se & 0x04: #Computation, decipherment, internal authentication and key agreement + pass + if se & 0x08: #Verification, encipherment, external authentication and key agreement + pass self.__set_SE(p2,data) elif(cmd== 0x02): self.__store_SE(p2) @@ -644,19 +646,18 @@ class Secure_Messaging(object): valid_p2 = (0xA4,0xA6,0xB4,0xB6,0xB8) if not p2 in valid_p2: raise SwError(SW["ERR_INCORRECTP1P2"]) - tag, length, value = TLVutils.unpack(data) #Only one object? if p2 == 0xA4: - self.current_SE.at.parse_SE_config(value) + self.current_SE.at.parse_SE_config(data) elif p2 == 0xA6: - self.current_SE.kat.parse_SE_config(value) + self.current_SE.kat.parse_SE_config(data) elif p2 == 0xAA: - self.current_SE.ht.parse_SE_config(value) + self.current_SE.ht.parse_SE_config(data) elif p2 == 0xB4: - self.current_SE.cct.parse_SE_config(value) + self.current_SE.cct.parse_SE_config(data) elif p2 == 0xB6: - self.current_SE.dst.parse_SE_config(value) + self.current_SE.dst.parse_SE_config(data) elif p2 == 0xB8: - self.current_SE.ct.parse_SE_config(value) + self.current_SE.ct.parse_SE_config(data) def __store_SE(self,SEID): """