Search code examples
javasmartcardjavacardsmartcard-readeromnikey

How to get access to Omnikey 3121 smart card reader


I want to use Java to get access to smart card by Omnikey reader. I found couple solutions like a smartcardio, but it didn't help enough. Basically I connected with reader, but it uses APDU when I don't need it. I have an idea to open stream to my reader by USB and by stream put binary commands to device and then get answer the same way, but technically how can I write it in Java?

I also found libraries like a usb4java, but also bad opinion about that. Maybe someone had any experience with this device and could give me some tips?

On the internet there aren't many tutorials about programming smart cards. I tried also use pyApduTool or HID Omnikey Sync API V2.0., but that only for test. I have to write simple requests to get information from card.


Solution

  • There are basically two ways around your issue:

    1. don't use the PC/SC interface used by java.smartcardio but use native, proprietary libraries from the card reader manufacturer, for instance using a wrapper (JNI based, but there are better / higher level alternatives out there);

    2. keep using APDU's, but use CLA byte set to FF hex, opening a connection to the reader. FF is reserved, but it is generally reserved for this kind of card reader access, e.g. to access memory cards without ISO/IEC 7816-4 layer that are supported by the reader manufacturer.

    3. out of two (for completeness only): many card readers have been created using a USB to serial interface chip, which means that you can directly connect to the (virtual) serial interface; needless to say, you will have to know what commands to send and program everything yourself, if this interface is present at all (Omnikey 3121 is relatively new, so I would be surprised).

    Both options rely on card reader specific functions, so you will have find the information for the reader to see what is possible. To my knowledge there is no way to request what functionality is provided. Don't expect too much from standardization for this kind of functionality.

    Did you check your card reader specific documentation?