sysmo_isim_sja2: cosmetic: remove unnecessary new lines
Related: SYS#6473
This commit is contained in:
parent
86a6bb6ea5
commit
359d8ef645
|
@ -102,17 +102,14 @@ class SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY:
|
||||||
def __init__(self, content = None):
|
def __init__(self, content = None):
|
||||||
if content == None:
|
if content == None:
|
||||||
return
|
return
|
||||||
|
|
||||||
header = content[0]
|
header = content[0]
|
||||||
self.algo = header & 0x0F
|
self.algo = header & 0x0F
|
||||||
self.use_opc = bool((header >> 4) & 1)
|
self.use_opc = bool((header >> 4) & 1)
|
||||||
|
|
||||||
if (header >> 5) & 1:
|
if (header >> 5) & 1:
|
||||||
self.sres_dev_func = 2
|
self.sres_dev_func = 2
|
||||||
else:
|
else:
|
||||||
self.sres_dev_func = 1
|
self.sres_dev_func = 1
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
dump = ""
|
dump = ""
|
||||||
pfx = " "
|
pfx = " "
|
||||||
|
@ -130,7 +127,6 @@ class SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY:
|
||||||
|
|
||||||
return dump
|
return dump
|
||||||
|
|
||||||
|
|
||||||
def encode(self):
|
def encode(self):
|
||||||
out = [0x00]
|
out = [0x00]
|
||||||
out[0] = self.algo & 0x0F
|
out[0] = self.algo & 0x0F
|
||||||
|
@ -153,7 +149,6 @@ class SYSMO_ISIMSJA2_FILE_EF_SIM_AUTH_KEY(SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY):
|
||||||
self.key = content[1:17]
|
self.key = content[1:17]
|
||||||
self.opc = content[17:33]
|
self.opc = content[17:33]
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
dump = ""
|
dump = ""
|
||||||
pfx = " "
|
pfx = " "
|
||||||
|
@ -204,7 +199,6 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY)
|
||||||
if len(content) > 17:
|
if len(content) > 17:
|
||||||
self.opc = content[17:33]
|
self.opc = content[17:33]
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
dump = ""
|
dump = ""
|
||||||
pfx = " "
|
pfx = " "
|
||||||
|
@ -278,7 +272,6 @@ class SYSMO_ISIMSJA2_FILE_EF_MILENAGE_CFG:
|
||||||
C5 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
C5 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08]
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08]
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, content = None):
|
def __init__(self, content = None):
|
||||||
if content == None:
|
if content == None:
|
||||||
return
|
return
|
||||||
|
@ -295,7 +288,6 @@ class SYSMO_ISIMSJA2_FILE_EF_MILENAGE_CFG:
|
||||||
self.C4 = content[53:69]
|
self.C4 = content[53:69]
|
||||||
self.C5 = content[69:85]
|
self.C5 = content[69:85]
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
dump = " R1: " + str(hex(self.R1)) + "\n"
|
dump = " R1: " + str(hex(self.R1)) + "\n"
|
||||||
dump += " R2: " + str(hex(self.R2)) + "\n"
|
dump += " R2: " + str(hex(self.R2)) + "\n"
|
||||||
|
@ -309,7 +301,6 @@ class SYSMO_ISIMSJA2_FILE_EF_MILENAGE_CFG:
|
||||||
dump += " C5: " + hexdump(self.C5)
|
dump += " C5: " + hexdump(self.C5)
|
||||||
return dump
|
return dump
|
||||||
|
|
||||||
|
|
||||||
def encode(self):
|
def encode(self):
|
||||||
out = [self.R1, self.R2, self.R3, self.R4, self.R5]
|
out = [self.R1, self.R2, self.R3, self.R4, self.R5]
|
||||||
out += self.C1 + self.C2 + self.C3 + self.C4 + self.C5
|
out += self.C1 + self.C2 + self.C3 + self.C4 + self.C5
|
||||||
|
@ -376,11 +367,9 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN:
|
||||||
self.age_limit = list_to_int(content[8:14])
|
self.age_limit = list_to_int(content[8:14])
|
||||||
self.freshness_data = content[15:(6*2**self.ind_size_bits)]
|
self.freshness_data = content[15:(6*2**self.ind_size_bits)]
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
pfx = " "
|
pfx = " "
|
||||||
dump = ""
|
dump = ""
|
||||||
|
|
||||||
dump += "%sIND (bits): %u\n" % (pfx, self.ind_size_bits)
|
dump += "%sIND (bits): %u\n" % (pfx, self.ind_size_bits)
|
||||||
if self.sqn_check_enabled:
|
if self.sqn_check_enabled:
|
||||||
dump += "%sSQN Check enabled\n" % pfx
|
dump += "%sSQN Check enabled\n" % pfx
|
||||||
|
@ -413,10 +402,8 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN:
|
||||||
dump += "%sMax Delta: %u\n" % (pfx, self.max_delta)
|
dump += "%sMax Delta: %u\n" % (pfx, self.max_delta)
|
||||||
dump += "%sAge Limit: %u\n" % (pfx, self.age_limit)
|
dump += "%sAge Limit: %u\n" % (pfx, self.age_limit)
|
||||||
dump += pfx + "Freshness Data:\n" + hexdump(self.freshness_data, True)
|
dump += pfx + "Freshness Data:\n" + hexdump(self.freshness_data, True)
|
||||||
|
|
||||||
return dump
|
return dump
|
||||||
|
|
||||||
|
|
||||||
def encode(self):
|
def encode(self):
|
||||||
out = [0x00, 0x00]
|
out = [0x00, 0x00]
|
||||||
|
|
||||||
|
@ -445,12 +432,10 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN:
|
||||||
out += self.freshness_data
|
out += self.freshness_data
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.freshness_data = [0x00] * (6*2**self.ind_size_bits)
|
self.freshness_data = [0x00] * (6*2**self.ind_size_bits)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Sysmo_isim_sja2(Sysmo_usim):
|
class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
algorithms = sysmo_isimsja2_algorithms
|
algorithms = sysmo_isimsja2_algorithms
|
||||||
|
|
||||||
|
@ -469,7 +454,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
if card_detected == True:
|
if card_detected == True:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Try card model #2
|
# Try card model #2
|
||||||
try:
|
try:
|
||||||
atr = "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 4C 75 31 33 02 51 B2"
|
atr = "3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 4C 75 31 33 02 51 B2"
|
||||||
|
@ -494,12 +478,10 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
if card_detected == True:
|
if card_detected == True:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Exit when we are not able to detect the card
|
# Exit when we are not able to detect the card
|
||||||
if card_detected != True:
|
if card_detected != True:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
# Show current milenage parameters
|
# Show current milenage parameters
|
||||||
def show_milenage_params(self):
|
def show_milenage_params(self):
|
||||||
print("Reading Milenage parameters...")
|
print("Reading Milenage parameters...")
|
||||||
|
@ -515,10 +497,8 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(str(ef))
|
print(str(ef))
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Write new milenage parameters
|
# Write new milenage parameters
|
||||||
def write_milenage_params(self, params):
|
def write_milenage_params(self, params):
|
||||||
|
|
||||||
print("Programming Milenage parameters...")
|
print("Programming Milenage parameters...")
|
||||||
|
|
||||||
if (len(params) < 85):
|
if (len(params) < 85):
|
||||||
|
@ -545,14 +525,12 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
self.sim.update_binary(ef_milenage_cfg.encode())
|
self.sim.update_binary(ef_milenage_cfg.encode())
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Select DF_SYSTEM/EF_SIM_AUTH_KEY
|
# Select DF_SYSTEM/EF_SIM_AUTH_KEY
|
||||||
def __select_ef_sim_auth_key(self):
|
def __select_ef_sim_auth_key(self):
|
||||||
self.sim.select(GSM_SIM_MF)
|
self.sim.select(GSM_SIM_MF)
|
||||||
self.sim.select(SYSMO_ISIMSJA2_DF_SYSTEM)
|
self.sim.select(SYSMO_ISIMSJA2_DF_SYSTEM)
|
||||||
self.sim.select(SYSMO_ISIMSJA2_EF_SIM_AUTH_KEY)
|
self.sim.select(SYSMO_ISIMSJA2_EF_SIM_AUTH_KEY)
|
||||||
|
|
||||||
|
|
||||||
# Authentication keys exist in various different files, which are
|
# Authentication keys exist in various different files, which are
|
||||||
# similar, thie method simplifies the selection of those files
|
# similar, thie method simplifies the selection of those files
|
||||||
def __select_xsim_auth_key(self, isim = False, _2G = False):
|
def __select_xsim_auth_key(self, isim = False, _2G = False):
|
||||||
|
@ -567,7 +545,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
else:
|
else:
|
||||||
self.sim.select(SYSMO_ISIMSJA2_EF_USIM_AUTH_KEY)
|
self.sim.select(SYSMO_ISIMSJA2_EF_USIM_AUTH_KEY)
|
||||||
|
|
||||||
|
|
||||||
# In the SJA2 model the key material and the algorithm configuration
|
# In the SJA2 model the key material and the algorithm configuration
|
||||||
# is distributed over multiple files, which may also have redundant
|
# is distributed over multiple files, which may also have redundant
|
||||||
# contents. Files can also be hard linked to other files so that
|
# contents. Files can also be hard linked to other files so that
|
||||||
|
@ -644,7 +621,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(" * ADF_ISIM/EF_ISIM_SQN:")
|
print(" * ADF_ISIM/EF_ISIM_SQN:")
|
||||||
print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu))
|
print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu))
|
||||||
|
|
||||||
|
|
||||||
def show_key_params(self):
|
def show_key_params(self):
|
||||||
"""
|
"""
|
||||||
Show current Key value
|
Show current Key value
|
||||||
|
@ -662,7 +638,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(" Key: " + hexdump(ef.key))
|
print(" Key: " + hexdump(ef.key))
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
def write_key_params(self, key):
|
def write_key_params(self, key):
|
||||||
"""
|
"""
|
||||||
Program new Key value
|
Program new Key value
|
||||||
|
@ -672,7 +647,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(" * New Key setting:")
|
print(" * New Key setting:")
|
||||||
print(" Key: " + hexdump(key))
|
print(" Key: " + hexdump(key))
|
||||||
print(" * Programming...")
|
print(" * Programming...")
|
||||||
|
|
||||||
self.__select_xsim_auth_key(isim = False, _2G = True)
|
self.__select_xsim_auth_key(isim = False, _2G = True)
|
||||||
res = self._read_binary(self.sim.filelen)
|
res = self._read_binary(self.sim.filelen)
|
||||||
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)
|
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)
|
||||||
|
@ -694,7 +668,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Show current athentication parameters
|
# Show current athentication parameters
|
||||||
# (Which algorithim is used for which rat?)
|
# (Which algorithim is used for which rat?)
|
||||||
def show_auth_params(self):
|
def show_auth_params(self):
|
||||||
|
@ -717,7 +690,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(" 3G: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_3g)))
|
print(" 3G: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_3g)))
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Program new authentication parameters
|
# Program new authentication parameters
|
||||||
def write_auth_params(self, algo_2g_str, algo_3g_str):
|
def write_auth_params(self, algo_2g_str, algo_3g_str):
|
||||||
print("Programming Authentication parameters...")
|
print("Programming Authentication parameters...")
|
||||||
|
@ -760,7 +732,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Show current OPc value
|
# Show current OPc value
|
||||||
def show_opc_params(self):
|
def show_opc_params(self):
|
||||||
print("Reading OP/c value...")
|
print("Reading OP/c value...")
|
||||||
|
@ -781,7 +752,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(" %s: %s" % (mode_str, hexdump(ef.opc)))
|
print(" %s: %s" % (mode_str, hexdump(ef.opc)))
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Program new OPc value
|
# Program new OPc value
|
||||||
def write_opc_params(self, select, op):
|
def write_opc_params(self, select, op):
|
||||||
if select:
|
if select:
|
||||||
|
@ -796,7 +766,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
print(" %s: %s" % (mode_str, hexdump(op)))
|
print(" %s: %s" % (mode_str, hexdump(op)))
|
||||||
|
|
||||||
print(" * Programming...")
|
print(" * Programming...")
|
||||||
|
|
||||||
self.__select_xsim_auth_key(isim = False, _2G = True)
|
self.__select_xsim_auth_key(isim = False, _2G = True)
|
||||||
res = self._read_binary(self.sim.filelen)
|
res = self._read_binary(self.sim.filelen)
|
||||||
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)
|
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)
|
||||||
|
@ -821,7 +790,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Show current milenage SQN parameters
|
# Show current milenage SQN parameters
|
||||||
def show_milenage_sqn_params(self):
|
def show_milenage_sqn_params(self):
|
||||||
print("Reading Milenage Sequence parameters...")
|
print("Reading Milenage Sequence parameters...")
|
||||||
|
@ -844,7 +812,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
# Reset milenage SQN configuration
|
# Reset milenage SQN configuration
|
||||||
def reset_milenage_sqn_params(self):
|
def reset_milenage_sqn_params(self):
|
||||||
print(" * Resetting SQN Configuration to defaults...")
|
print(" * Resetting SQN Configuration to defaults...")
|
||||||
|
@ -866,7 +833,6 @@ class Sysmo_isim_sja2(Sysmo_usim):
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
class Sysmo_isim_sja5(Sysmo_isim_sja2):
|
class Sysmo_isim_sja5(Sysmo_isim_sja2):
|
||||||
algorithms = sysmo_isimsja5_algorithms
|
algorithms = sysmo_isimsja5_algorithms
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue