leonidas79
leonidas79

Reputation: 469

write data to a smart card in StdData File

i created a file in a smart card using this apdu command :

String apdu = "90CD00000700000E0EA0000000"; channel.transmit(new CommandAPDU(DatatypeConverter.parseHexBinary(apdu)));

the file is successefuly created , however i can't write data in that file , i tried this command : String apdu = "903D00003B00000000000034" + data + "00";

but it failed with a response : sw1 91 sw2 BE (Out of boundary)

what is the problem about this file ?

Upvotes: 0

Views: 302

Answers (1)

vlp
vlp

Reputation: 8116

DESFire commands use little-endian byte order.

Your length (000034) gets interpreted as 3407872 bytes. You need to use 340000 to encode 52.

Try a shorter write, e.g.: 903D00000F00000000080000112233445566778800 to write '1122334455667788'...

Good luck!

EDIT>

Adjust lengths in P3 of APDU and WriteData for longer writes, e.g.:

  • 903D0000170000000010000000112233445566778899AABBCCDDEEFF00

Note that DESFire has a frame size limit which limits the number of bytes that can be written in a single command exchange (for ISO wrapped DESFire WriteData command it is approximately 47 bytes of data). You need to perform several writes with offset (remember litte-endian encoding) or use ADDITIONAL FRAME mechanism -- see your DESFire manual (the latter is slightly faster).

Upvotes: 1

Related Questions