<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23601">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">transport: Pass status word interpreter to exception handler<br><br>Prior to this patch, any SwMatchError raised within the 'transport'<br>would not be interpreted.<br><br>EXCEPTION of type 'SwMatchError' occurred with message: 'SW match failed! Expected 9000 and got 6982.'<br><br>vs (now)<br><br>EXCEPTION of type 'SwMatchError' occurred with message: 'SW match failed! Expected 9000 and got 6982: Command not allowed - Security status not satisfied'<br><br>Change-Id: I08b7f2b6bd422f7f2f36094bc8a29b187ff882a6<br>---<br>M pySim-shell.py<br>M pySim/transport/__init__.py<br>2 files changed, 9 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/01/23601/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 ae8a5a2..e73ec35 100755</span><br><span>--- a/pySim-shell.py</span><br><span>+++ b/pySim-shell.py</span><br><span>@@ -433,6 +433,8 @@</span><br><span>    profile.add_application(CardApplicationISIM)</span><br><span> </span><br><span>     rs = RuntimeState(card, profile)</span><br><span style="color: hsl(120, 100%, 40%);">+      # inform the transport that we can do context-specific SW interpretation</span><br><span style="color: hsl(120, 100%, 40%);">+      sl.set_sw_interpreter(rs)</span><br><span> </span><br><span>        # FIXME: do this dynamically</span><br><span>         rs.mf.add_file(DF_TELECOM())</span><br><span>diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py</span><br><span>index 10475c7..ea774cf 100644</span><br><span>--- a/pySim/transport/__init__.py</span><br><span>+++ b/pySim/transport/__init__.py</span><br><span>@@ -28,6 +28,12 @@</span><br><span> class LinkBase(object):</span><br><span>        """Base class for link/transport to card."""</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        sw_interpreter = None</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       def set_sw_interpreter(self, interp):</span><br><span style="color: hsl(120, 100%, 40%);">+         """Set an (optional) status word interpreter."""</span><br><span style="color: hsl(120, 100%, 40%);">+                self.sw_interpreter = interp</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>       def wait_for_card(self, timeout:int=None, newcardonly:bool=False):</span><br><span>           """Wait for a card and connect to it</span><br><span> </span><br><span>@@ -103,7 +109,7 @@</span><br><span>                rv = self.send_apdu(pdu)</span><br><span> </span><br><span>                 if not sw_match(rv[1], sw):</span><br><span style="color: hsl(0, 100%, 40%);">-                     raise SwMatchError(rv[1], sw.lower())</span><br><span style="color: hsl(120, 100%, 40%);">+                 raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)</span><br><span>           return rv</span><br><span> </span><br><span> def init_reader(opts) -> Optional[LinkBase]:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/23601">change 23601</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/+/23601"/><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: I08b7f2b6bd422f7f2f36094bc8a29b187ff882a6 </div>
<div style="display:none"> Gerrit-Change-Number: 23601 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>