MacOS X with RFID Smartcards – Notes

Notes on my experiences playing with RFID smartcards and RFIDIOt on OSX (10.8, 10.9)

RFIDIOt

I’m using an OMNIKEY 5321 USB, now made by HID. I have a couple of RFID cards to play with including an old Javacard bought from Adam Laurie.

OS-X supplies a bunch of PC/SC infrastructure to get going – however I’d strongly recommend downloading the driver from HID: http://www.hidglobal.com/drivers/20384.

There are READMEs displayed in the installer – they are surprisingly detailed about what the installer actually installs. Read them.

Once the driver is installed, you can test that everything is working – so plug in the reader. The pcsc daemon should run automatically; check by typing:

ps ax |grep pcscd |grep -v grep

So now you can run a test: place a card on the reader and run:

pcsctest

You should see something like this:

MUSCLE PC/SC Lite Test Program

Testing SCardEstablishContext    : Command successful.
Testing SCardGetStatusChange 
Please insert a working reader   : Command successful.
Testing SCardListReaders         : Command successful.
Reader 01: OMNIKEY CardMan 5x21 00 00
Reader 02: OMNIKEY CardMan 5x21 00 01
Enter the reader number          :

The 5321 has two readers, a regular smartcard reader and a contactless reader. From what I can tell, “Reader 01” is for regular smartcards and “Reader 02” is RFID. If you only see the entry for regular contact cards, you are probably suffering from this issue – to fix this all you need to do is install the drivers from Omnikey. The installer patches the installed card driver bundle so that it will use the correct driver.

So type “2”. You should see details about the card like:

Waiting for card insertion         
                                 : Command successful.
Testing SCardConnect             : Command successful.
Testing SCardStatus              : Command successful.
Current Reader Name              : OMNIKEY CardMan 5x21 00 01
Current Reader State             : 0x34
Current Reader Protocol          : 0x1
Current Reader ATR Size          : 20 (0x14)
Current Reader ATR Value         : 3B XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 
Testing SCardDisconnect          : Command successful.
Testing SCardReleaseContext      : Command successful.
Testing SCardEstablishContext    : Command successful.
Testing SCardGetStatusChange 
Please insert a working reader   : Command successful.
Testing SCardListReaders         : Command successful.
Reader 01: OMNIKEY CardMan 5x21 00 00
Reader 02: OMNIKEY CardMan 5x21 00 01

Congratulations – you have a working reader!

Install RFIDIOt from http://rfidiot.org/documentation.html. Read the documentation carefully.

I needed to install pyscard. The installer installed the libraries against Python 2.6 and on my machine the default python version is 2.7. Consequently, every time I tried to run any RFIDIOt tool I got the dreaded “*** Warning – no pyscard installed or pcscd not running”. Copying the modules into /Library/Python/2.7/site-packages from /Library/Python/2.6/site-packages did the trick.

I also needed to install PIL (actually Pillow) and pyasn1. These were simply a case of running:

sudo easy_install pyasn1
sudo pip install Pillow

gpshell and GlobalPlatform

gpshell is a tool for interacting with smart cards using globalplatform. First you need the globalplatform library. I managed to get it to compile with:

./configure PCSCLITE_CFLAGS=-I/Applications/Xcode45-DP1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/ --prefix=/opt/local/
make
sudo make install

The /opt/local prefix is because I wanted it to nestle in with my MacPorts stuff. Next I built gppcscconnectionplugin using:

./configure PCSCLITE_CFLAGS=-I/Applications/Xcode45-DP1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/ --prefix=/opt/local/ GLOBALPLATFORM_CFLAGS=-I/opt/local/include/globalplatform
make
sudo make install

And then gpshell would build with:

./configure PCSCLITE_CFLAGS=-I/Applications/Xcode45-DP1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/ --prefix=/opt/local/ GLOBALPLATFORM_CFLAGS=-I/opt/local/include/globalplatform
make
sudo make install

Feedback welcome

Share

Leave a Reply