-Fixed indention
-Improved a comment git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@516 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -36,8 +36,7 @@ class ePass_SE(Security_Environment):
|
|||||||
def compute_cryptographic_checksum(self, p1, p2, data):
|
def compute_cryptographic_checksum(self, p1, p2, data):
|
||||||
"""
|
"""
|
||||||
Compute a cryptographic checksum (e.g. MAC) for the given data.
|
Compute a cryptographic checksum (e.g. MAC) for the given data.
|
||||||
Algorithm and key are specified in the current (CAPDU) SE. The ePass
|
The ePass uses a Send Sequence Counter for MAC calculation
|
||||||
uses a Send Sequence Counter for MAC calculation
|
|
||||||
"""
|
"""
|
||||||
if p1 != 0x8E or p2 != 0x80:
|
if p1 != 0x8E or p2 != 0x80:
|
||||||
raise SwError(SW["ERR_INCORRECTP1P2"])
|
raise SwError(SW["ERR_INCORRECTP1P2"])
|
||||||
@@ -104,7 +103,7 @@ 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
|
||||||
Eifd = resp_data[:-8]
|
Eifd = resp_data[:-8]
|
||||||
padded_Eifd = vsCrypto.append_padding("DES", Eifd)
|
padded_Eifd = vsCrypto.append_padding("DES", Eifd)
|
||||||
Mifd = vsCrypto.crypto_checksum("CC", self.KMac, padded_Eifd)
|
Mifd = vsCrypto.crypto_checksum("CC", self.KMac, padded_Eifd)
|
||||||
#Check the MAC
|
#Check the MAC
|
||||||
if not Mifd == resp_data[-8:]:
|
if not Mifd == resp_data[-8:]:
|
||||||
@@ -120,7 +119,7 @@ class PassportSAM(SAM):
|
|||||||
#Generate Answer
|
#Generate Answer
|
||||||
data = plain[8:16] + plain[:8] + Kicc
|
data = plain[8:16] + plain[:8] + Kicc
|
||||||
Eicc = vsCrypto.encrypt("DES3-CBC", self.KEnc, data)
|
Eicc = vsCrypto.encrypt("DES3-CBC", self.KEnc, data)
|
||||||
padded_Eicc = vsCrypto.append_padding("DES", Eicc)
|
padded_Eicc = vsCrypto.append_padding("DES", Eicc)
|
||||||
Micc = vsCrypto.crypto_checksum("CC", self.KMac, padded_Eicc)
|
Micc = vsCrypto.crypto_checksum("CC", self.KMac, padded_Eicc)
|
||||||
#Derive the final keys and set the current SE
|
#Derive the final keys and set the current SE
|
||||||
KSseed = vsCrypto.operation_on_string(Kicc, Kifd, lambda a, b: a^b)
|
KSseed = vsCrypto.operation_on_string(Kicc, Kifd, lambda a, b: a^b)
|
||||||
|
|||||||
Reference in New Issue
Block a user