com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error

Forum / MIFARE SDK / com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error

  • 31. March 2019 at 16:42
    Dear Team,

    sub : com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error

    We have one device in which SAM Card can be inserted, while trying to authenticate the NFC tag , its getting Authentication Error.

    We followed the sample from :
    http://maven.taplinx.nxp.com/nexus/content/repositories/taplinxfiles/SampleAppSources/srcsamplenxpnfclib/1.5/

    Things we have done :-
    - Initialized the key :

    infoProvider.setKey(ALIAS_KEY_2KTDES, SampleAppKeys.EnumKeyType.EnumDESKey,
    SampleAppKeys.AUTH_KEY);


    public static final byte[] AUTH_KEY = {(byte) 0x00, (byte) 0x01,
    (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05,
    (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09,
    (byte) 0x10, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC,
    (byte) 0xDD, (byte) 0xEE
    };


    We gave the DAK Key of the SAM Card for authentication like below.But getting "com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error" exception.

    desFireEV2.authenticate(0, IDESFireEV1.AuthType.Native, KeyType.THREEDES,objKEY_2KTDES);


    Please guide if our approach is wrong.

    Thanks & Regards,
    Nitheesh ks


    + 0  |  - 0

    Re: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error

    1. April 2019 at 15:32
    Hi Nitheesh,

    Please let us split the problem. The authentication can be done with a local key. If it really comes from a SAM is a different matter. Using DES keys bear always the issue of invalid keys. For instance, 00…00 is an invalid 2K3DES key, because the 8 upper bytes are equal to the 8 lower bytes. The DESFire comes with DES keys as default, but you should always change the cipher to AES for your application.

    We have a lot of examples where we show the authentication and the change of keys for a MIFARE DESFire:

    DESFire EV1 authenticate with different keys for reading and writing:

    DESFire EV1 change key:

    DESFire EV2 Read/write encrypted file:

    DESFire EV1 Create app and file with 2K3DES cipher:

    The TapLinx team
    + 0  |  - 0

    Re: com.nxp.nfclib.exceptions.InvalidResponseLengthException: Authentication Error

    7. April 2019 at 8:33
    Thanks for the reply.

    Let us workout with the above information.
    + 0  |  - 0
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.