mirror of https://gerrit.osmocom.org/pysim
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
This commit is contained in:
parent
825b564115
commit
5998a3a8b3
|
@ -106,7 +106,8 @@ class CardProfile(object):
|
||||||
"""
|
"""
|
||||||
return interpret_sw(self.sw, sw)
|
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.
|
"""Decode the response to a SELECT command.
|
||||||
|
|
||||||
This is the fall-back method which doesn't perform any decoding. It mostly
|
This is the fall-back method which doesn't perform any decoding. It mostly
|
||||||
|
|
|
@ -154,7 +154,7 @@ class DF_SYSTEM(CardDF):
|
||||||
self.add_files(files)
|
self.add_files(files)
|
||||||
|
|
||||||
def decode_select_response(self, resp_hex):
|
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):
|
class EF_USIM_SQN(TransparentEF):
|
||||||
def __init__(self, fid='af30', name='EF.USIM_SQN'):
|
def __init__(self, fid='af30', name='EF.USIM_SQN'):
|
||||||
|
|
|
@ -473,28 +473,6 @@ Never_DO = TL0_DataObject('never', 'Never', 0x97)
|
||||||
SC_DO = DataObjectChoice('security_condition', 'Security Condition',
|
SC_DO = DataObjectChoice('security_condition', 'Security Condition',
|
||||||
members=[Always_DO, Never_DO, SecCondByte_DO(), SecCondByte_DO(0x9e), CRT_DO()])
|
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
|
# TS 102 221 Section 13.1
|
||||||
class EF_DIR(LinFixedEF):
|
class EF_DIR(LinFixedEF):
|
||||||
def __init__(self, fid='2f00', sfid=0x1e, name='EF.DIR', desc='Application Directory'):
|
def __init__(self, fid='2f00', sfid=0x1e, name='EF.DIR', desc='Application Directory'):
|
||||||
|
@ -694,8 +672,26 @@ class CardProfileUICC(CardProfile):
|
||||||
|
|
||||||
super().__init__(name, desc='ETSI TS 102 221', cla="00", sel_ctrl="0004", files_in_mf=files, sw=sw)
|
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:
|
@staticmethod
|
||||||
return decode_select_response(data_hex)
|
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
|
@staticmethod
|
||||||
def match_with_card(scc:SimCardCommands) -> bool:
|
def match_with_card(scc:SimCardCommands) -> bool:
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ class ADF_USIM(CardADF):
|
||||||
self.add_files(files)
|
self.add_files(files)
|
||||||
|
|
||||||
def decode_select_response(self, data_hex):
|
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')
|
@with_default_category('Application-Specific Commands')
|
||||||
class AddlShellCommands(CommandSet):
|
class AddlShellCommands(CommandSet):
|
||||||
|
|
|
@ -213,7 +213,7 @@ class ADF_ISIM(CardADF):
|
||||||
self.shell_commands += [ADF_USIM.AddlShellCommands()]
|
self.shell_commands += [ADF_USIM.AddlShellCommands()]
|
||||||
|
|
||||||
def decode_select_response(self, data_hex):
|
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
|
# TS 31.103 Section 7.1
|
||||||
sw_isim = {
|
sw_isim = {
|
||||||
|
|
|
@ -978,7 +978,8 @@ class CardProfileSIM(CardProfile):
|
||||||
|
|
||||||
super().__init__('SIM', desc='GSM SIM Card', cla="a0", sel_ctrl="0000", files_in_mf=[DF_TELECOM(), DF_GSM()], sw=sw)
|
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)
|
resp_bin = h2b(resp_hex)
|
||||||
struct_of_file_map = {
|
struct_of_file_map = {
|
||||||
0: 'transparent',
|
0: 'transparent',
|
||||||
|
|
Loading…
Reference in New Issue