From 47461a40ca95c27ddd7d6cbd16de1b877e8a5384 Mon Sep 17 00:00:00 2001 From: oepen Date: Fri, 29 Jul 2011 09:36:30 +0000 Subject: [PATCH] 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 --- virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py | 3 ++- virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py index 76df631..6443c6f 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py @@ -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] diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py index 215bf14..2cf769a 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py @@ -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