I currently can use pyscard correctly to talk with my smartcard, however when the apdu size is above 255 bytes, i need to receive the remaining bytes for the command.
What method gets me the remaining bytes in pyscard? To my understanding sw2 should be the number of remaining bytes.
def _cmd(self, cl, ins, p1, p2, data=''):
command = '%02x%02x%02x%02x%02x%s' % (cl, ins, p1, p2, len(data),
data.encode('hex'))
data, sw1, sw2 = self.reader.transmit(hex2cmd(command))
return data, sw1 << 8 | sw2
def _cmd_ok(self, *args, **kwargs):
data, status = self._cmd(*args, **kwargs)
if status != 0x9000:
raise Exception('APDU error: 0x%04x' % status)
return ''.join(map(chr, data))
I know that this is necroposting. Anyway:
My approach is different: 61 xx means that you need to get additional xx bytes of data. You can then send
response, sw1, sw2 = connection.transmit([0x00,0xC0,0x00,0x00,0xXX])
to get the 0xXX bytes back without polling for the 90 00 ack.