<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Smartcard on Colin O'Flynn</title><link>https://colinoflynn.com/tag/smartcard/</link><description>Recent content in Smartcard on Colin O'Flynn</description><generator>Hugo</generator><language>en-ca</language><lastBuildDate>Sat, 18 Feb 2023 02:20:58 +0000</lastBuildDate><atom:link href="https://colinoflynn.com/tag/smartcard/index.xml" rel="self" type="application/rss+xml"/><item><title>JCOP</title><link>https://colinoflynn.com/2013/03/jcop/</link><pubDate>Fri, 01 Mar 2013 11:23:00 +0000</pubDate><guid>https://colinoflynn.com/2013/03/jcop/</guid><description>&lt;p&gt;I recently bought some Smart Cards from [[http://www.smartcardsource.com/contents/en-ca/d9_JCOP-NXP-cards.html and has some comments/issues getting them up and running. They were NXP JCOP Cards, J2A040.&lt;/p&gt;
&lt;h2 id="round-1-gp-shell-and-card-personalization"&gt;Round 1: GP Shell and Card Personalization&lt;/h2&gt;
&lt;p&gt;I was using GPShell for my initial tests, you can download from [[http://sourceforge.net/projects/globalplatform/files/|Here. There is a good [[http://sourceforge.net/p/globalplatform/wiki/Home/|Wiki too.
The first test was attempting to list all the things already on the card. The results were less than satisfactory:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;C:\&amp;gt;GPShell-1.4.4&amp;gt;GPShell.exe listgp211.txt
mode_211
enable_trace
establish_context
card_connect -readerNumber 1
select -AID a000000003000000
Command -&amp;gt; 00A4040008A000000003000000
Wrapped command -&amp;gt; 00A4040008A000000003000000
Response &amp;lt;- 6A82
select_application() returns 0x80216A82 (6A82: The application to be selected could not be found.)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As it turns out you need to have the cards personalized (or fused) before you can use them. With GP 2.1.1 you can check this with the following script:&lt;/p&gt;</description></item><item><title>AtMega Card (Funcard) SmartCard Programming &amp; Fuse Setup</title><link>https://colinoflynn.com/2012/09/atmega-card-funcard-smartcard-programming-fuse-setup-2/</link><pubDate>Fri, 28 Sep 2012 22:32:00 +0000</pubDate><guid>https://colinoflynn.com/2012/09/atmega-card-funcard-smartcard-programming-fuse-setup-2/</guid><description>&lt;p&gt;I recently got an Atmel AtMega163-based smartcard for some side channel experiments, along with a SASEBO-W board. I owe a debt of thanks to Cryptography Research Inc. &amp;amp; Sakura for setting all that up!
Anyway I also got a normal smartcard reader, and wanted to experiment with programming the card &amp;amp; using it in a reader. I&amp;rsquo;m using &lt;a href="http://www.mbsks.franken.de/sosse/"&gt;SOSSE&lt;/a&gt; for these experiments.
It&amp;rsquo;s worth nothing these cards are pretty old now! They were used a bunch in the hayday of satellite hacking&amp;hellip; I don&amp;rsquo;t know if that&amp;rsquo;s still going on, but you might be able to pick some up pretty easy. The AtMega163 processor itself was EOLd in 2002 (10 years ago!!), so I&amp;rsquo;m also sceptical if there are any new ones made. Note you can use any AVR &amp;amp; program it with the SOSSE code, the SmartCard is just a form factor.
Internally, the SmartCard has this schematic:
&lt;img src="https://colinoflynn.com/oldsite/tiki-download_file.php?fileId=42&amp;amp;display" alt="Image"&gt;
The pinout of the card contact is looking AT the card. The easy way to figure it out is look for the GND contact, note how it covers the middle part.
What this means is you can use any old AVR programmer. I had a JTAG2 so could use that in ISP mode, although you can find an &lt;a href="http://www.makomk.com/2010/02/04/arduino-based-funcard-programmer/%7CArduino"&gt;http://www.makomk.com/2010/02/04/arduino-based-funcard-programmer/|Arduino&lt;/a&gt; based Funcard Programmer] too. Remember you can use any AVR programmer that supports the Mega163 (more on this later). Your normal AVR programmer probably has a &lt;a href="http://www.batsocks.co.uk/readme/isp_headers.htm"&gt;6-pin or 10-pin header&lt;/a&gt;, so you just map between them.
Note you also need a clock! This is besides the SCK pin - you also need to provide a fast clock into the &amp;lsquo;CLK&amp;rsquo; pin. If you have another AVR around program the &amp;lsquo;CLKOUT&amp;rsquo; fuse &amp;amp; take the clock on the output pin, that is by far the easiest. Or you can use the timer to generate an output pin (see the Arduino programmer, it does that). Alternatively if you have an AVR with a crystal, you can pick off the XTAL2 (not XTAL1) pin and feed that in. Here is a photo of my setup&amp;hellip; I&amp;rsquo;m using the SASEBO-W board for power. I&amp;rsquo;ve fed an external clock in (it does provide a clock, but I tri-stated it because I needed the IO lines tri-stated too) from an AVR using the XTAL2 trick. Finally you can see the cable to the programmer:
&lt;img src="https://colinoflynn.com/oldsite/tiki-download_file.php?fileId=43&amp;amp;display" alt="Image"&gt;
So what software to program with? avrdude claims to support the Mega163, so you could use that. Although my tests showed it did not work - FLASH couldn&amp;rsquo;t be verified, and the fuses didn&amp;rsquo;t read properly (not good - if SafeMode asks you to change fuses back say NO!).
AVRStudio doesn&amp;rsquo;t support the Mega163. BUT - you can use the Mega363, which is essentially the same part. I used AVR Studio 4 for my programming &amp;amp; verification&amp;hellip; worked perfect! Programmed both Fuses &amp;amp; FLASH.
One final problem: my SCR335 card reader didn&amp;rsquo;t recognize the smartcard. It turns out the default fuses have the clock mode as &amp;ldquo;Crystal Oscillator, Slowly Rising Power&amp;rdquo; (see Fuses tab in AVR Studio). While the &lt;a href="http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-3.aspx"&gt;SmartCard Specs&lt;/a&gt; say the Answer To Reset (ATR) needs to occur 400-40000 cycles after the SmartCard reader resets the card &amp;amp; starts the clock. At 67mS delay, that is 268000 cycles! So the SmartCard reader doesn&amp;rsquo;t even see the ATR, it&amp;rsquo;s given up already. You need to change the fuse to &amp;lsquo;fast rising power&amp;rsquo;. I also switched it to &amp;lsquo;Ext. Clock&amp;rsquo;, as it&amp;rsquo;s technically the correct option since you don&amp;rsquo;t have a crystal oscillator (e.g.: you don&amp;rsquo;t need the XTAL2 output).
&lt;img src="https://colinoflynn.com/oldsite/tiki-download_file.php?fileId=44&amp;amp;display" alt="Image"&gt;
Good Luck!&lt;/p&gt;</description></item></channel></rss>