From e80f3160a939192284d81650ca4431a8f70207d2 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 9 Feb 2026 13:26:57 +0100 Subject: [PATCH] pySim/euicc: fix encoding/decoding of Iccid The class Iccid uses a BcdAdapter to encoded/decode the ICCID. This works fine for ICCIDs that have an even (20) number of digits. In case the digit count is odd (19), the ICCID the last digit requires padding. Let's switch to PaddedBcdAdapter for encoding/decoding, to ensure that odd-length ICCIDs are padded automatically. Change-Id: I527a44ba454656a0d682ceb590eec6d9d0ac883a Related: OS#6868 --- pySim/euicc.py | 2 +- tests/pySim-shell_test/euicc/get_profiles_info.ok | 2 +- tests/pySim-shell_test/euicc/test.py | 2 +- tests/pySim-shell_test/euicc/test_gen_notif.script | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pySim/euicc.py b/pySim/euicc.py index ccb65be2..36e2d2a6 100644 --- a/pySim/euicc.py +++ b/pySim/euicc.py @@ -181,7 +181,7 @@ class SeqNumber(BER_TLV_IE, tag=0x80): class NotificationAddress(BER_TLV_IE, tag=0x0c): _construct = Utf8Adapter(GreedyBytes) class Iccid(BER_TLV_IE, tag=0x5a): - _construct = BcdAdapter(GreedyBytes) + _construct = PaddedBcdAdapter(GreedyBytes) class NotificationMetadata(BER_TLV_IE, tag=0xbf2f, nested=[SeqNumber, ProfileMgmtOperation, NotificationAddress, Iccid]): pass diff --git a/tests/pySim-shell_test/euicc/get_profiles_info.ok b/tests/pySim-shell_test/euicc/get_profiles_info.ok index 8450cb29..28eeff4e 100644 --- a/tests/pySim-shell_test/euicc/get_profiles_info.ok +++ b/tests/pySim-shell_test/euicc/get_profiles_info.ok @@ -15,7 +15,7 @@ }, { "profile_info": { - "iccid": "8949449999999990031f", + "iccid": "8949449999999990031", "isdp_aid": "a0000005591010ffffffff8900001200", "profile_state": "disabled", "service_provider_name": "OsmocomSPN", diff --git a/tests/pySim-shell_test/euicc/test.py b/tests/pySim-shell_test/euicc/test.py index 3cad8590..654d5759 100644 --- a/tests/pySim-shell_test/euicc/test.py +++ b/tests/pySim-shell_test/euicc/test.py @@ -23,7 +23,7 @@ import os import json from utils import * -# This testcase requires a sysmoEUICC1-C2T with the test prfile TS48V1-B-UNIQUE (ICCID 8949449999999990031f) +# This testcase requires a sysmoEUICC1-C2T with the test prfile TS48V1-B-UNIQUE (ICCID 8949449999999990031) # installed, and in disabled state. Also the profile must be installed in such a way that notifications are # generated when the profile is disabled or enabled (ProfileMetadata) diff --git a/tests/pySim-shell_test/euicc/test_gen_notif.script b/tests/pySim-shell_test/euicc/test_gen_notif.script index d97dc2b4..feb7ef2f 100644 --- a/tests/pySim-shell_test/euicc/test_gen_notif.script +++ b/tests/pySim-shell_test/euicc/test_gen_notif.script @@ -4,5 +4,5 @@ set echo true select ADF.ISD-R # Generate two (additional) notifications by quickly enabeling the test profile -enable_profile --iccid 8949449999999990031f +enable_profile --iccid 8949449999999990031 enable_profile --iccid 89000123456789012341