5.10.4. MIFARE DESFire EV2 : Authentication

Warning

To run this example, you would need the nxpnfcrdlib component for which a Non-Disclosure Agreement(NDA) needs to be signed. Please contact your FAE for additional details.

5.10.4.1. Prerequisites

Note : Order of execution se05x_Ev2PrepareCard, se05x_Ev2PrepareSE, se05x_Ev2ChangeKey, se05x_Ev2DivChngKey, se05x_Ev2AuthTransaction.

5.10.4.2. About the Example

This project is an example demonstrating the Mifare Desfire EV2 authentication using Se05x. After authentication, it performs encrypted communication with the desfire EV2 card.

It uses the following APIs and data types:

5.10.4.3. Running the Demo

  1. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo

If everything is setup correctly the output would be as follows:

App   :INFO :PlugAndTrust_v03.03.01_20210923
sss   :INFO :atr (Len=35)
                01 A0 00 00     03 96 04 03     E8 00 FE 02     0B 03 E8 00
                01 00 00 00     00 64 13 88     0A 00 65 53     45 30 35 31
                00 00 00
sss   :WARN :Communication channel is Plain.
sss   :WARN :!!!Not recommended for production use.!!!
App   :INFO :Sleeping for 10 seconds for debugger stabilization
App   :INFO :UID after L3 Activation (Len=10)
                08 81 68 F5     00 00 00 00     00 00
App   :INFO :ATS after L4 Activation (Len=6)
                06 75 77 81     02 80
App   :INFO :Select the AFC Application Successful

App   :INFO :attempting to authenticate with cardkey = 2 and Se0Obj ID = 2103308290
App   :INFO :
 CARD =====> SE050   16-byte Ek(RndB)  =
 (Len=16)
                58 DE D1 A3     07 65 1B 5B     6E 97 8F D5     F0 24 79 F1
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=32)
                34 91 01 A3     4D 19 98 A2     D5 5C CB FE     5F 61 E4 2B
                CF 04 DF 37     69 62 95 9C     AC F0 56 84     B3 B7 1B 1C
App   :INFO :
  CARD ======> SE050  32-byte E(Kx, TI||RndA'||PDCap2||PCDcap2) =
 (Len=32)
                B2 63 BF C7     D3 B0 A0 74     CB F7 86 C8     35 FB 1F 06
                84 9D 10 AC     5C 02 4F EC     B2 47 D6 1B     6D 65 B4 D8
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=12)
                00 00 00 00     00 00 00 00     00 00 00 00
App   :INFO :Dumped Session Key is (Len=16)
                FB 0E 3C 2D     2A 10 EB 6E     65 44 D3 67     A9 ED 63 F1
App   :INFO :Dumped Session Mac is (Len=16)
                FC 75 23 E2     2D 38 4C 90     8A 45 1C 06     E0 5D 1F F9
App   :INFO :Dumped TI is (Len=4)
                2B 30 C6 B4
App   :INFO :pDataParams->wCmdCtr=0
App   :INFO : EV2 First Authenticate  Successful

App   :INFO :CARD UID will be used for diversification
App   :INFO :Select the AFC Application Successful

App   :INFO :attempting to authenticate with cardkey = 0 and Se0Obj ID = 2103308294
App   :INFO :
 CARD =====> SE050   16-byte Ek(RndB)  =
 (Len=16)
                85 C2 89 57     CD A4 8A 69     EC 30 03 51     4F EB 84 46
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=32)
                FB F0 16 B2     8A 1F B4 DA     E8 FA 2B F0     AA 41 62 D1
                6D CE 52 51     5B CD 37 D1     F8 C4 A1 8F     72 DE FF B9
App   :INFO :
  CARD ======> SE050  32-byte E(Kx, TI||RndA'||PDCap2||PCDcap2) =
 (Len=32)
                6A 0D BA E6     94 4A 92 4C     25 32 6D CF     C2 06 35 34
                91 19 B7 E0     6C 46 0C 80     5A 57 B1 5C     CF 1F 7C D7
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=12)
                00 00 00 00     00 00 00 00     00 00 00 00
App   :INFO : EV2 First Authenticate  Successful

App   :INFO :
 CARD =====> SE050   16-byte Ek(RndB)  =
 (Len=16)
                65 61 B4 35     9E 9F 3C BC     F1 79 CB 08     6F 4A 9B E8
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=32)
                26 F5 4C 8B     86 22 95 93     13 71 A5 B9     06 9C FB 12
                C7 B6 97 5F     0F 66 39 0F     03 01 D2 20     79 60 2B 29
App   :INFO :
  CARD ======> SE050  32-byte E(Kx, TI||RndA'||PDCap2||PCDcap2) =
 (Len=16)
                BD 33 43 58     DB 50 80 3A     6E 1B 82 85     5E 47 65 6A
App   :INFO : EV2 Following Authenticate  Successful

App   :INFO :Authenticated with cardkey = 0 and Se0Obj ID = 2103308294
App   :INFO :attempting to change cardkey = 0 from  Old Se050ObjID= 0 to new Se050ObjID= 2103308295
App   :INFO : Change Key for card key 0 is Successful to Se050ObjID= 2103308295

App   :INFO :Select the AFC Application Successful

App   :INFO :attempting to authenticate with cardkey = 0 and Se0Obj ID = 2103308295
App   :INFO :
 CARD =====> SE050   16-byte Ek(RndB)  =
 (Len=16)
                5D 18 97 25     86 13 08 CD     93 50 FC CF     F6 FB F4 07
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=32)
                00 07 CD D3     B4 C1 02 5C     B6 E7 5A F0     F7 1E D8 3C
                A4 1D 5D 83     E1 95 BC AF     8F 20 23 A9     E1 13 33 6B
App   :INFO :
  CARD ======> SE050  32-byte E(Kx, TI||RndA'||PDCap2||PCDcap2) =
 (Len=32)
                0B D8 81 8B     3F 53 E2 5A     23 7C 66 8F     46 08 F6 9F
                4C BF 06 2A     63 4C 45 28     A1 8F AA FB     FB F4 40 78
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=12)
                00 00 00 00     00 00 00 00     00 00 00 00
App   :INFO :Dumped Session Key is (Len=16)
                AF 86 09 B0     88 A9 52 78     6C 7E D0 F7     14 F5 1A 75
App   :INFO :Dumped Session Mac is (Len=16)
                0E 7B 03 B3     77 A5 B1 A8     6C 99 AD 71     C3 5B 5E 19
App   :INFO :Dumped TI is (Len=4)
                C8 33 3B F7
App   :INFO :pDataParams->wCmdCtr=0
App   :INFO : EV2 First Authenticate  Successful

App   :INFO :
 CARD =====> SE050   16-byte Ek(RndB)  =
 (Len=16)
                C9 58 CB 6B     6B 3B BD C5     0B 8E FD 88     AD 55 65 2C
App   :INFO :
  CARD <====== SE050  E(Kx, RandA || RandB') =
 (Len=32)
                58 91 1B 41     46 AD 8E A9     A2 51 B3 DF     C9 3C FC 89
                C6 E3 C3 02     AC F2 58 E2     7A 71 F5 12     84 7E E8 BC
App   :INFO :
  CARD ======> SE050  32-byte E(Kx, TI||RndA'||PDCap2||PCDcap2) =
 (Len=16)
                CF 90 99 00     DE 02 96 22     C0 B8 EF 29     0A 43 83 99
App   :INFO :Dumped Session Key is (Len=16)
                19 01 7F 30     3C 08 21 FB     C3 5A F1 DC     25 9F 68 EC
App   :INFO :Dumped Session Mac is (Len=16)
                46 FC 59 4B     0B 7E 15 C5     47 65 82 20     19 B6 42 3E
App   :INFO :Dumped TI is (Len=4)
                C8 33 3B F7
App   :INFO :pDataParams->wCmdCtr=0
App   :INFO : EV2 Following Authenticate  Successful

App   :INFO :Authenticated with cardkey = 0 and Se0Obj ID = 2103308295
App   :INFO :phEx_Use_ValueFile...

App   :INFO :Performing Accreditation in AFC App....

App   :INFO :(Plain Communicatioon)Trying to Get the Current Value. Plain Communicatioon

App   :INFO :Getting current value Successful

App   :INFO :(Enc Communication using session Key)Trying to Add money to the account

App   :INFO :Add money to the account successful

App   :INFO : The amount in your account  After credit is 0 0 0 17

App   :INFO :   Accreditation DONE!

App   :INFO : Auth session is reset in software
App   :INFO : Auth session is killed in SE
App   :INFO :ex_sss Finished