From 022d562ae1a4686f747292f79334b25266e83835 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 7 Aug 2024 11:43:13 +0200 Subject: [PATCH] pySim.ts_102_221: Make sure FileDescriptor for BER-TLV contains file_type before this change, structure == 'ber_tlv' was missing the file_type == working_ef attribute. So for linear_fixed, transparent and cyclic, the file_type attribute was present, but for ber_tlv it was missing. This is illogical from a user point of vie and makes downstream code potentially more complex, as it cannot match on working_ef for all EF types. Change-Id: If0076cc6dd35a818c08309885f6ef1c1704052c6 --- pySim/ts_102_221.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py index c326ad1c..9e0db681 100644 --- a/pySim/ts_102_221.py +++ b/pySim/ts_102_221.py @@ -19,7 +19,7 @@ along with this program. If not, see . from bidict import bidict from construct import Select, Const, Bit, Struct, Int16ub, FlagsEnum, GreedyString, ValidationError -from construct import Optional as COptional +from construct import Optional as COptional, Computed from pySim.construct import * from pySim.utils import * @@ -95,7 +95,7 @@ class TotalFileSize(BER_TLV_IE, tag=0x81): # ETSI TS 102 221 11.1.1.4.3 class FileDescriptor(BER_TLV_IE, tag=0x82): _test_de_encode = [ - ( '82027921', { "file_descriptor_byte": { "shareable": True, "structure": "ber_tlv" }, "record_len": None, "num_of_rec": None } ), + ( '82027921', { "file_descriptor_byte": { "shareable": True, "file_type": "working_ef", "structure": "ber_tlv" }, "record_len": None, "num_of_rec": None } ), ( '82027821', { "file_descriptor_byte": { "shareable": True, "file_type": "df", "structure": "no_info_given" }, "record_len": None, "num_of_rec": None }), ( '82024121', { "file_descriptor_byte": { "shareable": True, "file_type": "working_ef", "structure": "transparent" }, "record_len": None, "num_of_rec": None } ), ( '82054221006e05', { "file_descriptor_byte": { "shareable": True, "file_type": "working_ef", "structure": "linear_fixed" }, "record_len": 110, "num_of_rec": 5 } ), @@ -110,7 +110,7 @@ class FileDescriptor(BER_TLV_IE, tag=0x82): return 0x39 raise ValidationError - FDB = Select(BitStruct(Const(0, Bit), 'shareable'/Flag, 'structure'/BerTlvAdapter(Const(0x39, BitsInteger(6)))), + FDB = Select(BitStruct(Const(0, Bit), 'shareable'/Flag, 'structure'/BerTlvAdapter(Const(0x39, BitsInteger(6))), 'file_type'/Computed('working_ef')), BitStruct(Const(0, Bit), 'shareable'/Flag, 'file_type'/Enum(BitsInteger(3), working_ef=0, internal_ef=1, df=7), 'structure'/Enum(BitsInteger(3), no_info_given=0, transparent=1, linear_fixed=2, cyclic=6)) )