From 0bb8b44ea828de58dfb25ec6325197b3b46654d4 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 23 Nov 2024 12:33:16 +0100 Subject: [PATCH] esim.saip.ProfileElementUSIM: Fix IMSI decode if [only] template based In case the fileDescriptor of EF.IMSI is purely template based and only the file content is given in the actual profile, we must pass a template reference to the File() constructor before we can read the IMSI. This fixes the following exception for some profiles: ValueError: File(ef-imsi): No fileDescriptor found in tuple, and none set by template before Change-Id: I14157a7b62ccd9b5b42de9b8060f2ebc5f91ebb3 --- pySim/esim/saip/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 2552c8e5..64ea7cb6 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -1130,7 +1130,8 @@ class ProfileElementUSIM(FsProfileElement): @property def imsi(self) -> Optional[str]: - f = File('ef-imsi', self.decoded['ef-imsi']) + template = templates.ProfileTemplateRegistry.get_by_oid(self.templateID) + f = File('ef-imsi', self.decoded['ef-imsi'], template.files_by_pename.get('ef-imsi', None)) return dec_imsi(b2h(f.body)) class ProfileElementOptUSIM(FsProfileElement):