MJay
MJay

Reputation: 1058

How to exchange APDUs without rooting the device?

I have written an applet on a sim card and successfully installed it on my sim. Now I want to send/receive APDUs to my sim card applet using an android application.

Some libraries (e.g. Seek) need rooted devices and do the task but I don't want to root devices. Is there any android libraries to interface my applet? All I have found is applications to use NFC or Bluetooth to send or receive APDUs to contactless cards, but I need to interface contact sims inserted to mobile sim card slot.

Appendix 1:

These are all applets existing on my USIM (output of GPShell list function):

mode_211
enable_trace
establish_context
card_connect -readerNumber 1
select -AID A000000151000000
Command --> 00A4040008A000000151000000
Wrapped command --> 00A4040008A000000151000000
Response <-- 6F108408A000000151000000A5049F6501FF9000
open_sc -scp 2 -scpimpl 0x55 -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f
Command --> 805000000853160BA36116264B00
Wrapped command --> 805000000853160BA36116264B00
Response <-- 000081210103B99E856DFF020032D2AE118D648EC6F57DFA6581CCC39000
Command --> 8482010010395D6343C2D216F30460633603DD27A2
Wrapped command --> 8482010010395D6343C2D216F30460633603DD27A2
Response <-- 9000
get_status -element 20
Command --> 80F22000024F0000
Wrapped command --> 84F220000A4F0075545E9C0668BCDA00
Response <-- 07A0000001515350010005A000000087010006A00000025108010010A0000000090005FFFFFFFF8915000000010008A000000151100303010010A0000000185000000000000052418050010007E0E1E2E3E4E501010008A00000015141434C01009000

List of elements (AID state privileges)
a0000001515350  1       0
a000000087      1       0
a00000025108    1       0
a0000000090005ffffffff8915000000        1       0
a000000151100303        1       0
a0000000185000000000000052418050        1       0
e0e1e2e3e4e501  1       0
a00000015141434c        1       0
get_status -element 40
Command --> 80F24000024F0000
Wrapped command --> 84F240000A4F0023B1458CFDA5C36100
Response <-- 10A0000000871002FF82FF3089010000FF070410A0000000871004FF47F00189000001FF070010A000000087ABCDFF47F00189000001FF070007A0000002510801070009A00000015110030301870010A0000000185000000000000052418041070009A0000000035350410107C009A0000000035350410207C009A0000000035350410307C009A0000000035350410407C009A0000000035350410507C009A00000000353504106078008E0E1E2E3E4E50102070209A00000015141434C0007029000

List of elements (AID state privileges)
a0000000871002ff82ff3089010000ff        7       4
a0000000871004ff47f00189000001ff        7       0
a000000087abcdff47f00189000001ff        7       0
a0000002510801  7       0
a00000015110030301      87      0
a0000000185000000000000052418041        7       0
a00000000353504101      7       c0
a00000000353504102      7       c0
a00000000353504103      7       c0
a00000000353504104      7       c0
a00000000353504105      7       c0
a00000000353504106      7       80
e0e1e2e3e4e50102        7       2
a00000015141434c00      7       2
card_disconnect
release_context

e0e1e2e3e4e50102 is my applet and a00000015141434c00 is allow all ARA applet.

Upvotes: 2

Views: 1208

Answers (1)

vlp
vlp

Reputation: 8106

Since Android 9 there is android.se.omapi package providing such access (implementing SIMalliance Open Mobile API). For older devices supporting OMAPI, see e.g. here, here, here.

To get access to your applet there has to be an ARA-M applet on SIM configured to allow your application to connect to your applet (there is a MIT licensed implementation available here and a special all-allowed implementation here).

Access configuration can be performed with GlobalPlatformPro.

Disclaimer: A lot has changed since I was dealing with this so please do validate my thoughts.

Good luck!

Upvotes: 2

Related Questions