Commit Graph

66 Commits

Author SHA1 Message Date
Christina Quast
b2d5aeb850 ccid.c: Remove test code 2015-04-07 12:51:11 +02:00
Christina Quast
fe25784411 simtrace_iso7816.c: removed unused fct get_buf_start 2015-04-06 23:30:47 +02:00
Christina Quast
b06fc38939 usb.c: fix compiler warning USBConfigurationDescriptor 2015-04-06 23:30:21 +02:00
Christina Quast
46f5ccabb1 cciddriver.c: comment out unused USBDCallbacks_RequestReceived 2015-04-06 23:29:42 +02:00
Christina Quast
4b1e98d058 cciddriver.c: Directly access configurationDescriptorsArr 2015-04-06 23:28:41 +02:00
Christina Quast
3debfd6595 Bugfix: ccid.c: Remove dead code 2015-04-06 23:26:38 +02:00
Christina Quast
c063cfe887 phone.c: Removed redundant definition of PR 2015-04-06 21:34:43 +02:00
Christina Quast
2f27c7c3d2 phone.c: Fixed incompatible pointer type comparison 2015-04-06 20:46:40 +02:00
Christina Quast
e76a3ee499 phone.c: Removed dead code (rst_cnt) 2015-04-06 20:43:11 +02:00
Christina Quast
a4d1d1619b phone.c: Remove double define of waittime 2015-04-06 20:41:50 +02:00
Christina Quast
443e55017d phone.c: remove dot printout 2015-04-06 20:38:51 +02:00
Christina Quast
ca39e16797 tc_etu.c: newline in printout inserted 2015-04-06 19:19:16 +02:00
Christina Quast
bdaa95484c Bug fix: Fix endless loop when ATR is not received
Without this fix, if the host software does not send an ATR, simtrace
waits for this answer in an endless loop of unsuccessfull USB
endpoint write attempts.
2015-04-06 00:52:08 +02:00
Christina Quast
14fbf9c8ad phone.c: more debug info in send_ATR 2015-04-06 00:36:12 +02:00
Christina Quast
3041854872 phone.c: Changed bus switch from sniffer to phone mode
In order to record the communication between simtrace and the
mobile phone with a logic analyzer I had to configure the
pins in sniffer mode in order to attach the sniffer clips
to the SIM card slot. I did not manage to connect them to
the connector to the phone flex cable.
2015-04-05 10:08:06 +02:00
Christina Quast
e01fb9a146 usb.c: mitm config with ccid interface 2015-04-04 19:56:23 +02:00
Christina Quast
394084615d mitm.c: second CCID and Phone init and run functions 2015-04-04 19:54:22 +02:00
Christina Quast
0becc0c51c Fixed compiler warn: USB descriptor array elements
The compiler warning:

simtrace/usb.c:553:5: warning: initialization from incompatible pointer type [enabled by default]
     &configurationDescriptorSniffer,
     ^
simtrace/usb.c:553:5: warning: (near initialization for 'configurationDescriptorsArr[0]') [enabled by default]
simtrace/usb.c:554:5: warning: initialization from incompatible pointer type [enabled by default]
     &configurationDescriptorCCID,
     ^
simtrace/usb.c:554:5: warning: (near initialization for 'configurationDescriptorsArr[1]') [enabled by default]
simtrace/usb.c:555:5: warning: initialization from incompatible pointer type [enabled by default]
     &configurationDescriptorPhone,
     ^
simtrace/usb.c:555:5: warning: (near initialization for 'configurationDescriptorsArr[2]') [enabled by default]
simtrace/usb.c:556:5: warning: initialization from incompatible pointer type [enabled by default]
     &configurationDescriptorMITM,
     ^
simtrace/usb.c:556:5: warning: (near initialization for 'configurationDescriptorsArr[3]') [enabled by default]
simtrace/usb.c: In function 'getConfigDesc':
simtrace/usb.c:560:5: warning: return discards 'const' qualifier from pointer target type [enabled by default]
     return configurationDescriptorsArr[idx];
     ^
simtrace/usb.c: At top level:
2015-04-04 13:04:06 +02:00
Christina Quast
b65b881de1 Phone uses USB endpoints 4 to 6 instead of 1 to 3 now 2015-04-04 10:51:37 +02:00
Christina Quast
6355ecedf7 Phone: Write err msg if writing to USB PHONE_INT endpoint failed 2015-04-04 10:15:38 +02:00
Christina Quast
6d9dcfc41d usb.c: updated phone descriptor length 2015-04-03 22:26:43 +02:00
Christina Quast
99d80ffb87 usb.c: Updated comment to be generic 2015-04-03 22:26:07 +02:00
Christina Quast
e90decef3d redefinition of PHONE_* in phone.c 2015-04-03 11:40:38 +02:00
Christina Quast
1d80ef23a0 defined PR to easily switch between INFO/DEBUG prints 2015-04-03 11:39:38 +02:00
Christina Quast
d3630cc86d phone ISR with mask (does not function yet) 2015-04-03 11:38:24 +02:00
Christina Quast
8e5381ca10 phone RST define taken from simtrace.h 2015-04-03 11:37:17 +02:00
Christina Quast
7123425841 redifined phone usb interface 2015-04-03 11:35:59 +02:00
Christina Quast
4bcc023be7 Phone hack: endless loop
Motorola seems to be in an endless loop?
In any case, it only shows the motorola logo and does not react to
pressing the power button.
2015-03-24 21:59:32 +01:00
Christina Quast
2889fc2d38 Bug fixed, timeout frequ increased 2015-03-22 19:06:51 +01:00
Christina Quast
a1dd0ef4bc Double size buf, a lot of debug 2015-03-22 19:06:12 +01:00
Christina Quast
0ca8390a8d first few communication steps work 2015-03-22 19:05:23 +01:00
Christina Quast
531d10b403 Timer counter functions, Makefile adjusted 2015-03-19 19:28:18 +01:00
Christina Quast
ce296b9def Attempt to implement working simcard emulator
The BUFLEN is fixed 5 bytes now, which has to be increased.
A timeout has to be implemented, which is smaller than max_waittime.
If the timeout is triggered, the data received in the buffer so far
should be sent to the host computer which is responsible for generating
a response. Without the timeout the max_waittime of the phone would
expire and it would repeat sending the command, so that we do not
have atomary messages anymore.
2015-03-18 18:41:19 +01:00
Christina Quast
578daaaeff first try of sim card emulator 2015-03-13 23:46:01 +01:00
Christina Quast
c5a78d72bf simtrace: wait until usb is configured 2015-03-10 15:37:52 +01:00
Christina Quast
5ce38abd36 Moved code for select file cmd into function
The select command mostly works when the blue sysmocom SIM card is inserted,
but with the white SuperSIM we always get timeouts and invalid answers.
Furthermore the white card takes much longer to answer the requests than the
blue one.
So probably there is a timing issue.

Currently this is the simtrace output for select and reading IMSI, etc:
(pcscd must be running as welil, otherwise we get:
$ ./simtrace.py -S
Exception: Failed to establish context : Service not available.)

$ ./simtrace.py -S
Context established!
PCSC Readers: ['ATMEL AT91SO CCID Smart Card Reader [SIMtraceCCID] 00 00']
Using reader: ATMEL AT91SO CCID Smart Card Reader [SIMtraceCCID] 00 00
Connected with active protocol 1
Select: 0x6E 0x00
Command: 0x6D 0x00
Disconnected
Released context.
==> Expected answer for Select: 0x6D 0x00
(based on trying to execute this command with gemalto usb smart card reader)
The command works only every now and then

$ ./simtrace.py -b
pcsc: wait_for_card
Reading ...
Traceback (most recent call last):
  File "./simtrace.py", line 105, in <module>
    main()
  File "./simtrace.py", line 66, in main
    ccid.pySim_read()
  File "/home/chrysh/ba_thesis/sysmocom_repo/usb_application/ccid.py", line 22, in pySim_read
    (res, sw) = scc.read_binary(['3f00', '2fe2'])
  File "/home/chrysh/code/src/pysim/pySim/commands.py", line 42, in read_binary
    r = self.select_file(ef)
  File "/home/chrysh/code/src/pysim/pySim/commands.py", line 35, in select_file
    data, sw = self._tp.send_apdu_checksw("a0a4000002" + i)
  File "/home/chrysh/code/src/pysim/pySim/transport/__init__.py", line 87, in send_apdu_checksw
    raise RuntimeError("SW match failed ! Expected %s and got %s." % (sw.lower(), rv[1]))
RuntimeError: SW match failed ! Expected 9000 and got 9404.
==> Error code 9404 does not exist, which suggests that we actually have a timing issue when
communicating with the smart cart
2015-03-10 15:16:13 +01:00
Christina Quast
1a224af098 Re-fixed ATR error not send on reset 2015-03-10 15:11:37 +01:00
Christina Quast
b58434eb2f Atr[3] is protocol, not Atr[5], right?
Also: Added debug information for command not supported
2015-03-09 17:13:07 +01:00
Christina Quast
0166c6d64e Temporary fix: mitm mode use EP 4-6 2015-03-05 15:44:05 +01:00
Christina Quast
b5ebebea0f main: configure red led, just in case 2015-03-05 15:43:01 +01:00
Christina Quast
541656cf60 Add CCID functions to func ptrs struct 2015-03-05 15:42:40 +01:00
Christina Quast
73e5658665 sniffer: removed debug write 2015-03-05 15:41:51 +01:00
Christina Quast
1bcac26786 removed atr buf in run func 2015-03-05 15:41:17 +01:00
Christina Quast
53a76082dc ccid: Get card atr in init 2015-03-04 19:01:34 +01:00
Christina Quast
8043fdd4d3 bus configuration in phone 2015-03-04 18:45:30 +01:00
Christina Quast
db7b1abd17 CCID config, init, run
Switching to config 1 and 2 works, but to 3 and 4 usb_enum.py is
hanging for some reason. Switching the USB config from Sniffer to
CCID reader was not tested yet.
2015-03-03 12:34:54 +01:00
Christina Quast
4ba4d2230b sniffer functionality fixed buffer
It is possible to use sniffer.py to sniff the phone-simcard-communication.

To be fixed: The buffer size read is fixed and the data is only send
over USB if the buffer max length is reached. which means we don not
get the last bytes of the transaction.
This should be changed in one of the next commits. Maybe the former
simtrace code can give some inspiration on this topic.
2015-03-02 16:14:09 +01:00
Christina Quast
cafde00218 conf initially sniff conf 2015-03-02 16:12:16 +01:00
Christina Quast
da373fde1b Add input interrupt endpoint to all configurations 2015-02-27 15:26:26 +01:00
Christina Quast
6032e796b9 string descr 0 is language identifier 2015-02-27 15:22:25 +01:00