M4t*_*tho 1 android apdu smartcard emv nfc
我正在尝试通过我的LG P710 Optimus L7 2读取智能卡.
我正在学习本教程
我可以选择"1PAY.SYS.DDF01"目录,
我可以选择应用程序
但我无法执行"获取处理选项"它总是导致6700错误(Lc或Le错误)
这是我的代码
NfcAdapter mNFCAdapter;
Intent intent;
PendingIntent pendingIntent;
private TextView mTextView;
String[][] techList;
IntentFilter[] filters = new IntentFilter[3];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextView = (TextView) findViewById(R.id.title);
mNFCAdapter = NfcAdapter.getDefaultAdapter(this);
intent = new Intent(getApplicationContext(), getClass());
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
techList = new String[][]{
new String[]
{ MifareClassic.class.getName() },
new String[]
{ IsoDep.class.getName() }
};
filters[0] = new IntentFilter();
filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
filters[0].addCategory(Intent.CATEGORY_DEFAULT);
// add type of tag data you want to have - here ndef -> plain text
try {
filters[0].addDataType(MIME_TEXT_PLAIN);
} catch (MalformedMimeTypeException e) {
e.printStackTrace();
}
filters[1] = new IntentFilter();
filters[1].addAction(NfcAdapter.ACTION_TAG_DISCOVERED);
filters[1].addCategory(Intent.CATEGORY_DEFAULT);
filters[2] = new IntentFilter();
filters[2].addAction(NfcAdapter.ACTION_TECH_DISCOVERED);
filters[2].addCategory(Intent.CATEGORY_DEFAULT);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String action = intent.getAction();
mTextView.setText(action);
Toast.makeText(getApplicationContext(), action, Toast.LENGTH_SHORT).show();
Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
IsoDep tagIsoDep;
if((tagIsoDep = IsoDep.get(tagFromIntent)) != null)
if(handleIsoDep(tagIsoDep))
return;
}
private boolean handleIsoDep(IsoDep tag){
try{
tag.connect();
tag.setTimeout(20);
byte[] responseAPDU;
//2PAY.SYS.DDF01
byte[] select_Dir = new byte[]{
(byte)0x00, (byte)0xa4, (byte)0x04, (byte)0x00, (byte)0x0e,
(byte)0x32, (byte)0x50, (byte)0x41, (byte)0x59, (byte)0x2e,
(byte)0x53, (byte)0x59, (byte)0x53, (byte)0x2e, (byte)0x44,
(byte)0x44, (byte)0x46, (byte)0x30, (byte)0x31
};
//Select CC Applet
byte[] select_Applet = new byte[]{
(byte)0x00, (byte)0xa4, (byte)0x04, (byte)0x00, (byte)7,
(byte)0xa0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04,
(byte)0x30, (byte)0x60
};
//Send GET PROCESSING OPTIONS command
byte[] Send_Get = new byte[]{
(byte)0x80,(byte)0xA8,(byte)0x00,(byte)0x00,(byte)0x02,
(byte)0x83,(byte)0x00,
(byte)0x00
};
responseAPDU = tag.transceive(select_Dir);
mTextView.setText(mTextView.getText() + handleResponse(responseAPDU));
Run Code Online (Sandbox Code Playgroud)
这将返回APDU-Statusword 9000 - > success
responseAPDU = tag.transceive(select_Applet);
mTextView.setText(mTextView.getText() + handleResponse(responseAPDU));
Run Code Online (Sandbox Code Playgroud)
这将返回APDU-Statusword 9000 - > success
responseAPDU = tag.transceive(Send_Get);
mTextView.setText(mTextView.getText() + handleResponse(responseAPDU));
Run Code Online (Sandbox Code Playgroud)
这个问题就出现了:它返回6700 - >错误的Lc或Le
mTextView.setText(mTextView.getText() + "\n\nDone");
tag.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
函数handleResponse只是将"responseAPDU"从Binary解析为Hex,并突出显示Statusword
任何人都可以告诉我出了什么问题吗?或者只是帮助我?
PS sry英语不好;)
作为对我的应用程序的响应 - 选择我得到:
6f298407a0000000043060a51e50074d41455354524f5f2d046465656e9f38039f5c08bf0c059f4d020b0a9000
6F -> FCI Template 29
84 -> DF Name 07 A0 00 00 00 04 30 60
A5 -> FCI Properietary Template 1E
50 -> Application Lable 07 4D 41 45 53 54 52 4F 5F 2D 04 64 65 6E
9F38 -> PDOL 03 9F 5C 08
BF0C -> FCI Issuer Data 05
9F4D -> Log Entry 02 0B
0A Additional Issuer Data
Run Code Online (Sandbox Code Playgroud)
但我不知道从GET处理选项插入到数据库中的是什么.
以下是EMV第3册"5.4使用数据对象列表规则(DOL)"一节中的指南.
那么我只需要设置数据字段83 03 9F 5C 08
和Lc = 5吗?
为了帮助您,需要整个ADPU对话框(命令/响应).
但是,根据您的代码:硬编码您的select_Dir和select_Applet命令是正确的,但您无法对GET PROCESSING OPTIONS命令进行硬编码,该命令的语法取决于卡(ICC)对select_Applet命令的响应.
EMV 4.3 1册,"表45:SELECT响应消息数据字段的ADF的(FCI)",解释了一个成功的卡响应于SELECT命令包含一个"处理选项数据对象列表"(PDOL,标签9F38).这是卡片处理交易所需的字段列表(例如:金额,......).这些字段值将由终端(您的电话)通过GET PROCESSING OPTIONS命令数据字段(标记83)返回到卡,如EMV 4.3第3册"6.5.8.3命令消息中发送的数据字段"部分所述":
命令消息的数据字段是根据ICC提供的PDOL编码的数据对象,如5.4节所定义,并由标签'83'引入.当ICC未提供数据对象列表时,终端将模板的长度字段设置为零.否则,模板的长度字段是发送到ICC的数据对象的值字段的总长度.
知道 :
您已将卡请求的PDOL识别为:9F38 - > 03 9F 5C 08. 03告诉您PDOL长度为3个字节.9F5C是请求字段的标记,08是电话要返回的字段值的长度.
标签9F5C在EMV Contactless 2.3 Book C2内核2规范,"A.1.59 DS请求的运营商ID"部分中定义.DS请求的运营商ID定义为
包含终端确定的数据存储操作员标识符.它在GET PROCESSING OPTIONS命令中发送到卡.
我不熟悉这个标签,所以我不能告诉你什么是合适的价值.但是,这里是GET PROCESSING OPTIONS命令的数据字段应该是什么样的,假设DS请求的操作员ID具有值01 02 03 04 05 06 07 08,并且在EMV Book 3中给出了数据对象列表格式化指南," 5.4使用数据对象列表(DOL)的规则":
83 08 01 02 03 04 05 06 07 08
并且Lc = 10
| 归档时间: |
|
| 查看次数: |
3769 次 |
| 最近记录: |