简体   繁体   中英

How to convert smart card APDU command on java to c#?

I have Java code that works fine for reading data from an smart card:

byte[] dataSetEF12 = {0, -80, -110, 0, 0};
apdu = new CommandAPDU(dataSetEF12);
ResponseAPDU response = cardChannel.transmit(apdu);
byte[] data = response.getData();

But I need this on c# & I write this:

apdu = new APDUCommand(0x00, 0xB0, 0x92, 0x00, null, 0x00);
APDUResponse response = cardReader.Transmit(command);
byte[] data = response.Data;

But on c# response.Data equals to null

Anyone know what is my mistake or what is the solution?

Based on what status code which is returned from card, your problem maybe has several reasons:

  1. SW = 61XX; You have to send GET_RESPONSE command to card.
  2. SW = 9000; You have to Check you C# wrapper. (Maybe you have to set Le in command apdu)
  3. SW = 6F00; Some thing wrong in your command or card
  4. SW = anything else; You have to search it on the web.

Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM