我已经使用过智能卡,我熟悉APDU命令(在ISO/IEC 7816和全球平台规范中定义).
现在我想知道是否有办法将APDU命令发送到插入手机的USIM/SIM卡?(安装了Android v4.4.4 kitkat的三星A3.)
我已经在谷歌搜索过,我发现了一些名为SIM Toolkit Application和Seek for Android的相关主题和工具.但我真的不明白这些是什么?这些项目是我必须在手机上安装的两个应用程序吗?或者这两个工具是否已经安装在USIM/SIM卡上并从手机接收命令?
主动命令,APDU命令和AT命令有什么区别?
我应该学习android来开发SIM卡应用程序还是我只需要Java Card规范和ETSI标准?
提前致谢.
我安装了必需的软件包,以便在Ubuntu-14-LTS中使用我的ACR122U非接触式智能卡读卡器.幸运的是它的工作正常:
ebrahim@ubuntu:~$ pcsc_scan
PC/SC device scanner
V 1.4.22 (c) 2001-2011, Ludovic Rousseau <ludovic.rousseau@free.fr>
Compiled with PC/SC lite version: 1.8.10
Using reader plug'n play mechanism
Scanning present readers...
0: ACS ACR122U 00 00
Mon Jun 29 05:16:00 2015
Reader 0: ACS ACR122U 00 00
Card state: Card removed,
Run Code Online (Sandbox Code Playgroud)
但是当我想用mfoc工具使用我的阅读器时,我收到以下错误并且我的阅读器禁用(其LED冻结和缺席或卡的存在不会产生任何蜂鸣声,通常当我移动时LED变为绿色和红色卡片内部或外部的卡片+产生哔哔声)
^C
ebrahim@ubuntu:~$ mfoc -O test.mfd
error libnfc.driver.acr122_usb Unable to write to USB (Connection timed out)
No NFC device found.
ebrahim@ubuntu:~$
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我已经使用EclipseJCDE插件和Java Card 2.2.2 Development Kit在Eclipse中为Java Card 2.2.2编写了程序。
现在,我想为智能卡(Java Card 3.0.1 Classic Edition)编写程序,但是我不知道该怎么做!
我现在可以用Eclipse编写程序还是需要新的插件?
据我所知,我必须为该新平台下载新的开发套件。所以我搜索了Oracle。在其中提到的一些地方:
Java Card 3平台由规范的3.0、3.0.1和3.0.4版本以及开发套件的3.0.1、3.0.2、3.0.3和3.0.4版本组成。
因此,我下载了Java Card 3.0.1规范和Java Card 3.0.3开发套件。但这并不是真正的开发套件!它只是一个.jar文件!
我应该怎么处理这个.jar文件?是否应将其与JC 2.2.2的库一起导入为项目中的库?
还是我必须将其复制到以前的开发套件的bin目录中?
我真的很困惑!我应该为Eclipse添加另一个插件吗?还是我必须更改mu IDE?
为什么JC 3.0.3开发套件与JC 2.2.2开发套件不同?
顺便说一句,我将其添加到项目的JAR文件库中,但是它包含一些奇怪的类,而这些类在JC 3.0.1 API规范中没有看到!而且它不包含任何框架或APDU或...类!
我应该怎么做才能为Java Card 3.0.1编写程序?以及如何将它们转换为.cap文件?(据我所知我不能再使用该转换器了,对吗?)
我编写了以下程序,在我的java卡中生成一个16字节的随机数.我使用apdu缓冲区作为种子:
public class RandomNumber extends Applet {
private RandomData rngRandom;
public static byte[] testArray1=new byte[16];
private RandomNumber() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new RandomNumber().register();
}
public void process(APDU arg0) throws ISOException {
byte[] buffer=arg0.getBuffer();
// CREATE RNG OBJECT
m_rngRandom = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
m_rngRandom.setSeed(buffer, (short)0,(short)buffer.length );
// GENERATE RANDOM BLOCK WITH 16 BYTES
m_rngRandom.generateData(testArray1, (short) 0, (short)16);
Util.arrayCopyNonAtomic(testArray1, (short)0, buffer, (short)0,(short) testArray1.length);
arg0.setOutgoingAndSend((short)0, (short)16);
}
}
Run Code Online (Sandbox Code Playgroud)
我转换它并将其上传到我的卡上,AID = 01020304050607080900.这对我来说可以.我重复发送SELECT APDU命令(所以我有一个固定的种子),我收到不同的数字作为随机输出: …
我有一个JCOP V2.4.2 R3 java卡,它的数据表中提到"卡支持T=1和T=0通信协议"
我还有一个ACR38智能卡读卡器,它支持T = 0和T = 1协议.(我成功地与一张卡进行了T = 0通信,并且成功地与该卡进行了T = 1通信.)
我编写了以下程序并将其上传到卡上以发送和接收扩展的APDU:
package extAPDU;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacardx.apdu.ExtendedLength;
public class ExAPDU extends Applet implements ExtendedLength {
private ExAPDU() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new ExAPDU().register();
}
public void process(APDU arg0) throws ISOException {
short number = arg0.setIncomingAndReceive();
arg0.setOutgoingAndSend((short)0, (short)(number+7));
}
}
Run Code Online (Sandbox Code Playgroud)
在CAD方面,我使用python脚本向卡发送不同的APDU.问题是:
1-为什么我无法启动与T = 0协议的通信(虽然提到该卡支持此协议):
python脚本:
from smartcard.scard import *
import …Run Code Online (Sandbox Code Playgroud) 我有一个包含的文本,\x我想用这个替换0x.我使用了以下Python命令,但都失败了:
>>> text= '\x1bs\x1b\x01Z\xa2\x8d\xa2^\xb9*d\x08\x10&B\xb1z\xd4\xa91\xa3D
\xaf\xa1\x9a\x94\x8c\xd3\xb2r\x80\xc3\xb7)\xd8\x1bi\x80\x81\x02\x04\x08\x10@
\x81}0\xa8J\x95\x02E\x08\x10 @\x81\x02\x04\x08\x10 @\x81\x02\x04\x08\x10@
\x9f+\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x1b\x02^\xd3Q\xcc\xd70\x0eB\x88A\x1chB\x1bL\x81\xadC\x00
\x84!\rr(\x07\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x03
\x00?\x1c\x1b0'
>>>
>>>
>>> text.replace('\x',' 0x')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \xXX escape
>>>
>>>
>>> text.replace(u'\x',' 0x')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \xXX escape
>>>
>>>
>>> text.replace(r'\x',' 0x')
'\x1bs\x1b\x01Z¢\x8d¢^¹*d\x08\x10&B±zÔ©1£D¯¡\x9a\x94\x8cÓ²r\x80÷)Ø\x1bi\x80
\x81\x02\x04\x08\x10 @\x81}0¨J\x95\x02E\x08\x10 @\x81\x02\x04\x08\x10 @\x81
\x02\x04\x08\x10@\x9f+\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x02^ÓQÌ×0\x0eB\x88A\x1chB\x1bL\x81\xadC
\x00\x84!\rr(\x07ÿ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x03
\x00?\x1c\x1b0'
>>>
>>>
>>> text.replace('\\x',' 0x')
'\x1bs\x1b\x01Z¢\x8d¢^¹*d\x08\x10&B±zÔ©1£D¯¡\x9a\x94\x8cÓ²r\x80÷)Ø\x1bi\x80 …Run Code Online (Sandbox Code Playgroud) 下面,您会看到一个java卡程序,它在收到APDU Command = 8000000000(其来源)时返回"Hello Word"
package helloWorldPackage;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;
public class HelloWorldApplet extends Applet
{
private static final byte[] helloWorld = {(byte)'H',(byte)'e',(byte)'l',(byte)'l',(byte)'o',(byte)' ',(byte)'W',(byte)'o',(byte)'r',(byte)'l',(byte)'d',};
private static final byte HW_CLA = (byte)0x80;
private static final byte HW_INS = (byte)0x00;
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new HelloWorldApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
}
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buffer = apdu.getBuffer(); …Run Code Online (Sandbox Code Playgroud)