From 3447849133e861c494e487af9575fd7a82b23d86 Mon Sep 17 00:00:00 2001 From: oepen Date: Tue, 26 Jul 2011 09:46:49 +0000 Subject: [PATCH] -Bugfix: The Le of the Command APDU was used when sending out an error R_APDU -Enhancement: Using correct effective Le for R_APDUs git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@435 96b47cad-a561-4643-ad3b-153ac7d7599c --- .../vpicc/virtualsmartcard/VirtualSmartcard.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py index c7f8352..b21d3ec 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py @@ -218,14 +218,7 @@ class Iso7816OS(SmartcardOS): # {{{ # }}} def formatResult(self, le, data, sw, sm): - if le == None: - count = 0 - elif le == 0: - count = self.maxle - else: - count = le - - self.lastCommandOffcut = data[count:] + self.lastCommandOffcut = data[le:] l = len(self.lastCommandOffcut) if l == 0: self.lastCommandSW = SW["NORMAL"] @@ -233,7 +226,7 @@ class Iso7816OS(SmartcardOS): # {{{ self.lastCommandSW = sw sw = SW["NORMAL_REST"] + min(0xff, l) - result = data[:count] + result = data[:le] if sm: sw, result = self.SAM.protect_result(sw,result) @@ -307,15 +300,15 @@ class Iso7816OS(SmartcardOS): # {{{ raise SwError("ERR_SECMESSNOTSUPPORTED") sw, result = self.ins2handler.get(c.ins, notImplemented)(c.p1, c.p2, c.data) if SM_STATUS == "Standard SM": - answer = self.formatResult(c.le, result, sw, True) + answer = self.formatResult(c.effective_Le, result, sw, True) else: - answer = self.formatResult(c.le, result, sw, False) + answer = self.formatResult(c.effective_Le, result, sw, False) except SwError, e: print e.message #traceback.print_exception(*sys.exc_info()) sw = e.sw result = "" - answer = self.formatResult(c.le, result, sw, False) + answer = self.formatResult(0, result, sw, False) return answer # }}}