2

I have EZ100PU usb smart card reader and new (clear) SLE4428 smart cards. I would like to write number sequence on them. I'm trying to do it with simple java application. That's my code based on others available on the internet:

public class Connection {

  public static void main(String[] args) throws Exception { 

    TerminalFactory factory = TerminalFactory.getDefault();

    CardTerminal terminal = terminals.get(1); 
    System.out.println("terminal: " + terminal.getName());
    Card card = terminal.connect("*");
    System.out.println("card: " + card);
    CardChannel channel = card.getBasicChannel(); 
    System.out.println("channel: " + channel.getChannelNumber());
    System.out.println("protocol: "+card.getProtocol());

    byte b[]=card.getATR().getBytes();
    for(int i=0;i<b.length;i++)
       System.out.print(b[i]);


//        byte[] bytes = {(byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x00};
//        ResponseAPDU r = channel.transmit(new CommandAPDU(bytes));

    card.disconnect(false);

  }
}

I have problem, because I always get "Unknown protocol 16" when card is inside reader. Probably because of that I can't write anything on the card, if I try I always get error. Can you help me?

Jon Lin
  • 142,182
  • 29
  • 220
  • 220

2 Answers2

2

Your SLE 4428 card has default PIN = FFFF. First you need to verify PIN USING below COMMAND :- FF 20 00 00 02 FFFF Then you can write data to SLE 4428 card. If data is "My name is Kashyap" then in hex it is 4D79206E616D65206973204B617368796170. Write Data:- FF D0 00 20 12 4D79206E616D65206973204B617368796170. You can also change default PIN. Suppose I want to chagne PIN to 1234 from FFFF then use below Command:- FF D0 03 FD 03 FF 1234.

To read data below command:- FF B0 00 20 12

Thanks, Kashyap

0

You are trying to use a method of connecting to ISO 7816-3 (T=0, T=1 or T=CL) compatible processor cards to connect to a lowly memory card. You will likely have to use a card specific reader library instead, you cannot just use javax.smartcardio.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • So can you tell me is it possible to get those libraries and how to get it? Or maybe it will be easier to use different smard cards - which would you recommend just to write short number sequence on them? – user1893184 Dec 12 '12 at 18:14
  • The cards are fine for that purpose, but you should contact your supplier for a good combination of reader and library. – Maarten Bodewes Dec 12 '12 at 18:52
  • Unfortunately I don't know who is original supplier, because I bought reader and cards as used from a private person. So I think it would be easier just to buy different smart cards. If you could recommend some cards I should buy to easy write on them (e.g. using javax.smartcardio or other different simple method) I would really appreciate it. – user1893184 Dec 12 '12 at 22:12
  • In general the memory cards are probably best for this kind of use, so I would stick to them and look for the required library from the reader manufacturer. They should be pretty common cards, so likely there should be a few. They are also likely to come with C/C++ header files though, so you may need JNI to communicate with Java. javax.smartcardio is probably not such a good idea for this, it's too high level. If you *do* go that way you might want to think about a DESFire card, which should contain a (pretty simple) APDU interface. – Maarten Bodewes Dec 12 '12 at 22:16
  • Hello sir, it's me again. I decided to use different type of smart cards because I wasn't able to find any way to write or read from my SLE4428 cards. I was looking for DESFire cards you said but from what I found it's only available in contactless version. So I would need contact smart card with, like you said, simple APDU. Could you name some cards like I need? Unfortunately I couldn't find it. As I see you're familiar with smard cards and I would be very grateful for help. – user1893184 Dec 23 '12 at 16:33
  • APDU stands for Application Protocol Data Unit. It kind of requires an application to be there, so you could try to find a file system card that contains a simple processor and no additional asymmetric coprocessors. Unfortunately, my realm is almost entirely on the high end part of the contactless smart card market. I would have to look into the current situation first before I could make any kind of recommendation - except for the one I already made: you really don't need APDU's to read/write sequence numbers. Look for a development set of reader and smart cards. – Maarten Bodewes Dec 24 '12 at 00:57
  • I found libraries for my card reader and I used my SLE4428 smart cards. Thank you for your help. Best regards. – user1893184 Dec 25 '12 at 23:11
  • Would you mind sharing where you found the libraries? – André van Schoubroeck Nov 04 '14 at 09:44