如何在不 root 设备的情况下交换 APDU?

How to exchange APDUs without rooting the device?

我在sim卡上写了一个小程序,并成功安装到我的sim卡上。现在我想使用 android 应用程序将 send/receive APDU 发送到我的 SIM 卡小程序。

一些库(例如 Seek)需要 root 设备并完成任务,但我不想 root 设备。 是否有任何 android 库来连接我的小程序?我所发现的只是使用 NFC 或蓝牙向非接触式卡发送或接收 APDU 的应用程序,但我需要连接插入移动 sim 卡插槽的接触式 sims。

附录 1:

这些都是我的USIM上存在的小程序(GPSshell列表函数的输出):

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 是我的小程序,a00000015141434c00 是允许所有 ARA 小程序。

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

要访问您的小程序,必须在 SIM 上配置一个 ARA-M 小程序以允许您的应用程序连接到您的小程序(有一个 MIT 许可的实现可用 here and a special all-allowed implementation here)。

可以使用GlobalPlatformPro进行访问配置。

免责声明:自从我处理这个问题以来发生了很多变化,所以请验证我的想法。

祝你好运!