NTAG 424 DNA authentication issues with custom PN7462AU reader design

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NTAG 424 DNA authentication issues with custom PN7462AU reader design

141 Views
Jeffw5555
Contributor II

We are planning to use the PN7462AU and NTAG 424 DNA for a simple embedded anti-counterfeiting application, where we will use Key0 master key to provide validation the tag is OK.  The board is up and operating, works great up to the phpalI14443p3a_ActivateCard tag activation step just prior to invoking the  phalMfNtag42XDna_AuthenticateEv2 function.  I have been trying for days to get authentication working, have tried both blank tags and tags programmed with a master Key0, but keep getting 0x2626 ERROR no matter what I have tried.

I have included logging for each step in my software stack to aid in debugging, here is the print from console showing all the layers I have set up prior to authentication:

Initialize Hardware Abstraction Layer (HAL)with phhalHw_PN7462AU_Init

HAL Initialized!

HAL ID: 0x020A

 

Initializing PAL, KeyStore, and Crypto

 

Initializing phpalI14443p3a_Sw_Init

phpalI14443p3a Initialized!

 

Initializing phpalI14443p4a_Sw_Init

phpalI14443p4a Initialized!

 

Initializing phpalI14443p4_Sw_Init

phpalI14443p4 Initialized!

 

Initializing phpalMifare_Sw_Init

Mifare Initialized!

 

Initializing phCryptoSym_Sw_Init (cryptoSymEnc)

phCryptoSym_Sw_Init cryptoSymEnc Success!

 

Initializing phCryptoSym_Sw_Init (cryptoSymMac)

phCryptoSym_Sw_Init cryptoSymMac Success!

 

Initializing phCryptoRng_Sw_Init

phCryptoRng_Sw_Init Success!

 

Initializing phKeyStore_Sw_Init

Keystore Initialized!

 

Initializing phKeyStore_SetConfig

phKeyStore_SetConfig NOT Initialized!

 

Initializing phKeyStore_Sw_FormatKeyEntry

Format Key Entry Succeeded!

 

Initializing phKeyStore_Sw_GetKeyEntry

Get Key Entry Succeeded!

Formatted key type = 0x000E

 

Invoking phKeyStore_Sw_SetKeyAtPos

Attempting SetKeyPosition using Key:

AB CD EF 09 AB CD EF 09 AB CD EF 09 AB CD EF 09

Setting AES-128 key at entry 0x00, position 0x00:

AB CD EF 09 AB CD EF 09 AB CD EF 09 AB CD EF 09

Set Key at Position Succeeded

 

Invoking phKeyStore_GetKeyEntry

phKeyStore_GetKeyEntry Success!

KeyEntry 0x00: 1 key(s), type = 0x000E, first version = 0x00

 

Verifying KeyStore Key at Position 0...

Invoking phKeyStore_GetKey

Key retrieved successfully

 

Initializing phalMfNtag42XDna_Sw_Init

Ntag42XDna_Sw_Init Succeeded!

 

dna.wId = 0x2601

cryptoSymEnc.wId = 0xE101

cryptoSymMac.wId = 0xE101

cryptoRng.wId = 0xE401

 

 

***System Initialized***

 

 

********Processing Tag************

 

 

Invoking phhalHw_ApplyProtocolSettings

ApplyProtocolSettings Succeeded!

 

Activating Tag via phpalI14443p3a_ActivateCard

Tag Activation Success!

UID before auth: 04 2C 19 12 C4 1B 90

 

Authenticating Tag via phalMfNtag42XDna_AuthenticateEv2

Tag Not Authenticated!

Authentication status: 0x2626

 

Can you please provide guidance to what I may be missing?

0 Kudos
Reply
3 Replies

116 Views
Jeffw5555
Contributor II

So I believe I had some errors in code causing Mifare to not be properly initialized, fixed those, and now I have what looks like everything OK until the EV2 Authenticate, which now gives a 0x2682 error.

 

Here is the debug log:

 

Initialize Hardware Abstraction Layer (HAL)with phhalHw_PN7462AU_Init

HAL Initialized!

HAL ID: 0x020A

 

 

 

HAL pTxBuffer: 0x001000A0

HAL pRxBuffer: 0x001001A8

Initializing KeyStore

 

 

Initializing phKeyStore_Sw_Init

Keystore Initialized!

 

Initializing phKeyStore_Sw_FormatKeyEntry

Format Key Entry Succeeded!

 

Setting AES-128 key at entry 0x00, position 0x00:

AB CD EF 09 AB CD EF 09 AB CD EF 09 AB CD EF 09

Set Key at Position Succeeded

 

phCryptoSym_Sw_Init cryptoSymEnc Success!

 

Initializing phCryptoSym_Sw_Init (cryptoSymMac)

phCryptoSym_Sw_Init cryptoSymMac Success!

 

Initializing phCryptoRng_Sw_Init

phCryptoRng_Sw_Init Success!

 

Initializing phpalI14443p3a_Sw_Init

phpalI14443p3a Initialized!

 

Initializing phpalI14443p4a_Sw_Init

phpalI14443p4a Initialized!

 

Initializing phpalI14443p4_Sw_Init

phpalI14443p4 Initialized!

 

Initializing phpalMifare_Sw_Init

Mifare Initialized!

 

palMifare.pPalI14443p4DataParams = 0x001003D4

Initializing phCryptoSym_Sw_Init (cryptoSymEnc)

Initializing phalMfNtag42XDna_Sw_Init

Ntag42XDna_Sw_Init Succeeded!

 

dna.wId = 0x2601

cryptoSymEnc.wId = 0xE101

cryptoSymMac.wId = 0xE101

cryptoRng.wId = 0xE401

 

 

***System Initialized***

 

 

********Processing Tag************

 

 

Invoking phhalHw_ApplyProtocolSettings

ApplyProtocolSettings Succeeded!

 

Activating Tag via phpalI14443p3a_ActivateCard

Tag Activation Succeeded!

 

Activating Tag via phpalI14443p4a_ActivateCard

phpalI14443p4a_ActivateCard succeeded!

Invoking phpalI14443p4_SetProtocol

SetProtocol Succeeded!

 

Invoking phalMfNtag42XDna_GetVersion()

GetVersion succeeded. Tag is in ISO-DEP mode.

Version: 04 04 02 30 00 11 05 04 04 Testing Mifare raw exchange...

Exchange Test Status: 0x0000

Exchange Test RxLen: 2

Exchange Test Response:

67 00

Authenticating Tag via phalMfNtag42XDna_AuthenticateEv2

dna.pPalMifareDataParams: 0x001003C0

palMifare.pPalI14443p4DataParams: 0x001003D4

palI14443p4.pHalDataParams: 0x001004F4

Tag Not Authenticated!

Authentication status: 0x2682

 

I think that my test key is not programmed properly to support EV2 on the Master Key0, and need RFIDDiscover or a known good sample key to further test my application.  I have submitted an NDA request and need RFIDDiscover to analyze EV2 capability of my test tag.

0 Kudos
Reply

130 Views
Jeffw5555
Contributor II

After previous posts I found reference to two key things I have changed in an updated log, attached below:

- I originally saw reference that the AES key should be set to 0x0EU, which was used in the previous log I sent, resulting in an authenticate error of 0x2626.  In most other documentation, it says to simply keep the default setting in phKeyStore of 0x00U, which I have updated to.  In the attached log, this now results in an authentication error of 0x0220.

- I also added two function calls between the phpalI14443p3a_ActivateCard and phalMfNtag42XDna_AuthenticateEv2 as follows:
        - phpalI14443p4a_GetProtocolParams
        - phpalI14443p4_SetProtocol

I still get an authentication error 0x0220.

 

Here is the log from console:

Initialize Hardware Abstraction Layer (HAL)with phhalHw_PN7462AU_Init
HAL Initialized!
HAL ID: 0x020A

*********Initializing PAL, KeyStore, and Crypto**********


Initializing phpalI14443p3a_Sw_Init
phpalI14443p3a Initialized!

Initializing phpalI14443p4a_Sw_Init
phpalI14443p4a Initialized!

Initializing phpalI14443p4_Sw_Init
phpalI14443p4 Initialized!

Initializing phpalMifare_Sw_Init
Mifare Initialized!

Initializing phCryptoSym_Sw_Init (cryptoSymEnc)
phCryptoSym_Sw_Init cryptoSymEnc Success!

Initializing phCryptoSym_Sw_Init (cryptoSymMac)
phCryptoSym_Sw_Init cryptoSymMac Success!

Initializing phCryptoRng_Sw_Init
phCryptoRng_Sw_Init Success!

Initializing phKeyStore_Sw_Init
Keystore Initialized!

Initializing phKeyStore_SetConfig
phKeyStore_SetConfig NOT Initialized!

Initializing phKeyStore_Sw_FormatKeyEntry
Format Key Entry Succeeded!

Initializing phKeyStore_Sw_GetKeyEntry
Get Key Entry Succeeded!
Formatted key type = 0x0000

Invoking phKeyStore_Sw_SetKeyAtPos
Attempting SetKeyPosition using Key:
AB CD EF 09 AB CD EF 09 AB CD EF 09 AB CD EF 09
Setting AES-128 key at entry 0x00, position 0x00:
AB CD EF 09 AB CD EF 09 AB CD EF 09 AB CD EF 09
Set Key at Position Succeeded

Invoking phKeyStore_GetKeyEntry
phKeyStore_GetKeyEntry Success!
KeyEntry 0x00: 1 key(s), type = 0x0000, first version = 0x00

Verifying KeyStore Key at Position 0...
Invoking phKeyStore_GetKey
Key retrieved successfully!
Key Type = 0x0000

Initializing phalMfNtag42XDna_Sw_Init
Ntag42XDna_Sw_Init Succeeded!

dna.wId = 0x2601
cryptoSymEnc.wId = 0xE101
cryptoSymMac.wId = 0xE101
cryptoRng.wId = 0xE401


***System Initialized***


********Processing Tag************


Invoking phhalHw_ApplyProtocolSettings
ApplyProtocolSettings Succeeded!

Activating Tag via phpalI14443p3a_ActivateCard
Tag Activation Succeeded!

Invoking phpalI14443p4a_GetProtocolParams
GetProtocolParams Succeeded!

Invoking phpalI14443p4_SetProtocol
SetProtocol Succeeded!

UID before auth: 04 2C 19 12 C4 1B 90
Key used in auth: AB CD EF 09 AB CD EF 09 AB CD EF 09 AB CD EF 09
Authenticating Tag via phalMfNtag42XDna_AuthenticateEv2
Tag Not Authenticated!
Authentication status: 0x0220


Retrieving Key Version via phalMfNtag42XDna_GetKeyVersion
GetKeyVersion failed. Status: 0x0220

 

0 Kudos
Reply

73 Views
jimmychan
NXP TechSupport
NXP TechSupport

Do you have PEGODA? 

It is useful to use with the RFIDDiscover. You could try the same things on RFIDDiscover.  Then compare the log with your result. 

0 Kudos
Reply