-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
This commit is contained in:
@@ -218,14 +218,7 @@ class Iso7816OS(SmartcardOS): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def formatResult(self, le, data, sw, sm):
|
def formatResult(self, le, data, sw, sm):
|
||||||
if le == None:
|
self.lastCommandOffcut = data[le:]
|
||||||
count = 0
|
|
||||||
elif le == 0:
|
|
||||||
count = self.maxle
|
|
||||||
else:
|
|
||||||
count = le
|
|
||||||
|
|
||||||
self.lastCommandOffcut = data[count:]
|
|
||||||
l = len(self.lastCommandOffcut)
|
l = len(self.lastCommandOffcut)
|
||||||
if l == 0:
|
if l == 0:
|
||||||
self.lastCommandSW = SW["NORMAL"]
|
self.lastCommandSW = SW["NORMAL"]
|
||||||
@@ -233,7 +226,7 @@ class Iso7816OS(SmartcardOS): # {{{
|
|||||||
self.lastCommandSW = sw
|
self.lastCommandSW = sw
|
||||||
sw = SW["NORMAL_REST"] + min(0xff, l)
|
sw = SW["NORMAL_REST"] + min(0xff, l)
|
||||||
|
|
||||||
result = data[:count]
|
result = data[:le]
|
||||||
if sm:
|
if sm:
|
||||||
sw, result = self.SAM.protect_result(sw,result)
|
sw, result = self.SAM.protect_result(sw,result)
|
||||||
|
|
||||||
@@ -307,15 +300,15 @@ class Iso7816OS(SmartcardOS): # {{{
|
|||||||
raise SwError("ERR_SECMESSNOTSUPPORTED")
|
raise SwError("ERR_SECMESSNOTSUPPORTED")
|
||||||
sw, result = self.ins2handler.get(c.ins, notImplemented)(c.p1, c.p2, c.data)
|
sw, result = self.ins2handler.get(c.ins, notImplemented)(c.p1, c.p2, c.data)
|
||||||
if SM_STATUS == "Standard SM":
|
if SM_STATUS == "Standard SM":
|
||||||
answer = self.formatResult(c.le, result, sw, True)
|
answer = self.formatResult(c.effective_Le, result, sw, True)
|
||||||
else:
|
else:
|
||||||
answer = self.formatResult(c.le, result, sw, False)
|
answer = self.formatResult(c.effective_Le, result, sw, False)
|
||||||
except SwError, e:
|
except SwError, e:
|
||||||
print e.message
|
print e.message
|
||||||
#traceback.print_exception(*sys.exc_info())
|
#traceback.print_exception(*sys.exc_info())
|
||||||
sw = e.sw
|
sw = e.sw
|
||||||
result = ""
|
result = ""
|
||||||
answer = self.formatResult(c.le, result, sw, False)
|
answer = self.formatResult(0, result, sw, False)
|
||||||
|
|
||||||
return answer
|
return answer
|
||||||
# }}}
|
# }}}
|
||||||
|
|||||||
Reference in New Issue
Block a user