alan-turing-institute / uicc_identity_toolbox

A framework of Java Card applets for enhancing the trustworthiness of DigitalID systems using low-cost basic and feature phone devices.
MIT License
8 stars 1 forks source link

Get Icons to display as big as possible (on stock devices) #2

Open hkscy opened 3 years ago

hkscy commented 3 years ago

Get Icons to display as BIG as possible. Current demo only shows a 27x27 icon.

hkscy commented 3 years ago

This is where we are today:

photo1629720537_smaller

We want to get as close to this as we can:

fullscreen

hkscy commented 3 years ago

One way to approach this is to look at the Android and Firefox OS source code to see what the limits are and how icons are processed for drawing to the screen. See e.g., https://android.googlesource.com/platform/packages/apps/Stk/+/eclair-release/src/com/android/stk/StkCmdReceiver.java and possibly dom/system/gonk/ril_worker.js on Firefox/Kai OS

hkscy commented 3 years ago

@lukehare @thobson88 This is clearly somewhat overlapping and linked with the other issue of modifying Android or Kai to accomplish the same. For clarity, this issue is about 'doing whatever is necessary' to get it working on an 'unmodified' handset and about testing the limits of off the shelf devices. Please feel free and very much encouraged to get involved with either of these issues (as well as anything else that piques your interest!)

hkscy commented 3 years ago

photo1631104326

Current progress is as follows. If the 'file size' is set to a value greater than 0x6f (111) then the icon will not be displayed. The icon width and height are still taken into consideration and the black area is where the pixels have not been loaded.

Diving into the PDU(s) send between the SIM and the ME, you can see (example here where we say the file is 8f long but you can see in the final PDU that the length is limited to 6f).

TPDU: 80 c2 00 00 09 d3 07 82 02 01 81 90 01 82 91 1e TPDU: 80 12 00 00 1e d0 1c 81 03 01 21 81 82 02 81 02 8d 05 04 49 44 20 20 1e 02 00 04 1e 02 00 04 1e 02 00 03 90 00 TPDU: 00 a4 08 04 06 7f 10 5f 50 4f 20 61 1b — SELECT FILE (this selects EF.IMG i.e., 4f20) TPDU: 00 c0 00 00 1b 62 19 82 05 42 21 00 0a 04 83 02 4f 20 8a 01 05 8b 03 2f 06 02 80 02 00 28 88 00 90 00 — GET RESPONSE TPDU: 00 b2 04 04 0a 01 36 36 11 4f 07 00 00 00 8f 90 00 — READ RECORD(S) (this reads the record 4 from 4f20) TPDU: 00 a4 08 04 06 7f 10 5f 50 4f 07 61 18 — SELECT FILE (selects icon file) TPDU: 00 c0 00 00 18 62 16 82 02 41 21 83 02 4f 07 8a 01 05 8b 03 2f 06 02 80 02 01 6f 88 00 90 00 — GET RESPONSE TPDU: 00 b0 00 00 6f 36 36 ff ff ff ff ff ff ff ff ff ff ff ff ff fc 00 0c ff 00 c0 00 f0 00 33 fc 03 00 03 cf fc cf 03 fc ff cf 3f f3 3c 0f f3 ff 3c c0 cc 3c f3 cc 0c f3 03 30 f3 cf 30 33 cc 0c c0 c3 cc c0 cf 30 33 03 0f 33 03 3c c0 cf 0c 00 cc 0c f3 03 3c 30 03 30 33 cf fc c0 ff fc ff cf 3f f3 03 ff f3 ff 3c 00 0c cc cc c0 00 f0 00 33 33 33 00 03 ff 90 00 `

It is at present entirely unclear why this is happening. The STK generates all of this automatically just from the display icon TLV (i.e., 1e 02 00 03 ) so it cannot (easily..) be manually overwritten.

Some things to try in the short-term:

hkscy commented 3 years ago

boot_to_show_icon.pcapng.zip

This PCAP captures the packets sent between the SIM and ME as the phone boots, opens the STK menu and opens an icon. You can see the binary files etc being loaded from the card using ISO commands

hkscy commented 3 years ago

The issue at present seems to be that the READ BINARY command sent (to the SIM from the ME/Kai OS?) has a randomly hard-coded 6f length parameter (i.e., 00 b0 00 00 6f is used to retrieve the image icon file). Why? Can we change it? --

Update: Android does not do this e.g. it uses 00 b0 00 00 00 which loads all of the file. i.e.,

TPDU: 00 b0 00 00 00 36 36 ff ff ff ff ff ff ff ff ff ff ff ff ff fc 00 0c ff 00 c0 00 f0 00 33 fc 03 00 03 cf fc cf 03 fc ff cf 3f f3 3c 0f f3 ff 3c c0 cc 3c f3 cc 0c f3 03 30 f3 cf 30 33 cc 0c c0 c3 cc c0 cf 30 33 03 0f 33 03 3c c0 cf 0c 00 cc 0c f3 03 3c 30 03 30 33 cf fc c0 ff fc ff cf 3f f3 03 ff f3 ff 3c 00 0c cc cc c0 00 f0 00 33 33 33 00 03 ff ff fc 3c cf ff ff ff ff f0 f3 3f ff fc 3c 0f cc fc f3 00 f0 f0 3f 33 f3 cc 03 fc 33 3f ff 0f c0 ff f0 cc ff fc 3f 03 c3 30 3f 0f ff c3 03 f0 03 cf f3 ff 0c 0f c0 0f 3f cf ff 03 00 33 f3 c0 cf fc 0c 00 cf cf 03 3c 03 0f 0c 3c 00 0f f0 0c 3c 30 f0 00 3f ff ff cc f0 0f cc 3f ff ff 33 c0 3f 30 fc 00 0f 0f f0 cc 3f f0 00 3c 3f c3 30 ff cf fc c0 cc cf c0 3f 3f f3 03 33 3f 00 fc c0 cc 03 0c 00 c0 f3 03 30 0c 30 03 03 cc 0c f3 cf f0 0f 0f 90 00 TPDU: 00 b0 01 00 6f 30 33 cf 3f c0 3c 3c c0 cf 00 00 03 03 f3 03 3c 00 00 0c 0f cf fc c3 33 3c 00 3f 3f f3 0c cc f0 00 fc 00 0c 3c 3f 3c c0 f0 00 30 f0 fc f3 03 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 90 00

It doesn't display it properly however. This leaves two options:

  1. Modify Android STK to display the icon as an image rather than using window.icon_left
  2. Modify KaiOS to remove the arbitrary icon size limit (see https://sites.google.com/view/bananahackers/devices/jio-phone for potential tt240 source code / custom firmware)