Attention is currently required from: laforge.
fixeria has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/pysim/+/41736?usp=email )
Change subject: pySim.esim.saip.ProfileElementSequence: Update type annotations
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41736?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: Ib99c00a38bf009c63180b4a593d6cc796ff282d3
Gerrit-Change-Number: 41736
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 26 Dec 2025 08:27:36 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: fixeria.
laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/pysim/+/41736?usp=email )
Change subject: pySim.esim.saip.ProfileElementSequence: Update type annotations
......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS4:
> Not sure if `(...)` is a valid type-spec. for tuples. […]
Done
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41736?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: Ib99c00a38bf009c63180b4a593d6cc796ff282d3
Gerrit-Change-Number: 41736
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 26 Dec 2025 07:42:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41765?usp=email )
Change subject: global_platform: Add KCV computation for TLS-PSK keys
......................................................................
global_platform: Add KCV computation for TLS-PSK keys
This adds support for computing the KCV (key check value) for TLS-PSK
keys such as those used in SCP81.
The spec reference is "Remote Application Management over HTTP
Card Specification v2.2 - Amendment B Version 1.1.3"
Change-Id: I8c56ba1341fd4615f8a9ed0c13f25790639f9098
---
M pySim/global_platform/__init__.py
1 file changed, 9 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/65/41765/1
diff --git a/pySim/global_platform/__init__.py b/pySim/global_platform/__init__.py
index 8a99677..a1f4824 100644
--- a/pySim/global_platform/__init__.py
+++ b/pySim/global_platform/__init__.py
@@ -18,6 +18,7 @@
"""
import io
+import hashlib
from copy import deepcopy
from typing import Optional, List, Dict, Tuple
from construct import Optional as COptional
@@ -1051,10 +1052,18 @@
cipher = AES.new(key, AES.MODE_ECB)
return cipher.encrypt(plaintext)
+def compute_kcv_sha1(key:bytes) -> bytes:
+ # GPC 2.2 B RAM over HTTP Section 3.8: A key check value shall be computed as the three most
+ # significant bytes of the SHA-1 digest of the PSK TLS Key
+ m = hashlib.sha1()
+ m.update(key)
+ return m.digest()[:3]
+
# dict is keyed by the string name of the KeyType enum above in this file
KCV_CALCULATOR = {
'aes': compute_kcv_aes,
'des': compute_kcv_des,
+ 'tls_psk': compute_kcv_sha1,
}
def compute_kcv(key_type: str, key: bytes) -> Optional[bytes]:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41765?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: I8c56ba1341fd4615f8a9ed0c13f25790639f9098
Gerrit-Change-Number: 41765
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Attention is currently required from: fixeria, laforge.
Hello Jenkins Builder, fixeria,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/pysim/+/41736?usp=email
to look at the new patch set (#5).
The following approvals got outdated and were removed:
Code-Review-1 by fixeria, Verified+1 by Jenkins Builder
Change subject: pySim.esim.saip.ProfileElementSequence: Update type annotations
......................................................................
pySim.esim.saip.ProfileElementSequence: Update type annotations
The type annotations didn't reflect reality in two cases.
Change-Id: Ib99c00a38bf009c63180b4a593d6cc796ff282d3
---
M pySim/esim/saip/__init__.py
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/36/41736/5
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41736?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: Ib99c00a38bf009c63180b4a593d6cc796ff282d3
Gerrit-Change-Number: 41736
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41735?usp=email )
(
5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: pySim.esim.saip.personalization: Support for EF.SMSP personalization
......................................................................
pySim.esim.saip.personalization: Support for EF.SMSP personalization
It's a not-too-uncommon requirement to modify the SMSC address stored in
EF.SMSP. This adds a ConfigurableParameter for this purpose.
Change-Id: I6b0776c2e753e0a6d158a8cf65cb030977782ec2
---
M pySim/esim/saip/personalization.py
1 file changed, 43 insertions(+), 0 deletions(-)
Approvals:
fixeria: Looks good to me, but someone else must approve
dexter: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index 71f115d..a1df068 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -22,6 +22,7 @@
from osmocom.tlv import camel_to_snake
from pySim.utils import enc_iccid, enc_imsi, h2b, rpad, sanitize_iccid
from pySim.esim.saip import ProfileElement, ProfileElementSequence
+from pySim.ts_51_011 import EF_SMSP
def remove_unwanted_tuples_from_list(l: List[Tuple], unwanted_keys: List[str]) -> List[Tuple]:
"""In a list of tuples, remove all tuples whose first part equals 'unwanted_key'."""
@@ -104,6 +105,48 @@
file_replace_content(pe.decoded['ef-acc'], acc.to_bytes(2, 'big'))
# TODO: DF.GSM_ACCESS if not linked?
+class SmspTpScAddr(ConfigurableParameter):
+ """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 +"""
+
+ def validate(self):
+ addr_str = str(self.input_value)
+ if addr_str[0] == '+':
+ digits = addr_str[1:]
+ international = True
+ else:
+ digits = addr_str
+ international = False
+ if len(digits) > 20:
+ raise ValueError('TP-SC-ADDR must not exceed 20 digits')
+ if not digits.isdecimal():
+ raise ValueError('TP-SC-ADDR must only contain decimal digits')
+ self.value = (international, digits)
+
+ def apply(self, pes: ProfileElementSequence):
+ international, digits = self.value
+ for pe in pes.get_pes_for_type('usim'):
+ # obtain the File instance from the ProfileElementUSIM
+ f_smsp = pe.files['ef-smsp']
+ #print("SMSP (orig): %s" % f_smsp.body)
+ # instantiate the pySim.ts_51_011.EF_SMSP class for decode/encode
+ ef_smsp = EF_SMSP()
+ # decode the existing file body
+ ef_smsp_dec = ef_smsp.decode_record_bin(f_smsp.body, 1)
+ # patch the actual number
+ ef_smsp_dec['tp_sc_addr']['call_number'] = digits
+ # patch the NPI to isdn_e164
+ ef_smsp_dec['tp_sc_addr']['ton_npi']['numbering_plan_id'] = 'isdn_e164'
+ # patch the TON to international or unknown depending on +
+ 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)
+ #print("SMSP (new): %s" % f_smsp.body)
+ # re-generate the pe.decoded member from the File instance
+ pe.file2pe(f_smsp)
class SdKey(ConfigurableParameter, metaclass=ClassVarMeta):
"""Configurable Security Domain (SD) Key. Value is presented as bytes."""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41735?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: I6b0776c2e753e0a6d158a8cf65cb030977782ec2
Gerrit-Change-Number: 41735
Gerrit-PatchSet: 7
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-Reviewer: neels <nhofmeyr(a)sysmocom.de>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41734?usp=email )
Change subject: esim.saip.FsProfileElement: Add file2pe() for single file conversion
......................................................................
esim.saip.FsProfileElement: Add file2pe() for single file conversion
We've had files2pe() for re-encoding all of the files, but let's add
a specific one for re-encoding only one of the files (such as commonly
needed during personalization)
Change-Id: I7b7f61aae6b7df6946dadf2f78fddf92995603ec
---
M pySim/esim/saip/__init__.py
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py
index 1c0c715..c0f5340 100644
--- a/pySim/esim/saip/__init__.py
+++ b/pySim/esim/saip/__init__.py
@@ -633,8 +633,15 @@
self.pe_sequence.cur_df = pe_df
self.pe_sequence.cur_df = self.pe_sequence.cur_df.add_file(file)
+ def file2pe(self, file: File):
+ """Update the "decoded" member for the given file with the contents from the given File instance.
+ We expect that the File instance is part of self.files"""
+ if self.files[file.pe_name] != file:
+ raise ValueError("The file you passed is not part of this ProfileElement")
+ self.decoded[file.pe_name] = file.to_tuples()
+
def files2pe(self):
- """Update the "decoded" member with the contents of the "files" member."""
+ """Update the "decoded" member for each file with the contents of the "files" member."""
for k, f in self.files.items():
self.decoded[k] = f.to_tuples()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41734?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: I7b7f61aae6b7df6946dadf2f78fddf92995603ec
Gerrit-Change-Number: 41734
Gerrit-PatchSet: 5
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>