blob: aa401255190d4170c0f1c2116e688656011bae0d [file] [log] [blame]
Christina Quast158c1dd2015-04-17 20:19:29 +02001#!/usr/bin/env python
2
3import constants
4import array
5
6INS = 1
7CNT = 4
8
9class SmartCardEmulator:
10 def getATR(self):
11 return array.array('B', constants.ATR_SYSMOCOM2)
12
13 def send_receive_cmd(self, cmd):
14 if len(cmd) == 5: # Received cmd from phone
15 if cmd[INS] == 0xA4:
16 resp = [cmd[INS]] # Respond with INS byte
17 elif cmd[INS] == 0xC0:
18 data = [0x00, 0x00, 0x00, 0x00,
19 0x7F, 0x20, 0x02, 0x00,
20 0x00, 0x00, 0x00, 0x00,
21 0x09, 0x91, 0x00, 0x17,
22 0x04, 0x00, 0x83, 0x8A,
23 0x83, 0x8A]
24 SW = [0x90, 0x00]
25 resp = [cmd[INS]] + data + SW # Respond with INS byte
26 #state = WAIT_RST
27 else:
28 print("Unknown cmd")
29 resp = [0x60, 0x00]
30 elif len(cmd) == 2:
31 resp = [0x9F, 0x16]
32 else:
33 resp = [0x60, 0x00]
34
35 print("Cmd, resp: ")
36 print("".join("%02x " % b for b in cmd))
37 print("".join("%02x " % b for b in resp))
38
39 return array.array('B', resp)
40
41 def reset_card():
42 pass
43
44 def close(self):
45 pass