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

September 2026

  • 1 participants
  • 1894 discussions
[S] Change in pysim[master]: pySim-shell: enable apdu_strict by default
by laforge 25 Sep '26

25 Sep '26
Attention is currently required from: Hoernchen, dexter. laforge has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43726?usp=email ) Change subject: pySim-shell: enable apdu_strict by default ...................................................................... Patch Set 1: (1 comment) Patchset: PS1: it's not that long ago since we merged the apdu_strict setting in the first place, is it? It's not even one year ago. I would wait for some more time, but I don't have super strong feelings about it, if a majorty of people think this should be merged. -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43726?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: Ic413e12e2792e8cd9d455b1b0d6791bdf757c80e Gerrit-Change-Number: 43726 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-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 25 Sep 2026 13:57:33 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No
1 0
0 0
[M] Change in pysim[master]: euicc: fix profile reset DER encoding
by laforge 25 Sep '26

25 Sep '26
Attention is currently required from: Hoernchen, dexter. laforge has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43725?usp=email ) Change subject: euicc: fix profile reset DER encoding ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43725?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: I318ea7b08bad9e0b34b14929ef750151f4c5fa4e Gerrit-Change-Number: 43725 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-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 25 Sep 2026 13:55:51 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in pysim[master]: ota: argparse helpers for the SCP80 key set and SPI
by dexter 25 Sep '26

25 Sep '26
Attention is currently required from: Hoernchen, laforge. dexter has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43720?usp=email ) Change subject: ota: argparse helpers for the SCP80 key set and SPI ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43720?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: I599a07f7e4e100ddce91ee7eae70bab3cf9c07c1 Gerrit-Change-Number: 43720 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-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Fri, 25 Sep 2026 13:08:22 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in pysim[master]: bip: report a location in PROVIDE LOCAL INFORMATION
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43565?usp=email ) Change subject: bip: report a location in PROVIDE LOCAL INFORMATION ...................................................................... bip: report a location in PROVIDE LOCAL INFORMATION TS 102 223 6.8.7: TERMINAL RESPONSE shall contain the data object the command qualifier (6.6.15) asked for. The card always asks for location information, so at least answer 00, with the GERAN form of TS 131.111 8.19.1, PLMN 262-01. Do not answer "terminal currently unable to process - no service"... Change-Id: I53547da2ea9f0a4ea7a4dd032985a546f2d4277f --- M pySim/bip.py M pySim/cat.py M tests/unittests/test_bip_relay.py 3 files changed, 57 insertions(+), 4 deletions(-) Approvals: dexter: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/bip.py b/pySim/bip.py index 549655a..1cd3ba0 100644 --- a/pySim/bip.py +++ b/pySim/bip.py @@ -39,10 +39,16 @@ from pySim.cat import (ProactiveCommand, SendShortMessage, SMS_TPDU, SMSPPDownload, BearerDescription, DeviceIdentities, Address, OtherAddress, UiccTransportLevel, BufferSize, ChannelStatus, ChannelData, - ChannelDataLength, EventList, EventDownload, Result) + ChannelDataLength, EventList, EventDownload, Result, + CommandDetails, LocationInformation) logger = logging.getLogger(__name__) +# PROVIDE LOCAL INFORMATION location, GERAN TS 31.111 8.19.1 +# - 3 byte PLMN of TS 24.008 10.5.1.3 -> 262-01 +# - 2 byte LAC and a 2 byte cid. +DEFAULT_LOCATION = h2b('62f21000010001') + def terminal_profile(num_channels: int = 7) -> bytes: """TERMINAL PROFILE for what we implement, TS 102 223 5.2 and annex T. @@ -247,12 +253,29 @@ sms_sink: callback(pdu), called with the SMPP deliver_sm of a SEND SHORT MESSAGE the card issued; pySim-smpp2sim.py hands it to its SMPP server. None: the SMS is logged and dropped. + location: Location information returned in PROVIDE LOCAL INFORMATION (location). """ - def __init__(self, data_available_sink=None, sms_sink=None): + def __init__(self, data_available_sink=None, sms_sink=None, location: bytes = DEFAULT_LOCATION): self.data_available_sink = data_available_sink self.sms_sink = sms_sink + self.location = location self.channels = ProactChannels(on_data_available=self._on_channel_data_available) + def handle_ProvideLocalInformation(self, pcmd: ProactiveCommand): + """only location + + TS 102 223 6.8.7 says TERMINAL RESPONSE to PROVIDE LOCAL INFORMATION "shall" + contain the data object the command qualifier (6.6.15) asked for. At least answer '00', + location information, usually requested. + + answering "terminal currently unable to process - no service", which is a handset + out of coverage makes SJA5 believe it and postpones the entire session! + it registers a location status event, starts a ten minute timer and waits for coverage.""" + cmd_det_ie = Proact._find_first_element_of_type(pcmd.children, CommandDetails) + if cmd_det_ie is not None and cmd_det_ie.decoded['command_qualifier'] == 0x00: + return self.prepare_response(pcmd) + [LocationInformation(decoded=self.location)] + return self.prepare_response(pcmd) + def receive_fetch(self, pcmd: ProactiveCommand): """Answer anything this handler has no specific handler for. diff --git a/pySim/cat.py b/pySim/cat.py index 92b7ea3..e65af3f 100644 --- a/pySim/cat.py +++ b/pySim/cat.py @@ -318,7 +318,9 @@ # TS 102 223 Section 8.19 class LocationInformation(COMPR_TLV_IE, tag=0x93): - pass + # 8.19: coding is per access technology, and the lengths differ (TS 131.111 8.19.1-.4: GERAN 7, + # UTRAN/E-UTRAN 9, NG-RAN 11) with nothing in the IE to say which -> keep the value opaque. + _construct = GreedyBytes class MobileIdentityAdapter(Adapter): """TS 124.008 section 10.5.1.4 figure 10.5.4 + table 10.5.4 diff --git a/tests/unittests/test_bip_relay.py b/tests/unittests/test_bip_relay.py index 46281bd..5f72411 100644 --- a/tests/unittests/test_bip_relay.py +++ b/tests/unittests/test_bip_relay.py @@ -28,7 +28,7 @@ from pySim.cat import (ProactiveCommand, CommandDetails, DeviceIdentities, BearerDescription, BufferSize, UiccTransportLevel, OtherAddress, ChannelData, ChannelDataLength, ChannelStatus, - Result) + Result, LocationInformation) from pySim.bip import Proact, ProactChannels, terminal_profile @@ -329,6 +329,34 @@ self.assertEqual(self.proact.channels.channels, {}) # channel given back +class ProvideLocalInformationTest(unittest.TestCase): + """TS 102 223 6.8.7: only 00 gets a data object; the rest keeps the empty result.""" + + def _cmd(self, qualifier): + return _pcmd([ + CommandDetails(decoded={'command_number': 1, 'type_of_command': 'provide_local_info', + 'command_qualifier': qualifier}).to_tlv(), + DeviceIdentities(decoded={'source_dev_id': 'uicc', 'dest_dev_id': 'terminal'}).to_tlv()]) + + def test_location(self): + til = Proact().handle_ProvideLocalInformation(self._cmd(0x00)) + b''.join(x.to_tlv() for x in til) + self.assertEqual(_first(til, Result).decoded['general_result'], 'performed_successfully') + self.assertEqual(b2h(_first(til, LocationInformation).to_tlv()), '930762f21000010001') + self.assertEqual(b2h(_first(til, DeviceIdentities).to_tlv()), '82028281') # 6.8.2 + + def test_other_qualifiers_get_no_data_object(self): + for qualifier in (0x01, 0x03, 0x04, 0x1a): + with self.subTest(command_qualifier=qualifier): + til = Proact().handle_ProvideLocalInformation(self._cmd(qualifier)) + b''.join(x.to_tlv() for x in til) + self.assertIsNone(_first(til, LocationInformation)) + + def test_location_is_configurable(self): + til = Proact(location=h2b('26f8100539')).handle_ProvideLocalInformation(self._cmd(0x00)) + self.assertEqual(b2h(_first(til, LocationInformation).to_tlv()), '930526f8100539') + + class TerminalProfileTest(unittest.TestCase): """TS 102 223 5.2, one bit per CAT facility""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43565?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: I53547da2ea9f0a4ea7a4dd032985a546f2d4277f Gerrit-Change-Number: 43565 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in pysim[master]: contrib: add scp81 OTA trigger builder
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43566?usp=email ) Change subject: contrib: add scp81 OTA trigger builder ...................................................................... contrib: add scp81 OTA trigger builder Change-Id: Ic646626319cd7a26195d0ffff55900032abcddeb --- A contrib/scp81_trigger.py 1 file changed, 100 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, approved diff --git a/contrib/scp81_trigger.py b/contrib/scp81_trigger.py new file mode 100755 index 0000000..0d84a77 --- /dev/null +++ b/contrib/scp81_trigger.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""scp81_trigger.py -- build the OTA packet that asks the card to open an SCP81 admin session.""" + +# (C) 2026 by sysmocom - s.f.m.c. GmbH +# All Rights Reserved +# +# Author: Eric Wild <ewild(a)sysmocom.de> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +# Prints the apdu line for AdmSessTriggerParams TLV as the sms secured data, Expanded RFM mode, +# to be fed into pysim_shell.py +# +# security params supplied either +# - in the trigger +# - from the cards data object, +# trigger wins when both are present. +# --no-sec omits them from the trigger so the stored ones are used. +# +# example params: +# --psk-id 'PSK Identity 123' --kvn 0x41 --kid-ref 5 +# --ip 127.0.0.1 --port 8080 --buffer 512 +# --host 172.96.0.1 --uri '/server/adminagent?cmd=1' + +import argparse +import sys + +from osmocom.utils import b2h # noqa: E402 +from pySim.cat import (sms_pp_download_envelope, BearerDescription, # noqa: E402 + BufferSize, UiccTransportLevel, OtherAddress) +from pySim.global_platform.http import (AdmSessTriggerParams, AdmSessionParams, # noqa: E402 + SecurityParams, HttpPostParams, RasConnectionParams, + AdminHostParam, AdminUriParam) + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument("--psk-id", help="PSK identity for ClientHello (required, unless --no-sec)") + ap.add_argument("--kvn", type=lambda s: int(s, 0), help="key version of the PSK (required, unless --no-sec)") + ap.add_argument("--kid-ref", type=lambda s: int(s, 0), help="PSK key id (required, unless --no-sec)") + ap.add_argument("--host", help="HTTP Host header (required, unless --no-http)") + ap.add_argument("--uri", help="HTTP request URI (required, unless --no-http)") + ap.add_argument("--ip", help="administration server address, BIP (required, unless --no-conn)") + ap.add_argument("--port", type=int, help="administration server port (required, unless --no-conn)") + ap.add_argument("--buffer", type=int, help="BIP buffer size (required, unless --no-conn)") + ap.add_argument("--no-conn", action="store_true", help="omit the connection params (tag 0x84)") + ap.add_argument("--no-sec", action="store_true", help="omit the security params (tag 0x85)") + ap.add_argument("--no-http", action="store_true", help="omit the HTTP POST params (tag 0x89)") + + args = ap.parse_args() + + missing = [] + if not args.no_conn: + missing += [n for n in ('ip', 'port', 'buffer') if getattr(args, n) is None] + if not args.no_sec: + missing += [n for n in ('psk_id', 'kvn', 'kid_ref') if getattr(args, n) is None] + if not args.no_http: + missing += [n for n in ('host', 'uri') if getattr(args, n) is None] + if missing: + ap.error("pass every value required: %s." % " ".join("--" + n.replace('_', '-') for n in missing)) + + session = [] + if not args.no_conn: + session.append(RasConnectionParams(children=[ + BearerDescription(decoded={'bearer_type': 'default', 'bearer_parameters': ''}), + BufferSize(decoded=args.buffer), + UiccTransportLevel(decoded={'protocol_type': 'tcp_uicc_client_remote', + 'port_number': args.port}), + OtherAddress(decoded={'type_of_address': 'ipv4', + 'address': bytes(int(b) for b in args.ip.split("."))})])) + if not args.no_sec: + session.append(SecurityParams(decoded={'psk_id': args.psk_id.encode(), 'kvn': args.kvn, + 'kid': args.kid_ref, 'sha_type': None})) + if not args.no_http: + session.append(HttpPostParams(children=[AdminHostParam(decoded=args.host), + AdminUriParam(decoded=args.uri)])) + trig = AdmSessTriggerParams(children=[AdmSessionParams(children=session)]).to_tlv() + + # stderr for logs, stdout for data + print("# trigger TLV %d B %s" % (len(trig), trig.hex()), file=sys.stderr) + print("# %-13s %d B %s" % ("secured data", len(trig), trig.hex()), file=sys.stderr) + print(trig.hex()) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43566?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: Ic646626319cd7a26195d0ffff55900032abcddeb Gerrit-Change-Number: 43566 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: pySim.log: apply cmd2 colors through _style()
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43567?usp=email ) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pySim.log: apply cmd2 colors through _style() ...................................................................... pySim.log: apply cmd2 colors through _style() The color scheme takes either - a raw escape sequence like "\033[33m" (pySim-read, pySim-prog, contrib/csv-to-pgsql.py) - a cmd2 color object (pySim-shell) Color of cmd2 >= 3.0.0 is a StrEnum, which led to pySim-shell warnings like yellowWARNING: EF.DIR seems to be empty! with a stray reset at the end. Fixed by exclusing Enum from the raw sequence branch. Change-Id: I8bae9fc3c54f1dab481d743d3b68e32e9d09267a --- M pySim/log.py M tests/unittests/test_log.py 2 files changed, 24 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve dexter: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/log.py b/pySim/log.py index 3fad90b..5aeeed4 100644 --- a/pySim/log.py +++ b/pySim/log.py @@ -24,6 +24,7 @@ # import logging +import enum import cmd2 from packaging import version @@ -126,7 +127,7 @@ formatted_message = logging.Formatter.format(PySimLogger.__formatter, record) color = PySimLogger.colors.get(record.levelno) if color: - if isinstance(color, str): + if isinstance(color, str) and not isinstance(color, enum.Enum): PySimLogger.print_callback(color + formatted_message + "\033[0m") else: PySimLogger.print_callback(_style(formatted_message, fg = color)) diff --git a/tests/unittests/test_log.py b/tests/unittests/test_log.py index ac651ae..a43fe41 100755 --- a/tests/unittests/test_log.py +++ b/tests/unittests/test_log.py @@ -20,11 +20,20 @@ import unittest import logging +import cmd2 +from packaging import version from pySim.log import PySimLogger import io import sys from inspect import currentframe, getframeinfo +if version.parse(cmd2.__version__) >= version.parse("3.0.0"): + from cmd2 import Color # pylint: disable=no-name-in-module + YELLOW = Color.YELLOW +else: # cmd2>=2.6.2 + from cmd2 import Fg # pylint: disable=no-name-in-module + YELLOW = Fg.YELLOW + log = PySimLogger.get(__name__) TEST_MSG_DEBUG = "this is a debug message" @@ -128,5 +137,18 @@ expected_message = "CRITICAL: " + TEST_MSG_CRITICAL log.critical(TEST_MSG_CRITICAL) + def test_05_color(self): + # A color is either + # - raw escape sequence + # - cmd2 color object + global expected_message + expected_message = "\033[33mWARNING: " + TEST_MSG_WARNING + "\033[0m" + + PySimLogger.setup(self._test_print_callback, {logging.WARN: "\033[33m"}) + log.warning(TEST_MSG_WARNING) + + PySimLogger.setup(self._test_print_callback, {logging.WARN: YELLOW}) + log.warning(TEST_MSG_WARNING) # don't leak cmd2 Color StrEnum + if __name__ == '__main__': unittest.main() -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43567?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: I8bae9fc3c54f1dab481d743d3b68e32e9d09267a Gerrit-Change-Number: 43567 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in pysim[master]: sysmocom_sjs1: CardModel for the sysmoUSIM-SJS1
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43568?usp=email ) Change subject: sysmocom_sjs1: CardModel for the sysmoUSIM-SJS1 ...................................................................... sysmocom_sjs1: CardModel for the sysmoUSIM-SJS1 SJS1 model lifted off the the legacy SysmoUSIMSJS1.program(), ADM is ADM1 with CHV 0x0a, already used by the generic UiccCardBase default. Change-Id: I32b011c68de5f990e709718b313b6f28a31ca78b --- M pySim/app.py A pySim/sysmocom_sjs1.py M tests/unittests/test_files.py 3 files changed, 66 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve dexter: Looks good to me, approved diff --git a/pySim/app.py b/pySim/app.py index 4e88788..b8c505f 100644 --- a/pySim/app.py +++ b/pySim/app.py @@ -30,10 +30,11 @@ log = PySimLogger.get(__name__) -# we need to import this module so that the SysmocomSJA2 sub-class of -# CardModel is created, which will add the ATR-based matching and -# calling of SysmocomSJA2.add_files. See CardModel.apply_matching_models +# we need to import these modules so that the SysmocomSJA2 / SysmocomSJS1 +# sub-classes of CardModel are created, which will add the ATR-based matching +# and calling of their add_files. See CardModel.apply_matching_models import pySim.sysmocom_sja2 +import pySim.sysmocom_sjs1 # we need to import these modules so that the various sub-classes of # CardProfile are created, which will be used in init_card() to iterate diff --git a/pySim/sysmocom_sjs1.py b/pySim/sysmocom_sjs1.py new file mode 100644 index 0000000..8f8c044 --- /dev/null +++ b/pySim/sysmocom_sjs1.py @@ -0,0 +1,61 @@ +# coding=utf-8 +"""Utilities / Functions related to sysmocom sysmoUSIM-SJS1 cards + +(C) 2026 by sysmocom - s.f.m.c. GmbH +All Rights Reserved + +Author: Eric Wild <ewild(a)sysmocom.de> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +""" + +from construct import Struct, Bytes, Flag +from osmocom.utils import * +from osmocom.construct import * + +from pySim.filesystem import * +from pySim.runtime import RuntimeState + + +class EF_Ki(TransparentEF): + _test_de_encode = [ + ('000102030405060708090a0b0c0d0e0f', + {'key': h2b('000102030405060708090a0b0c0d0e0f')}), + ] + + def __init__(self, fid='00ff', name='EF.Ki'): + super().__init__(fid, name=name, desc='K/Ki authentication key', size=(16, 16)) + self._construct = Struct('key'/Bytes(16)) + + +class EF_OPc(TransparentEF): + _test_de_encode = [ + ('016ca53d7a0a804561646816d7b0c702fb', + {'use_opc_instead_of_op': True, 'op_opc': h2b('6ca53d7a0a804561646816d7b0c702fb')}), + ] + + def __init__(self, fid='00f7', name='EF.OPc'): + super().__init__(fid, name=name, desc='OP/OPc for milenage', size=(17, 17)) + self._construct = Struct('use_opc_instead_of_op'/Flag, 'op_opc'/Bytes(16)) + + +class SysmoUSIMSJS1(CardModel): + _atrs = ["3b9f96801fc78031a073be21136743200718000001a5"] + + @classmethod + def add_files(cls, rs: RuntimeState): + """Add sysmoUSIM-SJS1 specific files to given RuntimeState.""" + # the key material lives in DF.GSM shared with ADF.USIM + if '7f20' in rs.mf.children: + rs.mf.children['7f20'].add_files([EF_Ki(), EF_OPc()]) diff --git a/tests/unittests/test_files.py b/tests/unittests/test_files.py index e7c50dc..e8a7bc0 100755 --- a/tests/unittests/test_files.py +++ b/tests/unittests/test_files.py @@ -27,6 +27,7 @@ import pySim.ts_31_103 import pySim.ts_51_011 import pySim.sysmocom_sja2 +import pySim.sysmocom_sjs1 import pySim.gsm_r import pySim.cdma_ruim -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43568?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: I32b011c68de5f990e709718b313b6f28a31ca78b Gerrit-Change-Number: 43568 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in pysim[master]: sms: don't mutate digits in AddressField.to_bytes()
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43556?usp=email ) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: sms: don't mutate digits in AddressField.to_bytes() ...................................................................... sms: don't mutate digits in AddressField.to_bytes() to_bytes() appended the BCD filler nibble, so the next call saw one digit more and derived a wrong length. This affects any code that encodes an address twice, even for printing/logging. Man, I really miss my beloved c++ const function decoration... Fix: keep the filler in a local. Change-Id: I81691c5a1fc5072d6d20c52d22da1eb2e180d04a --- M pySim/sms.py 1 file changed, 3 insertions(+), 3 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve dexter: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/sms.py b/pySim/sms.py index 75a9bde..55afbb7 100644 --- a/pySim/sms.py +++ b/pySim/sms.py @@ -246,8 +246,8 @@ def to_bytes(self) -> bytes: """Encode the AddressField into the binary representation as used in T-PDU.""" num_digits = len(self.digits) - if num_digits % 2: - self.digits += 'f' + # don't store the filler nibble or get_bytes() encodes it as digit and ends up too large + digits = self.digits + 'f' if num_digits % 2 else self.digits d = { 'addr_len': num_digits, 'type_of_addr': { @@ -255,7 +255,7 @@ 'type_of_number': self.ton, 'numbering_plan_id': self.npi, }, - 'digits': self.digits, + 'digits': digits, } return self._construct.build(d) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43556?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: I81691c5a1fc5072d6d20c52d22da1eb2e180d04a Gerrit-Change-Number: 43556 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: cat: add sms_pp_download_envelope()
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43557?usp=email ) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: cat: add sms_pp_download_envelope() ...................................................................... cat: add sms_pp_download_envelope() Put a helper for wrapping an SMS-DELIVER TPDU in the ENVELOPE of TS 102 223 section 7.5.1 the assembly next to SMSPPDownload, where the IEs already live, so it can be reused by other tooling, for example for triggering scp81 sessions. Change-Id: Id23227eac53d697f4f13a84e087c32bf1d60f474 --- M pySim-smpp2sim.py M pySim/cat.py 2 files changed, 18 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/pySim-smpp2sim.py b/pySim-smpp2sim.py index f7a45f5..95b9ccd 100755 --- a/pySim-smpp2sim.py +++ b/pySim-smpp2sim.py @@ -55,6 +55,7 @@ from pySim.commands import SimCardCommands from pySim.cards import UiccCardBase from pySim.exceptions import * +from pySim.cat import sms_pp_download_envelope from pySim.cat import ProactiveCommand, SendShortMessage, SMS_TPDU, SMSPPDownload, BearerDescription from pySim.cat import DeviceIdentities, Address, OtherAddress, UiccTransportLevel, BufferSize from pySim.cat import ChannelStatus, ChannelData, ChannelDataLength @@ -169,10 +170,7 @@ tpdu = SMS_DELIVER.from_smpp_submit(pdu) logger.info(tpdu) # 2) wrap into the CAT ENVELOPE for SMS-PP-Download - tpdu_ie = SMS_TPDU(decoded={'tpdu': b2h(tpdu.to_bytes())}) - addr_ie = Address(decoded={'ton_npi': {'ext':False, 'type_of_number':'unknown', 'numbering_plan_id':'unknown'}, 'call_number': '0123456'}) - dev_ids = DeviceIdentities(decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'}) - sms_dl = SMSPPDownload(children=[dev_ids, addr_ie, tpdu_ie]) + sms_dl = sms_pp_download_envelope(tpdu) # 3) send to the card envelope_hex = b2h(sms_dl.to_tlv()) logger.info("ENVELOPE: %s" % envelope_hex) diff --git a/pySim/cat.py b/pySim/cat.py index d755545..8959004 100644 --- a/pySim/cat.py +++ b/pySim/cat.py @@ -763,6 +763,22 @@ nested=[DeviceIdentities, Address, SMS_TPDU]): pass + +def sms_pp_download_envelope(tpdu, call_number: str = '0123456') -> SMSPPDownload: + """TS 31.111 Section 7.1.1.2 wrap of a SMS-DELIVER TPDU in the ENVELOPE (SMS-PP Download) + call_number : + SMSC address to report, defined in TS 31.111 7.1.1.2 as + "the RP_Originating_Address of the Service Centre (TS-Service-Centre-Address, 3GPP TS 24.011)" + its presence is Conditional, and the note there says the UICC should be fine + if its missing, so for remote management its presence should suffice (?). + """ + return SMSPPDownload(children=[ + DeviceIdentities(decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'}), + Address(decoded={'ton_npi': {'ext': False, 'type_of_number': 'unknown', + 'numbering_plan_id': 'unknown'}, + 'call_number': call_number}), + SMS_TPDU(decoded={'tpdu': b2h(tpdu.to_bytes())})]) + # TS 101 220 Table 7.17 + 31.111 7.1.1.3 class SMSCBDownload(BER_TLV_IE, tag=0xD2, nested=[DeviceIdentities, CBSPage]): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43557?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: Id23227eac53d697f4f13a84e087c32bf1d60f474 Gerrit-Change-Number: 43557 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: bip: answer proactive commands the relay does not implement
by Hoernchen 25 Sep '26

25 Sep '26
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43558?usp=email ) Change subject: bip: answer proactive commands the relay does not implement ...................................................................... bip: answer proactive commands the relay does not implement pySim-smpp2sim currently claims to support every feature flag that exists, but this immediately dies here with a SJA5: NotImplementedError: No handler method for ProvideLocalInformation(...) Answer anything unhandled with "performed_successfully" and log. Never "command_beyond_terminal_capability", tho, answering that for PROVIDE LOCAL INFORMATION refuses to open the session at all. Change-Id: I1e55d6f88c872a04b89a3946dd840d30b329621e --- M pySim/bip.py 1 file changed, 19 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified dexter: Looks good to me, approved diff --git a/pySim/bip.py b/pySim/bip.py index a23741e..d4c2875 100644 --- a/pySim/bip.py +++ b/pySim/bip.py @@ -219,6 +219,25 @@ self.sms_sink = sms_sink self.channels = ProactChannels(on_data_available=self._on_channel_data_available) + def receive_fetch(self, pcmd: ProactiveCommand): + """Answer anything this handler has no specific handler for. + + A card coming up will usually issue PROVIDE LOCAL INFORMATION, + POLL INTERVAL or TIMER MANAGEMENT before it gets anywhere near a BIP channel + because we claim to support every feature flag there is. + + Note that this is not the spec-correct answer. TS 102 223 6.8.7 + says a successful TERMINAL RESPONSE to PROVIDE LOCAL INFORMATION "shall" carry the + requested Local information data object, and 6.8.13/6.8.14 says the same for TIMER + MANAGEMENT, this returns empty results for all of them, which works with real cards. + + Always "performed_successfully", never "command_beyond_terminal_capability" because + answering that to PROVIDE LOCAL INFORMATION makes a card refuse to open the session. + """ + logger.info("no handler for %s, answering performed_successfully", + type(pcmd.decoded).__name__) + return self.prepare_response(pcmd, 'performed_successfully') + @staticmethod def _find_first_element_of_type(instlist, cls): for i in instlist: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43558?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: I1e55d6f88c872a04b89a3946dd840d30b329621e Gerrit-Change-Number: 43558 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • ...
  • 190
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.