fixeria has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/42674?usp=email )
Change subject: SmspTpScAddr: fix SMSP record length and alpha_id padding
......................................................................
SmspTpScAddr: fix SMSP record length and alpha_id padding
apply_val() was re-encoding the SMSP with the minimum total_len of 28,
which produces a 28-byte body with no alpha_id field. After a DER
round-trip, the profile machinery re-pads the body to the original
record length using the template's fill pattern, which may not be 0xFF.
Those non-0xFF fill bytes end up in the alpha_id area, and GSM 7-bit
decoding then fails with a KeyError when the modified profile is read
back.
Fix by:
- setting alpha_id = '' so the field is present but empty
- setting f_smsp.rec_len = 42 (28 fixed bytes + 14 bytes of alpha_id
padding) so the re-encoded body carries 0xFF-padded alpha_id space
and the efFileSize in the fileDescriptor stays consistent
- passing total_len=f_smsp.rec_len to encode_record_bin() so the
alpha_id area is actually padded to that length
Change-Id: Ief6e02517f3e96158a2509d763b88aec4bd5a296
Jenkins: skip-card-test
---
M pySim/esim/saip/personalization.py
1 file changed, 20 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
neels: Looks good to me, but someone else must approve
dexter: Looks good to me, approved
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 86c71f5..5565f6f 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -612,10 +612,28 @@
ef_smsp_dec['tp_sc_addr']['ton_npi']['type_of_number'] = 'international' if international else 'unknown'
# ensure the parameter_indicators.tp_sc_addr is True
ef_smsp_dec['parameter_indicators']['tp_sc_addr'] = True
- # re-encode into the File body
- f_smsp.body = ef_smsp.encode_record_bin(ef_smsp_dec, 1)
+
+ # alpha_id padding: to make room for a human readable SMSC name that can be provisioned to the profile later
+ # on, alpha_id needs to be empty but padded 0xff to some length.
+ # - alpha_id is optional, setting alpha_id = '' ensures the IE is present.
+ # - the length of the file is 28+Y where Y is the length of the alpha_id -- here the intended length of our padding
+ # (see 3GPP TS 31.102 4.2.27 EF.SMSP). So if we want a maximum length of alpha_id = 14, we set the total
+ # file size to 28+14 = 42.
+ # - this file size has to go in two places: encode_record_bin() needs to know the length to encode the right
+ # length of fillFileContent.
+ # - the f_smsp needs to show the right file size in the PES, as in
+ # 'ef-smsp': [('fileDescriptor', {'efFileSize': '2a', ...
+ # (where 2a == 42)
+ # - To generate the right amount of fillFileContent, pass total_len=42 to encode_record_bin().
+ # - To show the right size in the PES, set f_smsp.rec_len = 42
+ ef_smsp_dec['alpha_id'] = ''
+ f_smsp.rec_len = 42
+
+ # re-encode into the File body.
+ #
#print("SMSP (new): %s" % f_smsp.body)
# re-generate the pe.decoded member from the File instance
+ f_smsp.body = ef_smsp.encode_record_bin(ef_smsp_dec, 1, total_len=f_smsp.rec_len)
pe.file2pe(f_smsp)
@classmethod
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/42674?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: Ief6e02517f3e96158a2509d763b88aec4bd5a296
Gerrit-Change-Number: 42674
Gerrit-PatchSet: 7
Gerrit-Owner: fixeria <vyanitskiy(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>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/42268?usp=email )
(
6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: saip: add numeric_base indicator to ConfigurableParameter
......................................................................
saip: add numeric_base indicator to ConfigurableParameter
By default, numeric_base = None, to indicate that there are no explicit
limitations on the number space.
For parameters that are definitely decimal, set numeric_base = 10.
For definitely hexadecimal, set numeric_base = 16.
Do the same for ConfigurableParameter as well as ParamSource, so callers
can match them up: if a parameter is numeric_base = 10, then omit
sources that are numeric_base = 16, and vice versa.
Change-Id: Ib0977bbdd9a85167be7eb46dd331fedd529dae01
Jenkins: skip-card-test
---
M pySim/esim/saip/personalization.py
1 file changed, 6 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 782e8e2..efde37a 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -71,6 +71,7 @@
min_len: minimum length of an input str; min_len = 4
max_len: maximum length of an input str; max_len = 8
allow_len: permit only specific lengths; allow_len = (8, 16, 32)
+ numeric_base: indicate hex / decimal, if any; numeric_base = None; numeric_base = 10; numeric_base = 16
Subclasses may change the meaning of these by overriding validate_val(), for example that the length counts
resulting bytes instead of a hexstring length. Most subclasses will be covered by the default validate_val().
@@ -126,6 +127,7 @@
allow_len = None # a list of specific lengths
example_input = None
default_source = None # a param_source.ParamSource subclass
+ numeric_base = None # or 10 or 16
def __init__(self, input_value=None):
self.input_value = input_value # the raw input value as given by caller
@@ -301,6 +303,7 @@
"""
allow_types = (str, int)
allow_chars = '0123456789'
+ numeric_base = 10
@classmethod
def validate_val(cls, val):
@@ -346,6 +349,7 @@
class IntegerParam(ConfigurableParameter):
allow_types = (str, int)
allow_chars = '0123456789'
+ numeric_base = 10
# two integers, if the resulting int should be range limited
min_val = None
@@ -378,6 +382,7 @@
allow_types = (str, io.BytesIO, bytes, bytearray, int)
allow_chars = '0123456789abcdefABCDEF'
strip_chars = ' \t\r\n'
+ numeric_base = 16
default_source = param_source.RandomHexDigitSource
@classmethod
@@ -551,6 +556,7 @@
name = 'SMSP-TP-SC-ADDR'
allow_chars = '+0123456789'
strip_chars = ' \t\r\n'
+ numeric_base = 10
max_len = 21 # '+' and 20 digits
min_len = 1
example_input = '+49301234567'
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/42268?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: Ib0977bbdd9a85167be7eb46dd331fedd529dae01
Gerrit-Change-Number: 42268
Gerrit-PatchSet: 8
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Attention is currently required from: fixeria, laforge.
neels has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/pysim/+/42674?usp=email )
Change subject: SmspTpScAddr: fix SMSP record length and alpha_id padding
......................................................................
Patch Set 7: Code-Review+1
(1 comment)
File pySim/esim/saip/personalization.py:
https://gerrit.osmocom.org/c/pysim/+/42674/comment/a9d01739_e5a257fc?usp=em… :
PS5, Line 637: ef_smsp_dec['alpha_id'] = ''
> With (I0ec99b2648b22c56f9145345e4cd8776f9217701, already merged), setting the alpha id is optional. […]
that's correct. The original patch was written in parallel with dexter's work on "upstream" improvement, i left it in there so it would work with both old and new (for flexible rebasing of the branch used in esim-mgr production). the alpha_id line is now redundant. maybe the comment above that also needs tweaking to be accurate? (but it would also be ok to merge as-is, i have no strong onion)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/42674?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: Ief6e02517f3e96158a2509d763b88aec4bd5a296
Gerrit-Change-Number: 42674
Gerrit-PatchSet: 7
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 22 Jun 2026 14:30:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: fixeria, laforge, neels.
dexter has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/pysim/+/42674?usp=email )
Change subject: SmspTpScAddr: fix SMSP record length and alpha_id padding
......................................................................
Patch Set 7: Code-Review+2
(1 comment)
File pySim/esim/saip/personalization.py:
https://gerrit.osmocom.org/c/pysim/+/42674/comment/354878f2_81013728?usp=em… :
PS5, Line 638: f_smsp.rec_len = 42
> So, all in all, should it be `38` or `42`? […]
I think 42 should work fine as long as f_smsp.rec_len = 42 is set.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/42674?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: Ief6e02517f3e96158a2509d763b88aec4bd5a296
Gerrit-Change-Number: 42674
Gerrit-PatchSet: 7
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 22 Jun 2026 13:26:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: dexter, laforge, neels.
fixeria has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/pysim/+/42674?usp=email )
Change subject: SmspTpScAddr: fix SMSP record length and alpha_id padding
......................................................................
Patch Set 7:
(1 comment)
File pySim/esim/saip/personalization.py:
https://gerrit.osmocom.org/c/pysim/+/42674/comment/018545c8_8adaff7d?usp=em… :
PS5, Line 638: f_smsp.rec_len = 42
> The size of 38 is the default that TCA suggests. […]
So, all in all, should it be `38` or `42`?
Personally I like the Ultimate Question of Life, the Universe, and Everything :)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/42674?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: Ief6e02517f3e96158a2509d763b88aec4bd5a296
Gerrit-Change-Number: 42674
Gerrit-PatchSet: 7
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 22 Jun 2026 13:04:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>