<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Domi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thank you for the link!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">So am I right in concluding that the SIM has a PIN associated with it and I’m not sending the correct one (from the code it looks like it’s sending “DDDDDDDD”
 as the default since I’m not specifying it in the command line)?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks again,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Billy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Tomcsányi Domonkos [mailto:domi@tomcsanyi.net]
<br>
<b>Sent:</b> Wednesday, September 27, 2017 12:08 PM<br>
<b>To:</b> Billy Jones<br>
<b>Cc:</b> openbsc@lists.osmocom.org<br>
<b>Subject:</b> Re: pySim inconsistent on seemingly identical SIM cards<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Billy,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here you go:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://eftlab.co.uk/index.php/site-map/knowledge-base/118-apdu-response-list">https://eftlab.co.uk/index.php/site-map/knowledge-base/118-apdu-response-list</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Good luck!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Domi<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">2017. szept. 27. dátummal, 17:50 időpontban Billy Jones <<a href="mailto:wljones@praxiseng.com">wljones@praxiseng.com</a>> írta:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">I have two SIM card I inheritted from a previous project that I've been told came from the same vendor.  When I run `pcsc_scan` on them, I get the following output for both:<br>
<br>
Reader 0: OMNIKEY CardMan (076B:3022) 3021 00 00<br>
  Card state: Card inserted,<span class="apple-converted-space"> </span><br>
  ATR: 3B 7D 94 00 00 55 55 53 0A 74 86 93 0B 24 7C 4D 54 68<br>
<br>
ATR: 3B 7D 94 00 00 55 55 53 0A 74 86 93 0B 24 7C 4D 54 68<br>
+ TS = 3B --> Direct Convention<br>
+ T0 = 7D, Y(1): 0111, K: 13 (historical bytes)<br>
  TA(1) = 94 --> Fi=512, Di=8, 64 cycles/ETU<br>
    62500 bits/s at 4 MHz, fMax for Fi = 5 MHz => 78125 bits/s<br>
  TB(1) = 00 --> VPP is not electrically connected<br>
  TC(1) = 00 --> Extra guard time: 0<br>
+ Historical bytes: 55 55 53 0A 74 86 93 0B 24 7C 4D 54 68<br>
  Category indicator byte: 55 (proprietary format)<br>
<br>
Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):<br>
3B 7D 94 00 00 55 55 53 0A 74 86 93 0B 24 7C 4D 54 68<br>
    SIM from sysmocom sysmoSIM-GR2<br>
<br>
When I try to program one of the SIMs, it works fine:<br>
<br>
$ sudo ./pySim-prog.py -p 0 -i 001010000000001 -k ffffffffffffffffffffffffffffffff -t sysmoSIM-GR2 --num=1 --mcc=001 --mnc=01<br>
Insert card now (or CTRL-C to cancel)<br>
Generated card parameters :<br>
 > Name    : Magic<br>
 > SMSP    : e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000<br>
 > ICCID   : 8901001010000000017<br>
 > MCC/MNC : 1/1<br>
 > IMSI    : 001010000000001<br>
 > Ki      : ffffffffffffffffffffffffffffffff<br>
 > OPC     : f134b55cea2942ebbd213c82e084be62<br>
 > ACC     : None<br>
<br>
Programming ...<br>
Done !<br>
<br>
But on the other I get:<br>
<br>
$ sudo ./pySim-prog.py -p 0 -i 001010000000001 -k ffffffffffffffffffffffffffffffff -t sysmoSIM-GR2 --num=1 --mcc=001 --mnc=01<br>
<br>
Insert card now (or CTRL-C to cancel)<br>
Generated card parameters :<br>
 > Name    : Magic<br>
 > SMSP    : e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000<br>
 > ICCID   : 8901001010000000017<br>
 > MCC/MNC : 1/1<br>
 > IMSI    : 001010000000001<br>
 > Ki      : ffffffffffffffffffffffffffffffff<br>
 > OPC     : 53945a5223e299bf6cec05911922442c<br>
 > ACC     : None<br>
<br>
Programming ...<br>
Traceback (most recent call last):<br>
  File "./pySim-prog.py", line 636, in <module><br>
    card.program(cp)<br>
  File "/home/user/workspace/pysim/pySim/cards.py", line 382, in program<br>
    self._scc.verify_chv(0x05, pin)<br>
  File "/home/user/workspace/pysim/pySim/commands.py", line 111, in verify_chv<br>
    return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)<br>
  File "/home/user/workspace/pysim/pySim/transport/__init__.py", line 87, in send_apdu_checksw<br>
    raise RuntimeError("SW match failed ! Expected %s and got %s." % (sw.lower(), rv[1]))<br>
RuntimeError: SW match failed ! Expected 9000 and got 9840.<br>
<br>
<br>
I also tried some of the other branches, as people on other forums had reported better luck with those, but I get the same error.  Is there any documentation explaining the magic byte values that are sent back and forth to the card?  I'm having a hard time
 understanding the spec by which the program is trying too communicate with the card.<br>
<br>
Any help is greatly appreciated.<br>
<br>
Thanks,<br>
Billy<o:p></o:p></span></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>