Mifare DesFire Authentication

Forum / MIFARE and NFC Reader IC`s / Mifare DesFire Authentication

  • 5. June 2016 at 12:09
    Hello
    I would like to ask about Mifare Desfire Ev1
    I have one problem with authentication 3-pass mutual.(with default MasterKey 16 bytes 0x00)
    In last step when compare RndA and RndA' is not equal.But I dont know why.
    Because step befor Card send Status = 0x00(is OK..Authenticate).
    I created application in C# and I use SL032 reader interfae.
    And this is my communication.(S-send from PC)(R-received from Card)
    S:0A 00 -> R:AF DE D4 E1 04 62 13 C5 B2
    S:DB 47 CC D2 10 DA 8A 43 33 2B 67 E4 DD 8D C7 95 R:00 7C B5 65 E3 8B 65 BA 74 (this is last frame from CARD first byte is Status)
    And I use same implementation TripleDes(.net framework implementation TripleDESCryptoServiceProvider with CipherMode.CBC,PaddingMode.Zeros)
    in first step when I decrypt(IV= 8bytes 0x00) RndB' from card it is OK.
    in second step when I encrypt(IV=EncRndB[8bytes received in first step]) RndA and RndB it is OK because response from card is status:0x00.
    Can you help me why in last step when I decrypt(IV = second half SendData in second Step[enc RndB'] = 33 2B 67 E4 DD 8D C7 95) data from card is something wrong because is not same like RndA(I generated in first step)?

    Thank you for answer.
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    7. June 2016 at 9:09
    Hi Henrich,

    In the second step you have to encrypt (RndA+RndB’). The apostrophe means that RndB is rotated by 8 bits. Do you forget the rotation? In the third step the encrypted RndA from the card is also rotated.

    Kind regards,
    The MIFARE Team
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    7. June 2016 at 20:55
    Hi

    No I dont forget rotation.

    And received data in third step are totaly different.


    Any item in array received and decrypth in third step is not same with my RndA.

    Thx
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    8. June 2016 at 10:34
    Hi Henrich,

    Okay, let us check the steps. In step 2 you encrypt
    e(RndA+RndB’) with IV=e(RndB).
    The card decrypt d(e(RndA+RndB‘))=RndA+RndB‘ and checks RndB. Then the card encrypt
    e(RndA’) with IV=e(RndA+RndB)
    and on the reader side you have to
    d(e(RndA’))=RndA’
    and check RndA which you have sent.

    Please take attention to the IV vectors and the rotations and the reverse rotation. If the card rotate left, you have to rotate right to get the result.

    Kind regards,
    The MIFARE Team

    + 0  |  - 0

    Re: Mifare DesFire Authentication

    8. June 2016 at 18:14
    Hi

    I have litle bit problem with your description
    On card side:
    IV=e(RndA+RndB) I dont have this value. I have only e(RndA+RndB').If I have to use IV=e(RndA+RndB) what is vector for encrypt?
    And this vector is array with length 16?


    I thing my problem is in last step and IV on reader side.Maybe I use wrong vector.

    I send you image with my implementation and which IV I used for each steps.



    Thx.
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    9. June 2016 at 10:24
    Hi Henrich,

    Thanks for your remark. We have to decide the cipher.

    For DES/2K3DES we have:
    RndA is an 8 byte random number. The sent value is concatenated with RndB’ and decrypted with IV=00…00.

    For AES we have:
    RndA is an 16 byte random number. The sent value is also concatenated with RndB’ and decrypted but with IV=last block of e(RndB).

    On the card side for DES/2K3DES:
    The rotated RndA is encrypted with IV=00…00 and sent to the reader.

    For AES:
    The rotated RndA is encrypted with IV= last block of e(RndA+RndB’).

    So my example was for AES cipher and I missed the apostrophe. Thank you.

    By the way: the datasheet provides calculated number samples. See chapter 4.1 of the datasheet (MIFARE DESFire EV1, Functionality of implementations on smart card controllers).

    The MIFARE Team
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    9. June 2016 at 10:38
    Hello

    I use 3DES and everything is like datasheet but not datasheet what you wrote.

    Can you send me MIFARE DESFire EV1 complet datasheet pls?


    I thing you missed apostrophe but I have still problem with last step.


    Thx
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    9. June 2016 at 11:38
    Hi Henrich,

    What is the failure of your last step? Authentication failed or you get a different value for RndA?
    Kind regards,

    The MIFARE Team

    + 0  |  - 0

    Re: Mifare DesFire Authentication

    9. June 2016 at 11:51
    It's different value for RndA.

    And you wrote on card side RndA is encrypted with IV=00…00


    It means on card side is everytime use IV=00...00 for 3DES?


    PLease send me correct pdf for MIFARE DESFire EV1.


    Thank you
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    10. June 2016 at 9:25
    Hi Henrich,

    The functional datasheet is available under NDA. Please write to me at the following address:

    mifaresdk@nxp.com

    I will forward your request internally.

    Kind regards,
    The MIFARE Team

    + 0  |  - 0

    Re: Mifare DesFire Authentication

    10. June 2016 at 9:34
    Thank you

    Ok I'll wirte mail.

    I hope to help me this datasheet. :)
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    13. June 2016 at 18:38
    HEllo


    I would like ask you how long I have to wait to datasheet?

    Is enought what I send on mifaresdk@nxp.com?


    Thank you
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    16. June 2016 at 10:36
    Hi All, how to use fully enciphered communication in Mifare Desfire using DES algorithm? I use single DES authentication. I create reader using ACR122U and i use Java programming in my PC. I have success for authentication but i want to Enciphered Communication. Thanks for help before..
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    20. June 2016 at 9:36
    Hi Yastahaa,

    The cipher for an application is defined at creation of the application. If a dedicated file is read or written encrypted, it is defined with the file setting parameter at creation of the file.

    For an encrypted communication you have to encrypt all blocks to be sent to the card and decrypt all blocks read from the card.

    Kind regards,
    The MIFARE Team
    + 0  |  - 0

    Re: Mifare DesFire Authentication

    20. June 2016 at 17:00
    Ok, thanks Kind.

    I have tried to establish encrypt data transmission between smart card and reader using session key. The session key i get from random A and random B. I have communication setting when create file with 0x03 (that means enciphered communication ?).

    this is on my step that i have tried.

    1. CRC16 Calculation over
    ->’cmd+fileNo+offset+length+data’
    2. Append CRC16 to the data only without command, fileNo, offset and length.
    -> ‘data+CRC16’
    3. Padd the ‘data+CRC16’ with 0x00 (NOT 0x80, 0x00…) to a multiple of 16 Bytes, if needed.
    -> ‘data+CRC32+Zeropadding’
    4. Encrypt ‘data+CRC16+Zeropadding’ with Single DES
    -> crypted( ‘data+CRC16+Zeropadding’ )
    5. Send to the PICC
    ->’cmd+fileNo+offset+length + crypted(data+CRC16+Zeropadding)’

    write command :
    ff 00 00 00 1c d4 40 01 3d 00 00 00 00 11 00 00 8a 2b c7 21 23 24 47 73 1c c6 06 db b5 18 cd 90 00

    when i Write data to PICC, i get response from PICC :
    D5 41 00 af 90 00

    when i read data to PICC, i get response from PICC :
    24 byte message length of data,

    And i decrypt that message and the result is zero value and only 2 byte data not zero. why ?

    But i still confuse how to securing transmission ? do you have tutorial for secure transmission? i'm very need help... thanks...
    + 0  |  - 0
Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.