Bug #4742 ยป os4742.py
1 |
|
---|---|
2 |
from smartcard.System import readers |
3 |
import smartcard.CardConnection |
4 |
from smartcard.CardType import AnyCardType |
5 |
from smartcard.CardRequest import CardRequest |
6 |
from smartcard.CardConnectionObserver import ConsoleCardConnectionObserver |
7 |
from smartcard.util import toHexString, toBytes |
8 |
|
9 |
|
10 |
def run_testcase(reader): |
11 |
cardrequest = CardRequest(readers=[reader], timeout=10, cardType=AnyCardType()) |
12 |
cardservice = cardrequest.waitforcard() |
13 |
|
14 |
observer = ConsoleCardConnectionObserver() |
15 |
cardservice.connection.addObserver(observer) |
16 |
|
17 |
cardservice.connection.connect() |
18 |
|
19 |
command_list = [ |
20 |
"00a40004023f00", |
21 |
"00a40004027f10", |
22 |
"00a40004025F3A", |
23 |
"00a40004024f09", |
24 |
"00a20104020000", |
25 |
]
|
26 |
|
27 |
for c in command_list: |
28 |
response, sw1, sw2 = cardservice.connection.transmit(toBytes(c), cardservice.connection.T0_protocol) |
29 |
|
30 |
cardservice.connection.disconnect() |
31 |
|
32 |
|
33 |
r = readers() |
34 |
|
35 |
for i in range(0,8): |
36 |
run_testcase(r[i]) |
37 |
|