Forum / MIFARE SDK / DESFire Authentication with Advanced SDK
-
I'm using the Advanced SDK to read data from DESFire cards. These have a specific non-zero AID, Keys and standard file contents. So, I select the AID, use a key to authenticate and then readData from the files.
I'm finding the javadocs a bit confusing though.
For the authenticate() function, I have to pass the "(int) keyNo", "(byte) keyVersion" and "(int)cardKeyNo".
But I would have thought I would pass bytes from a Software KeyStore that has been set up using .setKey().
The samples all use Key 0 and default all-zero keys. Is there an example that uses real keys please?
Robert
+ 0 | - 0
Let me answer my own question!!
To use the SDK to read data from a DESFire EV1 Card:
Step 1: Create a soft Key Store into which you place your Card Key. Here, I have my byte array key in MY_CARD_KEY:
private IKeyStore ks = null;
ks = KeyStoreFactory.getInstance().getSoftwareKeyStore();
ks.formatKeyEntry(0, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_2K3DES);
ks.setKey(0, (byte) 0, IKeyConstants.KeyType.KEYSTORE_KEY_TYPE_2K3DES, MY_CARD_KEY);
libInstance.loadKeyStore(ks);
Step 2 : Connect to the Card and Select the Application AID using the mDESFire object from the @Override of onDESFireCardDetected()
mDESFire.connectL4();
mDESFire.selectApplication(MY_CARD_AID);
Step 3 : Authenticate using a reference to the soft Key Store Key we set up earlier and on the Card Key we are using. Here, I use Card Key 1:
mDESFire.authenticate(AuthType.Native, 0, (byte) 0, 1, (byte)IKeyConstants.DIV_OPTION_NODIVERSIFICATION, null);
Step 4 : Read Data (here I read 32 bytes from File 1)
mDESFire.setTimeout(2000);
mDESFire.readData(1, 0, 32, DESFire.CommunicationType.Enciphered, 32));
Step 5 : Tidy Up
mDESFire.closeL4();
+ 0 | - 0
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.