<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/26164">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">filesystem: define class byte and select control bytes in profile<br><br>The class byte and the select control bytes are different for SIM cards<br>and UICC cards. Lets define those parameters in the card profile, so<br>that we always get the correct parameters depending on which profile we<br>use.<br><br>Change-Id: I2d175e28bd748a4871b1373273b3a9be9ae8c4d0<br>Related: OS#5274<br>---<br>M pySim/filesystem.py<br>M pySim/ts_102_221.py<br>M pySim/ts_51_011.py<br>3 files changed, 11 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/64/26164/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/filesystem.py b/pySim/filesystem.py</span><br><span>index 3297858..75cd210 100644</span><br><span>--- a/pySim/filesystem.py</span><br><span>+++ b/pySim/filesystem.py</span><br><span>@@ -1068,6 +1068,11 @@</span><br><span>         self.card = card</span><br><span>         self.selected_file = self.mf # type: CardDF</span><br><span>         self.profile = profile</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        # make sure the class and selection control bytes, which are specified</span><br><span style="color: hsl(120, 100%, 40%);">+        # by the card profile are used</span><br><span style="color: hsl(120, 100%, 40%);">+        self.card.set_apdu_parameter(cla=self.profile.cla, sel_ctrl=self.profile.sel_ctrl)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>         # add application ADFs + MF-files from profile</span><br><span>         apps = self._match_applications()</span><br><span>         for a in apps:</span><br><span>@@ -1453,6 +1458,8 @@</span><br><span>             applications : List of CardApplications present on card</span><br><span>             sw : List of status word definitions</span><br><span>             shell_cmdsets : List of cmd2 shell command sets of profile-specific commands</span><br><span style="color: hsl(120, 100%, 40%);">+            cla : class byte that should be used with cards of this profile</span><br><span style="color: hsl(120, 100%, 40%);">+            sel_ctrl : selection control bytes class byte that should be used with cards of this profile</span><br><span>         """</span><br><span>         self.name = name</span><br><span>         self.desc = kw.get("desc", None)</span><br><span>@@ -1460,6 +1467,8 @@</span><br><span>         self.sw = kw.get("sw", [])</span><br><span>         self.applications = kw.get("applications", [])</span><br><span>         self.shell_cmdsets = kw.get("shell_cmdsets", [])</span><br><span style="color: hsl(120, 100%, 40%);">+        self.cla = kw.get("cla", "00")</span><br><span style="color: hsl(120, 100%, 40%);">+        self.sel_ctrl = kw.get("sel_ctrl", "0004")</span><br><span> </span><br><span>     def __str__(self):</span><br><span>         return self.name</span><br><span>diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py</span><br><span>index b763f0f..f86a8b3 100644</span><br><span>--- a/pySim/ts_102_221.py</span><br><span>+++ b/pySim/ts_102_221.py</span><br><span>@@ -534,7 +534,7 @@</span><br><span>             },</span><br><span>           }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        super().__init__('UICC', desc='ETSI TS 102 221', files_in_mf=files, sw=sw)</span><br><span style="color: hsl(120, 100%, 40%);">+        super().__init__('UICC', desc='ETSI TS 102 221', cla="00", sel_ctrl="0004", files_in_mf=files, sw=sw)</span><br><span> </span><br><span>     def decode_select_response(self, data_hex:str) -> Any:</span><br><span>         return pySim.ts_102_221_select.decode_select_response(data_hex)</span><br><span>diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py</span><br><span>index a00cf0d..c146a79 100644</span><br><span>--- a/pySim/ts_51_011.py</span><br><span>+++ b/pySim/ts_51_011.py</span><br><span>@@ -976,7 +976,6 @@</span><br><span> </span><br><span> class CardProfileSIM(CardProfile):</span><br><span>     def __init__(self):</span><br><span style="color: hsl(0, 100%, 40%);">-        super().__init__('SIM', desc='GSM SIM Card', files_in_mf=[DF_TELECOM(), DF_GSM()])</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+        super().__init__('SIM', desc='GSM SIM Card', cla="a0", sel_ctrl="0000", files_in_mf=[DF_TELECOM(), DF_GSM()])</span><br><span>     def decode_select_response(self, data_hex:str) -> Any:</span><br><span>         return _decode_select_response(data_hex)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/26164">change 26164</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/+/26164"/><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: I2d175e28bd748a4871b1373273b3a9be9ae8c4d0 </div>
<div style="display:none"> Gerrit-Change-Number: 26164 </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>