crosmax
Posts: 16
Joined: Tue May 08, 2018 1:30 pm

Someone with experience in Mifare Desfire?

Fri May 18, 2018 7:05 am

Hi!
I'm doing a project where I use Desfire contactless cards and I'm using an open source library called libfreefare https://github.com/nfc-tools/libfreefare.
Could someone tell me if with this library I can perform the authentication by calculating the session key in an external device (SAM module)?
The default authentication function calculates the session key internally, but in my case it does not work.
Default authentication traces between PICC (card) and PCD (reader):

Code: Select all

*** mifare_desfire_select_application ***
===> 0000   90 5a 00 00 03 00 00 01 00 
<=== 0000   91 00
PICC replied OPERATION_OK
*** authenticate ***
===> 0000   90 0a 00 00 01 02 00
<=== 0000   6c 62 96 21 59 07 b6 4e 91 af

### I need stop here and do something ###

*** authenticate ***
===> 0000   90 af 00 00 10 a3 54 d9 35 6f e3 3e 0d 68 a5 31
===> 0010   bb 81 40 4b f6 00
<=== 0000   91 ae
PICC replied AUTHENTICATION_ERROR

User avatar
topguy
Posts: 4937
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Someone with experience in Mifare Desfire?

Fri May 18, 2018 12:18 pm

The library is probably verified to work with Desfire cards, so its not unlikely that you may be using it slightly wrong.

Which reader are you using ?
Have you created the 0x010000 AID yourself ?
Are you sure you are using the correct Key type ( 3DES / AES ) ?

Its unlikely that the library support a SAM module so its likely you have to modify the authentication method to use your SAM for encryption/decryption and not take a key as parameter.

crosmax
Posts: 16
Joined: Tue May 08, 2018 1:30 pm

Re: Someone with experience in Mifare Desfire?

Mon May 21, 2018 10:18 am

Hi,

I'm using a generic PN532 reader and the Desfire cards. I also use the same card in other software that I have done with native commands (iso 14444-3) and works perfectly.
In my case, the authentication key is obtained from an external device and I need the random number (PICC_RndB) that is returned in the first authentication phase by the PICC and the libfreefare's authentication function do not contemplate.

Thanks

Return to “General programming discussion”