blob: a394124fcc514c72ce5116f2f28a91b93dfdfbc4 [file] [log] [blame]
Christina Quast158c1dd2015-04-17 20:19:29 +02001#!/usr/bin/env python
2
3import constants
4import array
5
6INS = 1
Christina Quastfb91bb72015-04-18 13:31:42 +02007LEN = 4
Christina Quast158c1dd2015-04-17 20:19:29 +02008
9class SmartCardEmulator:
10 def getATR(self):
Christina Quast61181462015-05-03 16:34:06 +020011 return array.array('B', constants.ATR_SYSMOCOM1)
Christina Quast158c1dd2015-04-17 20:19:29 +020012
13 def send_receive_cmd(self, cmd):
Christina Quastfb91bb72015-04-18 13:31:42 +020014 if cmd[INS] == 0xA4:
Christina Quast158c1dd2015-04-17 20:19:29 +020015 resp = [0x9F, 0x16]
Christina Quast61181462015-05-03 16:34:06 +020016 elif cmd == [0xff, 0x00, 0xff]:
17 resp = [0xff]
Christina Quastfb91bb72015-04-18 13:31:42 +020018 elif len(cmd) == 5 and cmd[INS] == 0xC0:
19 data = self.ans_from_len[cmd[LEN]]
20 SW = [0x90, 0x00]
21 resp = data + SW # Respond with INS byte
22 #state = WAIT_RST
Christina Quast158c1dd2015-04-17 20:19:29 +020023 else:
Christina Quastfb91bb72015-04-18 13:31:42 +020024 print("Unknown cmd")
Christina Quast158c1dd2015-04-17 20:19:29 +020025 resp = [0x60, 0x00]
26
27 print("Cmd, resp: ")
28 print("".join("%02x " % b for b in cmd))
29 print("".join("%02x " % b for b in resp))
30
31 return array.array('B', resp)
32
33 def reset_card():
34 pass
35
36 def close(self):
37 pass
Christina Quastfb91bb72015-04-18 13:31:42 +020038
39 ans_from_len = {0x16: [0x00, 0x00, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x09, 0x91, 0x00, 0x17,
41 0x04, 0x00, 0x83, 0x8A, 0x83, 0x8A],
42 }