Added a SAM reference to the Secure_Messaging class in order to resolve an error.
The classes in SmartcardSAM are way too entangled and definitively need to be refactored. git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@479 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -82,7 +82,7 @@ class SAM(object):
|
|||||||
else:
|
else:
|
||||||
self.cardSecret = cardSecret
|
self.cardSecret = cardSecret
|
||||||
|
|
||||||
self.SM_handler = Secure_Messaging(self.mf)
|
self.SM_handler = Secure_Messaging(self.mf, self)
|
||||||
|
|
||||||
def set_MF(self, mf):
|
def set_MF(self, mf):
|
||||||
self.mf = mf
|
self.mf = mf
|
||||||
@@ -313,7 +313,6 @@ class PassportSAM(SAM):
|
|||||||
self.KSenc = None
|
self.KSenc = None
|
||||||
self.KSmac = None
|
self.KSmac = None
|
||||||
self.__computeKeys()
|
self.__computeKeys()
|
||||||
#SAM.__init__(self, path, key,None)
|
|
||||||
SAM.__init__(self, None, None, mf)
|
SAM.__init__(self, None, None, mf)
|
||||||
self.SM_handler = ePass_SM(mf, None, None)
|
self.SM_handler = ePass_SM(mf, None, None)
|
||||||
self.SM_handler.current_SE.cct.algorithm = "CC"
|
self.SM_handler.current_SE.cct.algorithm = "CC"
|
||||||
@@ -352,7 +351,6 @@ class PassportSAM(SAM):
|
|||||||
|
|
||||||
#Receive Mutual Authenticate APDU from terminal
|
#Receive Mutual Authenticate APDU from terminal
|
||||||
#Decrypt data and check MAC
|
#Decrypt data and check MAC
|
||||||
#cipher = DES3.new(self.KEnc,"des3-cbc")
|
|
||||||
Eifd = resp_data[:-8]
|
Eifd = resp_data[:-8]
|
||||||
Mifd = self._mac(self.KMac, Eifd)
|
Mifd = self._mac(self.KMac, Eifd)
|
||||||
#Check the MAC
|
#Check the MAC
|
||||||
@@ -469,8 +467,9 @@ class Security_Environment(object):
|
|||||||
|
|
||||||
class Secure_Messaging(object):
|
class Secure_Messaging(object):
|
||||||
|
|
||||||
def __init__(self, MF, SE=None):
|
def __init__(self, MF, SAM, SE=None):
|
||||||
self.mf = MF
|
self.mf = MF
|
||||||
|
self.sam = SAM
|
||||||
if not SE:
|
if not SE:
|
||||||
self.current_SE = Security_Environment()
|
self.current_SE = Security_Environment()
|
||||||
else:
|
else:
|
||||||
@@ -555,7 +554,7 @@ class Secure_Messaging(object):
|
|||||||
"""
|
"""
|
||||||
SEstr = dumps(self.current_SE)
|
SEstr = dumps(self.current_SE)
|
||||||
try:
|
try:
|
||||||
self.SAM.addkey(SEID, SEstr) #TODO: Need SAM reference
|
self.sam.addkey(SEID, SEstr) #FIXME: Need SAM reference
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SwError["ERR_INCORRECTP1P2"]
|
raise SwError["ERR_INCORRECTP1P2"]
|
||||||
|
|
||||||
@@ -565,7 +564,7 @@ class Secure_Messaging(object):
|
|||||||
Restores a Security Environment from the SAM and replaces the current SE
|
Restores a Security Environment from the SAM and replaces the current SE
|
||||||
with it
|
with it
|
||||||
"""
|
"""
|
||||||
SEstr = self.SAM.get_key(SEID)
|
SEstr = self.sam.get_key(SEID)
|
||||||
SE = loads(SEstr)
|
SE = loads(SEstr)
|
||||||
if isinstance(SE, Security_Environment):
|
if isinstance(SE, Security_Environment):
|
||||||
self.current_SE = SE
|
self.current_SE = SE
|
||||||
@@ -576,7 +575,7 @@ class Secure_Messaging(object):
|
|||||||
"""
|
"""
|
||||||
Erases a Security Environment stored under SEID from the SAM
|
Erases a Security Environment stored under SEID from the SAM
|
||||||
"""
|
"""
|
||||||
self.SAM.removeKey(SEID)
|
self.sam.removeKey(SEID)
|
||||||
|
|
||||||
def parse_SM_CAPDU(self, CAPDU, header_authentication):
|
def parse_SM_CAPDU(self, CAPDU, header_authentication):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user