Attention is currently required from: laforge.
neels has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/40094?usp=email )
Change subject: personalization: set default values
......................................................................
Patch Set 4:
(6 comments)
Commit Message:
https://gerrit.osmocom.org/c/pysim/+/40094/comment/7d871308_60acd266?usp=em… :
PS2, Line 11: This is useful for user interaction, to prefill an input field that
: indicates a valid input to modify to taste.
> I beg to differ. […]
I think it looks odd in this patch because i later on separated the patch from the ParamSource patch. The defaults make more sense when you realize that, in practice, they mostly indicate the lengths for automatically generated digits.
For example, for Pin1 + RandomDigitSource, the user input is just '0000' to get a four digit random PIN, or '000000' to get a six digit pin.
A default value makes sense to indicate the input format to the user.
Indicating IMSI as '0010100000000000' + IncrementingDigitSource:
it is obvious that it is not a usual IMSI that I entered,
and it greatly clarifies what to enter to get a useful result.
A default value can make sense to indicate the most secure / most likely option,
like suggesting the longest allowed (random) key length, or choosing Milenage by default.
If I remove all defaults from sysmo-esim-mgr, then a user as to manually enter digits for all of K. Opc, Pin, Adm, all SdKeys before generating is possible.
It is infinitely more helpful to have a default of e.g. '0*16'+RandomDigitSource set for K, so users don't have to look it up.
Note, assigning a default value is not actually done in pysim, it is merely up to a caller to use the default value paired with a param source. code wise, it is very useful to place the info here, not in the caller.
File pySim/esim/saip/personalization.py:
https://gerrit.osmocom.org/c/pysim/+/40094/comment/64b7939f_cdedf895?usp=em… :
PS2, Line 278: default_value
> there's no point of an all-zero default ICCID.
that's true, it's a copy paste artifact from the random parameters...
in the esim mgr, we never let a user enter an ICCID so i never noticed.
I think it's still the most useful indicator for number of digits, if anyone ever used it.
We can set an empty default... but why drop the informational example?
https://gerrit.osmocom.org/c/pysim/+/40094/comment/22716676_d37c6a14?usp=em… :
PS2, Line 299:
> I also think there's no point in having a default for the IMSI
I explained my IMSI point above, let's continue the discussion there
https://gerrit.osmocom.org/c/pysim/+/40094/comment/3e590015_d58515a1?usp=em… :
PS2, Line 467: default_value = '0' * allow_len
> I'm not sure why any security key / pin should have any default value at all. […]
I made the point above: it goes with a RandomDigitSource, let's continue the discussion there
https://gerrit.osmocom.org/c/pysim/+/40094/comment/faf7649c_757c13aa?usp=em… :
PS2, Line 494: default_value = '0' * max_len
> same here
Done
https://gerrit.osmocom.org/c/pysim/+/40094/comment/a75bdfec_0b31fbde?usp=em… :
PS2, Line 582: default_value = '00' * allow_len
> no cryptographic key should have any default value. It's just creating security nightmares.
I made the point above: it is just a length indicator for a RandomDigitSource. Let's continue the discussion there
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40094?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: I2672fedcbc32cb7a6cb0c233a4a22112bd9aae03
Gerrit-Change-Number: 40094
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 04 Aug 2025 17:27:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Attention is currently required from: neels.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/40198?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: personalization: implement reading back values from a PES
......................................................................
personalization: implement reading back values from a PES
Implement get_values_from_pes(), the reverse direction of apply_val():
read back and return values from a ProfileElementSequence. Implement for
all ConfigurableParameter subclasses.
Future: SdKey.get_values_from_pes() is reading pe.decoded[], which works
fine, but I07dfc378705eba1318e9e8652796cbde106c6a52 will change this
implementation to use the higher level ProfileElementSD members.
Implementation detail:
Implement get_values_from_pes() as classmethod that returns a generator.
Subclasses should yield all occurences of their parameter in a given
PES.
For example, the ICCID can appear in multiple places.
Iccid.get_values_from_pes() yields all of the individual values. A set()
of the results quickly tells whether the PES is consistent.
Rationales for reading back values:
This allows auditing an eSIM profile, particularly for producing an
output.csv from a batch personalization (that generated lots of random
key material which now needs to be fed to an HLR...).
Reading back from a binary result is more reliable than storing the
values that were fed into a personalization.
By auditing final DER results with this code, I discovered:
- "oh, there already was some key material in my UPP template."
- "all IMSIs ended up the same, forgot to set up the parameter."
- the SdKey.apply() implementations currently don't work, see
I07dfc378705eba1318e9e8652796cbde106c6a52 for a fix.
Change-Id: I234fc4317f0bdc1a486f0cee4fa432c1dce9b463
---
M pySim/esim/saip/personalization.py
1 file changed, 122 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/98/40198/3
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40198?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I234fc4317f0bdc1a486f0cee4fa432c1dce9b463
Gerrit-Change-Number: 40198
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Jenkins Builder has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/40823?usp=email )
Change subject: add test_configurable_parameters.py
......................................................................
Patch Set 1:
(1 comment)
File pySim/esim/saip/personalization.py:
Robot Comment from checkpatch (run ID ):
https://gerrit.osmocom.org/c/pysim/+/40823/comment/fd5952cf_4970d2c6?usp=em… :
PS1, Line 230: where each occurence should reflect the same value (all currently known parameters).
'occurence' may be misspelled - perhaps 'occurrence'?
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40823?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: Ia55f0d11f8197ca15a948a83a34b3488acf1a0b4
Gerrit-Change-Number: 40823
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Mon, 04 Aug 2025 16:53:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: neels.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/40203?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: personalization: fix SdKey.apply_val() implementation
......................................................................
personalization: fix SdKey.apply_val() implementation
'securityDomain' elements are decoded to ProfileElementSD instances,
which keep higher level representations of the key data apart from the
decoded[] lists.
So far, apply_val() was dropping binary values in decoded[], which does
not work, because ProfileElementSD._pre_encode() overwrites
self.decoded[] from the higher level representation.
Implement using
- ProfileElementSD.find_key() and SecurityDomainKeyComponent to modify
an exsiting entry, or
- ProfileElementSD.add_key() to create a new entry.
Before this patch, SdKey parameters seemed to patch PES successfully,
but their modifications did not end up in the encoded DER.
(BTW, this does not fix any other errors that may still be present in
the various SdKey subclasses, patches coming up.)
Related: SYS#6768
Change-Id: I07dfc378705eba1318e9e8652796cbde106c6a52
---
M pySim/esim/saip/__init__.py
M pySim/esim/saip/personalization.py
2 files changed, 40 insertions(+), 27 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/03/40203/3
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40203?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I07dfc378705eba1318e9e8652796cbde106c6a52
Gerrit-Change-Number: 40203
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/40824?usp=email )
Change subject: personalization.ConfigurableParameter: fix BytesIO() input
......................................................................
personalization.ConfigurableParameter: fix BytesIO() input
Change-Id: I0ad160eef9015e76eef10baee7c6b606fe249123
---
M pySim/esim/saip/personalization.py
M tests/unittests/test_configurable_parameters.py
2 files changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/24/40824/1
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 27b570c..39f1cdf 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -196,6 +196,9 @@
if cls.allow_chars is not None:
if any(c not in cls.allow_chars for c in val):
raise ValueError(f"invalid characters in input value {val!r}, valid chars are {cls.allow_chars}")
+ elif isinstance(val, io.BytesIO):
+ val = val.getvalue()
+
if cls.allow_len is not None:
l = cls.allow_len
# cls.allow_len could be one int, or a tuple of ints. Wrap a single int also in a tuple.
diff --git a/tests/unittests/test_configurable_parameters.py b/tests/unittests/test_configurable_parameters.py
index a1ca91b..c4e95ff 100755
--- a/tests/unittests/test_configurable_parameters.py
+++ b/tests/unittests/test_configurable_parameters.py
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
+import io
from importlib import resources
from osmocom.utils import hexstr
from pySim.esim.saip import ProfileElementSequence
@@ -137,6 +138,10 @@
val=bytearray(b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16'),
expect_clean_val=b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16',
expect_val='01020304050607080910111213141516'),
+ Paramtest(param_cls=p13n.K,
+ val=io.BytesIO(b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16'),
+ expect_clean_val=b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16',
+ expect_val='01020304050607080910111213141516'),
Paramtest(param_cls=p13n.Opc,
val='01020304050607080910111213141516',
@@ -150,6 +155,10 @@
val=bytearray(b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16'),
expect_clean_val=b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16',
expect_val='01020304050607080910111213141516'),
+ Paramtest(param_cls=p13n.Opc,
+ val=io.BytesIO(b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16'),
+ expect_clean_val=b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16',
+ expect_val='01020304050607080910111213141516'),
]
for sdkey_cls in (
@@ -219,6 +228,11 @@
expect_clean_val=b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16',
expect_val='01020304050607080910111213141516',
),
+ Paramtest(param_cls=sdkey_cls,
+ val=io.BytesIO(b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16'),
+ expect_clean_val=b'\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16',
+ expect_val='01020304050607080910111213141516',
+ ),
])
for upp_fname in upp_fnames:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40824?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0ad160eef9015e76eef10baee7c6b606fe249123
Gerrit-Change-Number: 40824
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>