-1

I'm working with DESFire cards and I now want create a value file in my application (app has ID 00 00 01).

I successfully selected my app with the given ID and then send my command for creating the value file to the isodep.transceive method.

My command is here:

byte[] cmdCreateValueFile = new byte[]{
        //cmd
        (byte)0xCC,
        //file no
        (byte)0x01, 
        //com.sett.
        (byte)0x00 ,
        //access rights
        (byte)0x44 , (byte)0x44,
        //lower limit
        (byte)0x00 ,(byte)0x00 ,(byte)0x00 ,(byte)0x00 ,
        //upper limit
        (byte)0x00 ,(byte)0x0F ,(byte)0x42 ,(byte)0x40 ,
        //initial value
        (byte)0x00 ,(byte)0x00 ,(byte)0x00 ,(byte)0x00 ,
        //limited credit enabled
        (byte)0x00
};

My DESFire application has 6 keys and I want to use key #4 for READ, WRITE, READ & WRITE, and change access rights.

I expected to receive status code 91 00, which means successfully creation of file, but the response is 67 00, which means wrong length.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
setare ab
  • 183
  • 1
  • 12
  • 1
    I think you are mixing ISO commands (CLA INS P1 P2 LC DATA...) and native commands (INS DATA). Your previous command was (just guessing) an ISO command, that is why your card expects all commands to be ISO commands. – vojta May 26 '15 at 04:47
  • do you prefer using ISO command or native command totally? – setare ab May 26 '15 at 04:52
  • 1
    They are totally equivalent. You just have to chose one protocol and follow it all the time, you cannot switch between ISO commands and native commands. – vojta May 26 '15 at 04:53

1 Answers1

1

You are mixing ISO commands (CLA INS P1 P2 LC DATA...) and native commands (INS DATA). Your previous command was an ISO command, that is why your card expects all commands to be ISO commands.

vojta
  • 5,591
  • 2
  • 24
  • 64
  • Just for completeness: when working with ANdroid, you should prefer ISO or ISO wrapped native commands as the NDEF discovery procedure will switch the card to ISO mode on some platforms/Android versions. – Michael Roland May 26 '15 at 16:08