Attention is currently required from: Hoernchen.
laforge has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43172?usp=email )
Change subject: GP: LOAD/STORE DATA chunk size from SCP overhead
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/43172?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: Ic208f3959a38896f64fb6ccefb24cc360a3ac3a2
Gerrit-Change-Number: 43172
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 07 Aug 2026 07:50:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: Hoernchen, dexter, lynxis lazus.
laforge has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43136?usp=email )
Change subject: GP: mixed PSK TLS PUT KEY (Amendment B Table 3-13)
......................................................................
Patch Set 1:
(2 comments)
File pySim/global_platform/__init__.py:
https://gerrit.osmocom.org/c/pysim/+/43136/comment/f9c966a0_e5a90a56?usp=em… :
PS1, Line 655: (b'\x85' + bertlv_encode_len(len(block)) + block +
: bytes([len(kcv)]) + kcv)
I would have preferred the use of our object-oriented BER_TLV_IE encoder for the 0x85 as well as some new Transcodable-derived class for the LV KCV section. That would feel more "pysim-onic" to me ,than the low-level byte-concatenation here in a rather high-level method. Or alternatively some kind of costruct.
https://gerrit.osmocom.org/c/pysim/+/43136/comment/fb5dd59c_19f11f10?usp=em… :
PS1, Line 1113:
wouldn't this return more than the three bytes that the comment above indicates? But then, I see, the existing functions above do the same and the truncation happens in the shared compute_kcv() below.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/43136?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: I480a9d049a052aa5ae54fe6e2771dba44e89434d
Gerrit-Change-Number: 43136
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
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: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 07 Aug 2026 07:48:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: laforge.
Hoernchen has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/43171?usp=email )
Change subject: tlv: preserve the comprehension bit
......................................................................
Patch Set 1:
(1 comment)
File src/osmocom/tlv.py:
https://gerrit.osmocom.org/c/python/pyosmocom/+/43171/comment/97067343_d68b… :
PS1, Line 638: if x.tag > 0xff:
: # two byte tag: the comprehension bit is 0x8000!
: if x.tag & 0x8000 == 0:
: print("Fixing up COMPR_TLV_IE class %s: tag=0x%x has no comprehension bit" % (name, x.tag))
: x.tag = x.tag | 0x8000
> what exactly is the difference here? isn't this change semantically identical?
No, because the original condition was AND, so if either part didnt match it would fall through to the elif and that is what clobbered the two byte tag. As the comment says two byte is 0x8000 - precisely the part in the previous AND that would fail.
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/43171?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Ifae37785e2a586d9130d154bc7244f35fa6f2a55
Gerrit-Change-Number: 43171
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Thu, 06 Aug 2026 21:31:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Attention is currently required from: Hoernchen.
laforge has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/43171?usp=email )
Change subject: tlv: preserve the comprehension bit
......................................................................
Patch Set 1: Code-Review+1
(1 comment)
File src/osmocom/tlv.py:
https://gerrit.osmocom.org/c/python/pyosmocom/+/43171/comment/1567ed43_a4ce… :
PS1, Line 638: if x.tag > 0xff:
: # two byte tag: the comprehension bit is 0x8000!
: if x.tag & 0x8000 == 0:
: print("Fixing up COMPR_TLV_IE class %s: tag=0x%x has no comprehension bit" % (name, x.tag))
: x.tag = x.tag | 0x8000
what exactly is the difference here? isn't this change semantically identical?
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/43171?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Ifae37785e2a586d9130d154bc7244f35fa6f2a55
Gerrit-Change-Number: 43171
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 06 Aug 2026 16:33:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: fixeria, jolly.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/onomondo-eim/+/42881?usp=email )
Change subject: esipa_rest_utils: add support for PSMOs added in SGP.32 V.1.2
......................................................................
Patch Set 9:
(1 comment)
File contrib/rest_api_resource_schema.json:
https://gerrit.osmocom.org/c/onomondo-eim/+/42881/comment/452d1efe_6e49b3cd… :
PS9, Line 169: ,
> This would allow 0-9 and A-F and ','. I see it also in other definitions above and below.
Are you sure? I always thought the ',' is a delimiter. I used SGP.32, section 6.4.1. as an example. They also use a ',' in their definitions.
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/42881?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: I03cdd70065a83dfc611d614cf32d817c13fad347
Gerrit-Change-Number: 42881
Gerrit-PatchSet: 9
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 06 Aug 2026 15:57:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: jolly <andreas(a)eversberg.eu>
Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/43171?usp=email )
Change subject: tlv: preserve the comprehension bit
......................................................................
tlv: preserve the comprehension bit
The comprehension bit is data, not part of the tag: TS 101 220 7.1.1
defines it as an instruction to the receiver for treating
IEs it does not understand, which is why is_tag_compatible() masks it when
matching -> _encode_tag() re-emits the class tag, but ComprTlvMeta
forces CR, so decode(x)/encode() did not round trip properly
for IEs without the bit set
That is not hypothetical!
GP Amendment B administration session parameters stored by UICCs in an EF
carry the CAT TLVs inside tag 0x84 with the bit mixed:
- set on Command details and Device identities
- clear on the optional ones
That means reading and writing the same data led to not writing the
same data at all!
The cleanest fix here is to tri-state COMPR_TLV_IE.comprehension:
- None for an IE built from scratch which encode as before
- True/False for one parsed from a file which will now properly roundtrip.
_encode_tag() properly passes the flag to comprehensiontlv_encode_tag()
explicitly instead of deriving it from the int:
The int can't express "CR clear" for a one-byte tag at all, and
silently drops the flag for a two-byte one....
While at it fix ComprTlvMeta which would destroy two-byte tags
instead of setting the flag, currently tag=0x8123 -> 0x81a3.
Change-Id: Ifae37785e2a586d9130d154bc7244f35fa6f2a55
---
M src/osmocom/tlv.py
M tests/test_tlv.py
2 files changed, 63 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/71/43171/1
diff --git a/src/osmocom/tlv.py b/src/osmocom/tlv.py
index ada7380..9ca8728 100644
--- a/src/osmocom/tlv.py
+++ b/src/osmocom/tlv.py
@@ -635,20 +635,28 @@
if x.tag:
# we currently assume that the tag values always have the comprehension bit set;
# let's fix it up if a derived class has forgotten about that
- if x.tag > 0xff and x.tag & 0x8000 == 0:
- print("Fixing up COMPR_TLV_IE class %s: tag=0x%x has no comprehension bit" % (name, x.tag))
- x.tag = x.tag | 0x8000
+ if x.tag > 0xff:
+ # two byte tag: the comprehension bit is 0x8000!
+ if x.tag & 0x8000 == 0:
+ print("Fixing up COMPR_TLV_IE class %s: tag=0x%x has no comprehension bit" % (name, x.tag))
+ x.tag = x.tag | 0x8000
elif x.tag & 0x80 == 0:
print("Fixing up COMPR_TLV_IE class %s: tag=0x%x has no comprehension bit" % (name, x.tag))
x.tag = x.tag | 0x80
return x
class COMPR_TLV_IE(TLV_IE, metaclass=ComprTlvMeta):
- """TLV_IE formated as COMPREHENSION-TLV as described in ETSI TS 101 220."""
+ """TLV_IE formated as COMPREHENSION-TLV as described in ETSI TS 101 220.
+ - parsed IEs remember the bit and are emitted unchanged
+ - constructed IEs leave self.comprehension == None
+ and encode from class tag with forced CR by ComprTlvMeta with default "always CR" assumption
+ """
def __init__(self, **kwargs):
super().__init__(**kwargs)
- self.comprehension = False
+ # None: not parsed from file etc, so encode from the class tag
+ # True/False: as received
+ self.comprehension = None
@classmethod
def _decode_tag(cls, do: bytes) -> Tuple[dict, bytes]:
@@ -662,6 +670,19 @@
def _parse_len(cls, do: bytes) -> Tuple[int, bytes]:
return bertlv_parse_len(do)
+ @staticmethod
+ def _cr_mask(tag: int) -> int:
+ # The raw tag is always 0x7f_xx_xx for the 3 byte variant
+ return 0x8000 if tag > 0xffff else 0x80
+
+ def from_tlv(self, do: bytes, context: dict = {}):
+ """Record the comprehension bit and decode as usual."""
+ if len(do):
+ rawtag, _remainder = self._parse_tag_raw(do)
+ if rawtag:
+ self.comprehension = bool(rawtag & self._cr_mask(rawtag))
+ return super().from_tlv(do, context=context)
+
def is_tag_compatible(self, rawtag: int) -> bool:
"""Override is_tag_compatible as we need to mask out the
comprehension bit when doing compares."""
@@ -672,7 +693,14 @@
return ctag & 0x7f == rawtag & 0x7f
def _encode_tag(self) -> bytes:
- return comprehensiontlv_encode_tag(self._compute_tag())
+ # The class tag has a forced CR bit by ComprTlvMeta, so comprehensiontlv_encode_tag()
+ # gets bare tag + our explicit flag.
+ # The tag here is _just_ the class tag like 0x8123, not the raw tag like 0x7f8123
+ # so we check for 0xff and NOT 0xffff as above.
+ tag = self._compute_tag()
+ bit = 0x8000 if tag > 0xff else 0x80
+ compr = self.comprehension if self.comprehension is not None else bool(tag & bit)
+ return comprehensiontlv_encode_tag({'tag': tag & ~bit, 'comprehension': compr})
def _encode_len(self, val: bytes) -> bytes:
return bertlv_encode_len(len(val))
diff --git a/tests/test_tlv.py b/tests/test_tlv.py
index 6d33492..4d06d1d 100755
--- a/tests/test_tlv.py
+++ b/tests/test_tlv.py
@@ -18,7 +18,7 @@
import unittest
from construct import Int8ub, GreedyBytes
-from osmocom.tlv import COMPACT_TLV_IE, IE, TLV_IE_Collection, Transcodable, flatten_dict_lists, camel_to_snake
+from osmocom.tlv import COMPACT_TLV_IE, COMPR_TLV_IE, IE, TLV_IE_Collection, Transcodable, flatten_dict_lists, camel_to_snake
from osmocom.tlv import bertlv_encode_len, bertlv_parse_len, bertlv_parse_one, bertlv_parse_tag
from osmocom.tlv import comprehensiontlv_encode_tag, comprehensiontlv_parse_tag
from osmocom.tlv import dgi_encode_len, dgi_parse_len
@@ -74,6 +74,34 @@
res = comprehensiontlv_encode_tag({'tag': 0x1234, 'comprehension':True})
self.assertEqual(res, b'\x7f\x92\x34')
+ def test_ComprTlvIeCrRoundTrip(self):
+ """comprehension bit is data (TS 101 220 7.1.1) and has to survive decode/encode round trips.
+ It is clear in stored files, e.g. GP Amd B administration session parameters in a card EF
+ """
+ class MyIE(COMPR_TLV_IE, tag=0xbe):
+ _construct = GreedyBytes
+
+ for encoded in (b'\xbe\x02\xca\xfe', b'\x3e\x02\xca\xfe'):
+ ie = MyIE()
+ ie.from_tlv(encoded)
+ self.assertEqual(ie.to_tlv(), encoded)
+
+ # ...but an IE we build from scratch still encodes from the class tag (CR set)
+ ie = MyIE()
+ ie.from_bytes(b'\xca\xfe')
+ self.assertIsNone(ie.comprehension)
+ self.assertEqual(ie.to_tlv(), b'\xbe\x02\xca\xfe')
+
+ def test_ComprTlvIeCrRoundTripTwoByteTag(self):
+ """check that we do not mangle two byte tags"""
+ class MyLongIE(COMPR_TLV_IE, tag=0x8123):
+ _construct = GreedyBytes
+
+ for encoded in (b'\x7f\x81\x23\x01\xff', b'\x7f\x01\x23\x01\xff'):
+ ie = MyLongIE()
+ ie.from_tlv(encoded)
+ self.assertEqual(ie.to_tlv(), encoded)
+
class TestDgiTlv(unittest.TestCase):
def test_DgiTlvLenEnc(self):
self.assertEqual(dgi_encode_len(10), b'\x0a')
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/43171?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: Ifae37785e2a586d9130d154bc7244f35fa6f2a55
Gerrit-Change-Number: 43171
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Attention is currently required from: pespin.
fixeria has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/osmo-trx/+/43108?usp=email )
Change subject: libosmo-trx/client: add TRXC client (command queue) API
......................................................................
Patch Set 3:
(1 comment)
File libosmo-trx/src/trxc_client.c:
https://gerrit.osmocom.org/c/osmo-trx/+/43108/comment/005a5f69_0cfa9b1d?usp… :
PS3, Line 474: sf->cb(client, 0, sf->cb_data);
> By freeing "sf" after the cb, you may end up in a double free if the user callback frees the "client […]
Many things can go wrong if the callback free()s the client - this is currently not supported and calling `osmo_trxc_client_free()` would result in an assertion failure `OSMO_ASSERT(!client->in_rx)`.
--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/43108?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I817e394f74a10e3adae4a0b58342c82acdf0794e
Gerrit-Change-Number: 43108
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 06 Aug 2026 13:53:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Attention is currently required from: jolly.
pespin has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42817?usp=email )
Change subject: Add VTY test for "listen" node of osmo-stp VTY config
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42817?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ia1ceb5f0374f47ff269b557be30fc4d59550d1a6
Gerrit-Change-Number: 42817
Gerrit-PatchSet: 4
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Comment-Date: Thu, 06 Aug 2026 08:31:03 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes