laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33250 )
Change subject: Add ".py" suffix to sphinx-argparse generated docs
......................................................................
Add ".py" suffix to sphinx-argparse generated docs
This is important to produce the right command syntax when generating
command line reference in the user manual. However, we shouldn't add
this kludge to the individual programs, but only to the documentation
using the :prog: syntax.
Change-Id: I2ec7ab00c63d5d386f187e54755c71ffc2dce429
---
M docs/legacy.rst
M docs/shell.rst
M pySim-read.py
M pySim-shell.py
4 files changed, 18 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/docs/legacy.rst b/docs/legacy.rst
index d93358f..0961d17 100644
--- a/docs/legacy.rst
+++ b/docs/legacy.rst
@@ -98,3 +98,4 @@
.. argparse::
:module: pySim-read
:func: option_parser
+ :prog: pySim-read.py
diff --git a/docs/shell.rst b/docs/shell.rst
index e13d054..ef08fcf 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -35,6 +35,7 @@
.. argparse::
:module: pySim-shell
:func: option_parser
+ :prog: pySim-shell.py
Usage Examples
--------------
diff --git a/pySim-read.py b/pySim-read.py
index ddc193a..f80509c 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -40,8 +40,7 @@
from pySim.utils import format_xplmn_w_act, dec_st
from pySim.utils import h2s, format_ePDGSelection
-option_parser = argparse.ArgumentParser(prog='pySim-read',
- description='Legacy tool for reading some parts of a SIM card',
+option_parser = argparse.ArgumentParser(description='Legacy tool for reading some parts of a SIM card',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
argparse_add_reader_args(option_parser)
diff --git a/pySim-shell.py b/pySim-shell.py
index 3f0818a..c6782d4 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -949,7 +949,7 @@
-option_parser = argparse.ArgumentParser(prog='pySim-shell', description='interactive SIM card shell',
+option_parser = argparse.ArgumentParser(description='interactive SIM card shell',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
argparse_add_reader_args(option_parser)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33250
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2ec7ab00c63d5d386f187e54755c71ffc2dce429
Gerrit-Change-Number: 33250
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33247 )
Change subject: README: rephrase initial section; add HPSIM; programmable vs. standard
......................................................................
README: rephrase initial section; add HPSIM; programmable vs. standard
Change-Id: Ied7bce9fc4ebc9a71093ac41d9c1b8e67fe04d7e
---
M README.md
1 file changed, 27 insertions(+), 9 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/README.md b/README.md
index db13a52..86dc63d 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,25 @@
-pySim - Read, Write and Browse Programmable SIM/USIM Cards
-====================================================
+pySim - Read, Write and Browse Programmable SIM/USIM/ISIM/HPSIM Cards
+=====================================================================
-This repository contains Python programs that can be used
-to read, program (write) and browse certain fields/parameters on so-called programmable
-SIM/USIM cards.
+This repository contains a number of Python programs that can be used
+to read, program (write) and browse all fields/parameters/files on
+SIM/USIM/ISIM/HPSIM cards used in 3GPP cellular networks from 2G to 5G.
-Such SIM/USIM cards are special cards, which - unlike those issued by
-regular commercial operators - come with the kind of keys that allow you
-to write the files/fields that normally only an operator can program.
+Note that the access control configuration of normal production cards
+issue by operators will restrict significantly which files a normal
+user can read, and particularly write to.
+
+The full functionality of pySim hence can only be used with on so-called
+programmable SIM/USIM/ISIM/HPSIM cards.
+
+Such SIM/USIM/ISIM/HPSIM cards are special cards, which - unlike those
+issued by regular commercial operators - come with the kind of keys that
+allow you to write the files/fields that normally only an operator can
+program.
This is useful particularly if you are running your own cellular
-network, and want to issue your own SIM/USIM cards for that network.
+network, and want to configure your own SIM/USIM/ISIM/HPSIM cards for
+that network.
Homepage and Manual
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33247
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ied7bce9fc4ebc9a71093ac41d9c1b8e67fe04d7e
Gerrit-Change-Number: 33247
Gerrit-PatchSet: 1
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>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33234 )
Change subject: SJA5: EF.USIM_AUTH_KEY: Display / enforce proper length TUAK K
......................................................................
SJA5: EF.USIM_AUTH_KEY: Display / enforce proper length TUAK K
The K value in case of TUAK can be 16 or 32 bytes long. We used to
permit/parse/display 32 bytes even if only 16 bytes was configured.
Let's enforce the correct length of "K".
Fixes: OS#6053
Change-Id: Ia0f9a2138f16dce72f3118001e95baa1c80f23ce
---
M pySim/sysmocom_sja2.py
1 file changed, 16 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
dexter: Looks good to me, approved
diff --git a/pySim/sysmocom_sja2.py b/pySim/sysmocom_sja2.py
index 8b1fc04..1bd4a8a 100644
--- a/pySim/sysmocom_sja2.py
+++ b/pySim/sysmocom_sja2.py
@@ -207,7 +207,7 @@
'tuak_cfg'/TuakCfgByte,
'num_of_keccak_iterations'/Int8ub,
'op_opc'/HexAdapter(Bytes(32)),
- 'k'/HexAdapter(Bytes(32)))
+ 'k'/HexAdapter(Bytes(this.cfg.key_length//8)))
def _decode_bin(self, raw_bin_data: bytearray) -> dict:
if raw_bin_data[0] & 0x0F == 0x06:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33234
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia0f9a2138f16dce72f3118001e95baa1c80f23ce
Gerrit-Change-Number: 33234
Gerrit-PatchSet: 2
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>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33248 )
Change subject: README: remove redundancy 'Manual' and 'Documentation
......................................................................
README: remove redundancy 'Manual' and 'Documentation
Also, re-order sections oriented more towards the user (Docs first)
Change-Id: I4fc76222a1c22685131cb6926721ce24f0373046
---
M README.md
1 file changed, 44 insertions(+), 32 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/README.md b/README.md
index 86dc63d..2a89c9a 100644
--- a/README.md
+++ b/README.md
@@ -22,10 +22,40 @@
that network.
-Homepage and Manual
--------------------
+Homepage
+--------
-Please visit the [official homepage](https://osmocom.org/projects/pysim/wiki) for usage instructions, manual and examples. The user manual can also be built locally from this source code by ``cd docs && make html latexpdf`` for HTML and PDF format, respectively.
+Please visit the [official homepage](https://osmocom.org/projects/pysim/wiki)
+for usage instructions, manual and examples.
+
+
+Documentation
+-------------
+
+The pySim user manual can be built from this very source code by means
+of sphinx (with sphinxcontrib-napoleon and sphinx-argparse). See the
+Makefile in the 'docs' directory.
+
+A pre-rendered HTML user manual of the current pySim 'git master' is
+available from <https://downloads.osmocom.org/docs/latest/pysim/> and
+a downloadable PDF version is published at
+<https://downloads.osmocom.org/docs/latest/osmopysim-usermanual.pdf>.
+
+A slightly dated video presentation about pySim-shell can be found at
+<https://media.ccc.de/v/osmodevcall-20210409-laforge-pysim-shell>.
+
+
+pySim-shell vs. legacy tools
+----------------------------
+
+While you will find a lot of online resources still describing the use of
+pySim-prog.py and pySim-read.py, those tools are considered legacy by
+now and have by far been superseded by the much more capable
+pySim-shell. We strongly encourage users to adopt pySim-shell, unless
+they have very specific requirements like batch programming of large
+quantities of cards, which is about the only remaining use case for the
+legacy tools.
+
Git Repository
--------------
@@ -111,32 +141,3 @@
We are using a gerrit-based patch review process explained at
<https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit>
-
-
-Documentation
--------------
-
-The pySim user manual can be built from this very source code by means
-of sphinx (with sphinxcontrib-napoleon and sphinx-argparse). See the
-Makefile in the 'docs' directory.
-
-A pre-rendered HTML user manual of the current pySim 'git master' is
-available from <https://downloads.osmocom.org/docs/latest/pysim/> and
-a downloadable PDF version is published at
-<https://downloads.osmocom.org/docs/latest/osmopysim-usermanual.pdf>.
-
-A slightly dated video presentation about pySim-shell can be found at
-<https://media.ccc.de/v/osmodevcall-20210409-laforge-pysim-shell>.
-
-
-pySim-shell vs. legacy tools
-----------------------------
-
-While you will find a lot of online resources still describing the use of
-pySim-prog.py and pySim-read.py, those tools are considered legacy by
-now and have by far been superseded by the much more capable
-pySim-shell. We strongly encourage users to adopt pySim-shell, unless
-they have very specific requirements like batch programming of large
-quantities of cards, which is about the only remaining use case for the
-legacy tools.
-
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33248
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4fc76222a1c22685131cb6926721ce24f0373046
Gerrit-Change-Number: 33248
Gerrit-PatchSet: 1
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>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33249 )
Change subject: 31.102: Fix EF.Routing_Indicator for odd number of digits
......................................................................
31.102: Fix EF.Routing_Indicator for odd number of digits
The routing indicator is BCD-encoded but has an arbitrary length of
1, 2, 3 or 4 digits.
In order to support the odd lengths of 1 or 3, we must not pad on the
byte level, but on the nibble level. This requires a slight extension of
the Rpad() Adapter.
Change-Id: I6c26dccdd570de7b7a4cd48338068e230340ec7c
Fixes: OS#6054
---
M pySim/construct.py
M pySim/ts_31_102.py
2 files changed, 28 insertions(+), 7 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
dexter: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/pySim/construct.py b/pySim/construct.py
index 20a6946..ab44a63 100644
--- a/pySim/construct.py
+++ b/pySim/construct.py
@@ -66,26 +66,29 @@
class Rpad(Adapter):
"""
- Encoder appends padding bytes (b'\\xff') up to target size.
- Decoder removes trailing padding bytes.
+ Encoder appends padding bytes (b'\\xff') or characters up to target size.
+ Decoder removes trailing padding bytes/characters.
Parameters:
subcon: Subconstruct as defined by construct library
pattern: set padding pattern (default: b'\\xff')
+ num_per_byte: number of 'elements' per byte. E.g. for hex nibbles: 2
"""
- def __init__(self, subcon, pattern=b'\xff'):
+ def __init__(self, subcon, pattern=b'\xff', num_per_byte=1):
super().__init__(subcon)
self.pattern = pattern
+ self.num_per_byte = num_per_byte
def _decode(self, obj, context, path):
return obj.rstrip(self.pattern)
def _encode(self, obj, context, path):
- if len(obj) > self.sizeof():
+ target_size = self.sizeof() * self.num_per_byte
+ if len(obj) > target_size:
raise SizeofError("Input ({}) exceeds target size ({})".format(
- len(obj), self.sizeof()))
- return obj + self.pattern * (self.sizeof() - len(obj))
+ len(obj), target_size))
+ return obj + self.pattern * (target_size - len(obj))
class MultiplyAdapter(Adapter):
"""
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 81b671e..e7ae8f0 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -1089,7 +1089,8 @@
# responsibility of home network operator but BCD coding shall be used. If a network
# operator decides to assign less than 4 digits to Routing Indicator, the remaining digits
# shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
- self._construct = Struct('routing_indicator'/BcdAdapter(Rpad(Bytes(2))), 'rfu'/HexAdapter(Bytes(2)))
+ self._construct = Struct('routing_indicator'/Rpad(BcdAdapter(Bytes(2)), 'f', 2),
+ 'rfu'/HexAdapter(Bytes(2)))
# TS 31.102 Section 4.4.11.13
class EF_TN3GPPSNN(TransparentEF):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33249
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6c26dccdd570de7b7a4cd48338068e230340ec7c
Gerrit-Change-Number: 33249
Gerrit-PatchSet: 1
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>
Gerrit-MessageType: merged
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/33235 )
Change subject: test_ota: Add one first OTA SMS AES128 unit test
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33235
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id4a66bbfaec2d8610e8a7a2c72c0dfd08332edcd
Gerrit-Change-Number: 33235
Gerrit-PatchSet: 2
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>
Gerrit-Comment-Date: Sun, 11 Jun 2023 19:10:16 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment