laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/pysim/+/41973?usp=email )
Change subject: es9p_client: Fix type conversion in installation result notification
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41973?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: I83ad047e043dc6b3462b188ce6dd0b2cc0e52e87
Gerrit-Change-Number: 41973
Gerrit-PatchSet: 1
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-Comment-Date: Sat, 31 Jan 2026 01:23:09 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37925?usp=email )
Change subject: pySim-trace: pySim.apdu_source.stdin_hex
......................................................................
pySim-trace: pySim.apdu_source.stdin_hex
This introduces an "APDU source" for pySim-trace which enables the
decoding of APDUs that are copy+pasted from elsewhere, for example
APDU logs in text form created by proprietary tools, or to decode
personalization scripts or the like.
Change-Id: I5aacf13b7c27cea9efd42f01dacca61068c3aa33
---
M pySim-trace.py
A pySim/apdu_source/stdin_hex.py
2 files changed, 46 insertions(+), 0 deletions(-)
Approvals:
dexter: Looks good to me, approved; Verified
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim-trace.py b/pySim-trace.py
index 09e9584..0aa1e9c 100755
--- a/pySim-trace.py
+++ b/pySim-trace.py
@@ -23,6 +23,7 @@
from pySim.apdu_source.pyshark_rspro import PysharkRsproPcap, PysharkRsproLive
from pySim.apdu_source.pyshark_gsmtap import PysharkGsmtapPcap
from pySim.apdu_source.tca_loader_log import TcaLoaderLogApduSource
+from pySim.apdu_source.stdin_hex import StdinHexApduSource
from pySim.apdu.ts_102_221 import UiccSelect, UiccStatus
@@ -190,6 +191,10 @@
parser_tcaloader_log.add_argument('-f', '--log-file', required=True,
help='Name of the log file to be read')
+parser_stdin_hex = subparsers.add_parser('stdin-hex', help="""
+ Read APDUs as hex-string from stdin.""")
+
+
if __name__ == '__main__':
opts = option_parser.parse_args()
@@ -205,6 +210,8 @@
s = PysharkGsmtapPcap(opts.pcap_file)
elif opts.source == 'tca-loader-log':
s = TcaLoaderLogApduSource(opts.log_file)
+ elif opts.source == 'stdin-hex':
+ s = StdinHexApduSource()
else:
raise ValueError("unsupported source %s", opts.source)
diff --git a/pySim/apdu_source/stdin_hex.py b/pySim/apdu_source/stdin_hex.py
new file mode 100644
index 0000000..67eeb7d
--- /dev/null
+++ b/pySim/apdu_source/stdin_hex.py
@@ -0,0 +1,39 @@
+# coding=utf-8
+
+# (C) 2024 by Harald Welte <laforge(a)osmocom.org>
+#
+# 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 pySim.utils import h2b
+
+from pySim.apdu.ts_102_221 import ApduCommands as UiccApduCommands
+from pySim.apdu.ts_102_222 import ApduCommands as UiccAdmApduCommands
+from pySim.apdu.ts_31_102 import ApduCommands as UsimApduCommands
+from pySim.apdu.global_platform import ApduCommands as GpApduCommands
+
+from . import ApduSource, PacketType, CardReset
+
+ApduCommands = UiccApduCommands + UiccAdmApduCommands + UsimApduCommands + GpApduCommands
+
+class StdinHexApduSource(ApduSource):
+ """ApduSource for reading apdu hex-strings from stdin."""
+
+ def read_packet(self) -> PacketType:
+ while True:
+ command = input("C-APDU >")
+ if len(command) == 0:
+ continue
+ response = '9000'
+ return ApduCommands.parse_cmd_bytes(h2b(command) + h2b(response))
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37925?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: I5aacf13b7c27cea9efd42f01dacca61068c3aa33
Gerrit-Change-Number: 37925
Gerrit-PatchSet: 8
Gerrit-Owner: laforge <laforge(a)osmocom.org>
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>
Attention is currently required from: neels.
laforge has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/40096?usp=email )
Change subject: personalization: add param_source.py, implement batch personalization
......................................................................
Patch Set 10:
(3 comments)
File pySim/esim/saip/param_source.py:
https://gerrit.osmocom.org/c/pysim/+/40096/comment/b72f1045_0a1b2da0?usp=em… :
PS10, Line 50:
This is dead code. You would just write `pass` here as it is impossible to instantiate an instance of an ABC-inheriting class without overriding all the abstractmethods in that derived class.
https://gerrit.osmocom.org/c/pysim/+/40096/comment/e47f088e_2679bd4c?usp=em… :
PS10, Line 84:
likewise here, just `pass` will do.
File pySim/esim/saip/personalization.py:
https://gerrit.osmocom.org/c/pysim/+/40096/comment/9c3482f5_4e1f1342?usp=em… :
PS10, Line 705: def __init__(self,
highly unusual formatting which we don't do this way in any other part o the code. Do we really need those kind of cosmetic experiments? Also, we use spaces between name of the parameter and the type annotation. I'm not sure why code added doesn't just by default always uses the surrounding style without any attempt to do something different.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40096?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: I497c60c101ea0eea980e8b1a4b1f36c0eda39002
Gerrit-Change-Number: 40096
Gerrit-PatchSet: 10
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 30 Jan 2026 19:38:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/40093?usp=email )
Change subject: personalization: set some typical parameter names
......................................................................
personalization: set some typical parameter names
These names better match what humans expect to read, for example "PIN1"
instead of "Pin1".
(We still fall back to the __class__.__name__ if a subclass omits a
specific name, see the ConfigurableParameter init.)
Change-Id: I31f390d634e58c384589c50a33ca45d6f86d4e10
---
M pySim/esim/saip/personalization.py
1 file changed, 16 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 75a43aa..943784f 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -303,6 +303,7 @@
class Iccid(DecimalParam):
"""ICCID Parameter. Input: string of decimal digits.
If the string of digits is only 18 digits long, add a Luhn check digit."""
+ name = 'ICCID'
min_len = 18
max_len = 20
@@ -321,6 +322,8 @@
class Imsi(DecimalParam):
"""Configurable IMSI. Expects value to be a string of digits. Automatically sets the ACC to
the last digit of the IMSI."""
+
+ name = 'IMSI'
min_len = 6
max_len = 15
@@ -339,12 +342,13 @@
"""Configurable SMSC (SMS Service Centre) TP-SC-ADDR. Expects to be a phone number in national or
international format (designated by a leading +). Automatically sets the NPI to E.164 and the TON based on
presence or absence of leading +."""
+
+ name = 'SMSP-TP-SC-ADDR'
allow_chars = '+0123456789'
strip_chars = ' \t\r\n'
max_len = 21 # '+' and 20 digits
min_len = 1
-
@classmethod
def validate_val(cls, val):
val = super().validate_val(val)
@@ -507,9 +511,11 @@
f" cannot find pukCode with keyReference={cls.keyReference}")
class Puk1(Puk):
+ name = 'PUK1'
keyReference = 0x01
class Puk2(Puk):
+ name = 'PUK2'
keyReference = 0x81
class Pin(DecimalHexParam):
@@ -539,9 +545,11 @@
+ f' {cls.get_name()} cannot find pinCode with keyReference={cls.keyReference}')
class Pin1(Pin):
+ name = 'PIN1'
keyReference = 0x01
class Pin2(Pin):
+ name = 'PIN2'
keyReference = 0x81
@classmethod
@@ -557,9 +565,11 @@
+ f' {cls.get_name()} cannot find pinCode with keyReference={cls.keyReference} in {naa=}')
class Adm1(Pin):
+ name = 'ADM1'
keyReference = 0x0A
class Adm2(Pin):
+ name = 'ADM2'
keyReference = 0x0B
class AlgoConfig(ConfigurableParameter):
@@ -593,16 +603,19 @@
class K(BinaryParam, AlgoConfig):
"""use validate_val() from BinaryParam, and apply_val() from AlgoConfig"""
+ name = 'K'
algo_config_key = 'key'
allow_len = (128 // 8, 256 // 8) # length in bytes (from BinaryParam); TUAK also allows 256 bit
class Opc(K):
+ name = 'OPc'
algo_config_key = 'opc'
class MilenageRotationConstants(BinaryParam, AlgoConfig):
"""rotation constants r1,r2,r3,r4,r5 of Milenage, Range 0..127. See 3GPP TS 35.206 Sections 2.3 + 5.3.
Provided as octet-string concatenation of all 5 constants. Expects a bytes-like object of length 5, with
each byte in the range of 0..127. The default value by 3GPP is '4000204060' (hex notation)"""
+ name = 'MilenageRotation'
algo_config_key = 'rotationConstants'
allow_len = 5 # length in bytes (from BinaryParam)
@@ -625,11 +638,13 @@
00000000000000000000000000000004
00000000000000000000000000000008
"""
+ name = 'MilenageXOR'
algo_config_key = 'xoringConstants'
allow_len = 80 # length in bytes (from BinaryParam)
class TuakNumberOfKeccak(IntegerParam, AlgoConfig):
"""Number of iterations of Keccak-f[1600] permutation as recomended by Section 7.2 of 3GPP TS 35.231"""
+ name = 'KECCAK-N'
algo_config_key = 'numberOfKeccak'
min_val = 1
max_val = 255
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40093?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: I31f390d634e58c384589c50a33ca45d6f86d4e10
Gerrit-Change-Number: 40093
Gerrit-PatchSet: 12
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>