1

I am trying to write data to contactless card in HID Omnikey 5122 device using java smartcardIO functions.

The Data that I need to insert to the card is {00 01 02 03}.

APDU command I am trying to send through channel.transmit function is {FF D6 00 04 04 00 01 02 03} where:

  • FF is CLS
  • D6 is INS
  • 00 is P1
  • 04 is P2
  • 04 is Number of bytes to update
  • 00 01 02 03 is the data that I need to insert.

I am not able to correctly build the APDU command through below function. Can some one help me with this. I am using functions available in java smartcardio library.

ResponseAPDU respApdu = channel.transmit(           
                          new CommandAPDU(0xFF,0xD6,0x00,0x04,0x04,
                                          new byte[] {(byte) 0x00, 
                                          (byte) 0x01, 
                                          (byte)0x02,
                                          (byte)0x03}));

I am getting syntax error like constructor command is having invalid arguments.

Marc Sances
  • 2,402
  • 1
  • 19
  • 34
Suni
  • 11
  • 2
  • 1
    Welcome to Stack Overflow. Can you paste us the error message you have with the stack trace? Also having a full, [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) will help users track down your issue. Thanks for your collaboration! – Marc Sances Aug 19 '20 at 09:21

1 Answers1

0

It looks like you are trying to send an UPDATE BINARY APDU to update the transparent file at offset 4 (this is what you provide in P1-P2). You have to use a CLA byte of 00h (if that file operation doesn't require the use of Secure Messaging). Since P1-P2 doesn't specify a short file identifier in your case, your currently selected file has

  • to be compatible with the READ/UPDATE BINARY commands
  • to have file size >=9 byres.
ALe
  • 156
  • 1
  • 4
  • Could you let me know, how can I add the information of CLA byte of 00h in the below APDU call. ResponseAPDU respApdu = channel.transmit( new CommandAPDU(0xFF,0xD6,0x00,0x04,0x04, new byte[] {(byte) 0x00, (byte) 0x01, (byte)0x02, (byte)0x03})); – Suni Aug 21 '20 at 03:33
  • Sorry Suni, I mixed up the abbreviations. I used CLA synonymous with CLS. (0x00, 0xD6, ...) – ALe Aug 21 '20 at 09:18