From ce5da32a75aad7431f8412a5fa588892844cea1c Mon Sep 17 00:00:00 2001 From: kukutyin Date: Wed, 27 May 2026 15:02:20 +0200 Subject: [PATCH] fix(ts_51_011): apply correct access conditions length When the access conditions are extracted from resp_bin, the wrong length is used and only 2 bytes instead of 3 are extracted. 3GPP TS 51.011, section 9.2.1, table below "Response parameters/data in case of an EF", clearly states that the length should be 3 bytes (position 9-11) Related: OS#7018 Change-Id: I410fb58c395beafba8de6d5ab4e71452f424cdf2 --- pySim/ts_51_011.py | 2 +- tests/unittests/test_decode_select_resp.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 4cad0490..24cf5c5f 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -1305,7 +1305,7 @@ class CardProfileSIM(CardProfile): record_len = resp_bin[14] ret['file_descriptor']['record_len'] = record_len ret['file_descriptor']['num_of_rec'] = ret['file_size'] // record_len - ret['access_conditions'] = b2h(resp_bin[8:10]) + ret['access_conditions'] = b2h(resp_bin[8:11]) if resp_bin[11] & 0x01 == 0: ret['life_cycle_status_int'] = 'operational_activated' elif resp_bin[11] & 0x04: diff --git a/tests/unittests/test_decode_select_resp.py b/tests/unittests/test_decode_select_resp.py index 80dd72b8..72fb077c 100644 --- a/tests/unittests/test_decode_select_resp.py +++ b/tests/unittests/test_decode_select_resp.py @@ -47,10 +47,10 @@ class TestDecodeSelectResponse_CardProfile(unittest.TestCase): "decoded" : {'file_descriptor': {'file_descriptor_byte': {'file_type': 'df'}}, 'proprietary_info': {'available_memory': 0}, 'file_id': '7f10', 'file_characteristics': '81', 'num_direct_child_df': 0, 'num_direct_child_ef': 13, 'num_chv_unblock_adm_codes': 4}}, # EF.MSISDN {"resp_hex" : "000000346f40040011ffff0102011a", - "decoded" : {'file_descriptor': {'file_descriptor_byte': {'file_type': 'working_ef', 'structure': 'linear_fixed'}, 'record_len': 26, 'num_of_rec': 2}, 'proprietary_info': {}, 'file_id': '6f40', 'file_size': 52, 'access_conditions': '11ff', 'life_cycle_status_int': 'terminated'}}, + "decoded" : {'file_descriptor': {'file_descriptor_byte': {'file_type': 'working_ef', 'structure': 'linear_fixed'}, 'record_len': 26, 'num_of_rec': 2}, 'proprietary_info': {}, 'file_id': '6f40', 'file_size': 52, 'access_conditions': '11ffff', 'life_cycle_status_int': 'terminated'}}, # EF.ICCID {"resp_hex" : "0000000a2fe204000cffff01020000", - "decoded" : {'file_descriptor': {'file_descriptor_byte': {'file_type': 'working_ef', 'structure': 'transparent'}}, 'proprietary_info': {}, 'file_id': '2fe2', 'file_size': 10, 'access_conditions': '0cff', 'life_cycle_status_int': 'terminated'}}, + "decoded" : {'file_descriptor': {'file_descriptor_byte': {'file_type': 'working_ef', 'structure': 'transparent'}}, 'proprietary_info': {}, 'file_id': '2fe2', 'file_size': 10, 'access_conditions': '0cffff', 'life_cycle_status_int': 'terminated'}}, ] self.decode_select_response(CardProfileSIM, testcases)