lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

July 2024

  • 1 participants
  • 1379 discussions
[S] Change in pysim[master]: pySim.saip: Add ProfileElementRFM class
by laforge 08 Jul '24

08 Jul '24
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/37421?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified-1 by Jenkins Builder Change subject: pySim.saip: Add ProfileElementRFM class ...................................................................... pySim.saip: Add ProfileElementRFM class Change-Id: I547e02c12345932deafa4b914fcaeaa183b69798 --- M pySim/esim/saip/__init__.py M tests/test_esim_saip.py 2 files changed, 44 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/21/37421/2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37421?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: I547e02c12345932deafa4b914fcaeaa183b69798 Gerrit-Change-Number: 37421 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in pysim[master]: tests: Add ProfileElementSD and ProfileElementSSD to test_constructor...
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37418?usp=email ) Change subject: tests: Add ProfileElementSD and ProfileElementSSD to test_constructor_encode ...................................................................... tests: Add ProfileElementSD and ProfileElementSSD to test_constructor_encode Change-Id: Idc6f37b487dfa8a69ac7a50a537cfc317113d501 --- M tests/test_esim_saip.py 1 file changed, 11 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/18/37418/1 diff --git a/tests/test_esim_saip.py b/tests/test_esim_saip.py index 704f513..4c1b936 100755 --- a/tests/test_esim_saip.py +++ b/tests/test_esim_saip.py @@ -66,7 +66,8 @@ def test_constructor_encode(self): """Test that DER-encoding of PE created by "empty" constructor works without raising exception.""" for cls in [ProfileElementMF, ProfileElementPuk, ProfileElementPin, ProfileElementTelecom, - ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA]: + ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA, ProfileElementSD, + ProfileElementSSD]: with self.subTest(cls.__name__): pes = ProfileElementSequence() inst = cls() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37418?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: Idc6f37b487dfa8a69ac7a50a537cfc317113d501 Gerrit-Change-Number: 37418 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim.saip.oid: Properly differentiate optional from non-optional tem...
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37419?usp=email ) Change subject: pySim.saip.oid: Properly differentiate optional from non-optional templates ...................................................................... pySim.saip.oid: Properly differentiate optional from non-optional templates There are e.g. templates for usim and for opt-usim, and they should not be confused with each other. Let's reflect that in the naming. Change-Id: Ic6d04ce3172dc969c6b8c018b8d305eb6fd3f550 --- M pySim/esim/saip/__init__.py M pySim/esim/saip/oid.py M pySim/esim/saip/templates.py 3 files changed, 26 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/19/37419/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 2cddbe8..6e17de3 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -54,14 +54,14 @@ aid = h2b("") mandatory_services = ["csim"] pe_types = ["csim", "opt-csim", "cdmaParameter"] - templates = [oid.ADF_CSIM_by_default, oid.ADF_CSIM_not_by_default] + templates = [oid.ADF_CSIM_by_default, oid.ADF_CSIMopt_not_by_default] class NaaUsim(Naa): name = "usim" aid = h2b("") mandatory_services = ["usim"] pe_types = ["usim", "opt-usim"] - templates = [oid.ADF_USIM_by_default, oid.ADF_USIM_not_by_default, + templates = [oid.ADF_USIM_by_default, oid.ADF_USIMopt_not_by_default, oid.DF_PHONEBOOK_ADF_USIM, oid.DF_GSM_ACCESS_ADF_USIM, oid.DF_EAP, oid.DF_5GS, oid.DF_SAIP, oid.DF_SNPN, oid.DF_5GProSe] @@ -71,7 +71,7 @@ aid = h2b("") mandatory_services = ["isim"] pe_types = ["isim", "opt-isim"] - templates = [oid.ADF_ISIM_by_default, oid.ADF_ISIM_not_by_default] + templates = [oid.ADF_ISIM_by_default, oid.ADF_ISIMopt_not_by_default] NAAs = { NaaCsim.name: NaaCsim, diff --git a/pySim/esim/saip/oid.py b/pySim/esim/saip/oid.py index d33b786..91a48c1 100644 --- a/pySim/esim/saip/oid.py +++ b/pySim/esim/saip/oid.py @@ -57,18 +57,18 @@ DF_TELECOM_v2 = eOID("2.3.2") ADF_USIM_by_default = eOID("2.4") ADF_USIM_by_default_v2 = eOID("2.4.2") -ADF_USIM_not_by_default = eOID("2.5") -ADF_USIM_not_by_default_v2 = eOID("2.5.2") -ADF_USIM_not_by_default_v3 = eOID("2.5.3") +ADF_USIMopt_not_by_default = eOID("2.5") +ADF_USIMopt_not_by_default_v2 = eOID("2.5.2") +ADF_USIMopt_not_by_default_v3 = eOID("2.5.3") DF_PHONEBOOK_ADF_USIM = eOID("2.6") DF_GSM_ACCESS_ADF_USIM = eOID("2.7") ADF_ISIM_by_default = eOID("2.8") -ADF_ISIM_not_by_default = eOID("2.9") -ADF_ISIM_not_by_default_v2 = eOID("2.9.2") +ADF_ISIMopt_not_by_default = eOID("2.9") +ADF_ISIMopt_not_by_default_v2 = eOID("2.9.2") ADF_CSIM_by_default = eOID("2.10") ADF_CSIM_by_default_v2 = eOID("2.10.2") -ADF_CSIM_not_by_default = eOID("2.11") -ADF_CSIM_not_by_default_v2 = eOID("2.11.2") +ADF_CSIMopt_not_by_default = eOID("2.11") +ADF_CSIMopt_not_by_default_v2 = eOID("2.11.2") DF_EAP = eOID("2.12") DF_5GS = eOID("2.13") DF_5GS_v2 = eOID("2.13.2") diff --git a/pySim/esim/saip/templates.py b/pySim/esim/saip/templates.py index cd76247..417c83b 100644 --- a/pySim/esim/saip/templates.py +++ b/pySim/esim/saip/templates.py @@ -318,7 +318,7 @@ # Section 9.5.2 v2.3.1 class FilesUsimOptional(ProfileTemplate): created_by_default = False - oid = OID.ADF_USIM_not_by_default + oid = OID.ADF_USIMopt_not_by_default files = [ FileTemplate(0x6f05, 'EF.LI', 'TR', None, 6, 1, 0x02, 'FF...FF', False), FileTemplate(0x6f37, 'EF.ACMmax', 'TR', None, 3, 5, None, '000000', False, ass_serv=[13], pe_name='ef-acmax'), @@ -400,7 +400,7 @@ # Section 9.5.2 class FilesUsimOptionalV2(ProfileTemplate): created_by_default = False - oid = OID.ADF_USIM_not_by_default_v2 + oid = OID.ADF_USIMopt_not_by_default_v2 files = [ FileTemplate(0x6f05, 'EF.LI', 'TR', None, 6, 1, 0x02, 'FF...FF', False), FileTemplate(0x6f37, 'EF.ACMmax', 'TR', None, 3, 5, None, '000000', False, ass_serv=[13]), @@ -601,7 +601,7 @@ # Section 9.6.2 v2.3.1 class FilesIsimOptional(ProfileTemplate): created_by_default = False - oid = OID.ADF_ISIM_not_by_default + oid = OID.ADF_ISIMopt_not_by_default files = [ FileTemplate(0x6f09, 'EF.P-CSCF', 'LF', 1, None, 2, None, None, True, ['size'], ass_serv=[1,5]), FileTemplate(0x6f3c, 'EF.SMS', 'LF', 10, 176, 5, None, '00FF...FF', False, ass_serv=[6,8]), @@ -618,7 +618,7 @@ # Section 9.6.2 class FilesIsimOptionalv2(ProfileTemplate): created_by_default = False - oid = OID.ADF_ISIM_not_by_default_v2 + oid = OID.ADF_ISIMopt_not_by_default_v2 files = [ FileTemplate(0x6f09, 'EF.PCSCF', 'LF', 1, None, 2, None, None, True, ['size'], ass_serv=[1,5]), FileTemplate(0x6f3c, 'EF.SMS', 'LF', 10, 176, 5, None, '00FF...FF', False, ass_serv=[6,8]), -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37419?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: Ic6d04ce3172dc969c6b8c018b8d305eb6fd3f550 Gerrit-Change-Number: 37419 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim.esim.saip: Add ProfileElementOpt{USIM,ISIM} classes
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37420?usp=email ) Change subject: pySim.esim.saip: Add ProfileElementOpt{USIM,ISIM} classes ...................................................................... pySim.esim.saip: Add ProfileElementOpt{USIM,ISIM} classes Change-Id: Iebff2e767baa19f272eeddc62d7d5b3a8f665db5 --- M pySim/esim/saip/__init__.py M tests/test_esim_saip.py 2 files changed, 39 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/20/37420/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 6e17de3..e87e5c0 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -270,7 +270,9 @@ 'pinCodes': ProfileElementPin, 'telecom': ProfileElementTelecom, 'usim': ProfileElementUSIM, + 'opt-usim': ProfileElementOptUSIM, 'isim': ProfileElementISIM, + 'opt-isim': ProfileElementOptISIM, 'akaParameter': ProfileElementAKA, } """Construct an instance from given raw, DER encoded bytes.""" @@ -575,6 +577,19 @@ f = File('ef-imsi', self.decoded['ef-imsi']) return dec_imsi(b2h(f.stream.getvalue())) +class ProfileElementOptUSIM(ProfileElement): + type = 'opt-usim' + + def __init__(self, decoded: Optional[dict] = None): + super().__init__() + if decoded: + self.decoded = decoded + return + # provide some reasonable defaults for a MNO-SD + self.decoded = OrderedDict() + self.decoded['optusim-header'] = { 'mandated': None, 'identification': None} + self.decoded['templateID'] = str(oid.ADF_USIMopt_not_by_default_v2) + class ProfileElementISIM(ProfileElement): type = 'isim' @@ -594,6 +609,20 @@ def adf_name(self) -> str: return b2h(self.decoded['adf-isim'][0][1]['dfName']) +class ProfileElementOptISIM(ProfileElement): + type = 'opt-isim' + + def __init__(self, decoded: Optional[dict] = None): + super().__init__() + if decoded: + self.decoded = decoded + return + # provide some reasonable defaults for a MNO-SD + self.decoded = OrderedDict() + self.decoded['optisim-header'] = { 'mandated': None, 'identification': None} + self.decoded['templateID'] = str(oid.ADF_ISIMopt_not_by_default_v2) + + class ProfileElementAKA(ProfileElement): type = 'akaParameter' diff --git a/tests/test_esim_saip.py b/tests/test_esim_saip.py index 4c1b936..5a1284e 100755 --- a/tests/test_esim_saip.py +++ b/tests/test_esim_saip.py @@ -67,7 +67,7 @@ """Test that DER-encoding of PE created by "empty" constructor works without raising exception.""" for cls in [ProfileElementMF, ProfileElementPuk, ProfileElementPin, ProfileElementTelecom, ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA, ProfileElementSD, - ProfileElementSSD]: + ProfileElementSSD, ProfileElementOptUSIM, ProfileElementOptISIM]: with self.subTest(cls.__name__): pes = ProfileElementSequence() inst = cls() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37420?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: Iebff2e767baa19f272eeddc62d7d5b3a8f665db5 Gerrit-Change-Number: 37420 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim.saip: Add ProfileElementRFM class
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37421?usp=email ) Change subject: pySim.saip: Add ProfileElementRFM class ...................................................................... pySim.saip: Add ProfileElementRFM class Change-Id: I547e02c12345932deafa4b914fcaeaa183b69798 --- M pySim/esim/saip/__init__.py M tests/test_esim_saip.py 2 files changed, 44 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/21/37421/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index e87e5c0..a71c3c8 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -553,6 +553,34 @@ 'uiccToolkitApplicationSpecificParametersField': h2b('01000001000000020112036C756500'), } +class ProfileElementRFM(ProfileElement): + type = 'rfm' + + def __init__(self, decoded: Optional[dict] = None, + inst_aid: Optional[bytes] = None, sd_aid: Optional[bytes] = None, + adf_aid: Optional[bytes] = None, + tar_list: Optional[List[bytes]] = [], msl: Optional[int] = 0x06): + super().__init__() + ADM1_ACCESS = h2b('02000100') + if decoded: + self.decoded = decoded + return + # provide some reasonable defaults for a MNO-SD + self.decoded = OrderedDict() + self.decoded['rfm-header'] = { 'mandated': None, 'identification': None} + self.decoded['instanceAID'] = inst_aid + self.decoded['securityDomainAID'] = sd_aid + self.decoded['tarList'] = tar_list + self.decoded['minimumSecurityLevel'] = bytes([msl]) + self.decoded['uiccAccessDomain'] = ADM1_ACCESS + self.decoded['uiccAdminAccessDomain'] = ADM1_ACCESS + if adf_aid: + self.decoded['adfRFMAccess'] = { + 'adfAID': aid_rfm, + 'adfAccessDomain': ADM1_ACCESS, + 'adfAdminAccessDomain': ADM1_ACCESS, + } + class ProfileElementUSIM(ProfileElement): type = 'usim' diff --git a/tests/test_esim_saip.py b/tests/test_esim_saip.py index 5a1284e..e87a073 100755 --- a/tests/test_esim_saip.py +++ b/tests/test_esim_saip.py @@ -74,6 +74,13 @@ pes.append(inst) pes.to_der() + # RFM requires some constructor arguments + cls = ProfileElementRFM + with self.subTest(cls.__name__): + pes = ProfileElementSequence() + inst = cls(inst_aid=b'\x01\x02', sd_aid=b'\x03\x04', tar_list=[b'\x01\x02\x03']) + pes.append(inst) + pes.to_der() if __name__ == "__main__": -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37421?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: I547e02c12345932deafa4b914fcaeaa183b69798 Gerrit-Change-Number: 37421 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: pySim.esim.saip: Move initialization of PE header to base class
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37422?usp=email ) Change subject: pySim.esim.saip: Move initialization of PE header to base class ...................................................................... pySim.esim.saip: Move initialization of PE header to base class Let's avoid the copy+paste in the subclass constructors and initialize the profile element header in the base class constructor. Change-Id: I6e69ae1f0d33d963247fc506db33b3840c10c19a --- M pySim/esim/saip/__init__.py 1 file changed, 36 insertions(+), 47 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/22/37422/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index a71c3c8..9c1f77d 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -197,8 +197,15 @@ 'securityDomain': 'sd-Header', } - def __init__(self, decoded = None): - self.decoded = decoded + def __init__(self, decoded = None, mandated: bool = True): + if decoded: + self.decoded = decoded + else: + self.decoded = OrderedDict() + if self.header_name: + self.decoded[self.header_name] = { 'identification': None} + if mandated: + self.decoded[self.header_name] = { 'mandated': None} def _fixup_sqnInit_dec(self) -> None: """asn1tools has a bug when working with SEQUENCE OF that have DEFAULT values. Let's work around @@ -305,13 +312,10 @@ type = 'mf' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults - self.decoded = OrderedDict() - self.decoded['mf-header'] = { 'mandated': None, 'identification': None} self.decoded['templateID'] = str(oid.MF) for fname in ['mf', 'ef-iccid', 'ef-dir', 'ef-arr']: self.decoded[fname] = [] @@ -321,13 +325,10 @@ type = 'pukCodes' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults - self.decoded = OrderedDict() - self.decoded['puk-Header'] = { 'mandated': None, 'identification': None} self.decoded['pukCodes'] = [] self.add_puk(0x01, b'11111111') self.add_puk(0x81, b'22222222') @@ -354,13 +355,10 @@ type = 'pinCodes' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults - self.decoded = OrderedDict() - self.decoded['pin-Header'] = { 'mandated': None, 'identification': None} self.decoded['pinCodes'] = ('pinconfig', []) self.add_pin(0x01, b'0000\xff\xff\xff\xff', unblock_ref=1, pin_attrib=6) self.add_pin(0x10, b'11111111', pin_attrib=3) @@ -393,13 +391,10 @@ type = 'telecom' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['telecom-header'] = { 'mandated': None, 'identification': None} self.decoded['templateID'] = str(oid.DF_TELECOM_v2) for fname in ['df-telecom', 'ef-arr']: self.decoded[fname] = [] @@ -467,12 +462,10 @@ pass def __init__(self, decoded: Optional[dict] = None): + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['sd-Header'] = { 'mandated': None, 'identification': None } self.decoded['instance'] = { 'applicationLoadPackageAID': h2b('A0000001515350'), 'classAID': h2b('A000000251535041'), @@ -543,8 +536,10 @@ class ProfileElementSSD(ProfileElementSD): """Class representing a securityDomain ProfileElement for a SSD.""" - def __init__(self): - super().__init__() + def __init__(self, decoded: Optional[dict] = None): + super().__init__(decoded) + if decoded: + return # defaults [overriding ProfileElementSD) taken from SAIP v2.3.1 Section 11.2.12 self.decoded['instance']['instanceAID'] = h2b('A00000055910100102736456616C7565') self.decoded['instance']['applicationPrivileges'] = h2b('808000') @@ -560,14 +555,11 @@ inst_aid: Optional[bytes] = None, sd_aid: Optional[bytes] = None, adf_aid: Optional[bytes] = None, tar_list: Optional[List[bytes]] = [], msl: Optional[int] = 0x06): - super().__init__() + super().__init__(decoded) ADM1_ACCESS = h2b('02000100') if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['rfm-header'] = { 'mandated': None, 'identification': None} self.decoded['instanceAID'] = inst_aid self.decoded['securityDomainAID'] = sd_aid self.decoded['tarList'] = tar_list @@ -585,13 +577,10 @@ type = 'usim' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['usim-header'] = { 'mandated': None, 'identification': None} self.decoded['templateID'] = str(oid.ADF_USIM_by_default_v2) for fname in ['adf-usim', 'ef-imsi', 'ef-arr', 'ef-ust', 'ef-spn', 'ef-est', 'ef-acc', 'ef-ecc']: self.decoded[fname] = [] @@ -609,26 +598,20 @@ type = 'opt-usim' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['optusim-header'] = { 'mandated': None, 'identification': None} self.decoded['templateID'] = str(oid.ADF_USIMopt_not_by_default_v2) class ProfileElementISIM(ProfileElement): type = 'isim' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['isim-header'] = { 'mandated': None, 'identification': None} self.decoded['templateID'] = str(oid.ADF_ISIM_by_default) for fname in ['adf-isim', 'ef-impi', 'ef-impu', 'ef-domain', 'ef-ist', 'ef-arr']: self.decoded[fname] = [] @@ -641,13 +624,10 @@ type = 'opt-isim' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['optisim-header'] = { 'mandated': None, 'identification': None} self.decoded['templateID'] = str(oid.ADF_ISIMopt_not_by_default_v2) @@ -655,13 +635,10 @@ type = 'akaParameter' def __init__(self, decoded: Optional[dict] = None): - super().__init__() + super().__init__(decoded) if decoded: - self.decoded = decoded return # provide some reasonable defaults for a MNO-SD - self.decoded = OrderedDict() - self.decoded['aka-header'] = { 'mandated': None, 'identification': None} self.set_milenage(b'\x00'*16, b'\x00'*16) def set_milenage(self, k: bytes, opc: bytes): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37422?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: I6e69ae1f0d33d963247fc506db33b3840c10c19a Gerrit-Change-Number: 37422 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim.esim.saip: ProfileElement{Header,End} classes
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37423?usp=email ) Change subject: pySim.esim.saip: ProfileElement{Header,End} classes ...................................................................... pySim.esim.saip: ProfileElement{Header,End} classes Change-Id: I88e18c1ee4907eeac3ae5d04d7bc30d6765f91fa --- M pySim/esim/saip/__init__.py M tests/test_esim_saip.py 2 files changed, 39 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/23/37423/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 9c1f77d..2fe08ec 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -22,7 +22,7 @@ import asn1tools -from pySim.utils import bertlv_parse_tag, bertlv_parse_len, b2h, h2b, dec_imsi +from pySim.utils import bertlv_parse_tag, bertlv_parse_len, b2h, h2b, dec_imsi, Hexstr from pySim.ts_102_221 import FileDescriptor from pySim.construct import build_construct from pySim.esim import compile_asn1_subdir @@ -187,6 +187,7 @@ # names, so we have to manually translate the exceptions here... header_name_translation_dict = { 'header': None, + 'end': 'end-header', 'genericFileManagement': 'gfm-header', 'akaParameter': 'aka-header', 'cdmaParameter': 'cdma-header', @@ -281,6 +282,8 @@ 'isim': ProfileElementISIM, 'opt-isim': ProfileElementOptISIM, 'akaParameter': ProfileElementAKA, + 'header': ProfileElementHeader, + 'end': ProfileElementEnd, } """Construct an instance from given raw, DER encoded bytes.""" pe_type, decoded = asn1.decode('ProfileElement', der) @@ -676,6 +679,30 @@ 'mappingSource': aid, }) +class ProfileElementHeader(ProfileElement): + type = 'header' + def __init__(self, decoded: Optional[dict] = None, + ver_major: Optional[int] = 2, ver_minor: Optional[int] = 3, + iccid: Optional[Hexstr] = '0'*20, profile_type: Optional[str] = None): + super().__init__(decoded) + if decoded: + return + # provide some reasonable defaults + self.decoded = { + 'major-version': ver_major, + 'minor-version': ver_minor, + 'iccid': h2b(iccid), + 'eUICC-Mandatory-services': {}, # needs to be recomputed at the end + 'eUICC-Mandatory-GFSTEList': [], # needs to be recomputed at the end + } + if profile_type: + self.decoded['profileType'] = profile_type + +class ProfileElementEnd(ProfileElement): + type = 'end' + def __init__(self, decoded: Optional[dict] = None): + super().__init__(decoded) + def bertlv_first_segment(binary: bytes) -> Tuple[bytes, bytes]: """obtain the first segment of a binary concatenation of BER-TLV objects. Returns: tuple of first TLV and remainder.""" diff --git a/tests/test_esim_saip.py b/tests/test_esim_saip.py index e87a073..82ed692 100755 --- a/tests/test_esim_saip.py +++ b/tests/test_esim_saip.py @@ -67,7 +67,8 @@ """Test that DER-encoding of PE created by "empty" constructor works without raising exception.""" for cls in [ProfileElementMF, ProfileElementPuk, ProfileElementPin, ProfileElementTelecom, ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA, ProfileElementSD, - ProfileElementSSD, ProfileElementOptUSIM, ProfileElementOptISIM]: + ProfileElementSSD, ProfileElementOptUSIM, ProfileElementOptISIM, + ProfileElementHeader, ProfileElementEnd]: with self.subTest(cls.__name__): pes = ProfileElementSequence() inst = cls() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37423?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: I88e18c1ee4907eeac3ae5d04d7bc30d6765f91fa Gerrit-Change-Number: 37423 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: pySim.esim.saip: Add methods to rebuild "mandatory" lists in ProfileH...
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37424?usp=email ) Change subject: pySim.esim.saip: Add methods to rebuild "mandatory" lists in ProfileHeader ...................................................................... pySim.esim.saip: Add methods to rebuild "mandatory" lists in ProfileHeader The ProfileHeader PE contain lists of template-oids and services that are mandatory in this profile. Let's add methods that can be used to (re-) compute those lists based on the actual PE contents of the sequence. The idea is that during programmatic construction of a profile, those methods would be called after appending all PEs, just before encoding the profile as DER. Change-Id: Ib43db8695c6eb63965756364fda7546d82df0beb --- M pySim/esim/saip/__init__.py 1 file changed, 88 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/24/37424/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 2fe08ec..9a58f76 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -787,6 +787,76 @@ self.pes_by_naa[cur_naa] = [] self.pes_by_naa[cur_naa].append(cur_naa_list) + def rebuild_mandatory_services(self): + """(Re-)build the eUICC Mandatory services list of the ProfileHeader based on what's in the + PE-Sequence.""" + # services that we cannot auto-determine and which must hence be manually specified + manual_services = ['contactless', 'mbms', 'cat-tp', 'suciCalculatorApi', 'dns-resolution', + 'scp11ac', 'scp11c-authorization-mechanism', 's16mode', 'eaka'] + svc_set = set() + # rebuild mandatory NAAs + for naa in self.pes_by_naa.keys(): + if naa not in ['usim', 'isim', 'csim']: + continue + # see if any of the instances is mandatory + for inst in self.pes_by_naa[naa]: + if 'mandated' in inst[0].header: + svc_set.add(naa) + # rebuild algorithms of all mandatory akaParameters + for aka in self.get_pes_for_type('akaParameter'): + if 'mandated' in aka.header: + if aka.decoded['algoConfiguration'][0] == 'algoParameter': + algo_par = aka.decoded['algoConfiguration'][1] + algo_id = algo_par['algorithmID'] + if algo_id == 1: + svc_set.add('milenage') + elif algo_id == 2: + if len(algo_par['key']) == 32: + svc_set.add('tuak256') + else: + svc_set.add('tuak128') + elif algo_id == 3: + svc_set.add('usim-test-algorithm') + # rebuild algorithms of all mandatory cdmaParameter + for cdma in self.get_pes_for_type('cdmaParameter'): + if 'mandated' in cdma.header: + svc_set.add('cave') + # TODO: gba-{usim,isim} (determine from EF.GBA* ?) + # determine if EAP is mandatory + for eap in self.get_pes_for_type('eap'): + if 'mandated' in eap.header: + svc_set.add('eap') + # determine if javacard is mandatory + for app in self.get_pes_for_type('application'): + if 'mandated' in app.header: + # javacard / multos distinction is not automatically possible, but multos is hypothetical + svc_set.add('javacard') + # recompute multiple-{usim,isim,csim} + for naa_name in ['usim','isim','csim']: + if naa_name in self.pes_by_naa[naa]: + if len(self.pes_by_naa[naa]) > 1: + svc_set.add('multiple-' + naa_name) + # TODO: BER-TLV (scan all files for related type?) + # TODO: dfLinked files (scan all files, check for non-empty Fcp.linkPath presence of DFs) + # TODO: 5G related bits (derive from EF.UST or file presence?) + hdr_pe = self.get_pe_for_type('header') + # patch in the 'manual' services from the existing list: + for old_svc in hdr_pe.decoded['eUICC-Mandatory-services'].keys(): + if old_svc in manual_services: + svc_set.add(old_svc) + hdr_pe.decoded['eUICC-Mandatory-services'] = {x: None for x in svc_set} + + def rebuild_mandatory_gfstelist(self): + """(Re-)build the eUICC Mandatory GFSTEList of the ProfileHeader based on what's in the + PE-Sequence.""" + template_set = set() + for pe in self.pe_list: + if pe.header and 'mandated' in pe.header: + if 'templateID' in pe.decoded: + template_set.add(pe.decoded['templateID']) + hdr_pe = self.get_pe_for_type('header') + hdr_pe.decoded['eUICC-Mandatory-GFSTEList'] = list(template_set) + @classmethod def from_der(cls, der: bytes) -> 'ProfileElementSequence': """Construct an instance from given raw, DER encoded bytes.""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37424?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: Ib43db8695c6eb63965756364fda7546d82df0beb Gerrit-Change-Number: 37424 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in pysim[master]: pySim.esim.saip: Add ProfileElementAKA constructor + methods
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37417?usp=email ) Change subject: pySim.esim.saip: Add ProfileElementAKA constructor + methods ...................................................................... pySim.esim.saip: Add ProfileElementAKA constructor + methods This helps us to construct an akaParameter PE from scratch. Change-Id: I4cc42c98bf82aec085ab7f48aea4ff7efa0eae9e --- M pySim/esim/saip/__init__.py M tests/test_esim_saip.py 2 files changed, 61 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/17/37417/1 diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index e35e1a5..2cddbe8 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -271,6 +271,7 @@ 'telecom': ProfileElementTelecom, 'usim': ProfileElementUSIM, 'isim': ProfileElementISIM, + 'akaParameter': ProfileElementAKA, } """Construct an instance from given raw, DER encoded bytes.""" pe_type, decoded = asn1.decode('ProfileElement', der) @@ -593,6 +594,54 @@ def adf_name(self) -> str: return b2h(self.decoded['adf-isim'][0][1]['dfName']) +class ProfileElementAKA(ProfileElement): + type = 'akaParameter' + + def __init__(self, decoded: Optional[dict] = None): + super().__init__() + if decoded: + self.decoded = decoded + return + # provide some reasonable defaults for a MNO-SD + self.decoded = OrderedDict() + self.decoded['aka-header'] = { 'mandated': None, 'identification': None} + self.set_milenage(b'\x00'*16, b'\x00'*16) + + def set_milenage(self, k: bytes, opc: bytes): + """Configure akaParametes for MILENAGE.""" + self.decoded['algoConfiguration'] = ('algoParameter', { + 'algorithmID': 1, + 'algorithmOptions': b'\x00', # not relevant for milenage + 'key': k, + 'opc': opc, + }) + + def set_xor3g(self, k: bytes): + """Configure akaParametes for XOR-3G.""" + self.decoded['algoConfiguration'] = ('algoParameter', { + 'algorithmID': 3, + 'algorithmOptions': b'\x00', # not relevant for milenage + 'key': k, + 'opc': b'', # not used for MILENAGE + }) + + def set_tuak(self, k: bytes, topc: bytes, num_of_keccak: int = 1): + """Configure akaParametes for TUAK.""" + self.decoded['algoConfiguration'] = ('algoParameter', { + 'algorithmID': 2, + 'algorithmOptions': b'\x00', # not relevant for milenage + 'key': k, + 'opc': topc, + 'numberOfKeccak': bytes([num_of_keccak]), + }) + + def set_mapping(self, aid: bytes, options: int = 6): + """Configure akaParametes for a mapping from another AID.""" + self.decoded['algoConfiguration'] = ('mappingParamete', { + 'mappingOptions': bytes([options]), + 'mappingSource': aid, + }) + def bertlv_first_segment(binary: bytes) -> Tuple[bytes, bytes]: """obtain the first segment of a binary concatenation of BER-TLV objects. Returns: tuple of first TLV and remainder.""" diff --git a/tests/test_esim_saip.py b/tests/test_esim_saip.py index a43a139..704f513 100755 --- a/tests/test_esim_saip.py +++ b/tests/test_esim_saip.py @@ -66,7 +66,7 @@ def test_constructor_encode(self): """Test that DER-encoding of PE created by "empty" constructor works without raising exception.""" for cls in [ProfileElementMF, ProfileElementPuk, ProfileElementPin, ProfileElementTelecom, - ProfileElementUSIM, ProfileElementISIM]: + ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA]: with self.subTest(cls.__name__): pes = ProfileElementSequence() inst = cls() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37417?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: I4cc42c98bf82aec085ab7f48aea4ff7efa0eae9e Gerrit-Change-Number: 37417 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: pySim.esim: Allow calling compile_asn1_subdir() with non-DER coddec
by laforge 08 Jul '24

08 Jul '24
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37416?usp=email ) Change subject: pySim.esim: Allow calling compile_asn1_subdir() with non-DER coddec ...................................................................... pySim.esim: Allow calling compile_asn1_subdir() with non-DER coddec this isn't needed for the on-wire format, but can be useful for debug output in GSER or JER. Change-Id: I1de4b9506a92d60f582c328a180760332584f9e4 --- M pySim/esim/__init__.py 1 file changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/16/37416/1 diff --git a/pySim/esim/__init__.py b/pySim/esim/__init__.py index 1f7ea16..fbb90b9 100644 --- a/pySim/esim/__init__.py +++ b/pySim/esim/__init__.py @@ -3,7 +3,7 @@ from importlib import resources -def compile_asn1_subdir(subdir_name:str): +def compile_asn1_subdir(subdir_name:str, codec='der'): """Helper function that compiles ASN.1 syntax from all files within given subdir""" import asn1tools asn_txt = '' @@ -14,7 +14,7 @@ asn_txt += "\n" #else: #print(resources.read_text(__name__, 'asn1/rsp.asn')) - return asn1tools.compile_string(asn_txt, codec='der') + return asn1tools.compile_string(asn_txt, codec=codec) # SGP.22 section 4.1 Activation Code -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37416?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: I1de4b9506a92d60f582c328a180760332584f9e4 Gerrit-Change-Number: 37416 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.