Search code examples
nfc

NTag424 DNA ReadData[CommMode.Full] returns 7E


I'm trying to personalize an (NTag 424 DNA) Everything is going well except one problem I'm facing in ReadData command (CommMode.Full).

I call ChangeFileSettings on the file_02 to make two changes:

  1. CommMode => (Full)
  2. (read/write/read_write/change) => need Key0 (not free)

I pass the data (03 00 00) to (ChangeFileSettings) and it works perfectly with good response.

And the (GetFileSettings) now returns (00 03 00 00 00 01 00) (which indecates that the CommMode is now indeed (Full) )

The (WriteData) command works well (CommMode.Full). Now the problem is that the (ReadData) command returns (7Eh Command size not allowed)

(No matter what CommMode I use for it)

The (ReadData) works again in Plain mode if I revert the changes (make CommMode of the file (Plain) again)

here is the details of my ReadData example (Authed with Key0)

TI:             391267AA
KSesAuthENC:    2675CA630A2C87B4986AC116E66A0045
KSesAuthMAC:    B89AD52AB517855F8695018883DEF90F
CmdCtr:         1
Params:         (file:2, Offset: 0, Length: 255)
APDU Buffer:    90AD00000F02000000FF0000CC7137F33032F9F200
Response:       917E
My Reader:      ACR1281U-C1

Would you please help me get through this? What is the problem and how to overcome it?

Thanks in advance.


Solution

  • You didn't make anything wrong with your command but with a parameter you are using.

    The Standard File 02 on the NTAG 424 DNA has a predefined size of 256 bytes. As long as you don't change the file settings to "Full / Encrypted" mode this file operates in Communication Settings PLAIN.

    With your "change file settings" command you changed the file to the Communication Settings FULL including a change of authentication keys.

    After issuing this command the file needs to operate in Secure Messaging mode.

    In the next step you are trying to read 255 bytes of the 256 bytes long file and you receive a "7Eh" error:

    Length Error : 7Eh Command size not allowed

    This is indicating that you are using a command that is too long OR a parameter that would exceed any other limitation.

    The datasheet for the tag gives some hints on pages 73 + 74 ("Read Data Command"):

    Command Header Parameters
    Length 3 000000h Read the entire StandardData file, starting from the position specified in the offset value. Note that the short length Le limits response data to 256 byte including secure messaging (if applicable).
    
    Response data parameters description - ReadData
    Response data : up to 256 byte including secure messaging
    

    The important fact is the "including secure messaging" part. The secure messaging gives an additional overhead of data (e.g. because of padded encrypted data and MAC data) that is limiting the length of data.

    The maximum length of data you can retrieve in one run is 239 bytes.

    Solution: If you are exceeding this limit in Full Encrypted mode you receive the error "7Eh", so if you are need to read the full file you have to split it into (minimum) 2 parts by using the offset parameter.