From 118624d256f914553dae307e1ca760d3c5758687 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 22 Nov 2024 14:23:43 +0100 Subject: [PATCH] pySim.esim.saip: Treat "Readable and Updateable when deactivated" flag There's a second flag hidden in the TS 102 222 "Special File Information"; let's parse + re-encode it properly. Change-Id: I7644d265f746c662b64f7156b3be08a01e3a97aa Related: OS#6643 --- pySim/esim/saip/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 3c46ef89..6707802a 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -114,6 +114,7 @@ class File: self.nb_rec: Optional[int] = None self._file_size = 0 self.high_update: bool = False + self.read_and_update_when_deact: bool = False self.shareable: bool = True self.df_name = None self.fill_pattern = None @@ -194,6 +195,7 @@ class File: fileDescriptor = {} fdb_dec = {} pefi = {} + spfi = 0 if self.fid: fileDescriptor['fileID'] = self.fid.to_bytes(2, 'big') if self.sfi: @@ -233,7 +235,11 @@ class File: if len(fd_dict): fileDescriptor['fileDescriptor'] = build_construct(FileDescriptor._construct, fd_dict) if self.high_update: - pefi['specialFileInformation'] = b'\x80' # TS 102 222 Table 5 + spfi |= 0x80 # TS 102 222 Table 5 + if self.read_and_update_when_deact: + spfi |= 0x40 # TS 102 222 Table 5 + if spfi != 0x00: + pefi['specialFileInformation'] = spfi.to_bytes(1) if self.fill_pattern: if not self.fill_pattern_repeat: pefi['fillPattern'] = self.fill_pattern @@ -288,8 +294,11 @@ class File: self._file_size = self._decode_file_size(pefi['maximumFileSize']) specialFileInformation = pefi.get('specialFileInformation', None) if specialFileInformation: + # TS 102 222 Table 5 if specialFileInformation[0] & 0x80: self.high_update = True + if specialFileInformation[0] & 0x40: + self.read_and_update_when_deact = True if 'repeatPattern' in pefi: self.fill_pattern = pefi['repeatPattern'] self.fill_pattern_repeat = True