Reply To: Authentication to Mifare DesFire EV1 tag fails at PICC level with Master key..

Forum MIFARE and NFC Reader IC`s Authentication to Mifare DesFire EV1 tag fails at PICC level with Master key.. Reply To: Authentication to Mifare DesFire EV1 tag fails at PICC level with Master key..

Re: Authentication to Mifare DesFire EV1 tag fails at PICC level with Master key..

17. May 2016 at 16:43
Why do you need to default key with 00 bytes?
I don't understand the "format" logic. Why not just "setting" the key?
My initializeLibrary method works:
        KeyStoreFactory.KeyStoreType kst = libInstance.getKeyStoreType();

try {

IKeyStore iks= libInstance.getKeyStore();

ks = KeyStoreFactory.getInstance().getSoftwareKeyStore();

ks.formatKeyEntry(0,IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_AES128);
ks.setKey(0, (byte) 0, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_AES128, DEFAULT_KEY_AES128);

ks.formatKeyEntry(1, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_AES128);
ks.setKey(1, (byte) 0,
IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_AES128, KEY_CASHLESSCODE_APP);


} catch (SmartCardException e) {
showMessage(e.getMessage(), 'l');
showMessage("SmartCardException in init Keystore ... check LogCat",
't');
e.printStackTrace();
}
libInstance.loadKeyStore(ks);

But not my desfireEV1CardLogic:
        int keyNo = 1;
byte version = 0;

int[] appids;

try {

DESFireEV1.CardDetails details = objDESFireEV1.getCardDetails();
TextView txtUid = (TextView) findViewById(R.id.txtUid);
txtUid.setText(Utilities.dumpBytesAscii(details.uid));

//appids = objDESFireEV1.getApplicationIDs();

objDESFireEV1.selectApplication(131072);
// OK

byte[] dataCustomerCode = new byte[13];

dataCustomerCode = objDESFireEV1.readData(1, 0, dataCustomerCode.length, DESFireEV1.CommunicationType.Plain);
// OK for the plain data in this app !

TextView txtCustomerCode = (TextView) findViewById(R.id.txtCustomerCode);
txtCustomerCode.setText(Utilities.dumpBytesAscii(dataCustomerCode));

byte[] dataCashlessCode = new byte[12];

objDESFireEV1.selectApplication(65536);
// select the other app: OK

objDESFireEV1.authenticate(DESFireEV1.AuthType.AES, keyNo, version, 0, (byte) 0, null);
//
// authenticate KO !
//

dataCashlessCode = objDESFireEV1.readData(1, 0, dataCashlessCode.length, DESFireEV1.CommunicationType.Enciphered);


} catch (IOException e) {
e.printStackTrace();
} catch (DESFireException e) {
e.printStackTrace();
} catch (GeneralSecurityException e) {
e.printStackTrace();
} catch (SmartCardException e) {
e.printStackTrace();
}

+ 0  |  - 0