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

November 2026

  • 1 participants
  • 714 discussions
[S] Change in osmo-ttcn3-hacks[master]: udm: Fix TC_result_confirmation_inform expectancies
by pespin 04 Nov '26

04 Nov '26
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/44029?usp=email ) Change subject: udm: Fix TC_result_confirmation_inform expectancies ...................................................................... udm: Fix TC_result_confirmation_inform expectancies open5gs-udmd was sending the wrong message, as reported in https://github.com/open5gs/open5gs/issues/4896 The issue has been fixed, to adapt the test to properly trigger the scenario and adapt expectancies. Change-Id: If0c7fcfb673717472345b28139e3b4f6a15ef213 --- M udm/ConnHdlr.ttcn 1 file changed, 39 insertions(+), 7 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve diff --git a/udm/ConnHdlr.ttcn b/udm/ConnHdlr.ttcn index db16dc8..0a7ab1c 100644 --- a/udm/ConnHdlr.ttcn +++ b/udm/ConnHdlr.ttcn @@ -286,17 +286,16 @@ var template (value) AuthEvent1 auth_event; auth_event := ts_AuthEvent1(nfInstanceId := g_pars.ausf_instance_id, - success := true, + success := false, timeStamp := "2026-10-20T11:58:44.069417+00:00", /* TODO: generate the now() timestamp string */ authType := ts_AuthType1(FiveG_AKA), - servingNetworkName := g_pars.serving_network); + servingNetworkName := g_pars.serving_network, + authRemovalInd := true); http2_tx := f_n13_prepare_individual_auth_event(auth_event); f_http2_adapter_connect_send_udm(http2_tx, idx := http2_tx.conn_id); - /* FIXME: This is probably incorrect, it should send a DELETE, but it's what open5gs-udmd is sending right now... - * See https://github.com/open5gs/open5gs/issues/4896 */ - as_Nudr_DR_put_authentication_status(); + as_Nudr_DR_delete_authentication_status(); /* 3GPP TS 29.503 Table 6.3.3.6.2.1-3 */ http2_exp_rx := @@ -358,7 +357,7 @@ } } -/* 3GPP TS 29.505 5.2.2.3.1 AuthenticationSubscription (PUT) */ +/* 3GPP TS 29.505 5.2.24.3.1 Resource: AuthenticationStatus (PUT) */ function f_tr_Nudr_DR_put_authentication_status() runs on ConnHdlr return template (present) HTTP2_Msg { var template (present) HTTP2_Msg http2_msg; @@ -373,7 +372,7 @@ return http2_msg; } -/* 3GPP TS 29.505 5.2.2 Resource: AuthenticationSubscription */ +/* 3GPP TS 29.505 5.2.24.3.1 Resource: AuthenticationStatus (PUT) */ altstep as_Nudr_DR_put_authentication_status() runs on ConnHdlr { var HTTP2_Msg http2_rx; @@ -391,4 +390,37 @@ } } +/* 3GPP TS 29.505 5.2.24.3.3 Resource: AuthenticationStatus (DELETE) */ +function f_tr_Nudr_DR_delete_authentication_status() +runs on ConnHdlr return template (present) HTTP2_Msg { + var template (present) HTTP2_Msg http2_msg; + var template (present) HTTP2_header_block hb; + var template (present) HTTP2_pseudo_headers pseudo_headers; + var template HTTP2_header_list headers := *; + + pseudo_headers := tr_HTTP2_pseudo_headers_Req(method := "DELETE", + path := tr_Nudr_DR_path_authentication_status(g_pars.imsi_str)); + hb := tr_HTTP2_header_block(pseudo_headers, headers); + http2_msg := tr_HTTP2_Msg(?, ?, hb := hb, body := omit); + return http2_msg; +} + +/* 3GPP TS 29.505 5.2.24.3.3 Resource: AuthenticationStatus (DELETE) */ +altstep as_Nudr_DR_delete_authentication_status() +runs on ConnHdlr { + var HTTP2_Msg http2_rx; + [] HTTP2_CONN[HTTP2_CONN_SCP].receive(f_tr_Nudr_DR_delete_authentication_status()) -> value http2_rx { + var template (value) HTTP2_Msg http2_tx; + http2_tx := ts_HTTP2_Msg_204_No_Content(http2_rx.conn_id, + http2_rx.stream_id, + headers := { + ts_HTTP2_Hdr_content_type("application/json") + }, + body := omit); + + HTTP2_CONN[HTTP2_CONN_SCP].send(http2_tx); + setverdict(pass); + } +} + } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/44029?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: If0c7fcfb673717472345b28139e3b4f6a15ef213 Gerrit-Change-Number: 44029 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: udm: Fix TC_result_confirmation_inform expectancies
by pespin 04 Nov '26

04 Nov '26
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/44029?usp=email ) Change subject: udm: Fix TC_result_confirmation_inform expectancies ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/44029?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: If0c7fcfb673717472345b28139e3b4f6a15ef213 Gerrit-Change-Number: 44029 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Wed, 04 Nov 2026 20:51:11 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in osmo-hlr[master]: tests/db_upgrade: fix test failure with sqlite3 >= 3.54.0
by pespin 04 Nov '26

04 Nov '26
Attention is currently required from: fixeria, lynxis lazus, osmith. pespin has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/osmo-hlr/+/44028?usp=email ) Change subject: tests/db_upgrade: fix test failure with sqlite3 >= 3.54.0 ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/44028?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I7353988516b274eb228818e694dbe857509cf536 Gerrit-Change-Number: 44028 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Wed, 04 Nov 2026 20:41:14 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in pysim[master]: esim.saip: keep keyAccess and keyCounterValue of security domain keys
by laforge 04 Nov '26

04 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/44011?usp=email ) Change subject: esim.saip: keep keyAccess and keyCounterValue of security domain keys ...................................................................... esim.saip: keep keyAccess and keyCounterValue of security domain keys SecurityDomainKey only stored the usage qualifier, KID, KVN and key components, and ProfileElementSD._pre_encode() rebuilds keyList from it, so a non-default keyAccess and any keyCounterValue were lost on re-encode. Store both. keyAccess is only written if it is not '00'. The counter is an integer, encoded with the length of the protocol the KVN is reserved for (SAIP section 8.6.3: 2, 3 and 5 bytes for SCP02, SCP03 and SCP80, on the KVN ranges listed in global_platform/uicc.py), also when it was decoded with another length. A counter on any other KVN raises ValueError. The folder osmocom-pysim-saip-sd-key-access-counter of hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis and a repro. Change-Id: I7df8ef6f2c81cd8544a04dbf7ff5d096685103e3 --- M pySim/esim/saip/__init__.py M tests/unittests/test_esim_saip.py 2 files changed, 70 insertions(+), 6 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved dexter: Looks good to me, but someone else must approve diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 5966897..e18ac8a 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -1153,11 +1153,28 @@ class SecurityDomainKey: """Representation of a key used for SCP access to a security domain.""" def __init__(self, key_version_number: int, key_id: int, key_usage_qualifier: dict, - key_components: List[SecurityDomainKeyComponent]): + key_components: List[SecurityDomainKeyComponent], key_access: int = 0, + key_counter_value: Optional[int] = None): self.key_usage_qualifier = key_usage_qualifier self.key_identifier = key_id self.key_version_number = key_version_number self.key_components = key_components + self.key_access = key_access + self.key_counter_value = key_counter_value + + @staticmethod + def counter_len_for_kvn(kvn: int) -> int: + """Return the counter length of the protocol a KVN is reserved for (see the KVN table in + pySim.global_platform.uicc). Raises ValueError if that is not SCP80, SCP02 or SCP03.""" + # SAIP section 8.6.3: the default counter is '0000' for SCP02, '000000' for SCP03 and + # '0000000000' for SCP80 + if kvn in range(0x01, 0x10): + return 5 # SCP80 + if kvn in range(0x20, 0x30) or kvn == 0xff: + return 2 # SCP02 + if kvn in range(0x30, 0x40): + return 3 # SCP03 + raise ValueError('KVN 0x%02x is not reserved for SCP80, SCP02 or SCP03, its key counter length is unknown' % kvn) def __repr__(self) -> str: return 'SdKey(KVN=0x%02x, ID=0x%02x, Usage=0x%x, Comp=%s)' % (self.key_version_number, @@ -1168,18 +1185,32 @@ @classmethod def from_saip_dict(cls, saip: dict) -> 'SecurityDomainKey': """Construct instance from the dict as generated by SAIP asn.1 decoder.""" + counter = saip.get('keyCounterValue', None) inst = cls(int.from_bytes(saip['keyVersionNumber'], "big"), int.from_bytes(saip['keyIdentifier'], "big"), KeyUsageQualifier.parse(saip['keyUsageQualifier']), - [SecurityDomainKeyComponent.from_saip_dict(x) for x in saip['keyComponents']]) + [SecurityDomainKeyComponent.from_saip_dict(x) for x in saip['keyComponents']], + key_access=int.from_bytes(saip.get('keyAccess', b'\x00'), "big"), + key_counter_value=int.from_bytes(counter, "big") if counter is not None else None) return inst def to_saip_dict(self) -> dict: """Express instance in the dict format required by SAIP asn.1 encoder.""" - return {'keyUsageQualifier': KeyUsageQualifier.build(self.key_usage_qualifier), - 'keyIdentifier': bytes([self.key_identifier]), - 'keyVersionNumber': bytes([self.key_version_number]), - 'keyComponents': [k.to_saip_dict() for k in self.key_components]} + ret = {'keyUsageQualifier': KeyUsageQualifier.build(self.key_usage_qualifier), + 'keyIdentifier': bytes([self.key_identifier]), + 'keyVersionNumber': bytes([self.key_version_number]), + 'keyComponents': [k.to_saip_dict() for k in self.key_components]} + # keyAccess is DEFAULT '00', keyCounterValue OPTIONAL + if self.key_access: + ret['keyAccess'] = bytes([self.key_access]) + if self.key_counter_value is not None: + counter_len = self.counter_len_for_kvn(self.key_version_number) + try: + ret['keyCounterValue'] = self.key_counter_value.to_bytes(counter_len, "big") + except OverflowError as e: + raise ValueError('key counter %d of KVN 0x%02x does not fit in %d bytes' + % (self.key_counter_value, self.key_version_number, counter_len)) from e + return ret def get_key_component(self, key_type): for kc in self.key_components: diff --git a/tests/unittests/test_esim_saip.py b/tests/unittests/test_esim_saip.py index 4a02b71..50cb9d5 100755 --- a/tests/unittests/test_esim_saip.py +++ b/tests/unittests/test_esim_saip.py @@ -63,6 +63,39 @@ pes = ProfileElementSequence.from_der(der) self.assertEqual(pes.to_der(), der) + def test_sd_key_access_and_counter(self): + """Test that keyAccess and keyCounterValue of a security domain key survive a re-encode.""" + decoded = copy.deepcopy(self.pes.get_pe_for_type('securityDomain').decoded) + # KVN 0x01: SCP80 keyset, five byte counter + decoded['keyList'][0]['keyAccess'] = b'\x01' + decoded['keyList'][0]['keyCounterValue'] = h2b('0000000001') + der = asn1.encode('ProfileElement', ('securityDomain', decoded)) + pe = ProfileElement.from_der(der) + self.assertEqual(pe.keys[0].key_access, 1) + self.assertEqual(pe.keys[0].key_counter_value, 1) + self.assertEqual(pe.to_der(), der) + + def test_sd_key_counter_len(self): + """Test that a key counter is encoded with the length of the protocol its KVN is reserved for.""" + key = self.pes.get_pe_for_type('securityDomain').keys[0] + def counter(kvn: int, value: int = 1) -> str: + sd_key = SecurityDomainKey(kvn, key.key_identifier, key.key_usage_qualifier, key.key_components, + key_counter_value=value) + return b2h(sd_key.to_saip_dict()['keyCounterValue']) + self.assertEqual(counter(0x01), '0000000001') # SCP80 + self.assertEqual(counter(0x20), '0001') # SCP02 + self.assertEqual(counter(0xff), '0001') # SCP02 + self.assertEqual(counter(0x30), '000001') # SCP03 + # KVN 0x70 is not reserved for SCP80, SCP02 or SCP03; 0x1000000 needs more than 3 bytes + for kvn, value in ((0x70, 1), (0x30, 0x1000000)): + with self.assertRaises(ValueError): + counter(kvn, value) + # a decoded counter of another length re-encodes with the length of its KVN + decoded = copy.deepcopy(self.pes.get_pe_for_type('securityDomain').decoded) + decoded['keyList'][3]['keyCounterValue'] = h2b('0001') # KVN 0x02: SCP80 + pe = ProfileElement.from_der(asn1.encode('ProfileElement', ('securityDomain', decoded))) + self.assertEqual(pe.keys[3].to_saip_dict()['keyCounterValue'], h2b('0000000001')) + def test_sequence_helpers(self): """Verify that the convenience helpers worked as expected.""" self.assertEqual([x.type for x in self.pes.pe_list], self.expected_pet_list) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/44011?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: I7df8ef6f2c81cd8544a04dbf7ff5d096685103e3 Gerrit-Change-Number: 44011 Gerrit-PatchSet: 3 Gerrit-Owner: hampushellsberg <hampushellsberg(a)gmail.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
1 0
0 0
[M] Change in pysim[master]: esim.saip: keep keyAccess and keyCounterValue of security domain keys
by laforge 04 Nov '26

04 Nov '26
Attention is currently required from: hampushellsberg, lynxis lazus. laforge has posted comments on this change by hampushellsberg. ( https://gerrit.osmocom.org/c/pysim/+/44011?usp=email ) Change subject: esim.saip: keep keyAccess and keyCounterValue of security domain keys ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/44011?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I7df8ef6f2c81cd8544a04dbf7ff5d096685103e3 Gerrit-Change-Number: 44011 Gerrit-PatchSet: 3 Gerrit-Owner: hampushellsberg <hampushellsberg(a)gmail.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Attention: hampushellsberg <hampushellsberg(a)gmail.com> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Wed, 04 Nov 2026 13:22:37 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in pysim[master]: esim.saip: derive nb_rec from efFileSize when the descriptor omits it
by laforge 04 Nov '26

04 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43984?usp=email ) Change subject: esim.saip: derive nb_rec from efFileSize when the descriptor omits it ...................................................................... esim.saip: derive nb_rec from efFileSize when the descriptor omits it File.from_template copies the template's record count, so a profile whose fileDescriptor carries no number of records but declares a larger efFileSize kept the template default (EF.MSISDN: one 24-byte record from FilesUsimOptional against a 68-byte, two-record file). ETSI TS 102 222 sizes a linear fixed EF as record length times record count; when the descriptor is silent the declared size is the count. The folder osmocom-pysim-saip-record-count of hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis and a repro. Change-Id: I191b234446c278a5252a903d170c3336d9e0c1ba --- M pySim/esim/saip/__init__.py 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: neels: Looks good to me, approved laforge: Looks good to me, but someone else must approve dexter: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 2833fd0..5966897 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -366,8 +366,8 @@ if fd_dec['record_len']: self.rec_len = fd_dec['record_len'] if efFileSize: - if self.rec_len and self.nb_rec == None: - # compute the number of records from file size and record length + if self.rec_len and not fd_dec['num_of_rec']: + # the profile's size wins over a template count when the descriptor omits it self.nb_rec = self._file_size // self.rec_len if fdb_dec['structure'] == 'linear_fixed': self.file_type = 'LF' -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43984?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: I191b234446c278a5252a903d170c3336d9e0c1ba Gerrit-Change-Number: 43984 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-CC: hampushellsberg <hampushellsberg(a)gmail.com>
1 0
0 0
[S] Change in pysim[master]: esim.saip: split a fillFileOffset beyond the range of UInt16
by laforge 04 Nov '26

04 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/44010?usp=email ) Change subject: esim.saip: split a fillFileOffset beyond the range of UInt16 ...................................................................... esim.saip: split a fillFileOffset beyond the range of UInt16 fillFileOffset is a UInt16 (SAIP section 8.3.2), but file_content_to_tuples() emitted a gap of any length as a single offset. Split longer gaps into steps of at most 0xffff. The folder osmocom-pysim-saip-optimised-body-encoding of hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis. Change-Id: Iddd98b7f54abaebfdbf6682a8635339d13cf56e3 --- M pySim/esim/saip/__init__.py M tests/unittests/test_esim_saip.py 2 files changed, 19 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 60da704..86f0a39 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -524,7 +524,12 @@ for block in non_matching_blocks: # fillFileOffset moves the pointer relative to its current position, and # fillFileContent leaves it after the last byte written (SAIP section 8.3.5) - ret.append(('fillFileOffset', block.a - cur)) + offset = block.a - cur + # fillFileOffset is a UInt16 (SAIP section 8.3.2): a longer move takes several + while offset > 0xffff: + ret.append(('fillFileOffset', 0xffff)) + offset -= 0xffff + ret.append(('fillFileOffset', offset)) ret.append(('fillFileContent', self.body[block.a:block.a+block.size])) cur = block.a + block.size return ret diff --git a/tests/unittests/test_esim_saip.py b/tests/unittests/test_esim_saip.py index 75a38f4..e6f9882 100755 --- a/tests/unittests/test_esim_saip.py +++ b/tests/unittests/test_esim_saip.py @@ -125,6 +125,19 @@ pes.append(inst) pes.to_der() +class FileContentTest(unittest.TestCase): + def test_fill_file_offset_fits_uint16(self): + # fillFileOffset is a UInt16 (SAIP 8.3.2): a longer gap takes several steps + template = templates.FileTemplate(0x6f99, 'EF.TEST', 'TR', None, 70000, 5, None, None) + body = bytearray(b'\xff' * 70000) + body[66000] = 0x00 + f = File('test', [('fileDescriptor', {})], template) + f.body = bytes(body) + tuples = f.file_content_to_tuples(optimize=True) + offsets = [v for k, v in tuples if k == 'fillFileOffset'] + self.assertEqual(offsets, [0xffff, 66000 - 0xffff]) + self.assertEqual(f.file_content_from_tuples(tuples), bytes(body)) + class OidTest(unittest.TestCase): def test_cmp(self): self.assertTrue(oid.OID('1.0') > oid.OID('0.9')) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/44010?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: Iddd98b7f54abaebfdbf6682a8635339d13cf56e3 Gerrit-Change-Number: 44010 Gerrit-PatchSet: 2 Gerrit-Owner: hampushellsberg <hampushellsberg(a)gmail.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: esim.saip: fix decoding of rfu PEs with an empty body
by laforge 04 Nov '26

04 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/44012?usp=email ) Change subject: esim.saip: fix decoding of rfu PEs with an empty body ...................................................................... esim.saip: fix decoding of rfu PEs with an empty body rfu1..rfu5 are PE-Dummy, an empty SEQUENCE. from_der() creates a generic ProfileElement for them and sets the type afterwards, but the constructor treated the empty dict like a new PE and derived a header name from the unset type, so a profile with such a PE failed to load with an AttributeError. Only create a header if 'decoded' is None, as documented. The folder osmocom-pysim-saip-empty-pe-body of hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis and a repro. Change-Id: Ic47f74e8c111643c4ba435a9bac6aa9838bd3584 --- M pySim/esim/saip/__init__.py M tests/unittests/test_esim_saip.py 2 files changed, 18 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, approved diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 86f0a39..2833fd0 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -582,7 +582,8 @@ pe_sequence: back-reference to the PE-Sequence of which we're part of """ self.pe_sequence = pe_sequence - if decoded: + # PE-Dummy (rfu1..rfu5) decodes to an empty dict; only a new PE gets a header + if decoded is not None: self.decoded = decoded else: self.decoded = OrderedDict() diff --git a/tests/unittests/test_esim_saip.py b/tests/unittests/test_esim_saip.py index e6f9882..4a02b71 100755 --- a/tests/unittests/test_esim_saip.py +++ b/tests/unittests/test_esim_saip.py @@ -47,6 +47,22 @@ self.assertEqual(reenc_tlv, first_tlv) + def test_rfu_pe(self): + """Test that an rfu PE (PE-Dummy, an empty SEQUENCE without header) decodes and re-encodes.""" + rfu_der = asn1.encode('ProfileElement', ('rfu1', {})) + pe = ProfileElement.from_der(rfu_der) + self.assertEqual(pe.type, 'rfu1') + self.assertEqual(pe.to_der(), rfu_der) + # within a sequence: insert it before the trailing PE-End + tlvs = [] + remainder = self.per_input + while len(remainder): + first_tlv, remainder = bertlv_first_segment(remainder) + tlvs.append(first_tlv) + der = b''.join(tlvs[:-1]) + rfu_der + tlvs[-1] + pes = ProfileElementSequence.from_der(der) + self.assertEqual(pes.to_der(), der) + def test_sequence_helpers(self): """Verify that the convenience helpers worked as expected.""" self.assertEqual([x.type for x in self.pes.pe_list], self.expected_pet_list) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/44012?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: Ic47f74e8c111643c4ba435a9bac6aa9838bd3584 Gerrit-Change-Number: 44012 Gerrit-PatchSet: 2 Gerrit-Owner: hampushellsberg <hampushellsberg(a)gmail.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: personalization: SmspTpScAddr edits record 1 of EF.SMSP only
by laforge 04 Nov '26

04 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43983?usp=email ) Change subject: personalization: SmspTpScAddr edits record 1 of EF.SMSP only ...................................................................... personalization: SmspTpScAddr edits record 1 of EF.SMSP only SmspTpScAddr decoded the whole EF.SMSP body as record 1 and wrote one encoded record back as the whole body. EF.SMSP is linear fixed and a profile can declare more than one record: both TS.48 v5 profiles in smdpp-data/upp carry a fileDescriptor with record length 42 and no record count, and efFileSize 84, so two records. While pySim takes the record count from the template (one record) this goes unnoticed; once the count follows efFileSize, the body holds both records, decoding all 84 bytes as one record fails on the alpha identifier, and test_configurable_parameters fails. Decode and encode record 1 only, and keep the records after it. The folder osmocom-pysim-saip-record-count of hampushellsberg-dev/PySIM-upstream-patches on GitHub carries this patch next to the record count fix that needs it. Change-Id: I47b1abc97d7b8caad0c74d7af2e5da38e9a895b1 --- M pySim/esim/saip/personalization.py M tests/unittests/test_configurable_parameters.py 2 files changed, 29 insertions(+), 5 deletions(-) Approvals: Jenkins Builder: Verified neels: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py index 5ccface..9e5b7fd 100644 --- a/pySim/esim/saip/personalization.py +++ b/pySim/esim/saip/personalization.py @@ -614,8 +614,10 @@ #print("SMSP (orig): %s" % f_smsp.body) # instantiate the pySim.ts_51_011.EF_SMSP class for decode/encode ef_smsp = EF_SMSP() - # decode the existing file body - ef_smsp_dec = ef_smsp.decode_record_bin(f_smsp.body, 1) + # decode the first record; a profile may declare more than one (efFileSize), and the + # File body then holds all of them + rec_len = f_smsp.rec_len + ef_smsp_dec = ef_smsp.decode_record_bin(f_smsp.body[:rec_len], 1) # patch the actual number ef_smsp_dec['tp_sc_addr']['call_number'] = digits # patch the NPI to isdn_e164 @@ -644,8 +646,9 @@ # f_smsp.rec_len = 42 # but leave rec_len unchanged to keep the same length as was found in the eSIM template. - # re-encode into the File body. - f_smsp.body = ef_smsp.encode_record_bin(ef_smsp_dec, 1, total_len=f_smsp.rec_len) + # re-encode the first record into the File body, keeping any records after it. + record = ef_smsp.encode_record_bin(ef_smsp_dec, 1, total_len=rec_len) + f_smsp.body = record + f_smsp.body[rec_len:] # re-generate the pe.decoded member from the File instance pe.file2pe(f_smsp) @@ -654,7 +657,7 @@ for pe in pes.get_pes_for_type('usim'): f_smsp = pe.files['ef-smsp'] ef_smsp = EF_SMSP() - ef_smsp_dec = ef_smsp.decode_record_bin(f_smsp.body, 1) + ef_smsp_dec = ef_smsp.decode_record_bin(f_smsp.body[:f_smsp.rec_len], 1) tp_sc_addr = ef_smsp_dec.get('tp_sc_addr', None) diff --git a/tests/unittests/test_configurable_parameters.py b/tests/unittests/test_configurable_parameters.py index 15f434a..7ff05c6 100755 --- a/tests/unittests/test_configurable_parameters.py +++ b/tests/unittests/test_configurable_parameters.py @@ -728,6 +728,27 @@ self.assertEqual(p13n.AlgorithmID.clean_name_str('foo bar!'), 'foobar') +class TestSmspTpScAddr(unittest.TestCase): + """SmspTpScAddr edits record 1 of EF.SMSP and keeps the records after it.""" + + def test_records_after_the_first_are_kept(self): + der = resources.read_binary(smdpp_data.upp, 'TS48v5_SAIP2.1A_NoBERTLV.der') + for nb_rec in (1, 2): + with self.subTest(nb_rec=nb_rec): + pes = ProfileElementSequence.from_der(der) + f_smsp = pes.get_pes_for_type('usim')[0].files['ef-smsp'] + rec_len = f_smsp.rec_len + tail = bytes(range(rec_len)) * (nb_rec - 1) + f_smsp.body = f_smsp.body[:rec_len] + tail + param = p13n.SmspTpScAddr('+1234567') + param.validate() + param.apply(pes) + self.assertEqual(len(f_smsp.body), nb_rec * rec_len) + self.assertEqual(f_smsp.body[rec_len:], tail) + self.assertEqual(tuple(p13n.SmspTpScAddr.get_values_from_pes(pes)), + ({'SMSP-TP-SC-ADDR': '+1234567'},)) + + if __name__ == "__main__": if '-u' in sys.argv: update_expected_output = True -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43983?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: I47b1abc97d7b8caad0c74d7af2e5da38e9a895b1 Gerrit-Change-Number: 43983 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-CC: hampushellsberg <hampushellsberg(a)gmail.com>
1 0
0 0
[S] Change in libosmo-gprs[master]: gprs_sndcp_xid: double check buffer size after writing SAPIs
by laforge 04 Nov '26

04 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/44023?usp=email ) Change subject: gprs_sndcp_xid: double check buffer size after writing SAPIs ...................................................................... gprs_sndcp_xid: double check buffer size after writing SAPIs The function encode_pcomp_applicable_sapis writes the applicable SAPIs to the output buffer. For this it requires 2 bytes. After that, each encoder function writes the remaining information to the buffer. The check at the beginning of each encoder function is sufficient to ensure that the buffer is large enough. However, this remains only true in case the number of bytes that encode_pcomp_applicable_sapis writes is 2. If there are changes to the spec or similar, the function might write more than 2 bytes. So let's place an additional length check to be on the secure side. This patch has been ported from: osmo-sgsn.git I059c903885e21215ad1e6b835f34db2c5f70d87a Related: OS#7095 Change-Id: Iff1dd10644e37e344ca822a91d156e50288fcb30 --- M src/sndcp/sndcp_xid.c 1 file changed, 20 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/src/sndcp/sndcp_xid.c b/src/sndcp/sndcp_xid.c index bd6bcc2..785f4fb 100644 --- a/src/sndcp/sndcp_xid.c +++ b/src/sndcp/sndcp_xid.c @@ -112,6 +112,10 @@ dst += rc; dst_counter += rc; + /* We still need to write 1 byte from here */ + if (dst_maxlen < dst_counter + 1) + return -ENOMEM; + /* Encode s01 (see also: 3GPP TS 44.065, 6.5.2.1, Table 5) */ if (params->s01 < 0 || params->s01 > 255) return -EINVAL; @@ -150,6 +154,10 @@ dst += rc; dst_counter += rc; + /* We still need to write 7 bytes from here */ + if (dst_maxlen < dst_counter + 7) + return -ENOMEM; + /* Encode F_MAX_PERIOD (see also: 3GPP TS 44.065, 6.5.3.1, Table 6) */ if (params->f_max_period < 1 || params->f_max_period > 65535) return -EINVAL; @@ -229,6 +237,10 @@ dst += rc; dst_counter += rc; + /* We still need to write 36 bytes from here */ + if (dst_maxlen < dst_counter + 36) + return -ENOMEM; + /* Encode MAX_CID (see also: 3GPP TS 44.065, 6.5.4.1, Table 10) */ if (params->max_cid < 0 || params->max_cid > 16383) return -EINVAL; @@ -285,6 +297,10 @@ dst += rc; dst_counter += rc; + /* We still need to write 4 bytes from here */ + if (dst_maxlen < dst_counter + 4) + return -ENOMEM; + /* Encode P0 (see also: 3GPP TS 44.065, 6.6.2.1, Table 7a) */ if (params->p0 < 0 || params->p0 > 3) return -EINVAL; @@ -337,6 +353,10 @@ dst += rc; dst_counter += rc; + /* We still need to write 10 bytes from here */ + if (dst_maxlen < dst_counter + 10) + return -ENOMEM; + /* Encode C0 (see also: 3GPP TS 44.065, 6.6.3.1, Table 7c) */ if (params->c0 != 0x80 && params->c0 != 0xC0) return -EINVAL; -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/44023?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Iff1dd10644e37e344ca822a91d156e50288fcb30 Gerrit-Change-Number: 44023 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • ...
  • 72
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.