Code style improvements
git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@451 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -181,12 +181,12 @@ class SAM(object):
|
|||||||
else:
|
else:
|
||||||
self.CardContainer.cipher = algo
|
self.CardContainer.cipher = algo
|
||||||
|
|
||||||
def set_asym_algorithm(self, cipher, type):
|
def set_asym_algorithm(self, cipher, keytype):
|
||||||
"""
|
"""
|
||||||
@param cipher: Public/private key object from Crypto.PublicKey used for encryption
|
@param cipher: Public/private key object from Crypto.PublicKey used for encryption
|
||||||
@param type: Type of the public key (e.g. RSA, DSA)
|
@param keytype: Type of the public key (e.g. RSA, DSA)
|
||||||
"""
|
"""
|
||||||
if not type in range(0x07, 0x08):
|
if not keytype in range(0x07, 0x08):
|
||||||
raise ValueError, "Illegal Parameter"
|
raise ValueError, "Illegal Parameter"
|
||||||
else:
|
else:
|
||||||
self.CardContainer.cipher = type
|
self.CardContainer.cipher = type
|
||||||
@@ -392,8 +392,8 @@ class SAM(object):
|
|||||||
filedescriptor=0, data="Key from the FS."))
|
filedescriptor=0, data="Key from the FS."))
|
||||||
|
|
||||||
df = mf.currentDF()
|
df = mf.currentDF()
|
||||||
file = df.select('fid', 0X1012)
|
fake_ef = df.select('fid', 0X1012)
|
||||||
sw, result = file.readbinary(0)
|
sw, result = fake_ef.readbinary(0)
|
||||||
return sw, result
|
return sw, result
|
||||||
|
|
||||||
#The following commands define the interface to the Secure Messaging functions
|
#The following commands define the interface to the Secure Messaging functions
|
||||||
@@ -542,8 +542,7 @@ class Security_Environment(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.SEID = None
|
self.SEID = None
|
||||||
self.sm_objects = ""
|
self.sm_objects = ""
|
||||||
#Default configuration
|
|
||||||
ct = "\x80\x01\x01\x82\x01\x00\x85\x01\x00"
|
|
||||||
#Control Reference Tables
|
#Control Reference Tables
|
||||||
self.at = CRT(TEMPLATE_AT)
|
self.at = CRT(TEMPLATE_AT)
|
||||||
self.kat = CRT(TEMPLATE_KAT)
|
self.kat = CRT(TEMPLATE_KAT)
|
||||||
@@ -1137,14 +1136,14 @@ class CryptoflexSM(Secure_Messaging):
|
|||||||
|
|
||||||
#Write result to FID 10 12 EF-PUB-KEY
|
#Write result to FID 10 12 EF-PUB-KEY
|
||||||
df = self.mf.currentDF()
|
df = self.mf.currentDF()
|
||||||
file = df.select("fid", 0x1012)
|
ef_pub_key = df.select("fid", 0x1012)
|
||||||
file.writebinary([0], [pk_n])
|
ef_pub_key.writebinary([0], [pk_n])
|
||||||
data = file.getenc('data')
|
data = ef_pub_key.getenc('data')
|
||||||
|
|
||||||
#Write private key to FID 00 12 EF-PRI-KEY (not necessary?)
|
#Write private key to FID 00 12 EF-PRI-KEY (not necessary?)
|
||||||
file = df.select("fid", 0x0012)
|
ef_priv_key = df.select("fid", 0x0012)
|
||||||
file.writebinary([0], [inttostring(d)]) #Do we need encoding for the private key?
|
ef_priv_key.writebinary([0], [inttostring(d)]) #Do we need encoding for the private key?
|
||||||
data = file.getenc('data')
|
data = ef_priv_key.getenc('data')
|
||||||
return PublicKey
|
return PublicKey
|
||||||
|
|
||||||
class ePass_SM(Secure_Messaging):
|
class ePass_SM(Secure_Messaging):
|
||||||
@@ -1178,8 +1177,6 @@ if __name__ == "__main__":
|
|||||||
Unit test:
|
Unit test:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import virtualsmartcard.CryptoUtils
|
|
||||||
|
|
||||||
password = "DUMMYKEYDUMMYKEY"
|
password = "DUMMYKEYDUMMYKEY"
|
||||||
#generate_SAM_config("1234567890", "1234", "keykeykeykeykeyk", path, password)
|
#generate_SAM_config("1234567890", "1234", "keykeykeykeykeyk", path, password)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user