From 8fa7727a14db2472ccf03f1fe147ee653a84f45d Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 23 Apr 2026 14:45:37 +0200 Subject: [PATCH] pySim-prog/cards: fix programming of EF.SMSP The legacy code found in legacy/cards.py does not use the modern construct based encoder (pySim-read uses it). The card classes either use their own implementation of update_smsp or use the generic method provided by the SimCard class. The latter one is true for FairwavesSIM and WavemobileSim. Unfortunately the implementation found in the SimCard is wrong. It adds padding at the end of the file instead of the beginning. This completely messes up the contents of EF.SMSP for the cards using this method. To fix this, let's use the leftpad feature provided by the update_record. This will ensure a correct alignment of the file contents. Related: SYS#7765 Change-Id: Ie112418f1f1461762d61365d3863181ca6be7245 --- pySim/legacy/cards.py | 3 ++- tests/pySim-prog_test/Fairwaves-SIM.ok | 2 +- tests/pySim-prog_test/Wavemobile-SIM.ok | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pySim/legacy/cards.py b/pySim/legacy/cards.py index 9efa66b8..3b66328b 100644 --- a/pySim/legacy/cards.py +++ b/pySim/legacy/cards.py @@ -152,7 +152,8 @@ class SimCard(SimCardBase): return sw def update_smsp(self, smsp): - data, sw = self._scc.update_record(EF['SMSP'], 1, rpad(smsp, 84)) + print("using update_smsp") + data, sw = self._scc.update_record(EF['SMSP'], 1, smsp, leftpad=True) return sw def update_ad(self, mnc=None, opmode=None, ofm=None, path=EF['AD']): diff --git a/tests/pySim-prog_test/Fairwaves-SIM.ok b/tests/pySim-prog_test/Fairwaves-SIM.ok index 42e92e8e..5210d012 100644 --- a/tests/pySim-prog_test/Fairwaves-SIM.ok +++ b/tests/pySim-prog_test/Fairwaves-SIM.ok @@ -5,7 +5,7 @@ ICCID: 8988219000000117833 IMSI: 001010000000111 GID1: ffffffffffffffff GID2: ffffffffffffffff -SMSP: e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000ffffffffffffffffffffffffffff +SMSP: ffffffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 SMSC: 0015555 SPN: Fairwaves Show in HPLMN: False diff --git a/tests/pySim-prog_test/Wavemobile-SIM.ok b/tests/pySim-prog_test/Wavemobile-SIM.ok index 86f4830e..3d9e9b38 100644 --- a/tests/pySim-prog_test/Wavemobile-SIM.ok +++ b/tests/pySim-prog_test/Wavemobile-SIM.ok @@ -5,7 +5,7 @@ ICCID: 89445310150011013678 IMSI: 001010000000102 GID1: Can't read file -- SW match failed! Expected 9000 and got 6a82. GID2: Can't read file -- SW match failed! Expected 9000 and got 6a82. -SMSP: e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000ffffffffffffffffffffffffffff +SMSP: ffffffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 SMSC: 0015555 SPN: wavemobile Show in HPLMN: False