Code style improvements
git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@450 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -705,8 +705,8 @@ class Secure_Messaging(object):
|
||||
else:
|
||||
to_authenticate = ""
|
||||
|
||||
for object in structure:
|
||||
tag, length, value = object
|
||||
for tlv in structure:
|
||||
tag, length, value = tlv
|
||||
#TODO: Sanity checking
|
||||
#if not SM_Class.has_key(tag):
|
||||
# raise ValueError, "unknown Secure messaging tag %#X" % tag
|
||||
@@ -856,14 +856,15 @@ class Secure_Messaging(object):
|
||||
in ISO 7816-8. It will invoke the appropiate command and return its result
|
||||
"""
|
||||
|
||||
allowed_P1P2 = ((0x90,0x80),(0x90,0xA0),(0x9E,0x9A),(0x9E,0xAC),(0x9E,0xBC),(0x00,0xA2),
|
||||
(0x00,0xA8),(0x00,0x92),(0x00,0xAE),(0x00,0xBE),(0x82,0x80),(0x84,0x80),
|
||||
allowed_P1P2 = ((0x90, 0x80), (0x90, 0xA0), (0x9E, 0x9A), (0x9E, 0xAC), \
|
||||
(0x9E, 0xBC), (0x00, 0xA2), (0x00, 0xA8), (0x00, 0x92), \
|
||||
(0x00, 0xAE), (0x00, 0xBE), (0x82, 0x80), (0x84, 0x80), \
|
||||
(0x86, 0x80), (0x80, 0x82), (0x80, 0x84), (0x80, 0x86))
|
||||
|
||||
if (p1, p2) not in allowed_P1P2:
|
||||
raise SwError(SW["INCORRECTP1P2"])
|
||||
|
||||
if(p2 in (0x80,0xA0) and p1==0x90):
|
||||
if((p2 in (0x80, 0xA0)) and (p1 == 0x90)):
|
||||
sw, response_data = self.hash(p1, p2, data)
|
||||
elif(p2 in (0x9A, 0xAC, 0xBC) and p1 == 0x9E):
|
||||
sw, response_data = self.compute_digital_signature(p1, p2, data)
|
||||
@@ -887,8 +888,7 @@ class Secure_Messaging(object):
|
||||
def compute_cryptographic_checksum(self, p1, p2, data):
|
||||
"""
|
||||
Compute a cryptographic checksum (e.g. MAC) for the given data.
|
||||
Algorithm and key are specified in the current (CAPDU) SE
|
||||
@bug: Always use CAPDU settings ???
|
||||
Algorithm and key are specified in the current SE
|
||||
"""
|
||||
if p1 != 0x8E or p2 != 0x80:
|
||||
raise SwError(SW["ERR_INCORRECTP1P2"])
|
||||
@@ -1129,7 +1129,9 @@ class CryptoflexSM(Secure_Messaging):
|
||||
e_str = inttostring(e, 4)
|
||||
e_str = e_str[::-1]
|
||||
padd = 187 * '\x30' #We don't have chinese remainder theorem components, so we need to inject padding
|
||||
pk_n = TLVutils.bertlv_pack(((0x81,len(n_str),n_str),(0x01,len(padd),padd),(0x82,len(e_str),e_str)))
|
||||
pk_n = TLVutils.bertlv_pack(((0x81, len(n_str), n_str),
|
||||
(0x01, len(padd), padd),
|
||||
(0x82, len(e_str), e_str)))
|
||||
#Private key
|
||||
d = PublicKey.__getstate__()['d']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user