从DESFire EVO1卡读取数据(AES加密)时,我收到InvalidResponseLengthException。我正在使用1.5版的taplinx库
我的代码如下:
private void cardLogic(final Intent intent){
CardType cardType = m_libInstance.getCardType(intent);
Log.v(logTag, cardType.getTagName());
IDESFireEV1 objDESFireEV1 = DESFireFactory.getInstance().getDESFire(m_libInstance.getCustomModules());
Key key = new SecretKeySpec(AUTHENTICATION_KEY, "AES");
KeyData kd = new KeyData();
kd.setKey(key);
try {
objDESFireEV1.getReader().connect();
objDESFireEV1.getReader().setTimeout(2000);
objDESFireEV1.selectApplication(APP_ID);
Log.v(logTag, objDESFireEV1.getAuthStatus());
objDESFireEV1.authenticate(1, IDESFireEV1.AuthType.AES,KeyType.AES128 , kd);
Log.v(logTag, objDESFireEV1.getAuthStatus());
byte[] data = objDESFireEV1.readData(1, 0, 3);
Log.v(logTag, data.toString());
} catch(Throwable t) {
Log.e(logTag, t.getMessage(), t);
}
}
LogCat
2018-11-22 10:19:13.874 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: on New intent
2018-11-22 10:19:13.977 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: DESFire EV1
2018-11-22 10:19:13.993 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: Not Authenticated
2018-11-22 10:19:14.035 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: AES
2018-11-22 10:19:14.045 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: Authentication Error
com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error
at com.nxp.nfclib.desfire.ʻ.ˋ(:4559)
at com.nxp.nfclib.desfire.ʻ.ˋ(:4600)
at com.nxp.nfclib.desfire.ʿ.ˊ(:182)
at com.nxp.nfclib.desfire.ʻ.getFileSettings(:2043)
at com.nxp.nfclib.desfire.ʻ.ˏ(:2494)
at com.nxp.nfclib.desfire.ʻ.readData(:2531)
at eu.mobitrace.mifaredesfiretest2.MainActivity.cardLogic(MainActivity.java:101)
我从卡制造商处获得的信息:
我尝试过的事情:
问题 这是怎么了?是某种身份验证问题,还是我使用lib错误?
答案 0 :(得分:0)
我解决了这个问题。
byte [] data = objDESFireEV1.readData(1、0、3);
更改为:
byte [] data = objDESFireEV1.readData(1、0、3,IDESFireEV1.CommunicationType.Plain,3);
可以吗?