laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/44008?usp=email ) Change subject: esim/asn1/rsp: add the two types the SGP.32 module imports ...................................................................... esim/asn1/rsp: add the two types the SGP.32 module imports The SGP.32 v1.3 ASN.1 module imports OperatorId and VendorSpecificExtension from RSPDefinitions (sgp22v2). The v2 module spells the first OperatorID and lacks the second, which SGP.22 v3.1 marks as supported from v2.4.0, so compiling the SGP.32 module against it fails. Add OperatorId as an alias, and VendorSpecificExtension as Annex H of SGP.22 v3.1 defines it, with OBJECT IDENTIFIER and ANY for its two OPENTYPE members. The folder osmocom-pysim-rsp-operatorid of hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis and a repro. Change-Id: I23d8c7e061a5573caa750fe76a6e8756ddbf0898 --- M pySim/esim/asn1/rsp/rsp.asn M tests/unittests/test_esim_rsp.py 2 files changed, 45 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/asn1/rsp/rsp.asn b/pySim/esim/asn1/rsp/rsp.asn index e87b74e..9f10104 100644 --- a/pySim/esim/asn1/rsp/rsp.asn +++ b/pySim/esim/asn1/rsp/rsp.asn @@ -174,6 +174,17 @@ gid2 OCTET STRING OPTIONAL -- referring to content of EF GID2 (file identifier '6F3F') as defined in 3GPP TS 31.102 [54] } +-- workaround: The same type as spelled in SGP.22 v3.1 Annex H, and imported under that name from this +-- module by the SGP.32 v1.3 ASN.1 module (IMPORTS ... OperatorId ... FROM RSPDefinitions) +OperatorId ::= OperatorID + +-- workaround: Also imported by the SGP.32 v1.3 ASN.1 module. SGP.22 v3.1 Annex H types the two members +-- as OPENTYPE.&typeId and OPENTYPE.&Type, which encode as OBJECT IDENTIFIER and ANY. +VendorSpecificExtension ::= SEQUENCE OF SEQUENCE { -- #SupportedFromV2.4.0# + vendorOid [0] OBJECT IDENTIFIER, -- OID of the vendor who defined this specific extension + vendorSpecificData [1] ANY +} + ProfileInfoListError ::= INTEGER {incorrectInputValues(1), undefinedError(127)} -- Definition of StoreMetadata request diff --git a/tests/unittests/test_esim_rsp.py b/tests/unittests/test_esim_rsp.py index 553c63b..36b5fe5 100644 --- a/tests/unittests/test_esim_rsp.py +++ b/tests/unittests/test_esim_rsp.py @@ -156,5 +156,39 @@ self.assertEqual(dec['operationType'], (h2b('80'), 1)) +class TestSgp32Imports(unittest.TestCase): + """The SGP.32 v1.3 module imports OperatorId and VendorSpecificExtension from + RSPDefinitions; the v2 module calls the first OperatorID.""" + + OWNER = {'mccMnc': h2b('00f110'), 'gid1': h2b('01')} + + def test_alias_encodes_like_operator_id(self): + enc = rsp.asn1.encode('OperatorId', self.OWNER) + self.assertEqual(enc, rsp.asn1.encode('OperatorID', self.OWNER)) + self.assertEqual(rsp.asn1.decode('OperatorId', enc), self.OWNER) + + def test_importable_under_the_v3_name(self): + from importlib import resources + rsp_dir = resources.files('pySim.esim').joinpath('asn1').joinpath('rsp') + rsp_txt = '\n'.join(i.read_text() for i in rsp_dir.iterdir() if i.name.endswith('.asn')) + importer = """Importer DEFINITIONS AUTOMATIC TAGS ::= BEGIN +IMPORTS OperatorId, VendorSpecificExtension FROM RSPDefinitions {joint-iso-itu-t(2) international-organizations(23) gsma(146) rsp(1) asn1modules(1) sgp22v2(2)}; +Owner ::= SEQUENCE { profileOwner [23] OperatorId } +VendorInfo ::= SEQUENCE { info [10] VendorSpecificExtension } +END +""" + spec = asn1tools.compile_string(rsp_txt + '\n' + importer, codec='der') + enc = spec.encode('Owner', {'profileOwner': self.OWNER}) + self.assertEqual(enc[2:], h2b('b7') + rsp.asn1.encode('OperatorID', self.OWNER)[1:]) + ext = {'info': [{'vendorOid': '1.3.6.1.4.1.1', 'vendorSpecificData': h2b('0402aabb')}]} + self.assertEqual(spec.decode('VendorInfo', spec.encode('VendorInfo', ext)), ext) + + def test_vendor_specific_extension_encodes_like_v3(self): + ext = [{'vendorOid': '1.3.6.1.4.1.1', 'vendorSpecificData': h2b('0402aabb')}] + enc = rsp.asn1.encode('VendorSpecificExtension', ext) + self.assertEqual(enc, rsp.asn1_v3.encode('VendorSpecificExtension', ext)) + self.assertEqual(rsp.asn1.decode('VendorSpecificExtension', enc), ext) + + if __name__ == "__main__": unittest.main() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/44008?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I23d8c7e061a5573caa750fe76a6e8756ddbf0898 Gerrit-Change-Number: 44008 Gerrit-PatchSet: 4 Gerrit-Owner: hampushellsberg <hampushellsberg@gmail.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org>