laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/37679?usp=email )


Change subject: Support EF.ICCID and EF.PL on classic TS 51.011 SIM
......................................................................

Support EF.ICCID and EF.PL on classic TS 51.011 SIM

So far we only had the EF.ICCID and EF.PL within our UICC card profile.
However, a classic GSM SIM card is not an UICC, so the CardProfileSIM
also needs those files.

To avoid circular dependencies, move the definitions from ts_102_221.py
to ts_51_011.py

Change-Id: I6eaa5b579f02c7d75f443ee2b2cc8ae0ba13f2fe
Closes: OS#6485
---
M pySim/ts_102_221.py
M pySim/ts_51_011.py
2 files changed, 64 insertions(+), 40 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/79/37679/1

diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index 211bf68..c326ad1 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -31,7 +31,7 @@

 # A UICC will usually also support 2G functionality. If this is the case, we
 # need to add DF_GSM and DF_TELECOM along with the UICC related files
-from pySim.ts_51_011 import AddonSIM
+from pySim.ts_51_011 import AddonSIM, EF_ICCID, EF_PL
 from pySim.gsm_r import AddonGSMR
 from pySim.cdma_ruim import AddonRUIM

@@ -666,44 +666,6 @@
         super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=(5, 54))
         self._tlv = EF_DIR.ApplicationTemplate

-# TS 102 221 Section 13.2
-class EF_ICCID(TransparentEF):
-    _test_de_encode = [
-        ( '988812010000400310f0', { "iccid": "8988211000000430010" } ),
-    ]
-    def __init__(self, fid='2fe2', sfid=0x02, name='EF.ICCID', desc='ICC 
Identification'):
-        super().__init__(fid, sfid=sfid, name=name, desc=desc, size=(10, 10))
-
-    def _decode_hex(self, raw_hex):
-        return {'iccid': dec_iccid(raw_hex)}
-
-    def _encode_hex(self, abstract):
-        return enc_iccid(abstract['iccid'])
-
-# TS 102 221 Section 13.3
-class EF_PL(TransRecEF):
-    _test_de_encode = [
-        ( '6465', "de" ),
-        ( '656e', "en" ),
-        ( 'ffff', None ),
-    ]
-
-    def __init__(self, fid='2f05', sfid=0x05, name='EF.PL', desc='Preferred 
Languages'):
-        super().__init__(fid, sfid=sfid, name=name,
-                         desc=desc, rec_len=2, size=(2, None))
-
-    def _decode_record_bin(self, bin_data, **kwargs):
-        if bin_data == b'\xff\xff':
-            return None
-        else:
-            return bin_data.decode('ascii')
-
-    def _encode_record_bin(self, in_json, **kwargs):
-        if in_json is None:
-            return b'\xff\xff'
-        else:
-            return in_json.encode('ascii')
-

 # TS 102 221 Section 13.4
 class EF_ARR(LinFixedEF):
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index 9b56b0e..f6bd3cc 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -955,6 +955,44 @@
         super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, 
**kwargs)


+# TS 102 221 Section 13.2 / TS 31.101 Section 13 / TS 51.011 Section 10.1.1
+class EF_ICCID(TransparentEF):
+    _test_de_encode = [
+        ( '988812010000400310f0', { "iccid": "8988211000000430010" } ),
+    ]
+    def __init__(self, fid='2fe2', sfid=0x02, name='EF.ICCID', desc='ICC 
Identification'):
+        super().__init__(fid, sfid=sfid, name=name, desc=desc, size=(10, 10))
+
+    def _decode_hex(self, raw_hex):
+        return {'iccid': dec_iccid(raw_hex)}
+
+    def _encode_hex(self, abstract):
+        return enc_iccid(abstract['iccid'])
+
+# TS 102 221 Section 13.3 / TS 31.101 Secction 13 / TS 51.011 Section 10.1.2
+class EF_PL(TransRecEF):
+    _test_de_encode = [
+        ( '6465', "de" ),
+        ( '656e', "en" ),
+        ( 'ffff', None ),
+    ]
+
+    def __init__(self, fid='2f05', sfid=0x05, name='EF.PL', desc='Preferred 
Languages'):
+        super().__init__(fid, sfid=sfid, name=name,
+                         desc=desc, rec_len=2, size=(2, None))
+
+    def _decode_record_bin(self, bin_data, **kwargs):
+        if bin_data == b'\xff\xff':
+            return None
+        else:
+            return bin_data.decode('ascii')
+
+    def _encode_record_bin(self, in_json, **kwargs):
+        if in_json is None:
+            return b'\xff\xff'
+        else:
+            return in_json.encode('ascii')
+
 class DF_GSM(CardDF):
     def __init__(self, fid='7f20', name='DF.GSM', desc='GSM Network related 
files'):
         super().__init__(fid=fid, name=name, desc=desc)
@@ -1085,12 +1123,19 @@
             },
         }

+        files = [
+            EF_ICCID(),
+            EF_PL(),
+            DF_TELECOM(),
+            DF_GSM(),
+        ]
+
         addons = [
             AddonGSMR,
         ]

         super().__init__('SIM', desc='GSM SIM Card', cla="a0",
-                         sel_ctrl="0000", files_in_mf=[DF_TELECOM(), 
DF_GSM()], sw=sw, addons = addons)
+                         sel_ctrl="0000", files_in_mf=files, sw=sw, addons = 
addons)

     @staticmethod
     def decode_select_response(resp_hex: str) -> object:

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37679?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6eaa5b579f02c7d75f443ee2b2cc8ae0ba13f2fe
Gerrit-Change-Number: 37679
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to