fixed handling of SW1=0x61 in handler_test

This commit is contained in:
Frank Morgner
2013-07-18 14:09:38 +02:00
parent cdf68d62b3
commit a766a6e01a

View File

@@ -568,38 +568,37 @@ class HandlerTestOS(SmartcardOS):
ok = '\x90\x00'
error = '\x6d\x00'
if msg == '\x00\xA4\x04\x00\x06\xA0\x00\x00\x00\x18\x50' or msg == '\x00\xA4\x04\x00\x06\xA0\x00\x00\x00\x18\xFF':
print 'Select applet'
logging.info('Select applet')
return ok
elif msg.startswith('\x80\x38\x00'):
print 'Time Request'
logging.info('Time Request')
return ok
elif msg == '\x80\x30\x00\x00':
print 'Case 1, APDU'
logging.info('Case 1, APDU')
return ok
elif msg == '\x80\x30\x00\x00\x00':
print 'Case 1, TPDU'
logging.info('Case 1, TPDU')
return ok
elif msg.startswith('\x80\x32\x00\x00'):
print 'Case 3'
logging.info('Case 3')
return ok
elif msg.startswith('\x80\x34'):
print 'Case 2'
logging.info('Case 2')
return self.__output_from_le(msg) + ok
elif msg.startswith('\x80\x36'):
if len(msg) == 5+ord(msg[4]):
print 'Case 4, TPDU'
logging.info('Case 4, TPDU')
self.lastCommandOffcut = self.__output_from_le(msg)
# XXX the return code is expected by handler_test.c. According
# to ISO 7816 this should be:
# '\x61' + chr(max(0xff, len(self.lastCommandOffcut)))
return '\x61' + chr(len(self.lastCommandOffcut)&0xFF)
if len(self.lastCommandOffcut) > 0xFF:
return '\x61\x00'
return '' + chr(len(self.lastCommandOffcut)&0xFF)
elif len(msg) == 6+ord(msg[4]):
print 'Case 4, APDU'
logging.info('Case 4, APDU')
return self.__output_from_le(msg) + ok
else:
return error
elif msg.startswith('\x80\xC0\x00\x00'):
print 'Get response'
logging.info('Get response')
out = self.lastCommandOffcut[:ord(msg[4])]
self.lastCommandOffcut = self.lastCommandOffcut[ord(msg[4]):]
return out + ok