laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/27650 )
Change subject: ts_102_221: Add encode/write support of EF.ARR records
......................................................................
ts_102_221: Add encode/write support of EF.ARR records
With this change, we can also encode/write EF.ARR records, not just
decode/read.
Change-Id: Id0da2b474d05aba12136b9cae402ad8326700182
---
M pySim/ts_102_221.py
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/50/27650/1
diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index 713d169..bf63f55 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -672,6 +672,11 @@
# 'un-flattening' decoder, and hence would be unable to encode :(
return dec[0]
+ def _encode_record_bin(self, in_json):
+ # we can only guess if we should decode for EF or DF here :(
+ arr_seq = DataObjectSequence('arr', sequence=[AM_DO_EF, SC_DO])
+ return arr_seq.encode_multi(in_json)
+
@with_default_category('File-Specific Commands')
class AddlShellCommands(CommandSet):
def __init__(self):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27650
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id0da2b474d05aba12136b9cae402ad8326700182
Gerrit-Change-Number: 27650
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/27649 )
Change subject: utils: Add DataObjectSequence.encode_multi()
......................................................................
utils: Add DataObjectSequence.encode_multi()
This is the analogous to the decode_multi() method.
Change-Id: Ifdd1b1bd4d67f447638858c3e92742ca6f884bfa
---
M pySim/utils.py
1 file changed, 12 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/49/27649/1
diff --git a/pySim/utils.py b/pySim/utils.py
index 8a7fcdb..ef770f9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1561,6 +1561,18 @@
i += 1
return encoded
+ def encode_multi(self, decoded) -> bytes:
+ """Encode multiple occurrences of the sequence from the decoded input data.
+ Args:
+ decoded : list of json-serializable input data; one sequence per list item
+ Returns:
+ binary encoded output data
+ """
+ encoded = bytearray()
+ for d in decoded:
+ encoded += self.encode(d)
+ return encoded
+
class CardCommand:
"""A single card command / instruction."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27649
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifdd1b1bd4d67f447638858c3e92742ca6f884bfa
Gerrit-Change-Number: 27649
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/27648 )
Change subject: utils: Fix bugs in DataObject encoders
......................................................................
utils: Fix bugs in DataObject encoders
The DataObject is some weird / rarely used different code than the
normal TLV encoder/decoder. It has apparently so far only been used
for decoding, without testing the encoding side, resulting in related
bugs.
Let's fix those that I encountered today, and add a test case.
Change-Id: I31370066f43c22fc3ce9e2b9ee75986a652f6fc4
---
M pySim/utils.py
M tests/test_utils.py
2 files changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/48/27648/1
diff --git a/pySim/utils.py b/pySim/utils.py
index 555aa82..8a7fcdb 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -1333,7 +1333,7 @@
bytes encoded in TLV format.
"""
val = self.to_bytes()
- return bytes(self._compute_tag()) + bytes(len(val)) + val
+ return bertlv_encode_tag(self._compute_tag()) + bertlv_encode_len(len(val)) + val
# 'codec' interface
def decode(self, binary: bytes) -> Tuple[dict, bytes]:
@@ -1481,7 +1481,8 @@
# 'codec' interface
def encode(self, decoded) -> bytes:
- obj = self.members_by_name(decoded[0])
+ obj = self.members_by_name[list(decoded)[0]]
+ obj.decoded = list(decoded.values())[0]
return obj.to_tlv()
diff --git a/tests/test_utils.py b/tests/test_utils.py
index ae23461..b7f790d 100755
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -4,6 +4,22 @@
from pySim import utils
from pySim.ts_31_102 import EF_SUCI_Calc_Info
+# we don't really want to thest TS 102 221, but the underlying DataObject codebase
+from pySim.ts_102_221 import AM_DO_EF, AM_DO_DF, SC_DO
+
+class DoTestCase(unittest.TestCase):
+
+ def testSeqOfChoices(self):
+ """A sequence of two choices with each a variety of DO/TLVs"""
+ arr_seq = utils.DataObjectSequence('arr', sequence=[AM_DO_EF, SC_DO])
+ # input data
+ dec_in = [{'access_mode': ['update_erase', 'read_search_compare']}, {'control_reference_template':'PIN1'}]
+ # encode it once
+ encoded = arr_seq.encode(dec_in)
+ # decode again
+ re_decoded = arr_seq.decode(encoded)
+ self.assertEqual(dec_in, re_decoded[0])
+
class DecTestCase(unittest.TestCase):
# TS33.501 Annex C.4 test keys
hnet_pubkey_profile_b = "0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1" # ID 27 in test file
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/27648
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I31370066f43c22fc3ce9e2b9ee75986a652f6fc4
Gerrit-Change-Number: 27648
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27646 )
Change subject: jenkins: Validate gsm 08.58 IEs are added to tlv_definition
......................................................................
Patch Set 3:
(1 comment)
File include/osmocom/gsm/protocol/gsm_08_58.h:
https://gerrit.osmocom.org/c/libosmocore/+/27646/comment/c7165e06_d3648808
PS3, Line 356: RSL_IE_LLP_APDU,
There's lots of lines above that don't have " = ". These are not covered by the check. Adjust them in the patch as well (or rather in a separate patch)?
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27646
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
Gerrit-Change-Number: 27646
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 05 Apr 2022 12:28:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: osmith, pespin.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27646 )
Change subject: jenkins: Validate gsm 08.58 IEs are added to tlv_definition
......................................................................
Patch Set 3:
(2 comments)
File include/osmocom/gsm/protocol/gsm_08_58.h:
https://gerrit.osmocom.org/c/libosmocore/+/27646/comment/ff5609dc_d41744b3
PS3, Line 388: RSL_IE_IPAC_RTP_PAYLOAD2 = 0xfc,
> It is needed to have same syntax in all enums, with a separation between name and equal. […]
Ok, fine then.
File src/gsm/rsl.c:
https://gerrit.osmocom.org/c/libosmocore/+/27646/comment/1ddafb2d_eeb5b33a
PS3, Line 128: [RSL_IE_IPAC_SRTP_CONFIG] = { TLV_TYPE_TLV },
> It's not unrelated, precisely having this line makes the new contrib/jenkins. […]
Ok, but I still think fixing things and adding build verification checks are separate things.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27646
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
Gerrit-Change-Number: 27646
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 05 Apr 2022 12:14:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: pespin, fixeria.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27644 )
Change subject: rsl: Fix tlv_parse of IPAC_DLCX_IND message
......................................................................
Patch Set 1:
(3 comments)
File tests/abis/abis_test.c:
https://gerrit.osmocom.org/c/libosmocore/+/27644/comment/2b2de44c_60f2dde4
PS1, Line 196: SYS#5915
> Same here.
I think it's fine as used here, the comment makes sense even without (being able to) reading the issue, but it can be useful if somebody wants the additional context.
https://gerrit.osmocom.org/c/libosmocore/+/27644/comment/c225a99e_363a7e7e
PS1, Line 235: 5891
* different issue number?
* I'd also not mention it here, having it once in the comment makes more sense IMHO
https://gerrit.osmocom.org/c/libosmocore/+/27644/comment/a9c14de7_52bc27f9
PS1, Line 251: sys5915
> It is still fine to add a suffix to it in case we want to test decoding same message type using diff […]
Using tickets in the function names seems weird to me. Even if one has access to it, it's not meaningful until looking up the ticket. I'd suggest using test_dec_ipac_dlc_indx() instead, and if we want to do additional tests like you said, then find another (hopefully more descriptive) suffix for those.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/27644
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib637197ef3508ec94aec05d08d4e6aa15ddea055
Gerrit-Change-Number: 27644
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 05 Apr 2022 12:11:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment