Reduced overlap between ePass_SE and PassportSAM

git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@506 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
oepen
2011-08-23 13:39:23 +00:00
parent 63f3f3809c
commit 0a308c078e

View File

@@ -61,8 +61,6 @@ class PassportSAM(SAM):
self.KSeed = None
self.KEnc = None
self.KMac = None
self.KSenc = None
self.KSmac = None
self.__computeKeys()
SAM.__init__(self, None, None, mf)
self.current_SE = ePass_SE(None, None)
@@ -120,17 +118,11 @@ class PassportSAM(SAM):
data = plain[8:16] + plain[:8] + Kicc
Eicc = vsCrypto.encrypt("DES3-CBC", self.KEnc, data)
Micc = self._mac(self.KMac, Eicc)
#Derive the final keys
#Derive the final keys and set the current SE
KSseed = vsCrypto.operation_on_string(Kicc, Kifd, lambda a, b: a^b)
self.KSenc = self.derive_key(KSseed, 1)
self.KSmac = self.derive_key(KSseed, 2)
#self.ssc = rnd_icc[-4:] + rnd_ifd[-4:]
#Set the current SE
self.current_SE.ct.key = self.KSenc
self.current_SE.cct.key = self.KSmac
self.current_SE.ct.key = self.derive_key(KSseed, 1)
self.current_SE.cct.key = self.derive_key(KSseed, 2)
self.current_SE.ssc = stringtoint(rnd_icc[-4:] + rnd_ifd[-4:])
self.current_SE.ct.algorithm = "DES3-CBC"
self.current_SE.cct.algorithm = "CC"
return SW["NORMAL"], Eicc + Micc
def _mac(self, key, data, ssc = None, dopad=True):
@@ -142,4 +134,4 @@ class PassportSAM(SAM):
a = vsCrypto.encrypt("des-cbc", key[:8], data)
b = vsCrypto.decrypt("des-ecb", key[8:16], a[-8:])
c = vsCrypto.encrypt("des-ecb", key[:8], b)
return c
return c