{"id":1050,"date":"2015-06-07T17:37:40","date_gmt":"2015-06-07T17:37:40","guid":{"rendered":"http:\/\/fatsquirrel.org\/oldfartsalmanac\/?page_id=1050"},"modified":"2015-06-07T17:38:53","modified_gmt":"2015-06-07T17:38:53","slug":"macos-x-with-rfid-smartcards-notes","status":"publish","type":"page","link":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/random\/macos-x-with-rfid-smartcards-notes\/","title":{"rendered":"MacOS X with RFID Smartcards &#8211; Notes"},"content":{"rendered":"<p><i>Notes on my experiences playing with RFID smartcards and <a href=\"http:\/\/rfidiot.org\/\">RFIDIOt<\/a> on OSX (10.8, 10.9)<\/i><\/p>\n<h2>RFIDIOt<\/h2>\n<p>I&#8217;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.<\/p>\n<p>OS-X supplies a bunch of PC\/SC infrastructure to get going &#8211; however I&#8217;d <i>strongly<\/i> recommend downloading the driver from HID: <a href=\"http:\/\/www.hidglobal.com\/drivers\/20384\" name=\"drivers\">http:\/\/www.hidglobal.com\/drivers\/20384<\/a>.<br \/>\n<!--<a href=\"http:\/\/www.hidglobal.com\/driverDownloads.php?techCat=19&amp;prod_id=171\">http:\/\/www.hidglobal.com\/driverDownloads.php?techCat=19&amp;prod_id=171.--><br \/>\nThere are READMEs displayed in the installer &#8211; they are surprisingly detailed about what the installer actually installs. Read them. <\/p>\n<p>Once the driver is installed, you can test that everything is working &#8211; so plug in the reader. The pcsc daemon should run automatically; check by typing:<\/p>\n<pre>\r\nps ax |grep pcscd |grep -v grep\r\n<\/pre>\n<p>So now you can run a test: place a card on the reader and run:\n<\/p>\n<pre>\r\npcsctest\r\n<\/pre>\n<p>You should see something like this:<\/p>\n<pre>\r\nMUSCLE PC\/SC Lite Test Program\r\n\r\nTesting SCardEstablishContext    : Command successful.\r\nTesting SCardGetStatusChange \r\nPlease insert a working reader   : Command successful.\r\nTesting SCardListReaders         : Command successful.\r\nReader 01: OMNIKEY CardMan 5x21 00 00\r\nReader 02: OMNIKEY CardMan 5x21 00 01\r\nEnter the reader number          :\r\n<\/pre>\n<p>The 5321 has two readers, a regular smartcard reader and a contactless reader. From what I can tell, &#8220;Reader 01&#8221; is for regular smartcards and &#8220;Reader 02&#8221; is RFID. <i>If you only see the entry for regular contact cards, you are probably suffering from <a href=\"http:\/\/rfidiot.org\/documentation.html#mozTocId727134\">this issue<\/a> &#8211; to fix this all you need to do is install the <a href=\"#drivers\">drivers from Omnikey<\/a>. The installer patches the installed card driver bundle so that it will use the correct driver. <\/i><\/p>\n<p>So type &#8220;2&#8221;. You should see details about the card like:\n<\/p>\n<pre>\r\nWaiting for card insertion         \r\n                                 : Command successful.\r\nTesting SCardConnect             : Command successful.\r\nTesting SCardStatus              : Command successful.\r\nCurrent Reader Name              : OMNIKEY CardMan 5x21 00 01\r\nCurrent Reader State             : 0x34\r\nCurrent Reader Protocol          : 0x1\r\nCurrent Reader ATR Size          : 20 (0x14)\r\nCurrent Reader ATR Value         : 3B XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX \r\nTesting SCardDisconnect          : Command successful.\r\nTesting SCardReleaseContext      : Command successful.\r\nTesting SCardEstablishContext    : Command successful.\r\nTesting SCardGetStatusChange \r\nPlease insert a working reader   : Command successful.\r\nTesting SCardListReaders         : Command successful.\r\nReader 01: OMNIKEY CardMan 5x21 00 00\r\nReader 02: OMNIKEY CardMan 5x21 00 01\r\n<\/pre>\n<p>Congratulations &#8211; you have a working reader!\n<\/p>\n<p>Install RFIDIOt from <a href=\"http:\/\/rfidiot.org\/documentation.html\">http:\/\/rfidiot.org\/documentation.html<\/a>. Read the documentation carefully. <\/p>\n<p>I needed to install <a href=\"http:\/\/pyscard.sourceforge.net\/\">pyscard<\/a>. 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 &#8220;*** Warning &#8211; no pyscard installed or pcscd not running&#8221;. Copying the modules into \/Library\/Python\/2.7\/site-packages from \/Library\/Python\/2.6\/site-packages did the trick.\n<\/p>\n<p>I also needed to install PIL (actually Pillow)  and pyasn1. These were simply a case of running:\n<\/p>\n<pre>\r\nsudo easy_install pyasn1\r\nsudo pip install Pillow\r\n<\/pre>\n<h2>gpshell and GlobalPlatform<\/h2>\n<p>gpshell is a tool for interacting with smart cards using globalplatform. First you need the <a href=\"http:\/\/sourceforge.net\/projects\/globalplatform\/files\/GlobalPlatform%20Library\/GlobalPlatform%20Library%206.0.0\/\">globalplatform library<\/a>. I managed to get it to compile with:<\/p>\n<pre>\r\n.\/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\/\r\nmake\r\nsudo make install\r\n<\/pre>\n<p>The \/opt\/local prefix is because I wanted it to nestle in with my MacPorts stuff. Next I built gppcscconnectionplugin using:<\/p>\n<pre>\r\n.\/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\r\nmake\r\nsudo make install\r\n<\/pre>\n<p>And then <a href=\"http:\/\/sourceforge.net\/projects\/globalplatform\/files\/GPShell\/GPShell-1.4.4\/\">gpshell<\/a> would build with:<\/p>\n<pre>\r\n.\/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\r\nmake\r\nsudo make install\r\n<\/pre>\n<p>\nFeedback <a href=\"\/veghead\/contact\/\" target=\"_blank\">welcome<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Notes on my experiences playing with RFID smartcards and RFIDIOt on OSX (10.8, 10.9) RFIDIOt I&#8217;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 &#8211; however [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1029,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1050","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/pages\/1050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/comments?post=1050"}],"version-history":[{"count":3,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/pages\/1050\/revisions"}],"predecessor-version":[{"id":1053,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/pages\/1050\/revisions\/1053"}],"up":[{"embeddable":true,"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/pages\/1029"}],"wp:attachment":[{"href":"https:\/\/fatsquirrel.org\/oldfartsalmanac\/wp-json\/wp\/v2\/media?parent=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}