Attention is currently required from: laforge.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/35565?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: ts_102_221: Better explain 'selected file invalidated'
......................................................................
ts_102_221: Better explain 'selected file invalidated'
Some specs call it 'invalidated', others call it 'deactivated'. If the
user is unfamiliar with this, the error message about "invalidated"
might not be obvious enough; let's also mention 'deactivated' in the
message and explicitly mention that it needs to be activated before use.
Change-Id: I91488b0e7dc25a8970022b09e575485a4165eefa
---
M docs/shell.rst
M pySim-shell.py
M pySim/ts_102_221.py
3 files changed, 37 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/65/35565/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35565?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I91488b0e7dc25a8970022b09e575485a4165eefa
Gerrit-Change-Number: 35565
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newpatchset
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35556?usp=email )
Change subject: TLV: Add DGI encoding of "GP Scripting Language Annex B"
......................................................................
TLV: Add DGI encoding of "GP Scripting Language Annex B"
The DGI encoding is specified in Annex B of the
"GlobalPlatform Systems Scripting Language Specification v1.1.0"
which is an "archived" specification that is no longer published
by GlobalPlatform, despite it being referenced from the GlobalPlatform
Card Specification v2.3, which is the basis of the GSMA eSIM
specifications.
For some reason it was the belief of the specification authors that
yet another format of TLV encoding is needed, in addition to the BER-TLV
and COMPREHENSION-TLV used by the very same specifications.
The encoding of the tag is not really specified anywhere, but I've only
seen 16-bit examples. The encoding of the length is specified and
implemented here accordingly.
Change-Id: Ie29ab7eb39f3165f3d695fcc1f02051338095697
---
M pySim/tlv.py
M pySim/utils.py
M tests/test_utils.py
3 files changed, 97 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/pySim/tlv.py b/pySim/tlv.py
index 826f02f..31051aa 100644
--- a/pySim/tlv.py
+++ b/pySim/tlv.py
@@ -24,6 +24,7 @@
from pySim.utils import bertlv_encode_len, bertlv_parse_len, bertlv_encode_tag, bertlv_parse_tag
from pySim.utils import comprehensiontlv_encode_tag, comprehensiontlv_parse_tag
from pySim.utils import bertlv_parse_tag_raw, comprehensiontlv_parse_tag_raw
+from pySim.utils import dgi_parse_tag_raw, dgi_parse_len, dgi_encode_tag, dgi_encode_len
from pySim.construct import build_construct, parse_construct, LV, HexAdapter, BcdAdapter, BitsRFU, GsmStringAdapter
from pySim.exceptions import *
@@ -302,6 +303,27 @@
return bertlv_encode_len(len(val))
+class DGI_TLV_IE(TLV_IE):
+ """TLV_IE formated as GlobalPlatform Systems Scripting Language Specification v1.1.0 Annex B."""
+
+ def __init__(self, **kwargs):
+ super().__init__(**kwargs)
+
+ @classmethod
+ def _parse_tag_raw(cls, do: bytes) -> Tuple[int, bytes]:
+ return dgi_parse_tag_raw(do)
+
+ @classmethod
+ def _parse_len(cls, do: bytes) -> Tuple[int, bytes]:
+ return dgi_parse_len(do)
+
+ def _encode_tag(self) -> bytes:
+ return dgi_encode_tag(self._compute_tag())
+
+ def _encode_len(self, val: bytes) -> bytes:
+ return dgi_encode_len(len(val))
+
+
class TLV_IE_Collection(metaclass=TlvCollectionMeta):
# we specify the metaclass so any downstream subclasses will automatically use it
"""A TLV_IE_Collection consists of multiple TLV_IE classes identified by their tags.
diff --git a/pySim/utils.py b/pySim/utils.py
index 6523d98..581abf2 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -358,6 +358,42 @@
return (tagdict, length, value, remainder)
+def dgi_parse_tag_raw(binary: bytes) -> Tuple[int, bytes]:
+ # In absence of any clear spec guidance we assume it's always 16 bit
+ return int.from_bytes(binary[:2], 'big'), binary[2:]
+
+def dgi_encode_tag(t: int) -> bytes:
+ return t.to_bytes(2, 'big')
+
+def dgi_encode_len(length: int) -> bytes:
+ """Encode a single Length value according to GlobalPlatform Systems Scripting Language
+ Specification v1.1.0 Annex B.
+ Args:
+ length : length value to be encoded
+ Returns:
+ binary output data of encoded length field
+ """
+ if length < 255:
+ return length.to_bytes(1, 'big')
+ elif length <= 0xffff:
+ return b'\xff' + length.to_bytes(2, 'big')
+ else:
+ raise ValueError("Length > 32bits not supported")
+
+def dgi_parse_len(binary: bytes) -> Tuple[int, bytes]:
+ """Parse a single Length value according to GlobalPlatform Systems Scripting Language
+ Specification v1.1.0 Annex B.
+ Args:
+ binary : binary input data of BER-TLV length field
+ Returns:
+ Tuple of (length, remainder)
+ """
+ if binary[0] == 255:
+ assert len(binary) >= 3
+ return ((binary[1] << 8) | binary[2]), binary[3:]
+ else:
+ return binary[0], binary[1:]
+
# IMSI encoded format:
# For IMSI 0123456789ABCDE:
#
diff --git a/tests/test_utils.py b/tests/test_utils.py
index ea1964b..7609f80 100755
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -222,5 +222,19 @@
res = utils.comprehensiontlv_encode_tag({'tag': 0x1234, 'comprehension':True})
self.assertEqual(res, b'\x7f\x92\x34')
+class TestDgiTlv(unittest.TestCase):
+ def test_DgiTlvLenEnc(self):
+ self.assertEqual(utils.dgi_encode_len(10), b'\x0a')
+ self.assertEqual(utils.dgi_encode_len(254), b'\xfe')
+ self.assertEqual(utils.dgi_encode_len(255), b'\xff\x00\xff')
+ self.assertEqual(utils.dgi_encode_len(65535), b'\xff\xff\xff')
+ with self.assertRaises(ValueError):
+ utils.dgi_encode_len(65536)
+
+ def testDgiTlvLenDec(self):
+ self.assertEqual(utils.dgi_parse_len(b'\x0a\x0b'), (10, b'\x0b'))
+ self.assertEqual(utils.dgi_parse_len(b'\xfe\x0b'), (254, b'\x0b'))
+ self.assertEqual(utils.dgi_parse_len(b'\xff\x00\xff\x0b'), (255, b'\x0b'))
+
if __name__ == "__main__":
unittest.main()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35556?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie29ab7eb39f3165f3d695fcc1f02051338095697
Gerrit-Change-Number: 35556
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/35564?usp=email )
Change subject: global_platform: More definitions to support key loading
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35564?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I853c94d37939ef3dd795f893232b0276a5a4af81
Gerrit-Change-Number: 35564
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Tue, 16 Jan 2024 18:03:35 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35595?usp=email )
Change subject: pySim-shell: Permit 'reset' command also in unqeuipped stage
......................................................................
pySim-shell: Permit 'reset' command also in unqeuipped stage
If we are not 'equipped' as we could not detect any known applications
on the card, we used to only permit the 'apdu' command. However, we
should also permit the 'reset' command, as it also is something that's
possible with ever card, even of unknown types.
Change-Id: I23199da727973d7095ac18031f49e1e8423aa287
---
M pySim-shell.py
1 file changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/95/35595/1
diff --git a/pySim-shell.py b/pySim-shell.py
index c645403..5b80588 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -254,6 +254,13 @@
if not sw_match(sw, opts.expect_sw):
raise SwMatchError(sw, opts.expect_sw)
+ @cmd2.with_category(CUSTOM_CATEGORY)
+ def do_reset(self, opts):
+ """Reset the Card."""
+ atr = self.card.reset()
+ self.poutput('Card ATR: %s' % i2h(atr))
+ self.update_prompt()
+
class InterceptStderr(list):
def __init__(self):
self._stderr_backup = sys.stderr
@@ -702,12 +709,6 @@
raise RuntimeError(
"unable to export %i dedicated files(s)%s" % (context['ERR'], exception_str_add))
- def do_reset(self, opts):
- """Reset the Card."""
- atr = self._cmd.card.reset()
- self._cmd.poutput('Card ATR: %s' % i2h(atr))
- self._cmd.update_prompt()
-
def do_desc(self, opts):
"""Display human readable file description for the currently selected file"""
desc = self._cmd.lchan.selected_file.desc
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35595?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I23199da727973d7095ac18031f49e1e8423aa287
Gerrit-Change-Number: 35595
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: jolly.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/35572?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: Add logging category for libosmo-cc
......................................................................
Add logging category for libosmo-cc
A new library is introduced: https://gitea.osmocom.org/cc/libosmo-cc
It depends on logging API of libosmocore. The new category is DLCC.
Change-Id: I9df433b2cfb51f04dbf16e9f8dee567a59ab5cb7
---
M include/osmocom/core/logging.h
M src/core/logging.c
M tests/logging/logging_vty_test.vty
3 files changed, 23 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/72/35572/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35572?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I9df433b2cfb51f04dbf16e9f8dee567a59ab5cb7
Gerrit-Change-Number: 35572
Gerrit-PatchSet: 2
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-MessageType: newpatchset