<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/25804">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pySim-shell: do not use usim/isim APDUs in the beginnning<br><br>Some simcards like sysmo-usim-sjs1 and sysmo-usim-sja2 might tolerate it<br>when USIM or ISIM APDUs are used without selecting either the ISIM or<br>USIM application first. However, this tolerance is not specified. As<br>long as no USIM or ISIM application is selected it is not guaranteed<br>that the card will accept APDUs with class byte 0x00. It might be that<br>only class 0x0A APDUs are accepted.<br><br>To make pySim-shell more spec complient lets start with 0x0A class byte<br>and 0x00 for p1 and p2 during select. With this setting we will read out<br>the application identifiers. Then we select the first USIM or ISIM<br>application on the card. For this we will change to 0x00 and 0x04 for p2<br>during select.<br><br>Change-Id: I985261a1bddae60ffeaccb9c8d8d1b8a2ae4d0fc<br>---<br>M pySim-shell.py<br>1 file changed, 23 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/04/25804/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim-shell.py b/pySim-shell.py</span><br><span>index 9258bd6..a0031a5 100755</span><br><span>--- a/pySim-shell.py</span><br><span>+++ b/pySim-shell.py</span><br><span>@@ -78,8 +78,13 @@</span><br><span> </span><br><span>  card = card_detect("auto", scc)</span><br><span>    if card is None:</span><br><span style="color: hsl(0, 100%, 40%);">-                print("Could not detect card type!")</span><br><span style="color: hsl(0, 100%, 40%);">-          return None, None;</span><br><span style="color: hsl(120, 100%, 40%);">+            print("Warning: Could not detect card type, assuming generic SIM card type!")</span><br><span style="color: hsl(120, 100%, 40%);">+               card = SimCard(scc);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        # Until no USIM or ISIM application is selected, we will use only</span><br><span style="color: hsl(120, 100%, 40%);">+     # classic 3GPP TS 51.011 class APDUs.</span><br><span style="color: hsl(120, 100%, 40%);">+ scc.cla_byte = "a0"</span><br><span style="color: hsl(120, 100%, 40%);">+ scc.sel_ctrl = "0000"</span><br><span> </span><br><span>  # Create runtime state with card profile</span><br><span>     profile = CardProfileUICC()</span><br><span>@@ -87,6 +92,19 @@</span><br><span>     profile.add_application(CardApplicationISIM)</span><br><span>         rs = RuntimeState(card, profile)</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  # Select the first application on the card.</span><br><span style="color: hsl(120, 100%, 40%);">+   aids_card = card.read_aids()</span><br><span style="color: hsl(120, 100%, 40%);">+  apps_profile = profile.applications</span><br><span style="color: hsl(120, 100%, 40%);">+   app_name = None</span><br><span style="color: hsl(120, 100%, 40%);">+       for f in apps_profile:</span><br><span style="color: hsl(120, 100%, 40%);">+                if f.aid in aids_card[0]:</span><br><span style="color: hsl(120, 100%, 40%);">+                     app_name = f.name</span><br><span style="color: hsl(120, 100%, 40%);">+     if app_name:</span><br><span style="color: hsl(120, 100%, 40%);">+          print("Selecting first application on card: " + app_name)</span><br><span style="color: hsl(120, 100%, 40%);">+           card._scc.cla_byte = "00"</span><br><span style="color: hsl(120, 100%, 40%);">+           card._scc.sel_ctrl = "0004" #request an FCP</span><br><span style="color: hsl(120, 100%, 40%);">+         rs.select("ADF." + app_name)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     # FIXME: do this dynamically</span><br><span>         rs.mf.add_file(DF_TELECOM())</span><br><span>         rs.mf.add_file(DF_GSM())</span><br><span>@@ -96,6 +114,9 @@</span><br><span>        # inform the transport that we can do context-specific SW interpretation</span><br><span>     sl.set_sw_interpreter(rs)</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ # Make sure the MF is selected after the initialization is done.</span><br><span style="color: hsl(120, 100%, 40%);">+      rs.select('MF')</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>    return rs, card</span><br><span> </span><br><span> class PysimApp(cmd2.Cmd):</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/25804">change 25804</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/25804"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I985261a1bddae60ffeaccb9c8d8d1b8a2ae4d0fc </div>
<div style="display:none"> Gerrit-Change-Number: 25804 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>