发送APDU命令到USIM

发送APDU命令到USIM

本文介绍了发送APDU命令到USIM / SIM卡的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作与智能卡和我所熟悉的APDU命令(即在 ISO / IEC 7816 全球平台的规范中定义)。

I was already worked with smart cards and I am familiar with APDU commands (that are defined in ISO/IEC 7816 and Global Platform specifications).

现在我想知道是否有什么办法发送APDU命令被插入到我的手机我的USIM / SIM卡? (三星A3与Android v4.4.4奇巧安装。)

Now I want to know if is there any way to send an APDU command to my USIM/SIM card that is inserted to my mobile phone? (Samsung A3 with Android v4.4.4 kitkat installed.)

我已经搜索在谷歌,我发现了一些相关的主题和命名的 SIM工具包应用的工具和寻求Android版的。但我真的不明白这是什么意思?难道这些项目,我必须安装在我的手机两个应用程序?或者是被安装在已经在USIM / SIM卡和从移动电话接收命令?这两个工具

I already searched in the Google and I found some related topics and tools named SIM Toolkit Application and Seek for Android. But I don't really understand what are these? Are these items two applications that I must install on my mobile phone? or are those two tools that was installed on the USIM/SIM card already and receive commands from the mobile phone?

主动命令 APDU命令 AT指令的?

我应该学习Android的开发SIM卡的应用程序或我只需要Java卡规范和ETSI标准?

Should I learn android to develop SIM card applications or I just need Java Card specifications and ETSI standards?

在此先感谢。

推荐答案

有可能是您的SIM卡两种不同类型的小程序present。

There can be two different types of applets present on your SIM card.

常用小程序

常用小程序写在普通的Java卡。这是您从共同智能卡世界用于小应用程序的类型。它具有过程方法和智能卡是在通信被动:你的应用程序发送APDU命令和卡响应

Common applets written in plain JavaCard. This is the type of applet you are used to from the world of common smart cards. It has the process method and smart card is the passive subject in the communication: your app sends APDU commands and the card responses.

您可以使用一组特殊的Andr​​oid库的呼吁寻求Android的这些小程序进行通信。有一个在本教程学习如何创建这样的手机应用程序:的

You can communicate with these applets using a special set of Android libraries called SEEK for Android. Have a look at this tutorial to learn how to create such a phone application: https://code.google.com/p/seek-for-android/wiki/UsingSmartCardAPI

开始在API级别21也有一个沟通方式使用电话管理器到SIM卡:http://developer.android.com/reference/android/telephony/TelephonyManager.html#iccTransmitApduBasicChannel%28int,%20int,%20int,%20int,%20int,%20java.lang.String%29 (根据意见之一,未测试)。

Starting on API level 21 there is also a way to communicate to SIM using Telephony Manager: http://developer.android.com/reference/android/telephony/TelephonyManager.html#iccTransmitApduBasicChannel%28int,%20int,%20int,%20int,%20int,%20java.lang.String%29 (based on one of comments, not tested).

SIM工具包的小程序

SIM卡是不是只是一个普通的智能卡,如果你想用一切准备的SIM卡提供写一个小程序的SIM卡可以更比一个普通的智能卡更复杂得多。我建议您阅读本文( HTTP://miun.diva -portal.org/smash/get/diva2:423013/FULLTEXT02.pdf ) - 这是谁家的学士论文,但它是一个初学者,我发现在互联网上最好的概述。我还建议从DefConn发布会视频: https://www.youtube.com/watch?v = 31D94QOo2gY

A SIM card is much more than just a common smart card and writing an applet for a SIM card can be much more complicated than for a common smart card if you want to use all the possibilities the SIM card offers. I recommend you to read this paper (http://miun.diva-portal.org/smash/get/diva2:423013/FULLTEXT02.pdf) - it is someone's bachelor thesis, but it is the best overview for a beginner I have found all over the Internet. I also recommend this video from the DefConn conference: https://www.youtube.com/watch?v=31D94QOo2gY.

在SIM卡中加载的小程序的作用是不同的:该小程序不再是被动的实体。手机经常会询问你的applet:有什么新的我能为你做什么?和你的小程序可以这样回答:是的,发送此短信,请或告诉我它是什么时候等。此外,你的小程序可以成为一些事件的监听器:来电,收到的短信,时间间隔已过等有,SIM卡似乎从技术上看是被动的,但它的作用实际上是一个活跃的地区之一。这是谁的命令发送到手机SIM卡

The role of the applet loaded on the SIM card is different: the applet is no longer a passive entity. The phone asks your applet regularly: "Is there anything new I can do for you?" and your applet can reply: "Yes, send this SMS, please" or "Tell me what time it is" etc. Moreover, your applet can become a listener of some events: incoming call, received SMS, time interval elapsed etc. Yes, the SIM card seems to be passive from the technical point of view, but its role is in fact an active one: it is the SIM card who sends commands to the phone.

这些命令被称为积极的命令或SIM卡应用工具包命令。结构是相同的 - CLA INS P1 P2 LC数据文件;的含义是不同的。

These commands are called "proactive commands" or SIM Application Toolkit commands. Structure is the same - CLA INS P1 P2 LC data LE; the meaning is different.

您可以将它们从你的小程序使用类称为特殊的JavaCard的包裹寄到 sim.toolkit

You can send them from your applet using classes in a special JavaCard package called sim.toolkit.

(SIM应用工具包是一个标准,规定以同样的方式全球平台指定applet的生命周期中主动命令。)

(SIM Application Toolkit is a standard that specifies the proactive commands in the same way Global Platform specifies the applet's lifecycle.)

的SIM工具包的小程序示例:

Example of SIM Toolkit applet:

import sim.toolkit.ToolkitInterface;
import sim.toolkit.ToolkitRegistry;
...
import javacard.framework.ISOException;

public class STKTest extends Applet implements ToolkitInterface {

public static void install(byte[] bArray, short bOffset, byte bLength) {
    // GP-compliant JavaCard applet registration
    new STKTest().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
//this method handles standard APDU commands
public void process(APDU apdu) {
    // Good practice: Return 9000 on SELECT
    if (selectingApplet()) {
        return;
    }

    apdu.setIncomingAndReceive();
    final byte[] buf = apdu.getBuffer();
    switch (buf[ISO7816.OFFSET_INS]) {
    case (byte) 0x00:
        //do something
        break;
    }
}
//this method handles the SIM Toolkit commands
public void processToolkit(byte event) throws ToolkitException {
    switch (event) {

    case ToolkitConstants.EVENT_TIMER_EXPIRATION:
        //do something
        break;
    }
}

}

是的,你应该学会机器人 - 你会需要它来使用Seek库。你提的问题是非常广泛的,请向我任何细节,如果你想要的。

Yes, you should learn Android - you will need it to use the SEEK library. Your question is very broad, please ask me for any details, if you want.

这篇关于发送APDU命令到USIM / SIM卡的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 01:56