Change in pysim[master]: filesystem: define class byte and select control bytes in profile

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Nov 8 15:46:25 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/26164 )


Change subject: filesystem: define class byte and select control bytes in profile
......................................................................

filesystem: define class byte and select control bytes in profile

The class byte and the select control bytes are different for SIM cards
and UICC cards. Lets define those parameters in the card profile, so
that we always get the correct parameters depending on which profile we
use.

Change-Id: I2d175e28bd748a4871b1373273b3a9be9ae8c4d0
Related: OS#5274
---
M pySim/filesystem.py
M pySim/ts_102_221.py
M pySim/ts_51_011.py
3 files changed, 11 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/64/26164/1

diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 3297858..75cd210 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1068,6 +1068,11 @@
         self.card = card
         self.selected_file = self.mf # type: CardDF
         self.profile = profile
+
+        # make sure the class and selection control bytes, which are specified
+        # by the card profile are used
+        self.card.set_apdu_parameter(cla=self.profile.cla, sel_ctrl=self.profile.sel_ctrl)
+
         # add application ADFs + MF-files from profile
         apps = self._match_applications()
         for a in apps:
@@ -1453,6 +1458,8 @@
             applications : List of CardApplications present on card
             sw : List of status word definitions
             shell_cmdsets : List of cmd2 shell command sets of profile-specific commands
+            cla : class byte that should be used with cards of this profile
+            sel_ctrl : selection control bytes class byte that should be used with cards of this profile
         """
         self.name = name
         self.desc = kw.get("desc", None)
@@ -1460,6 +1467,8 @@
         self.sw = kw.get("sw", [])
         self.applications = kw.get("applications", [])
         self.shell_cmdsets = kw.get("shell_cmdsets", [])
+        self.cla = kw.get("cla", "00")
+        self.sel_ctrl = kw.get("sel_ctrl", "0004")
 
     def __str__(self):
         return self.name
diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index b763f0f..f86a8b3 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -534,7 +534,7 @@
             },
           }
 
-        super().__init__('UICC', desc='ETSI TS 102 221', files_in_mf=files, sw=sw)
+        super().__init__('UICC', desc='ETSI TS 102 221', cla="00", sel_ctrl="0004", files_in_mf=files, sw=sw)
 
     def decode_select_response(self, data_hex:str) -> Any:
         return pySim.ts_102_221_select.decode_select_response(data_hex)
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index a00cf0d..c146a79 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -976,7 +976,6 @@
 
 class CardProfileSIM(CardProfile):
     def __init__(self):
-        super().__init__('SIM', desc='GSM SIM Card', files_in_mf=[DF_TELECOM(), DF_GSM()])
-
+        super().__init__('SIM', desc='GSM SIM Card', cla="a0", sel_ctrl="0000", files_in_mf=[DF_TELECOM(), DF_GSM()])
     def decode_select_response(self, data_hex:str) -> Any:
 	    return _decode_select_response(data_hex)

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/26164
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2d175e28bd748a4871b1373273b3a9be9ae8c4d0
Gerrit-Change-Number: 26164
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211108/f33494ca/attachment.htm>


More information about the gerrit-log mailing list