<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23423">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">commands: better exception string for authentication failures<br><br>At the moment we use the send_apdu_checksw() method to send the APDU for<br>ADM authentication. This method only checks if the command returns with<br>sw = 9000. If not it raises an exception that the sw is not as expected.<br>The user may think that this is a problem with thr reader, pcscd or<br>pySim in the first place and may try multiple times until the card is<br>permanently locked. A better execption string that also displays the<br>tries which are left may be helpful.<br><br>Change-Id: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13<br>Related: OS#4963<br>---<br>M pySim/commands.py<br>1 file changed, 4 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/23/23423/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/commands.py b/pySim/commands.py</span><br><span>index 2fb1041..9aed588 100644</span><br><span>--- a/pySim/commands.py</span><br><span>+++ b/pySim/commands.py</span><br><span>@@ -205,4 +205,7 @@</span><br><span> </span><br><span>      def verify_chv(self, chv_no, code):</span><br><span>          fc = rpad(b2h(code), 16)</span><br><span style="color: hsl(0, 100%, 40%);">-                return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)</span><br><span style="color: hsl(120, 100%, 40%);">+             data, sw = self._tp.send_apdu(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)</span><br><span style="color: hsl(120, 100%, 40%);">+         if (sw != '9000'):</span><br><span style="color: hsl(120, 100%, 40%);">+                    raise RuntimeError('Failed to authenticate with ADM key %s, %i tries left.' % (code, int(sw[3])))</span><br><span style="color: hsl(120, 100%, 40%);">+             return (data,sw)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/23423">change 23423</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/+/23423"/><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: Icf428831094f8c1045eefaa8cb2b92e6a36b0c13 </div>
<div style="display:none"> Gerrit-Change-Number: 23423 </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>