Forum Replies Created
-
Re: Re: DESFire getUID with lite SDK
22. January 2015 at 15:10 in reply to: DESFire getUID with lite SDKAn alternative is to use the Android getId function before you connect to the card with the NXP MIFARE SDK. So, something like this:
@Override
protected void onNewIntent(final Intent intent) {
libInstance.filterIntent(intent, new Nxpnfclibcallback() {
@Override
public void onDESFireCardDetected(final DESFire objDESFire) {
mDESFire = objDESFire;
String action = intent.getAction();
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) {
try {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] uid = tag.getId();
... then use the byte array with the Card's UID in here...
I sometimes use the DESFire Card UID as a diversification input, so reading the Card's UID like this before I authenticate access to an application file on the DESFire card is useful.
Robert
+ 0 | - 0
Re: Re: DESFire Authentication with Advanced SDK
22. January 2015 at 15:00 in reply to: DESFire Authentication with Advanced SDKLet 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)