4

I have been working of the read / write operation of smart cards, I believe my card is sle_4428 and I am using HID OMNIKEY 3121 USB Card Reader. The problem is that when I enter card in card reader my program responds as the smart card is not responding to a reset with error code 0x80100066, instead of connecting the card and getting ATR...

[EDIT] It works fine if I do only the read operation. When I do the write operation and then reinsert the card it stops responding, giving the above message. The APDU command I use to write is: FF D6 00 00 #(01 02)

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
Darab Javaid
  • 145
  • 2
  • 13
  • 1
    Have you tried a different card? – guidot Aug 02 '17 at 15:52
  • Yeah, I tried different card, at first it was detected and I read/write the data successfully, then again, after re-inserting, it stopped responding giving the same error message as above. – Darab Javaid Aug 03 '17 at 16:56
  • Always check the length which you are sending with your commands.. – shadygoneinsane Aug 04 '17 at 12:43
  • @shadygoneinsane, actually it works fine if I do only the read operation. When I do the write operation and then reinsert the card it stops responding, giving the above message....APDU commad I use to Write is: FF D6 00 00 #( 01 02) – Darab Javaid Aug 06 '17 at 07:50
  • We are also having problem with HID OMNIKEY 5421 reset. I try looking into HID omnikey workbench tool and its dll's. I found method which is "WAntennaControl". With this method you can properly cold reset smart card. Try out workbench tool and do reset from there. – TomazStoiljkovic Nov 02 '17 at 07:53

1 Answers1

1

Your problem is that HID Omnikey failes to properly "cold" reset smart card.

With the following Java code-snipped, you can reset HID Omnikey reader CL.

import jnasmartcardio.Smartcardio;

import javax.smartcardio.*;
import javax.xml.bind.DatatypeConverter;

public class OMNIKEYConfiguration {

public static void main(String... args) throws Exception {
    TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null, new Smartcardio());

    String terminalName = "OMNIKEY CardMan 5x21-CL 0";
    CardTerminal terminal = factory.terminals().getTerminal(terminalName);

    // Connect directly to reader
    Card card = terminal.connect("DIRECT");

    int code = 3224092; // #define IOCTL_CCID_ESCAPE SCARD_CTL_CODE(3500)
    byte[] command = DatatypeConverter.parseHexBinary("0300"); // 0300 - ON; 0301 - OFF
    byte[] resp = card.transmitControlCommand(code, command);
    System.out.println(DatatypeConverter.printHexBinary(resp));

    card.disconnect(true);
}
}

Use command "0x0300" to turn ON antenna, otherwise use "0x0301" to turn OFF antenna.

For cold reset call OFF and then ON commands.

TomazStoiljkovic
  • 808
  • 8
  • 21