This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/26276 ) Change subject: profile: decode_select_response can be a static method ...................................................................... profile: decode_select_response can be a static method The method decode_select_response does not access any property of the object. This means the method can be static. Change-Id: Idd7aaebcf1ab0099cd40a88b8938604e84d8a88b --- M pySim/profile.py M pySim/sysmocom_sja2.py M pySim/ts_102_221.py M pySim/ts_31_102.py M pySim/ts_31_103.py M pySim/ts_51_011.py 6 files changed, 27 insertions(+), 29 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/profile.py b/pySim/profile.py index f068d7c..768064f 100644 --- a/pySim/profile.py +++ b/pySim/profile.py @@ -106,7 +106,8 @@ """ return interpret_sw(self.sw, sw) - def decode_select_response(self, data_hex:str) -> Any: + @staticmethod + def decode_select_response(data_hex:str) -> Any: """Decode the response to a SELECT command. This is the fall-back method which doesn't perform any decoding. It mostly diff --git a/pySim/sysmocom_sja2.py b/pySim/sysmocom_sja2.py index 263999d..6d49572 100644 --- a/pySim/sysmocom_sja2.py +++ b/pySim/sysmocom_sja2.py @@ -154,7 +154,7 @@ self.add_files(files) def decode_select_response(self, resp_hex): - return pySim.ts_102_221.decode_select_response(resp_hex) + return pySim.ts_102_221.CardProfileUICC.decode_select_response(resp_hex) class EF_USIM_SQN(TransparentEF): def __init__(self, fid='af30', name='EF.USIM_SQN'): diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py index 53cd118..1d10988 100644 --- a/pySim/ts_102_221.py +++ b/pySim/ts_102_221.py @@ -473,28 +473,6 @@ SC_DO = DataObjectChoice('security_condition', 'Security Condition', members=[Always_DO, Never_DO, SecCondByte_DO(), SecCondByte_DO(0x9e), CRT_DO()]) - -# ETSI TS 102 221 Section 11.1.1.3 -def decode_select_response(resp_hex): - fixup_fcp_proprietary_tlv_map(FCP_Proprietary_TLV_MAP) - resp_hex = resp_hex.upper() - # outer layer - fcp_base_tlv = TLV(['62']) - fcp_base = fcp_base_tlv.parse(resp_hex) - # actual FCP - fcp_tlv = TLV(FCP_TLV_MAP) - fcp = fcp_tlv.parse(fcp_base['62']) - # further decode the proprietary information - if fcp['A5']: - prop_tlv = TLV(FCP_Proprietary_TLV_MAP) - prop = prop_tlv.parse(fcp['A5']) - fcp['A5'] = tlv_val_interpret(FCP_prorietary_interpreter_map, prop) - fcp['A5'] = tlv_key_replace(FCP_Proprietary_TLV_MAP, fcp['A5']) - # finally make sure we get human-readable keys in the output dict - r = tlv_val_interpret(FCP_interpreter_map, fcp) - return tlv_key_replace(FCP_TLV_MAP, r) - - # TS 102 221 Section 13.1 class EF_DIR(LinFixedEF): def __init__(self, fid='2f00', sfid=0x1e, name='EF.DIR', desc='Application Directory'): @@ -694,8 +672,26 @@ super().__init__(name, desc='ETSI TS 102 221', cla="00", sel_ctrl="0004", files_in_mf=files, sw=sw) - def decode_select_response(self, data_hex:str) -> Any: - return decode_select_response(data_hex) + @staticmethod + def decode_select_response(resp_hex:str) -> Any: + """ETSI TS 102 221 Section 11.1.1.3""" + fixup_fcp_proprietary_tlv_map(FCP_Proprietary_TLV_MAP) + resp_hex = resp_hex.upper() + # outer layer + fcp_base_tlv = TLV(['62']) + fcp_base = fcp_base_tlv.parse(resp_hex) + # actual FCP + fcp_tlv = TLV(FCP_TLV_MAP) + fcp = fcp_tlv.parse(fcp_base['62']) + # further decode the proprietary information + if fcp['A5']: + prop_tlv = TLV(FCP_Proprietary_TLV_MAP) + prop = prop_tlv.parse(fcp['A5']) + fcp['A5'] = tlv_val_interpret(FCP_prorietary_interpreter_map, prop) + fcp['A5'] = tlv_key_replace(FCP_Proprietary_TLV_MAP, fcp['A5']) + # finally make sure we get human-readable keys in the output dict + r = tlv_val_interpret(FCP_interpreter_map, fcp) + return tlv_key_replace(FCP_TLV_MAP, r) @staticmethod def match_with_card(scc:SimCardCommands) -> bool: diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 14d7ec1..647a4d7 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -1067,7 +1067,7 @@ self.add_files(files) def decode_select_response(self, data_hex): - return pySim.ts_102_221.decode_select_response(data_hex) + return pySim.ts_102_221.CardProfileUICC.decode_select_response(data_hex) @with_default_category('Application-Specific Commands') class AddlShellCommands(CommandSet): diff --git a/pySim/ts_31_103.py b/pySim/ts_31_103.py index 63ef99e..9c7843f 100644 --- a/pySim/ts_31_103.py +++ b/pySim/ts_31_103.py @@ -213,7 +213,7 @@ self.shell_commands += [ADF_USIM.AddlShellCommands()] def decode_select_response(self, data_hex): - return pySim.ts_102_221.decode_select_response(data_hex) + return pySim.ts_102_221.CardProfileUICC.decode_select_response(data_hex) # TS 31.103 Section 7.1 sw_isim = { diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 2d3ad0c..f330460 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -978,7 +978,8 @@ super().__init__('SIM', desc='GSM SIM Card', cla="a0", sel_ctrl="0000", files_in_mf=[DF_TELECOM(), DF_GSM()], sw=sw) - def decode_select_response(self, resp_hex:str) -> Any: + @staticmethod + def decode_select_response(resp_hex:str) -> Any: resp_bin = h2b(resp_hex) struct_of_file_map = { 0: 'transparent', -- To view, visit https://gerrit.osmocom.org/c/pysim/+/26276 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Idd7aaebcf1ab0099cd40a88b8938604e84d8a88b Gerrit-Change-Number: 26276 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211122/e51e864a/attachment.htm>