neels has uploaded this change for review.
saip/personalization: add EuiccMandatoryServiceParam for 3 services
Even though the eUICC-Mandatory-services are always set by
saip.PES.rebuild_mandatory_services(), these new params are useful to
audit and validate the values as present in a given DER.
Change-Id: Icddeb2488c4a024c6ee5afcc1b6c8cc0e436c43c
Jenkins: skip-card-test
---
M pySim/esim/saip/__init__.py
M pySim/esim/saip/personalization.py
M tests/unittests/test_configurable_parameters.py
M tests/unittests/xo/test_configurable_parameters
4 files changed, 137 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/67/43867/1
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 356800b..01302df 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -1517,8 +1517,11 @@
def mandatory_service_add(self, service_name):
self.decoded['eUICC-Mandatory-services'][service_name] = None
+ def mandatory_service_present(self, service_name):
+ return service_name in self.decoded['eUICC-Mandatory-services'].keys()
+
def mandatory_service_remove(self, service_name):
- if service_name in self.decoded['eUICC-Mandatory-services'].keys():
+ if self.mandatory_service_present(service_name):
del self.decoded['eUICC-Mandatory-services'][service_name]
else:
raise ValueError("service not in eUICC-Mandatory-services list, cannot remove")
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index a3347cb..d6fa08d 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -30,6 +30,7 @@
from pySim.ts_51_011 import EF_SMSP
from pySim.esim.saip import param_source
from pySim.esim.saip import ProfileElement, ProfileElementSD, ProfileElementSequence
+from pySim.esim.saip import ProfileElementHeader
from pySim.esim.saip import SecurityDomainKey, SecurityDomainKeyComponent
from pySim.global_platform import KeyUsageQualifier, KeyType
@@ -1383,3 +1384,48 @@
"""SUCI Calculation Information as in section 4.4.11.8 of 3GPP TS 31.102, readable only by USIM (DF-SAIP)"""
name = '5G-SUCI-CalcInfo-USIM'
suci_calc_info_pe = SuciCalcInfoParameter.PE_IN_USIM
+
+class EuiccMandatoryServiceParam(EnumParam):
+ """superclass for managing items of the ProfileHeader / eUICC-Mandatory-services ServicesList"""
+ service_name = None
+ value_map = { 'mandatory': True, 'optional': False }
+ default_source = param_source.ConstantSource
+ example_input = sorted(value_map.keys())[0]
+
+ @classmethod
+ def apply_val(cls, pes: ProfileElementSequence, val):
+ for pe in pes.get_pes_for_type('header'):
+ assert isinstance(pe, ProfileElementHeader)
+ if val:
+ pe.mandatory_service_add(cls.service_name)
+ else:
+ # explicitly check to avoid exception when the service is already not-present
+ if pe.mandatory_service_present(cls.service_name):
+ pe.mandatory_service_remove(cls.service_name)
+
+ @classmethod
+ def get_values_from_pes(cls, pes: ProfileElementSequence):
+ for pe in pes.get_pes_for_type('header'):
+ assert isinstance(pe, ProfileElementHeader)
+ val = pe.mandatory_service_present(cls.service_name)
+ yield { cls.name: cls.map_val_to_name(val) }
+
+class EuiccMandatoryServiceGetIdentity(EuiccMandatoryServiceParam):
+ """eUICC Mandatory Services: get-identity. The eUICC must be capable of providing a 5G identity using SUCI-CalcInfo
+ located in the USIM's DF-SAIP, see parameter 5G-SUCI-CalcInfo-USIM."""
+ name = '5G-eUICC-get-identity'
+ service_name = 'get-identity'
+
+class EuiccMandatoryServiceProfileA(EuiccMandatoryServiceParam):
+ """eUICC Mandatory Services: profile-a-x25519. The eUICC must be able to estblish a 5G identity using an X25519 key,
+ as provided in a profile-A ("identifier": 1) key in SUCI-CalcInfo located in the USIM's DF-SAIP, see parameter
+ 5G-SUCI-CalcInfo-USIM."""
+ name = '5G-eUICC-profile-a-x25519'
+ service_name = 'profile-a-x25519'
+
+class EuiccMandatoryServiceProfileB(EuiccMandatoryServiceParam):
+ """eUICC Mandatory Services: profile-b-p256. The eUICC must be able to estblish a 5G identity using a P256 key, as
+ provided in a profile-B ("identifier": 2) key in SUCI-CalcInfo located in the USIM's DF-SAIP, see parameter
+ 5G-SUCI-CalcInfo-USIM."""
+ name = '5G-eUICC-profile-b-p256'
+ service_name = 'profile-b-p256'
diff --git a/tests/unittests/test_configurable_parameters.py b/tests/unittests/test_configurable_parameters.py
index 33c7647..d541925 100755
--- a/tests/unittests/test_configurable_parameters.py
+++ b/tests/unittests/test_configurable_parameters.py
@@ -278,6 +278,33 @@
val=3,
expect_clean_val=3,
expect_val='3'),
+
+ Paramtest(param_cls=p13n.EuiccMandatoryServiceGetIdentity,
+ val='mandatory',
+ expect_clean_val=True,
+ expect_val='mandatory'),
+ Paramtest(param_cls=p13n.EuiccMandatoryServiceGetIdentity,
+ val='optional',
+ expect_clean_val=False,
+ expect_val='optional'),
+
+ Paramtest(param_cls=p13n.EuiccMandatoryServiceProfileA,
+ val='mandatory',
+ expect_clean_val=True,
+ expect_val='mandatory'),
+ Paramtest(param_cls=p13n.EuiccMandatoryServiceProfileA,
+ val='optional',
+ expect_clean_val=False,
+ expect_val='optional'),
+
+ Paramtest(param_cls=p13n.EuiccMandatoryServiceProfileB,
+ val='mandatory',
+ expect_clean_val=True,
+ expect_val='mandatory'),
+ Paramtest(param_cls=p13n.EuiccMandatoryServiceProfileB,
+ val='optional',
+ expect_clean_val=False,
+ expect_val='optional'),
]
Paramtest.iff_present_default = True
diff --git a/tests/unittests/xo/test_configurable_parameters b/tests/unittests/xo/test_configurable_parameters
index 822e33e..0866229 100644
--- a/tests/unittests/xo/test_configurable_parameters
+++ b/tests/unittests/xo/test_configurable_parameters
@@ -214,6 +214,36 @@
previous value: ['2']
read_back_val={'MNC-LEN': '3'}:{str}
+ok: TS48v5_SAIP2.1A_NoBERTLV.der EuiccMandatoryServiceGetIdentity(val='mandatory':str)
+ clean_val=True:bool
+ previous value: ['optional']
+ read_back_val={'5G-eUICC-get-identity': 'mandatory'}:{str}
+
+ok: TS48v5_SAIP2.1A_NoBERTLV.der EuiccMandatoryServiceGetIdentity(val='optional':str)
+ clean_val=False:bool
+ previous value: ['optional']
+ read_back_val={'5G-eUICC-get-identity': 'optional'}:{str}
+
+ok: TS48v5_SAIP2.1A_NoBERTLV.der EuiccMandatoryServiceProfileA(val='mandatory':str)
+ clean_val=True:bool
+ previous value: ['optional']
+ read_back_val={'5G-eUICC-profile-a-x25519': 'mandatory'}:{str}
+
+ok: TS48v5_SAIP2.1A_NoBERTLV.der EuiccMandatoryServiceProfileA(val='optional':str)
+ clean_val=False:bool
+ previous value: ['optional']
+ read_back_val={'5G-eUICC-profile-a-x25519': 'optional'}:{str}
+
+ok: TS48v5_SAIP2.1A_NoBERTLV.der EuiccMandatoryServiceProfileB(val='mandatory':str)
+ clean_val=True:bool
+ previous value: ['optional']
+ read_back_val={'5G-eUICC-profile-b-p256': 'mandatory'}:{str}
+
+ok: TS48v5_SAIP2.1A_NoBERTLV.der EuiccMandatoryServiceProfileB(val='optional':str)
+ clean_val=False:bool
+ previous value: ['optional']
+ read_back_val={'5G-eUICC-profile-b-p256': 'optional'}:{str}
+
ok: TS48v5_SAIP2.1A_NoBERTLV.der SuciActive(val='SUCI-on':str)
clean_val=True:bool
previous value: ['SUCI-on']
@@ -1134,6 +1164,36 @@
previous value: ['2']
read_back_val={'MNC-LEN': '3'}:{str}
+ok: TS48v5_SAIP2.3_BERTLV_SUCI.der EuiccMandatoryServiceGetIdentity(val='mandatory':str)
+ clean_val=True:bool
+ previous value: ['mandatory']
+ read_back_val={'5G-eUICC-get-identity': 'mandatory'}:{str}
+
+ok: TS48v5_SAIP2.3_BERTLV_SUCI.der EuiccMandatoryServiceGetIdentity(val='optional':str)
+ clean_val=False:bool
+ previous value: ['mandatory']
+ read_back_val={'5G-eUICC-get-identity': 'optional'}:{str}
+
+ok: TS48v5_SAIP2.3_BERTLV_SUCI.der EuiccMandatoryServiceProfileA(val='mandatory':str)
+ clean_val=True:bool
+ previous value: ['mandatory']
+ read_back_val={'5G-eUICC-profile-a-x25519': 'mandatory'}:{str}
+
+ok: TS48v5_SAIP2.3_BERTLV_SUCI.der EuiccMandatoryServiceProfileA(val='optional':str)
+ clean_val=False:bool
+ previous value: ['mandatory']
+ read_back_val={'5G-eUICC-profile-a-x25519': 'optional'}:{str}
+
+ok: TS48v5_SAIP2.3_BERTLV_SUCI.der EuiccMandatoryServiceProfileB(val='mandatory':str)
+ clean_val=True:bool
+ previous value: ['mandatory']
+ read_back_val={'5G-eUICC-profile-b-p256': 'mandatory'}:{str}
+
+ok: TS48v5_SAIP2.3_BERTLV_SUCI.der EuiccMandatoryServiceProfileB(val='optional':str)
+ clean_val=False:bool
+ previous value: ['mandatory']
+ read_back_val={'5G-eUICC-profile-b-p256': 'optional'}:{str}
+
ok: TS48v5_SAIP2.3_BERTLV_SUCI.der SuciActive(val='SUCI-on':str)
clean_val=True:bool
previous value: ['SUCI-on']
To view, visit change 43867. To unsubscribe, or for help writing mail filters, visit settings.