Taplinx: InvalidResponseLengthException: readData on desfire EV1 card












0















When reading data from a DESFire EVO1 card (AES encryption) I get a InvalidResponseLengthException. I'm using the taplinx library version 1.5



My code looks as follows:



private void cardLogic(final Intent intent){

CardType cardType = m_libInstance.getCardType(intent);

Log.v(logTag, cardType.getTagName());

IDESFireEV1 objDESFireEV1 = DESFireFactory.getInstance().getDESFire(m_libInstance.getCustomModules());



Key key = new SecretKeySpec(AUTHENTICATION_KEY, "AES");

KeyData kd = new KeyData();

kd.setKey(key);

try {

objDESFireEV1.getReader().connect();

objDESFireEV1.getReader().setTimeout(2000);

objDESFireEV1.selectApplication(APP_ID);

Log.v(logTag, objDESFireEV1.getAuthStatus());

objDESFireEV1.authenticate(1, IDESFireEV1.AuthType.AES,KeyType.AES128 , kd);

Log.v(logTag, objDESFireEV1.getAuthStatus());

byte data = objDESFireEV1.readData(1, 0, 3);

Log.v(logTag, data.toString());

} catch(Throwable t) {

Log.e(logTag, t.getMessage(), t);

}

}


LogCat



2018-11-22 10:19:13.874 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: on New intent
2018-11-22 10:19:13.977 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: DESFire EV1
2018-11-22 10:19:13.993 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: Not Authenticated
2018-11-22 10:19:14.035 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: AES
2018-11-22 10:19:14.045 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: Authentication Error

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

at com.nxp.nfclib.desfire.ʻ.ˋ(:4559)

at com.nxp.nfclib.desfire.ʻ.ˋ(:4600)

at com.nxp.nfclib.desfire.ʿ.ˊ(:182)

at com.nxp.nfclib.desfire.ʻ.getFileSettings(:2043)

at com.nxp.nfclib.desfire.ʻ.ˏ(:2494)

at com.nxp.nfclib.desfire.ʻ.readData(:2531)

at eu.mobitrace.mifaredesfiretest2.MainActivity.cardLogic(MainActivity.java:101)


Information I got from the maker of the card:




  • Application Id: This looks to work fine, when I enter a other ID I get a exception saying the app is not found

  • Authentication Key: This also looks to work fine, It doesn't throw an exception when using this key. When I use a other one (zeros or reversed) it throws a exception right here

  • Key Rights for this key: read(1)

  • File-Id: 1

  • Read offset: 0 bytes

  • Read length: 3 bytes


What I've tried:




  • Using the ISO command set: this was a total failure

  • Playing around with the integers in the read command to check if there was a error made in creating this (starting counting from 0/1)


Question
What is going wrong here? Is it some kind of authentication problem or am I using the lib wrong?










share|improve this question





























    0















    When reading data from a DESFire EVO1 card (AES encryption) I get a InvalidResponseLengthException. I'm using the taplinx library version 1.5



    My code looks as follows:



    private void cardLogic(final Intent intent){

    CardType cardType = m_libInstance.getCardType(intent);

    Log.v(logTag, cardType.getTagName());

    IDESFireEV1 objDESFireEV1 = DESFireFactory.getInstance().getDESFire(m_libInstance.getCustomModules());



    Key key = new SecretKeySpec(AUTHENTICATION_KEY, "AES");

    KeyData kd = new KeyData();

    kd.setKey(key);

    try {

    objDESFireEV1.getReader().connect();

    objDESFireEV1.getReader().setTimeout(2000);

    objDESFireEV1.selectApplication(APP_ID);

    Log.v(logTag, objDESFireEV1.getAuthStatus());

    objDESFireEV1.authenticate(1, IDESFireEV1.AuthType.AES,KeyType.AES128 , kd);

    Log.v(logTag, objDESFireEV1.getAuthStatus());

    byte data = objDESFireEV1.readData(1, 0, 3);

    Log.v(logTag, data.toString());

    } catch(Throwable t) {

    Log.e(logTag, t.getMessage(), t);

    }

    }


    LogCat



    2018-11-22 10:19:13.874 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: on New intent
    2018-11-22 10:19:13.977 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: DESFire EV1
    2018-11-22 10:19:13.993 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: Not Authenticated
    2018-11-22 10:19:14.035 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: AES
    2018-11-22 10:19:14.045 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: Authentication Error

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

    at com.nxp.nfclib.desfire.ʻ.ˋ(:4559)

    at com.nxp.nfclib.desfire.ʻ.ˋ(:4600)

    at com.nxp.nfclib.desfire.ʿ.ˊ(:182)

    at com.nxp.nfclib.desfire.ʻ.getFileSettings(:2043)

    at com.nxp.nfclib.desfire.ʻ.ˏ(:2494)

    at com.nxp.nfclib.desfire.ʻ.readData(:2531)

    at eu.mobitrace.mifaredesfiretest2.MainActivity.cardLogic(MainActivity.java:101)


    Information I got from the maker of the card:




    • Application Id: This looks to work fine, when I enter a other ID I get a exception saying the app is not found

    • Authentication Key: This also looks to work fine, It doesn't throw an exception when using this key. When I use a other one (zeros or reversed) it throws a exception right here

    • Key Rights for this key: read(1)

    • File-Id: 1

    • Read offset: 0 bytes

    • Read length: 3 bytes


    What I've tried:




    • Using the ISO command set: this was a total failure

    • Playing around with the integers in the read command to check if there was a error made in creating this (starting counting from 0/1)


    Question
    What is going wrong here? Is it some kind of authentication problem or am I using the lib wrong?










    share|improve this question



























      0












      0








      0








      When reading data from a DESFire EVO1 card (AES encryption) I get a InvalidResponseLengthException. I'm using the taplinx library version 1.5



      My code looks as follows:



      private void cardLogic(final Intent intent){

      CardType cardType = m_libInstance.getCardType(intent);

      Log.v(logTag, cardType.getTagName());

      IDESFireEV1 objDESFireEV1 = DESFireFactory.getInstance().getDESFire(m_libInstance.getCustomModules());



      Key key = new SecretKeySpec(AUTHENTICATION_KEY, "AES");

      KeyData kd = new KeyData();

      kd.setKey(key);

      try {

      objDESFireEV1.getReader().connect();

      objDESFireEV1.getReader().setTimeout(2000);

      objDESFireEV1.selectApplication(APP_ID);

      Log.v(logTag, objDESFireEV1.getAuthStatus());

      objDESFireEV1.authenticate(1, IDESFireEV1.AuthType.AES,KeyType.AES128 , kd);

      Log.v(logTag, objDESFireEV1.getAuthStatus());

      byte data = objDESFireEV1.readData(1, 0, 3);

      Log.v(logTag, data.toString());

      } catch(Throwable t) {

      Log.e(logTag, t.getMessage(), t);

      }

      }


      LogCat



      2018-11-22 10:19:13.874 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: on New intent
      2018-11-22 10:19:13.977 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: DESFire EV1
      2018-11-22 10:19:13.993 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: Not Authenticated
      2018-11-22 10:19:14.035 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: AES
      2018-11-22 10:19:14.045 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: Authentication Error

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

      at com.nxp.nfclib.desfire.ʻ.ˋ(:4559)

      at com.nxp.nfclib.desfire.ʻ.ˋ(:4600)

      at com.nxp.nfclib.desfire.ʿ.ˊ(:182)

      at com.nxp.nfclib.desfire.ʻ.getFileSettings(:2043)

      at com.nxp.nfclib.desfire.ʻ.ˏ(:2494)

      at com.nxp.nfclib.desfire.ʻ.readData(:2531)

      at eu.mobitrace.mifaredesfiretest2.MainActivity.cardLogic(MainActivity.java:101)


      Information I got from the maker of the card:




      • Application Id: This looks to work fine, when I enter a other ID I get a exception saying the app is not found

      • Authentication Key: This also looks to work fine, It doesn't throw an exception when using this key. When I use a other one (zeros or reversed) it throws a exception right here

      • Key Rights for this key: read(1)

      • File-Id: 1

      • Read offset: 0 bytes

      • Read length: 3 bytes


      What I've tried:




      • Using the ISO command set: this was a total failure

      • Playing around with the integers in the read command to check if there was a error made in creating this (starting counting from 0/1)


      Question
      What is going wrong here? Is it some kind of authentication problem or am I using the lib wrong?










      share|improve this question
















      When reading data from a DESFire EVO1 card (AES encryption) I get a InvalidResponseLengthException. I'm using the taplinx library version 1.5



      My code looks as follows:



      private void cardLogic(final Intent intent){

      CardType cardType = m_libInstance.getCardType(intent);

      Log.v(logTag, cardType.getTagName());

      IDESFireEV1 objDESFireEV1 = DESFireFactory.getInstance().getDESFire(m_libInstance.getCustomModules());



      Key key = new SecretKeySpec(AUTHENTICATION_KEY, "AES");

      KeyData kd = new KeyData();

      kd.setKey(key);

      try {

      objDESFireEV1.getReader().connect();

      objDESFireEV1.getReader().setTimeout(2000);

      objDESFireEV1.selectApplication(APP_ID);

      Log.v(logTag, objDESFireEV1.getAuthStatus());

      objDESFireEV1.authenticate(1, IDESFireEV1.AuthType.AES,KeyType.AES128 , kd);

      Log.v(logTag, objDESFireEV1.getAuthStatus());

      byte data = objDESFireEV1.readData(1, 0, 3);

      Log.v(logTag, data.toString());

      } catch(Throwable t) {

      Log.e(logTag, t.getMessage(), t);

      }

      }


      LogCat



      2018-11-22 10:19:13.874 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: on New intent
      2018-11-22 10:19:13.977 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: DESFire EV1
      2018-11-22 10:19:13.993 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: Not Authenticated
      2018-11-22 10:19:14.035 20228-20228/eu.mobitrace.mifaredesfiretest2 V/app-logger: AES
      2018-11-22 10:19:14.045 20228-20228/eu.mobitrace.mifaredesfiretest2 E/app-logger: Authentication Error

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

      at com.nxp.nfclib.desfire.ʻ.ˋ(:4559)

      at com.nxp.nfclib.desfire.ʻ.ˋ(:4600)

      at com.nxp.nfclib.desfire.ʿ.ˊ(:182)

      at com.nxp.nfclib.desfire.ʻ.getFileSettings(:2043)

      at com.nxp.nfclib.desfire.ʻ.ˏ(:2494)

      at com.nxp.nfclib.desfire.ʻ.readData(:2531)

      at eu.mobitrace.mifaredesfiretest2.MainActivity.cardLogic(MainActivity.java:101)


      Information I got from the maker of the card:




      • Application Id: This looks to work fine, when I enter a other ID I get a exception saying the app is not found

      • Authentication Key: This also looks to work fine, It doesn't throw an exception when using this key. When I use a other one (zeros or reversed) it throws a exception right here

      • Key Rights for this key: read(1)

      • File-Id: 1

      • Read offset: 0 bytes

      • Read length: 3 bytes


      What I've tried:




      • Using the ISO command set: this was a total failure

      • Playing around with the integers in the read command to check if there was a error made in creating this (starting counting from 0/1)


      Question
      What is going wrong here? Is it some kind of authentication problem or am I using the lib wrong?







      mifare






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 10:14







      Michiel Knevels

















      asked Nov 22 '18 at 10:00









      Michiel KnevelsMichiel Knevels

      13




      13
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428337%2ftaplinx-invalidresponselengthexception-readdata-on-desfire-ev1-card%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428337%2ftaplinx-invalidresponselengthexception-readdata-on-desfire-ev1-card%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin