SmartcardSAM: Fixed syntax errors

SEutils: Now replying with error RAPDU when we do not support a referenced algorithm


git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@445 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
oepen
2011-07-29 09:36:30 +00:00
parent 6cd71ddd55
commit 47461a40ca
2 changed files with 4 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ from time import time
from random import seed, randint
from virtualsmartcard.ConstantDefinitions import *
from virtualsmartcard.utils import inttostring, stringtoint
from virtualsmartcard.SWutils import *
class ControlReferenceTemplate:
def __init__(self,type,config=""):
@@ -61,7 +62,7 @@ class ControlReferenceTemplate:
def __set_algo(self,data):
if not ALGO_MAPPING.has_key(data):
raise ValueError
raise SwError(SW["ERR_REFNOTUSABLE"])
else:
#TODO: Sanity checking
self.algorithm = ALGO_MAPPING[data]

View File

@@ -939,7 +939,7 @@ class Secure_Messaging(object):
if p1 != 0x8E or p2 != 0x80:
raise SwError(SW["ERR_INCORRECTP1P2"])
if self.CAPDU_SE.cct.algorithm == None or self.current_SE.cct.key == None:
raise SWError(SE["ERR_CONDITIONNOTSATISFIED"])
raise SwError(SE["ERR_CONDITIONNOTSATISFIED"])
checksum = virtualsmartcard.CryptoUtils.crypto_checksum(self.current_SE.cct.algorithm,
self.current_SE.cct.key,
@@ -959,7 +959,7 @@ class Secure_Messaging(object):
if p1 != 0x9E or not p2 in (0x9A,0xAC,0xBC):
raise SwError(SW["ERR_INCORRECTP1P2"])
if self.current_SE.dst.key == None:
raise SWError(SE["ERR_CONDITIONNOTSATISFIED"])
raise SwError(SE["ERR_CONDITIONNOTSATISFIED"])
if p2 == 0x9A: #Data to be signed
to_sign = data