[英]How can I make SELECT command from concret AID on Smart Card with Android NFC
I try read data from smart card by NFC and Android. 我尝试通过NFC和Android从智能卡读取数据。
I have smart card with application. 我有带有应用程序的智能卡。 Application has AID(Application ID)
A0000006581010
应用程序具有AID(应用程序ID)
A0000006581010
I need make SELECT command and read result. 我需要执行SELECT命令并读取结果。
I write method: 我写方法:
private static final String SAMPLE_LOYALTY_CARD_AID = "F222222222";
private void performTransaction(Intent nfcIntent) {
Tag tagFromIntent = nfcIntent.getParcelableExtra(EXTRA_TAG);
NfcA mNfc = NfcA.get(tagFromIntent);
try {
mNfc.connect();
//I can read ID
byte[] id = mNfc.getTag().getId();
//I tried create SELECT command
byte[] selCommand = BuildSelectApdu(SAMPLE_LOYALTY_CARD_AID);
//I try send command to card
byte[] result = mNfc.transceive(selCommand);
//I get result == {106, -126}
} catch (IOException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
} finally {
if (mNfc != null) {
try {
mNfc.close();
} catch (IOException e) {
Log.v("tag", "error closing the tag");
}
}
}
}
How can I make SELECT command from concret AID on Smart Card? 如何从智能卡上的concrete AID发出SELECT命令?
SELECT is a standard APDU command, you can find a specification that defines it from Global Platform . SELECT是标准的APDU命令,您可以从Global Platform中找到定义它的规范。 Building it from an AID is quite mechanical:
从AID构建它是非常机械的:
00A40400 + AID lenght in hexadecimal + AID + 00
For example, for your AID of A0000006581010
the SELECT command is: 例如,对于您的AID
A0000006581010
,SELECT命令为:
00A4040007A000000658101000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.