diff --git a/common.py b/common.py index d718fce..f207dae 100644 --- a/common.py +++ b/common.py @@ -28,8 +28,8 @@ import sys, getopt COMMON_GETOPTS = "hfa:J:nN:lL:kK:tT:oO:C:sSip" COMMON_GETOPTS_LONG = ["help", "force", "adm1=", "set-imsi=", "mnclen", - "set-mnclen=", "milenage", "set-milenage=", "ki", - "set-ki=", "auth", "set-auth=", "opc", "set-op=", + "set-mnclen=", "milenage", "set-milenage=", "key", + "set-key=", "auth", "set-auth=", "opc", "set-op=", "set-opc=", "seq-parameters", "reset-seq-parameters" "iccid", "aid"] @@ -46,8 +46,8 @@ class Common(): show_mnclen = None show_milenage = False write_milenage = None - show_ki = None - write_ki = None + show_key = None + write_key = None show_auth = False write_auth = None show_opc = False @@ -91,14 +91,14 @@ class Common(): self.show_milenage = True elif opt in ("-L", "--set-milenage"): self.write_milenage = asciihex_to_list(arg) - elif opt in ("-k", "--ki"): - self.show_ki = True - elif opt in ("-K", "--set-ki"): - self.write_ki = asciihex_to_list(arg) + elif opt in ("-k", "--key"): + self.show_key = True + elif opt in ("-K", "--set-key"): + self.write_key = asciihex_to_list(arg) elif opt in ("-t", "--auth"): self.show_auth = True elif opt in ("-T", "--set-auth"): - self.write_auth = arg.split(':',1) + self.write_auth = arg.split(':', 2) elif opt in ("-o", "--opc"): self.show_opc = True elif opt in ("-O", "--set-op"): @@ -141,10 +141,10 @@ class Common(): print(" -N, --set-mnclen ............... Set MNC length value") print(" -l, --milenage ................. Show milenage parameters") print(" -L, --set-milenage HEXSTRING ... Set milenage parameters") - print(" -k, --ki ....................... Show KI value") - print(" -K, --set-ki ................... Set KI value") - print(" -t, --auth ..................... Show Authentication algorithms") - print(" -T, --set-auth 2G:3G ........... Set 2G/3G Auth algo (e.g. COMP128v1:COMP128v1)") + print(" -k, --key ...................... Show auth key value") + print(" -K, --set-key .................. Set auth key value") + print(" -t, --auth ..................... Show authentication algorithms") + print(" -T, --set-auth 2g:3g[:4g5g] .... Set 2G/3G auth algo (e.g. COMP128v1:COMP128v1)") print(" -o, --opc ...................... Show OP/c configuration") print(" -O, --set-op HEXSTRING ......... Set OP value") print(" -C, --set-opc HEXSTRING ........ Set OPc value") @@ -182,17 +182,20 @@ class Common(): if self.show_milenage: self.sim.show_milenage_params() - if self.write_ki: - self.sim.write_ki_params(self.write_ki) + if self.write_key: + self.sim.write_key_params(self.write_key) - if self.show_ki: - self.sim.show_ki_params() + if self.show_key: + self.sim.show_key_params() if self.show_auth: self.sim.show_auth_params() if self.write_auth: - self.sim.write_auth_params(self.write_auth[0], self.write_auth[1]) + if len(self.write_auth) > 2: + self.sim.write_auth_params(self.write_auth[0], self.write_auth[1], self.write_auth[2]) + else: + self.sim.write_auth_params(self.write_auth[0], self.write_auth[1]) if self.show_opc: self.sim.show_opc_params() diff --git a/sysmo-isim-tool.sja5.py b/sysmo-isim-tool.sja5.py index 343100e..130e605 100755 --- a/sysmo-isim-tool.sja5.py +++ b/sysmo-isim-tool.sja5.py @@ -32,7 +32,8 @@ from common import * class Application(Common): getopt_dump = False - + getopt_show_tuak_cfg = False + getopt_write_tuak_cfg = None # Automatically executed by superclass def _banner(self): @@ -46,16 +47,27 @@ class Application(Common): for opt, arg in opts: if opt in ("-d", "--dump"): self.getopt_dump = True - + elif opt in ("-w", "--tuak-cfg"): + self.getopt_show_tuak_cfg = True + elif opt in ("-W", "--set-tuak-cfg"): + self.getopt_write_tuak_cfg = arg.split(':', 3) # Automatically executed by superclass when -h or --help is supplied as option def _helptext(self): print(" -d, --dump ..................... Dump propritary file contents") + #TODO: add a help screen to explain what RMCK means + print(" -w, --tuak-cfg ................. Show TUAK configuration") + print(" -W, --set-tuak-cfg R:M:C:K ..... Set TUAK configuration") print("") print(" For Option -T, the following algorithms are valid:") print('\n'.join([' %d %s' % entry for entry in sysmo_isimsja5_algorithms])) print("") - + print(" For Option -W, the following values are applicable:") + print(" R = RES-Size in bits: 32, 64, 128 or 256") + print(" M = MAC-A and MAC-S size in bits: 64, 128 or 256") + print(" C = CK and IK size in bits: 128 or 256") + print(" K = Number of Keccak iterations: 1-255") + print("") # Automatically executed by superclass before _execute() is called def _init(self): @@ -67,11 +79,15 @@ class Application(Common): if self.getopt_dump: self.sim.dump() - + elif self.getopt_show_tuak_cfg: + self.sim.show_tuak_cfg() + elif self.getopt_write_tuak_cfg: + self.sim.write_tuak_cfg(self.getopt_write_tuak_cfg[0], self.getopt_write_tuak_cfg[1], \ + self.getopt_write_tuak_cfg[2], self.getopt_write_tuak_cfg[3]) def main(argv): - Application(argv, "d", ["dump"]) + Application(argv, "dwW:", ["dump"]) if __name__ == "__main__": diff --git a/sysmo_isim_sja2.py b/sysmo_isim_sja2.py index 606da78..aeeb75e 100644 --- a/sysmo_isim_sja2.py +++ b/sysmo_isim_sja2.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- """ -Gadgets to modify sysmoISIM-SJA2 parameters +Gadgets to modify sysmoISIM-SJA2/sysmoISIM-SJA5 parameters -(C) 2017-2022 by sysmocom - s.f.m.c. GmbH +(C) 2017-2023 by sysmocom - s.f.m.c. GmbH All Rights Reserved Author: Philipp Maier @@ -40,15 +40,15 @@ import math # | # +--[ADF_USIM] # | | -# | +--[USIM_AUTH_KEY 0xAF20] (regular file) +# | +--[EF_USIM_AUTH_KEY 0xAF20] (regular file) # | | # | +--[EF_USIM_AUTH_KEY_2G 0xAF22] (link to DF_SYSTEM/EF_SIM_AUTH_KEY) # | # +--[ADF_ISIM] # | -# +--[USIM_AUTH_KEY 0xAF20] (regular file) +# +--[EF_ISIM_AUTH_KEY 0xAF20] (regular file) # | -# +--[EF_USIM_AUTH_KEY_2G 0xAF22] (link to DF_SYSTEM/EF_SIM_AUTH_KEY) +# +--[EF_ISIM_AUTH_KEY_2G 0xAF22] (link to DF_SYSTEM/EF_SIM_AUTH_KEY) # # Note: EF_MILENAGE_CFG and EF_USIM_SQN not yet listed here. @@ -74,6 +74,7 @@ SYSMO_ISIMSJA5_ALGO_TUAK = 0x06 SYSMO_ISIMSJA5_ALGO_XOR_2G = 0x0E SYSMO_ISIMSJA2_ALGO_XOR = 0x0F +# Algorithms that are supported by sysmo-isim-sja2 (and also sysmo-isim-sja5) sysmo_isimsja2_algorithms = [ (SYSMO_ISIMSJA2_ALGO_COMP12V1, 'COMP128v1'), (SYSMO_ISIMSJA2_ALGO_COMP12V2, 'COMP128v2'), @@ -83,181 +84,379 @@ sysmo_isimsja2_algorithms = [ (SYSMO_ISIMSJA2_ALGO_XOR, 'XOR'), ] +# Algorithms that are supported by sysmo-isim-sja5. This also includes all +# algorithms supported by sysmo-isim-sja2y sysmo_isimsja5_algorithms = sysmo_isimsja2_algorithms + [ (SYSMO_ISIMSJA5_ALGO_XOR_2G, 'XOR-2G'), (SYSMO_ISIMSJA5_ALGO_TUAK, 'TUAK'), ] -class SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY: +# Algorithms that use a 16 byte Ki +sysmo_isimsjax_ki_algorithms = [ + SYSMO_ISIMSJA2_ALGO_COMP12V1, + SYSMO_ISIMSJA2_ALGO_COMP12V2, + SYSMO_ISIMSJA2_ALGO_COMP12V3, + SYSMO_ISIMSJA2_ALGO_MILENAGE, + SYSMO_ISIMSJA2_ALGO_SHA1AKA, + SYSMO_ISIMSJA2_ALGO_XOR, + SYSMO_ISIMSJA5_ALGO_XOR_2G, + ] + +# TUAK configuration byte +SYSMO_ISIMSJA5_TUAK_RES_SIZE_32_BIT = 0 +SYSMO_ISIMSJA5_TUAK_RES_SIZE_64_BIT = 1 +SYSMO_ISIMSJA5_TUAK_RES_SIZE_128_BIT = 2 +SYSMO_ISIMSJA5_TUAK_RES_SIZE_256_BIT = 3 +SYSMO_ISIMSJA5_TUAK_MAC_SIZE_64_BIT = 0 +SYSMO_ISIMSJA5_TUAK_MAC_SIZE_128_BIT = 1 +SYSMO_ISIMSJA5_TUAK_MAC_SIZE_256_BIT = 2 +SYSMO_ISIMSJA5_TUAK_CKIK_SIZE_128_BIT = 0 +SYSMO_ISIMSJA5_TUAK_CKIK_SIZE_256_BIT = 1 +sysmo_isimsja5_res_sizes = [ + (SYSMO_ISIMSJA5_TUAK_RES_SIZE_32_BIT, "32"), + (SYSMO_ISIMSJA5_TUAK_RES_SIZE_64_BIT, "64"), + (SYSMO_ISIMSJA5_TUAK_RES_SIZE_128_BIT, "128"), + (SYSMO_ISIMSJA5_TUAK_RES_SIZE_256_BIT, "256") + ] +sysmo_isimsja5_mac_sizes = [ + (SYSMO_ISIMSJA5_TUAK_MAC_SIZE_64_BIT, "64"), + (SYSMO_ISIMSJA5_TUAK_MAC_SIZE_128_BIT, "128"), + (SYSMO_ISIMSJA5_TUAK_MAC_SIZE_256_BIT, "256") + ] +sysmo_isimsja5_ckik_sizes = [ + (SYSMO_ISIMSJA5_TUAK_CKIK_SIZE_128_BIT, "128"), + (SYSMO_ISIMSJA5_TUAK_CKIK_SIZE_256_BIT, "256") + ] + + +sysmo_isimsjax_op_opc = [ + (True, 'OPc'), + (False, 'OP'), + ] +sysmo_isimsja5_top_topc = [ + (True, 'TOPc'), + (False, 'TOP'), + ] + +class SYSMO_ISIMSJAX_ALGO_PARS_MILENAGE: + use_opc = False + sres_dev_func = 1 + four_byte_res = 0 #sysmo-usim-sja5 only + + def __init__(self, content = None): + if content == None: + return + header = content[0] + self.use_opc = bool((header >> 4) & 1) + if (header >> 5) & 1: + self.sres_dev_func = 2 + self.four_byte_res = bool((header >> 6) & 1) + + def __str__(self) -> str: + dump = "" + pfx = " " + if self.use_opc == True: + dump += pfx + "use OPc\n" + else: + dump += pfx + "use OP\n" + dump += pfx + "use SRES deviation function " + str(self.sres_dev_func) + "\n" + if self.four_byte_res: + dump += pfx + "Return 4 byte RES\n" + else: + dump += pfx + "Return full 8 byte RES\n" + return dump + + def encode(self) -> int: + out = 0x00 + if self.use_opc == True: + out |= 1 << 4 + out |= ((self.sres_dev_func-1) & 1) << 5 + out |= ((self.four_byte_res) & 1) << 6 + return out + + +class SYSMO_ISIMSJAX_ALGO_PARS_SHA1AKA: + four_byte_res = 0 #sysmo-usim-sja5 only + + def __init__(self, content = None): + if content == None: + return + header = content[0] + self.four_byte_res = bool((header >> 6) & 1) + + def __str__(self) -> str: + dump = "" + pfx = " " + if self.four_byte_res: + dump += pfx + "Return 4 byte RES\n" + else: + dump += pfx + "Return full 8 byte RES (default)\n" + return dump + + def encode(self) -> int: + out = 0x00 + out |= ((self.four_byte_res) & 1) << 6 + return out + + +class SYSMO_ISIMSJAX_ALGO_PARS_XOR: + sres_dev_func = 1 + four_byte_res = 0 + sixteen_byte_res = 0 #Return 16 byte RES (ignores full_res) + + def __init__(self, content = None): + if content == None: + return + header = content[0] + if (header >> 5) & 1: + self.sres_dev_func = 2 + self.four_byte_res = bool((header >> 6) & 1) + self.sixteen_byte_res = bool((header >> 7) & 1) + + def __str__(self) -> str: + dump = "" + pfx = " " + dump += pfx + "use SRES deviation function" + str(self.sres_dev_func) + "\n" + if self.sixteen_byte_res: + dump += pfx + "Return extended 16 byte RES\n" + elif self.four_byte_res: + dump += pfx + "Return 4 byte RES\n" + else: + dump += pfx + "Return full 8 byte RES (default)\n" + return dump + + def encode(self) -> int: + out = 0x00 + out |= ((self.sres_dev_func-1) & 1) << 5 + out |= ((self.four_byte_res) & 1) << 6 + out |= ((self.sixteen_byte_res) & 1) << 7 + return out + + +class SYSMO_ISIMSJA5_ALGO_PARS_TUAK: + use_topc = False + sres_dev_func = 1 + use_256_bit_key = False + + def __init__(self, content = None): + if content == None: + return + header = content[0] + self.use_topc = bool((header >> 4) & 1) + if (header >> 5) & 1: + self.sres_dev_func = 2 + self.use_256_bit_key = bool((header >> 6) & 1) + + def __str__(self) -> str: + dump = "" + pfx = " " + if self.use_topc == True: + dump += pfx + "use TOPc\n" + else: + dump += pfx + "use TOP\n" + dump += pfx + "use SRES deviation function " + str(self.sres_dev_func) + "\n" + if self.use_256_bit_key: + dump += pfx + "256 bit key length\n" + else: + dump += pfx + "128 bit key length\n" + return dump + + + def encode(self) -> int: + out = 0x00 + if self.use_topc == True: + out |= 1 << 4 + out |= ((self.sres_dev_func-1) & 1) << 5 + out |= ((self.use_256_bit_key) & 1) << 6 + return out + + +class SYSMO_ISIMSJAX_FILE_EF_XSIM_AUTH_KEY: """ - Superclass model that generates that handles the header byte of + Superclass model that generates and parses the header byte of SYSMO_ISIMSJA2_EF_USIM_AUTH_KEY, SYSMO_ISIMSJA2_EF_USIM_AUTH_KEY_2G and SYSMO_ISIMSJA2_EF_USIM_AUTH_KEY_GBA. """ algo = SYSMO_ISIMSJA2_ALGO_COMP12V1 - use_opc = False - sres_dev_func = 1 + algo_pars = None def __init__(self, content = None): if content == None: return - header = content[0] self.algo = header & 0x0F - self.use_opc = bool((header >> 4) & 1) + if self.algo == SYSMO_ISIMSJA2_ALGO_MILENAGE: + self.algo_pars = SYSMO_ISIMSJAX_ALGO_PARS_MILENAGE(content) + elif self.algo == SYSMO_ISIMSJA2_ALGO_SHA1AKA: + self.algo_pars = SYSMO_ISIMSJAX_ALGO_PARS_SHA1AKA(content) + elif self.algo == SYSMO_ISIMSJA2_ALGO_XOR: + self.algo_pars = SYSMO_ISIMSJAX_ALGO_PARS_XOR(content) + elif self.algo == SYSMO_ISIMSJA5_ALGO_TUAK: + self.algo_pars = SYSMO_ISIMSJA5_ALGO_PARS_TUAK(content) - if (header >> 5) & 1: - self.sres_dev_func = 2 - else: - self.sres_dev_func = 1 - - - def __str__(self): + def __str__(self) -> str: dump = "" pfx = " " - dump += pfx + "Algorithm: " dump += id_to_str(sysmo_isimsja5_algorithms, self.algo) dump += "\n" - - if self.use_opc == True: - dump += pfx + "Milenage: use OPc\n" - else: - dump += pfx + "Milenage: use OP\n" - - dump += pfx + "Milenage: use SRES deviation function " + str(self.sres_dev_func) + "\n" - + if self.algo_pars: + dump += str(self.algo_pars) return dump - def encode(self): out = [0x00] out[0] = self.algo & 0x0F - if self.use_opc == True: - out[0] |= 1 << 4 - out[0] |= ((self.sres_dev_func-1) & 1) << 5 + if self.algo_pars: + out[0] |= self.algo_pars.encode() return out +class SYSMO_ISIMSJAX_ALGO_KEY_COMP128: -class SYSMO_ISIMSJA2_FILE_EF_SIM_AUTH_KEY(SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY): - - key = [0xAA] * 16 - opc = [0xBB] * 16 + ki = [0x00] * 16 def __init__(self, content = None): if content == None: return + self.ki = content[1:17] - SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY.__init__(self, content) - self.key = content[1:17] - self.opc = content[17:33] - - - def __str__(self): + def __str__(self) -> str: dump = "" pfx = " " - - dump += SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY.__str__(self) - - if self.algo == SYSMO_ISIMSJA2_ALGO_MILENAGE: - dump += pfx + "Key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) - elif self.algo == SYSMO_ISIMSJA2_ALGO_XOR: - dump += pfx + "Key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) - elif self.algo == SYSMO_ISIMSJA2_ALGO_SHA1AKA: - dump += pfx + "Root key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) + " (unused)" - else: - dump += pfx + "Key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) + " (unused)" - + dump += pfx + "Ki: " + hexdump(self.ki) return dump - - def encode(self): - out = SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY.encode(self) - out += self.key + self.opc - return out + def encode(self) -> list: + return self.ki -class SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY): - - full_res = True # Return full 8-byte RES or first 4 bytes only - ext_res = False # Return 16 byte RES (ignores full_res, only valid with 3G XOR) - - key = [0x00] * 16 - opc = [0x00] * 16 # Only for Milenage - - def __init__(self, content = None): - if content == None: - return - - SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY.__init__(self, content) - header = content[0] - - self.full_res = bool((header >> 6) & 1) - self.ext_res = bool((header >> 7) & 1) - - self.key = content[1:17] - if len(content) > 17: - self.opc = content[17:33] - - - def __str__(self): - dump = "" - pfx = " " - - dump += SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY.__str__(self) - if self.full_res == True and self.ext_res == False: - dump += pfx + "3G: Return full 8-byte RES\n" - elif self.full_res == False and self.ext_res == False: - dump += pfx + "3G: Return first four bytes of RES\n" - elif self.ext_res == True: - dump += pfx + "3G: Return 16-byte RES (XOR 3G only)\n" - else: - dump += pfx + "(invalid RES length setting)" - - if self.algo != SYSMO_ISIMSJA2_ALGO_XOR and self.ext_res: - dump += pfx + "Warning: 16-byte RES is only valid with XOR 3G!\n" - - if self.algo == SYSMO_ISIMSJA2_ALGO_MILENAGE: - dump += pfx + "Key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) - elif self.algo == SYSMO_ISIMSJA2_ALGO_XOR: - dump += pfx + "Key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) - elif self.algo == SYSMO_ISIMSJA2_ALGO_SHA1AKA: - dump += pfx + "Root key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) + " (unused)" - else: - dump += pfx + "Key: " + hexdump(self.key) + "\n" - dump += pfx + "OPc: " + hexdump(self.opc) + " (unused)" - return dump - - - def encode(self): - out = SYSMO_ISIMSJA2_FILE_EF_XSIM_AUTH_KEY.encode(self) - if self.full_res == True: - out[0] |= 1 << 6 - if self.ext_res == True: - out[0] |= 1 << 7 - out += self.key - - # Note: Normally an OPc is only used with milenage, but lets - # write the value anyway, even if it is not used. - out += self.opc - return out - - -# EF_USIM_AUTH_KEY_2G and EF_USIM_AUTH_KEY_GBA have the same layout as -# EF_USIM_AUTH_KEY, so there is nothing to specialize other than the class name -class SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY): +#XOR has the same key length COMP128 (16 byte, no extra data) +class SYSMO_ISIMSJAX_ALGO_KEY_XOR(SYSMO_ISIMSJAX_ALGO_KEY_COMP128): pass -class SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_GBA(SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY): +#SHA1AKA has the same key length COMP128 (16 byte, no extra data) +class SYSMO_ISIMSJAX_ALGO_KEY_SHA1AKA(SYSMO_ISIMSJAX_ALGO_KEY_COMP128): + pass + + +#Milenage adds a 16 byte OP/c +class SYSMO_ISIMSJAX_ALGO_KEY_MILENAGE(SYSMO_ISIMSJAX_ALGO_KEY_COMP128): + + opc = [0x00] * 16 + + def __init__(self, content = None): + if content == None: + return + super().__init__(content) + self.opc = content[17:33] + + def __str__(self) -> str: + dump = "" + pfx = " " + dump += super().__str__() + dump += "\n" + dump += pfx + "OPc: " + hexdump(self.opc) + return dump + + def encode(self) -> list: + return super().encode() + self.opc + + +class SYSMO_ISIMSJAX_ALGO_KEY_TUAK: + + res_size = 0 #3 bit value + mac_size = 0 #3 bit value + ckik_size = 0 #1 bit value + num_keccak = 0 #1 byte value + topc = [0x00] * 32 + key = [0x00] * 32 + + def __init__(self, content = None): + if content == None: + return + self.res_size = int(content[1] & 7) + self.mac_size = int((content[1] >> 3) & 7) + self.ckik_size = bool((content[1] >> 6) & 1) + self.num_keccak = content[2] + self.topc = content[3:35] + self.key = content[35:67] + + def __str__(self) -> str: + dump = "" + pfx = " " + dump += pfx + "RES size: %s bit" % id_to_str(sysmo_isimsja5_res_sizes, self.res_size) + "\n" + dump += pfx + "MAC-A/MAC-S size: %s bit" % id_to_str(sysmo_isimsja5_mac_sizes, self.mac_size) + "\n" + dump += pfx + "Keccak iterations: %d" % self.num_keccak + "\n" + dump += pfx + "TOPc: " + hexdump(self.topc) + "\n" + #TODO: Keys may be 128 or 256 bits long. The key length is defined + #in the header of the file, which means we cannot access this bit + #from here but it would be nice to display the key in its correct + #length though. + dump += pfx + "Key: " + hexdump(self.key) + return dump + + def encode(self) -> list: + param_byte = self.res_size & 7 + param_byte |= (self.res_size & 7) << 3 + param_byte |= (self.ckik_size & 1) << 6 + out = [param_byte] + out += [self.num_keccak] + out += self.topc + out += self.key + return out + + +class SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(SYSMO_ISIMSJAX_FILE_EF_XSIM_AUTH_KEY): + + algo_key = None + + def __init__(self, content = None): + # The superclass constructor must ensure that a valid algo and + # algo parameters are set since we need this information to pick + # the key configuration below. + super().__init__(content) + if self.algo == SYSMO_ISIMSJA2_ALGO_COMP12V1 or \ + self.algo == SYSMO_ISIMSJA2_ALGO_COMP12V2 or \ + self.algo == SYSMO_ISIMSJA2_ALGO_COMP12V3: + self.algo_key = SYSMO_ISIMSJAX_ALGO_KEY_COMP128(content) + elif self.algo == SYSMO_ISIMSJA2_ALGO_MILENAGE: + self.algo_key = SYSMO_ISIMSJAX_ALGO_KEY_MILENAGE(content) + elif self.algo == SYSMO_ISIMSJA2_ALGO_SHA1AKA: + self.algo_key = SYSMO_ISIMSJAX_ALGO_KEY_SHA1AKA(content) + elif self.algo == SYSMO_ISIMSJA2_ALGO_XOR or \ + self.algo == SYSMO_ISIMSJA5_ALGO_XOR_2G: + self.algo_key = SYSMO_ISIMSJAX_ALGO_KEY_XOR(content) + elif self.algo == SYSMO_ISIMSJA5_ALGO_TUAK: + self.algo_key = SYSMO_ISIMSJAX_ALGO_KEY_TUAK(content) + + def __str__(self) -> str: + dump = "" + dump += super().__str__() + dump += str(self.algo_key) + return dump + + def encode(self) -> list: + out = super().encode() + if self.algo_key: + out += self.algo_key.encode() + else: + raise ValueError("key data encoding not supported for selected algorithm!") + return out + + +# EF_USIM_AUTH_KEY_2G, EF_SIM_AUTH_KEY and EF_USIM_AUTH_KEY_GBA have the same layout as +# EF_USIM_AUTH_KEY, so there is nothing to specialize other than the class name +class SYSMO_ISIMSJA2_FILE_EF_SIM_AUTH_KEY(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY): + pass + + +class SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY_2G(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY): + pass + + +class SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY_GBA(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY): pass @@ -278,7 +477,6 @@ class SYSMO_ISIMSJA2_FILE_EF_MILENAGE_CFG: C5 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08] - def __init__(self, content = None): if content == None: return @@ -295,8 +493,7 @@ class SYSMO_ISIMSJA2_FILE_EF_MILENAGE_CFG: self.C4 = content[53:69] self.C5 = content[69:85] - - def __str__(self): + def __str__(self) -> str: dump = " R1: " + str(hex(self.R1)) + "\n" dump += " R2: " + str(hex(self.R2)) + "\n" dump += " R3: " + str(hex(self.R3)) + "\n" @@ -309,14 +506,13 @@ class SYSMO_ISIMSJA2_FILE_EF_MILENAGE_CFG: dump += " C5: " + hexdump(self.C5) return dump - - def encode(self): + def encode(self) -> list: out = [self.R1, self.R2, self.R3, self.R4, self.R5] out += self.C1 + self.C2 + self.C3 + self.C4 + self.C5 return out -class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN: +class SYSMO_ISIMSJAX_FILE_EF_USIM_SQN: # Flag1: ind_size_bits = 5 # speficy file length by 2^ind_len @@ -376,11 +572,9 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN: self.age_limit = list_to_int(content[8:14]) self.freshness_data = content[15:(6*2**self.ind_size_bits)] - - def __str__(self): + def __str__(self) -> str: pfx = " " dump = "" - dump += "%sIND (bits): %u\n" % (pfx, self.ind_size_bits) if self.sqn_check_enabled: dump += "%sSQN Check enabled\n" % pfx @@ -413,11 +607,9 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN: dump += "%sMax Delta: %u\n" % (pfx, self.max_delta) dump += "%sAge Limit: %u\n" % (pfx, self.age_limit) dump += pfx + "Freshness Data:\n" + hexdump(self.freshness_data, True) - return dump - - def encode(self): + def encode(self) -> list: out = [0x00, 0x00] # Flag1: @@ -445,12 +637,10 @@ class SYSMO_ISIMSJA2_FILE_EF_USIM_SQN: out += self.freshness_data return out - def reset(self): self.freshness_data = [0x00] * (6*2**self.ind_size_bits) - class Sysmo_isim_sja2(Sysmo_usim): algorithms = sysmo_isimsja2_algorithms @@ -469,7 +659,6 @@ class Sysmo_isim_sja2(Sysmo_usim): if card_detected == True: return - # Try card model #2 try: 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 +683,10 @@ class Sysmo_isim_sja2(Sysmo_usim): if card_detected == True: return - # Exit when we are not able to detect the card if card_detected != True: sys.exit(1) - # Show current milenage parameters def show_milenage_params(self): print("Reading Milenage parameters...") @@ -515,10 +702,8 @@ class Sysmo_isim_sja2(Sysmo_usim): print(str(ef)) print("") - # Write new milenage parameters def write_milenage_params(self, params): - print("Programming Milenage parameters...") if (len(params) < 85): @@ -545,14 +730,12 @@ class Sysmo_isim_sja2(Sysmo_usim): self.sim.update_binary(ef_milenage_cfg.encode()) print("") - # Select DF_SYSTEM/EF_SIM_AUTH_KEY def __select_ef_sim_auth_key(self): self.sim.select(GSM_SIM_MF) self.sim.select(SYSMO_ISIMSJA2_DF_SYSTEM) self.sim.select(SYSMO_ISIMSJA2_EF_SIM_AUTH_KEY) - # Authentication keys exist in various different files, which are # similar, thie method simplifies the selection of those files def __select_xsim_auth_key(self, isim = False, _2G = False): @@ -588,27 +771,27 @@ class Sysmo_isim_sja2(Sysmo_usim): self.__select_xsim_auth_key(isim = False, _2G = True) res = self._read_binary(self.sim.filelen) print(" * ADF_USIM/EF_USIM_AUTH_KEY_2G:") - print(SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)) if self.sim.has_isim: # ADF_ISIM/EF_ISIM_AUTH_KEY_2G: self.__select_xsim_auth_key(isim = True, _2G = True) res = self._read_binary(self.sim.filelen) print(" * ADF_ISIM/EF_ISIM_AUTH_KEY_2G:") - print(SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)) # ADF_USIM/EF_USIM_AUTH_KEY: self.__select_xsim_auth_key(isim = False, _2G = False) res = self._read_binary(self.sim.filelen) print(" * ADF_USIM/EF_USIM_AUTH_KEY:") - print(SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu)) if self.sim.has_isim: # ADF_ISIM/EF_ISIM_AUTH_KEY: self.__select_xsim_auth_key(isim = True, _2G = False) res = self._read_binary(self.sim.filelen) print(" * ADF_ISIM/EF_ISIM_AUTH_KEY:") - print(SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu)) # ADF_USIM/EF_MILENAGE_CFG: self.sim.select(GSM_SIM_MF) @@ -633,7 +816,7 @@ class Sysmo_isim_sja2(Sysmo_usim): self.sim.select(SYSMO_ISIMSJA2_EF_USIM_SQN) res = self._read_binary(self.sim.filelen) print(" * ADF_USIM/EF_USIM_SQN:") - print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_SQN(res.apdu)) if self.sim.has_isim: # ADF_USIM/EF_ISIM_SQN: @@ -642,82 +825,128 @@ class Sysmo_isim_sja2(Sysmo_usim): self.sim.select(SYSMO_ISIMSJA2_EF_USIM_SQN) res = self._read_binary(self.sim.filelen) print(" * ADF_ISIM/EF_ISIM_SQN:") - print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_SQN(res.apdu)) + def __display_key(self, ef, gen:str): + """ + Helper method to display key + """ + if ef.algo in sysmo_isimsjax_ki_algorithms: + print(" %s: Key: %s" % (gen, hexdump(ef.algo_key.ki))) + elif ef.algo is SYSMO_ISIMSJA5_ALGO_TUAK: + if not ef.algo_pars.use_256_bit_key: + print(" %s: Key: %s" % (gen, hexdump(ef.algo_key.key[0:16]))) + else: + print(" %s: Key: %s" % (gen, hexdump(ef.algo_key.key))) + else: + print(" * %s: Key not applicable for selected algorithm." % gen) - # Show current KI value - def show_ki_params(self): - print("Reading KI value...") + def show_key_params(self): + """ + Show current Key value + """ + print("Reading Key value...") self._init() - # Note: The KI is expected to be the same in all eligible files print(" * Reading...") self.__select_xsim_auth_key(isim = False, _2G = True) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) - - print(" * Current KI setting:") - print(" KI: " + hexdump(ef.key)) - print("") - - - # Program new KI value - def write_ki_params(self, ki): - print("Writing KI value...") - self._init() - - print(" * New KI setting:") - print(" KI: " + hexdump(ki)) - - print(" * Programming...") - - self.__select_xsim_auth_key(isim = False, _2G = True) - res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) - ef.key = ki - self.sim.update_binary(ef.encode()) + ef_2g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) self.__select_xsim_auth_key(isim = False, _2G = False) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) - ef.key = ki - self.sim.update_binary(ef.encode()) + ef_3g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) if self.sim.has_isim: self.__select_xsim_auth_key(isim = True, _2G = False) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) - ef.key = ki - self.sim.update_binary(ef.encode()) + ef_4g5g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + else: + ef_4g5g = None + + print(" * Current Key setting:") + self.__display_key(ef_2g, "2g") + self.__display_key(ef_3g, "3g") + if ef_4g5g: + self.__display_key(ef_4g5g, "4g5g") print("") + def __program_key(self, key, gen:str): + """ + Helper method to program key, EF must be selected first + """ + res = self._read_binary(self.sim.filelen) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + if ef.algo in sysmo_isimsjax_ki_algorithms: + ef.algo_key.ki = key + self.sim.update_binary(ef.encode()) + print(" * %s: Key programmed." % gen) + elif ef.algo is SYSMO_ISIMSJA5_ALGO_TUAK: + ef.algo_key.key = key + ef.algo_pars.use_256_bit_key = False + if len(ki) > 16: + ef.algo_pars.use_256_bit_key = True + self.sim.update_binary(ef.encode()) + print(" * %s: Key programmed." % gen) + else: + print(" * %s: Key not applicable for selected algorithm." % gen) + + def write_key_params(self, key): + """ + Program new Key value + """ + print("Writing Key value...") + self._init() + print(" * New Key setting:") + print(" Key: " + hexdump(key)) + print(" * Programming...") + self.__select_xsim_auth_key(isim = False, _2G = True) + self.__program_key(key, "2g") + self.__select_xsim_auth_key(isim = False, _2G = False) + self.__program_key(key, "3g") + if self.sim.has_isim: + self.__select_xsim_auth_key(isim = True, _2G = False) + self.__program_key(key, "4g5g") + + print("") - # Show current athentication parameters - # (Which algorithim is used for which rat?) def show_auth_params(self): + """ + Show current authentication parameters + """ print("Reading Authentication parameters...") self._init() print(" * Reading...") self.__select_xsim_auth_key(isim = False, _2G = True) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) algo_2g = ef.algo self.__select_xsim_auth_key(isim = False, _2G = False) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) algo_3g = ef.algo + if self.sim.has_isim: + self.__select_xsim_auth_key(isim = True, _2G = False) + res = self._read_binary(self.sim.filelen) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + algo_4g5g = ef.algo + else: + algo_4g5g = algo_3g + print(" * Current algorithm setting:") - print(" 2G: %d=%s" % (algo_2g, id_to_str(self.algorithms, algo_2g))) - print(" 3G: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_3g))) + print(" 2g: %d=%s" % (algo_2g, id_to_str(self.algorithms, algo_2g))) + print(" 3g: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_3g))) + print(" 4g5g: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_4g5g))) print("") - - # 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, algo_4g5g_str = None): + """ + Write new authentication parameters + """ print("Programming Authentication parameters...") self._init() @@ -731,106 +960,143 @@ class Sysmo_isim_sja2(Sysmo_usim): else: algo_3g = str_to_id(self.algorithms, algo_3g_str) + if algo_4g5g_str: + if algo_4g5g_str.isdigit(): + algo_4g5g = int(algo_4g5g_str) + else: + algo_4g5g = str_to_id(self.algorithms, algo_4g5g_str) + else: + algo_4g5g = algo_3g + print(" * New algorithm setting:") - print(" 2G: %d=%s" % (algo_2g, id_to_str(self.algorithms, algo_2g))) - print(" 3G: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_3g))) + print(" 2g: %d=%s" % (algo_2g, id_to_str(self.algorithms, algo_2g))) + print(" 3g: %d=%s" % (algo_3g, id_to_str(self.algorithms, algo_3g))) + print(" 4g5g: %d=%s" % (algo_4g5g, id_to_str(self.algorithms, algo_4g5g))) print(" * Programming...") self.__select_xsim_auth_key(isim = False, _2G = True) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) ef.algo = algo_2g self.sim.update_binary(ef.encode()) self.__select_xsim_auth_key(isim = False, _2G = False) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) ef.algo = algo_3g self.sim.update_binary(ef.encode()) if self.sim.has_isim: self.__select_xsim_auth_key(isim = True, _2G = False) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) - ef.algo = algo_3g + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + ef.algo = algo_4g5g self.sim.update_binary(ef.encode()) print("") + def __display_opc(self, ef, gen:str): + """ + Helper method to display OP/OPc + """ + if ef.algo is SYSMO_ISIMSJA2_ALGO_MILENAGE: + print(" %s: %s: %s" % (gen, id_to_str(sysmo_isimsjax_op_opc, ef.algo_pars.use_opc), \ + hexdump(ef.algo_key.opc))) + elif ef.algo is SYSMO_ISIMSJA5_ALGO_TUAK: + print(" %s: %s: %s" % (gen, id_to_str(sysmo_isimsja5_top_topc, ef.algo_pars.use_topc), \ + hexdump(ef.algo_key.topc))) + else: + print(" * %s: OP/OPc not applicable for selected algorithm." % gen) - # Show current OPc value def show_opc_params(self): + """ + Show OP/OPc current configuration. (see also method: write_opc_params). + """ print("Reading OP/c value...") self._init() - # Note: The OPc is expected to be the same in all eligible files print(" * Reading...") - self.__select_xsim_auth_key(isim = False, _2G = False) - res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) - - if ef.use_opc: - mode_str = "OPc" - else: - mode_str = "OP" - - print(" * Current OP/OPc setting:") - print(" %s: %s" % (mode_str, hexdump(ef.opc))) - print("") - - - # Program new OPc value - def write_opc_params(self, select, op): - if select: - print("Writing OPc value...") - mode_str = "OPc" - else: - print("Writing OP value...") - mode_str = "OP" - self._init() - - print(" * New OPc setting:") - print(" %s: %s" % (mode_str, hexdump(op))) - - print(" * Programming...") - self.__select_xsim_auth_key(isim = False, _2G = True) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) - ef.opc = op - ef.use_opc = bool(select) - self.sim.update_binary(ef.encode()) + ef_2g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + + self.__select_xsim_auth_key(isim = False, _2G = False) + res = self._read_binary(self.sim.filelen) + ef_3g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) if self.sim.has_isim: self.__select_xsim_auth_key(isim = True, _2G = False) res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) - ef.opc = op - ef.use_opc = bool(select) - self.sim.update_binary(ef.encode()) + ef_4g5g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + else: + ef_4g5g = None - self.__select_xsim_auth_key(isim = False, _2G = False) - res = self._read_binary(self.sim.filelen) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) - ef.opc = op - ef.use_opc = bool(select) - self.sim.update_binary(ef.encode()) + print(" * Current OP/OPc setting:") + self.__display_opc(ef_2g, "2g") + self.__display_opc(ef_3g, "3g") + if ef_4g5g: + self.__display_opc(ef_3g, "4g5g") print("") + def __program_opc(self, select:bool, op, gen:str): + """ + Helper method to program OP/OPc, EF must be selected first + """ + res = self._read_binary(self.sim.filelen) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + if ef.algo is SYSMO_ISIMSJA2_ALGO_MILENAGE: + ef.algo_key.opc = op + ef.algo_pars.use_opc = bool(select) + self.sim.update_binary(ef.encode()) + print(" %s %s programmed." % (gen, id_to_str(sysmo_isimsjax_op_opc, bool(select)))); + elif ef.algo is SYSMO_ISIMSJA5_ALGO_TUAK: + ef.algo_key.topc = op + ef.algo_pars.use_topc = bool(select) + self.sim.update_binary(ef.encode()) + print(" %s %s programmed." % (gen, id_to_str(sysmo_isimsja5_top_topc, bool(select)))); + else: + print(" %s OP/OPc not applicable for selected algorithm, skipping..." % gen) + + def write_opc_params(self, select:bool, op): + """ + Program new OP/OPc value. The new OP/OPc value is programmed into all files where the algorithm is + configured to Milenage. When Milenage is not configured, then the respective file is not touched. + As a simplification we program the same OP/OPc configuration to all files (2G, 3G, 4G/5G). Even though + the cards would permit a different setting in each file, it is extremly unlikely that any HLR/HSS would + use such a configuration. + """ + print("Writing %s value..." % id_to_str(sysmo_isimsjax_op_opc, bool(select))) + self._init() + + print(" * New OPc setting:") + print(" %s: %s" % (id_to_str(sysmo_isimsjax_op_opc, bool(select)), hexdump(op))) + + print(" * Programming...") + self.__select_xsim_auth_key(isim = False, _2G = True) + self.__program_opc(select, op, "2g") + self.__select_xsim_auth_key(isim = False, _2G = False) + self.__program_opc(select, op, "3g") + if self.sim.has_isim: + self.__select_xsim_auth_key(isim = True, _2G = False) + self.__program_opc(select, op, "4g5g") + + print("") # Show current milenage SQN parameters def show_milenage_sqn_params(self): print("Reading Milenage Sequence parameters...") self._init() + #FIXME: What about EF_USIM_SQN in DF.SYSTEM? + print(" * Current SQN Configuration for ADF_USIM:") self.sim.select(GSM_SIM_MF) self.sim.card.SELECT_ADF_USIM() self.sim.select(SYSMO_ISIMSJA2_EF_USIM_SQN) res = self._read_binary(self.sim.filelen) - print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_SQN(res.apdu)) if self.sim.has_isim: print(" * Current SQN Configuration for ADF_ISIM:") @@ -838,11 +1104,10 @@ class Sysmo_isim_sja2(Sysmo_usim): self.sim.card.SELECT_ADF_ISIM() self.sim.select(SYSMO_ISIMSJA2_EF_USIM_SQN) res = self._read_binary(self.sim.filelen) - print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu)) + print(SYSMO_ISIMSJAX_FILE_EF_USIM_SQN(res.apdu)) print("") - # Reset milenage SQN configuration def reset_milenage_sqn_params(self): print(" * Resetting SQN Configuration to defaults...") @@ -853,17 +1118,119 @@ class Sysmo_isim_sja2(Sysmo_usim): self.sim.card.SELECT_ADF_USIM() self.sim.select(SYSMO_ISIMSJA2_EF_USIM_SQN) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_SQN() + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_SQN() self.sim.update_binary(ef.encode()) if self.sim.has_isim: self.sim.card.SELECT_ADF_ISIM() self.sim.select(SYSMO_ISIMSJA2_EF_USIM_SQN) - ef = SYSMO_ISIMSJA2_FILE_EF_USIM_SQN() + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_SQN() self.sim.update_binary(ef.encode()) print("") + def __display_tuak_cfg(self, ef, gen:str): + """ + Helper method to display key + """ + if ef.algo is SYSMO_ISIMSJA5_ALGO_TUAK: + print(" %s: TUAK configuration:" % gen) + print(" RES size: %s bit" % id_to_str(sysmo_isimsja5_res_sizes, ef.algo_key.res_size)) + print(" MAC-A/MAC-S size: %s bit" % id_to_str(sysmo_isimsja5_mac_sizes, ef.algo_key.mac_size)) + print(" CK/IK size: %s bit" % id_to_str(sysmo_isimsja5_ckik_sizes, ef.algo_key.ckik_size)) + print(" Keccak iterations: %d" % ef.algo_key.num_keccak) + else: + print(" * %s: TUAK configuration not applicable for selected algorithm." % gen) + + def show_tuak_cfg(self): + print("Reading TUAK configuration...") + self._init() + + print(" * Reading...") + self.__select_xsim_auth_key(isim = False, _2G = True) + res = self._read_binary(self.sim.filelen) + ef_2g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + + self.__select_xsim_auth_key(isim = False, _2G = False) + res = self._read_binary(self.sim.filelen) + ef_3g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + + if self.sim.has_isim: + self.__select_xsim_auth_key(isim = True, _2G = False) + res = self._read_binary(self.sim.filelen) + ef_4g5g = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY(res.apdu) + else: + ef_4g5g = None + + print(" * Current TUAK configuration:") + self.__display_tuak_cfg(ef_2g, "2g") + self.__display_tuak_cfg(ef_3g, "3g") + if ef_4g5g: + self.__display_tuak_cfg(ef_4g5g, "4g5g") + print("") + + def __program_tuak_cfg(self, res_size:int, mac_size:int, ckik_size:int, num_keccak:int, gen:str): + """ + Helper method to program key, EF must be selected first + """ + res = self._read_binary(self.sim.filelen) + ef = SYSMO_ISIMSJAX_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) + if ef.algo is SYSMO_ISIMSJA5_ALGO_TUAK: + ef.algo_key.res_size = res_size + ef.algo_key.mac_size = mac_size + ef.algo_key.ckik_size = bool(ckik_size) + ef.algo_key.num_keccak = num_keccak + self.sim.update_binary(ef.encode()) + print(" %s TUAK configuration programmed." % gen); + else: + print(" %s TUAK configuration not applicable for selected algorithm, skipping..." % gen) + + def write_tuak_cfg(self, res_size_str:str, mac_size_str:str, ckik_size_str:str, num_keccak_str:str): + + print("Writing TUAK configuration...") + self._init() + + print(" * New TUAK configuration:") + + res_size = str_to_id(sysmo_isimsja5_res_sizes, res_size_str, -1) + if res_size < 0: + print(" * Invalid TUAK configuration, RES-Size must be 32, 64, 128 or 256 bit!") + print("") + return + + mac_size = str_to_id(sysmo_isimsja5_mac_sizes, mac_size_str, -1) + if mac_size < 0: + print(" * Invalid TUAK configuration, MAC-Size must be 64, 128 or 256 bit!") + print("") + return + + ckik_size = str_to_id(sysmo_isimsja5_ckik_sizes, ckik_size_str, -1) + if ckik_size < 0: + print(" * Invalid TUAK configuration, MAC-Size must be 128 or 256 bit!") + print("") + return + + num_keccak = int(num_keccak_str) + if num_keccak > 255: + print(" * Invalid TUAK configuration, number of Keccak iterations must not exceed 256!") + print("") + return + + print(" RES size: %s bit" % id_to_str(sysmo_isimsja5_res_sizes, res_size)) + print(" MAC-A/MAC-S size: %s bit" % id_to_str(sysmo_isimsja5_mac_sizes, mac_size)) + print(" CK/IK size: %s bit" % id_to_str(sysmo_isimsja5_ckik_sizes, ckik_size)) + print(" Keccak iterations: %d" % num_keccak) + + print(" * Programming...") + self.__select_xsim_auth_key(isim = False, _2G = True) + self.__program_tuak_cfg(res_size, mac_size, ckik_size, num_keccak, "2g") + self.__select_xsim_auth_key(isim = False, _2G = False) + self.__program_tuak_cfg(res_size, mac_size, ckik_size, num_keccak, "3g") + if self.sim.has_isim: + self.__select_xsim_auth_key(isim = True, _2G = False) + self.__program_tuak_cfg(res_size, mac_size, ckik_size, num_keccak, "4g5g") + + print("") class Sysmo_isim_sja5(Sysmo_isim_sja2): algorithms = sysmo_isimsja5_algorithms diff --git a/sysmo_usim_sjs1.py b/sysmo_usim_sjs1.py index 01777e0..6b59696 100644 --- a/sysmo_usim_sjs1.py +++ b/sysmo_usim_sjs1.py @@ -471,7 +471,7 @@ class Sysmo_usim_sjs1(Sysmo_usim): # Show current KI value - def show_ki_params(self): + def show_key_params(self): print("Reading KI value...") print(" * Reading...") self.sim.select(GSM_SIM_DF_GSM) @@ -484,7 +484,7 @@ class Sysmo_usim_sjs1(Sysmo_usim): # Program new KI value - def write_ki_params(self, ki): + def write_key_params(self, ki): print("Writing KI value...") self._init() diff --git a/tests/run-tests b/tests/run-tests index bf81b83..f5d5353 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -32,3 +32,20 @@ echo "" echo "" echo "" echo "" + +echo "==========================================================" +echo " EXECUTING TESTS FOR SYSMO-USIM-SJA5" +echo "==========================================================" +echo "" +cd ./sja5 +echo "Location $PWD" +echo "" +sh ./run-tests +if [ ! $? -eq 0 ]; then + exit 1 +fi +cd .. +echo "" +echo "" +echo "" +echo "" diff --git a/tests/sja2/02_algo.out b/tests/sja2/02_algo.out index 9429c3d..4cd3dbe 100644 --- a/tests/sja2/02_algo.out +++ b/tests/sja2/02_algo.out @@ -16,8 +16,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 1=COMP128v1 - 3G: 1=COMP128v1 + 2g: 1=COMP128v1 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 * Programming... Done! @@ -40,8 +41,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 1=COMP128v1 - 3G: 1=COMP128v1 + 2g: 1=COMP128v1 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 Done! sysmoISIM-SJA2 parameterization tool @@ -62,8 +64,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 3=COMP128v3 - 3G: 1=COMP128v1 + 2g: 3=COMP128v3 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 * Programming... Done! @@ -86,8 +89,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 3=COMP128v3 - 3G: 1=COMP128v1 + 2g: 3=COMP128v3 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 Done! sysmoISIM-SJA2 parameterization tool @@ -108,8 +112,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 4=MILENAGE - 3G: 1=COMP128v1 + 2g: 4=MILENAGE + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 * Programming... Done! @@ -132,8 +137,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 4=MILENAGE - 3G: 1=COMP128v1 + 2g: 4=MILENAGE + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 Done! sysmoISIM-SJA2 parameterization tool @@ -154,8 +160,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 5=SHA1-AKA - 3G: 1=COMP128v1 + 2g: 5=SHA1-AKA + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 * Programming... Done! @@ -178,8 +185,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 5=SHA1-AKA - 3G: 1=COMP128v1 + 2g: 5=SHA1-AKA + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 Done! sysmoISIM-SJA2 parameterization tool @@ -200,8 +208,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 15=XOR - 3G: 1=COMP128v1 + 2g: 15=XOR + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 * Programming... Done! @@ -224,8 +233,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 15=XOR - 3G: 1=COMP128v1 + 2g: 15=XOR + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 Done! sysmoISIM-SJA2 parameterization tool @@ -246,8 +256,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 1=COMP128v1 - 3G: 4=MILENAGE + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE * Programming... Done! @@ -270,8 +281,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 1=COMP128v1 - 3G: 4=MILENAGE + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE Done! sysmoISIM-SJA2 parameterization tool @@ -292,8 +304,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 3=COMP128v3 - 3G: 15=XOR + 2g: 3=COMP128v3 + 3g: 15=XOR + 4g5g: 15=XOR * Programming... Done! @@ -316,8 +329,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 3=COMP128v3 - 3G: 15=XOR + 2g: 3=COMP128v3 + 3g: 15=XOR + 4g5g: 15=XOR Done! sysmoISIM-SJA2 parameterization tool @@ -338,8 +352,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 2=COMP128v2 - 3G: 2=COMP128v2 + 2g: 2=COMP128v2 + 3g: 2=COMP128v2 + 4g5g: 2=COMP128v2 * Programming... Done! @@ -362,8 +377,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 2=COMP128v2 - 3G: 2=COMP128v2 + 2g: 2=COMP128v2 + 3g: 2=COMP128v2 + 4g5g: 2=COMP128v2 Done! sysmoISIM-SJA2 parameterization tool @@ -384,8 +400,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 1=COMP128v1 - 3G: 3=COMP128v3 + 2g: 1=COMP128v1 + 3g: 3=COMP128v3 + 4g5g: 3=COMP128v3 * Programming... Done! @@ -408,8 +425,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 1=COMP128v1 - 3G: 3=COMP128v3 + 2g: 1=COMP128v1 + 3g: 3=COMP128v3 + 4g5g: 3=COMP128v3 Done! sysmoISIM-SJA2 parameterization tool @@ -430,8 +448,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 4=MILENAGE - 3G: 4=MILENAGE + 2g: 4=MILENAGE + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE * Programming... Done! @@ -454,8 +473,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 4=MILENAGE - 3G: 4=MILENAGE + 2g: 4=MILENAGE + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE Done! sysmoISIM-SJA2 parameterization tool @@ -476,8 +496,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 1=COMP128v1 - 3G: 4=MILENAGE + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE * Programming... Done! @@ -500,8 +521,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 1=COMP128v1 - 3G: 4=MILENAGE + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE Done! sysmoISIM-SJA2 parameterization tool @@ -522,8 +544,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 3=COMP128v3 - 3G: 4=MILENAGE + 2g: 3=COMP128v3 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE * Programming... Done! @@ -546,8 +569,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 3=COMP128v3 - 3G: 4=MILENAGE + 2g: 3=COMP128v3 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE Done! sysmoISIM-SJA2 parameterization tool @@ -568,8 +592,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 2=COMP128v2 - 3G: 4=MILENAGE + 2g: 2=COMP128v2 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE * Programming... Done! @@ -592,8 +617,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 2=COMP128v2 - 3G: 4=MILENAGE + 2g: 2=COMP128v2 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE Done! sysmoISIM-SJA2 parameterization tool @@ -614,8 +640,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 5=SHA1-AKA - 3G: 15=XOR + 2g: 5=SHA1-AKA + 3g: 15=XOR + 4g5g: 15=XOR * Programming... Done! @@ -638,8 +665,9 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 5=SHA1-AKA - 3G: 15=XOR + 2g: 5=SHA1-AKA + 3g: 15=XOR + 4g5g: 15=XOR Done! sysmoISIM-SJA2 parameterization tool @@ -660,8 +688,9 @@ Authenticating... Programming Authentication parameters... * Initalizing... * New algorithm setting: - 2G: 1=COMP128v1 - 3G: 4=MILENAGE + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE * Programming... Done! @@ -684,7 +713,8 @@ Reading Authentication parameters... * Initalizing... * Reading... * Current algorithm setting: - 2G: 1=COMP128v1 - 3G: 4=MILENAGE + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE Done! diff --git a/tests/sja2/04_op_opc.out b/tests/sja2/04_op_opc.out index 73c4cfe..d5eb28c 100644 --- a/tests/sja2/04_op_opc.out +++ b/tests/sja2/04_op_opc.out @@ -1,6 +1,30 @@ sysmoISIM-SJA2 parameterization tool Copyright (c) 2019-2022 sysmocom - s.f.m.c. GmbH +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 4C 75 30 34 05 4B A9 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 4=MILENAGE + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA2 parameterization tool +Copyright (c) 2019-2022 sysmocom - s.f.m.c. GmbH + Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 4C 75 30 34 05 4B A9 Initializing smartcard terminal... * Detected Card IMSI: 901700000046734 @@ -18,6 +42,9 @@ Writing OPc value... * New OPc setting: OPc: 000102030405060708090a0b0c0d0e0f * Programming... + 2g OPc programmed. + 3g OPc programmed. + 4g5g OPc programmed. Done! sysmoISIM-SJA2 parameterization tool @@ -39,7 +66,9 @@ Reading OP/c value... * Initalizing... * Reading... * Current OP/OPc setting: - OPc: 000102030405060708090a0b0c0d0e0f + 2g: OPc: 000102030405060708090a0b0c0d0e0f + 3g: OPc: 000102030405060708090a0b0c0d0e0f + 4g5g: OPc: 000102030405060708090a0b0c0d0e0f Done! sysmoISIM-SJA2 parameterization tool @@ -62,6 +91,9 @@ Writing OP value... * New OPc setting: OP: 840337c3d45397ce8ea8609ffdc47224 * Programming... + 2g OP programmed. + 3g OP programmed. + 4g5g OP programmed. Done! sysmoISIM-SJA2 parameterization tool @@ -83,6 +115,8 @@ Reading OP/c value... * Initalizing... * Reading... * Current OP/OPc setting: - OP: 840337c3d45397ce8ea8609ffdc47224 + 2g: OP: 840337c3d45397ce8ea8609ffdc47224 + 3g: OP: 840337c3d45397ce8ea8609ffdc47224 + 4g5g: OP: 840337c3d45397ce8ea8609ffdc47224 Done! diff --git a/tests/sja2/04_op_opc.sh b/tests/sja2/04_op_opc.sh index b3e9e41..b7ca8c4 100755 --- a/tests/sja2/04_op_opc.sh +++ b/tests/sja2/04_op_opc.sh @@ -1,6 +1,8 @@ #!/bin/sh . ./test-data +$TOOL -a $ADMPIN -T "MILENAGE:MILENAGE" + $TOOL -a $ADMPIN -C 000102030405060708090a0b0c0d0e0f $TOOL -a $ADMPIN -o diff --git a/tests/sja2/05_ki.out b/tests/sja2/05_ki.out index 0ac6fdd..5889c68 100644 --- a/tests/sja2/05_ki.out +++ b/tests/sja2/05_ki.out @@ -13,11 +13,14 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Writing KI value... +Writing Key value... * Initalizing... - * New KI setting: - KI: a0b1c2d3e4f5061728394a5b6c7d8e9f + * New Key setting: + Key: a0b1c2d3e4f5061728394a5b6c7d8e9f * Programming... + * 2g: Key programmed. + * 3g: Key programmed. + * 4g5g: Key programmed. Done! sysmoISIM-SJA2 parameterization tool @@ -35,11 +38,13 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Reading KI value... +Reading Key value... * Initalizing... * Reading... - * Current KI setting: - KI: a0b1c2d3e4f5061728394a5b6c7d8e9f + * Current Key setting: + 2g: Key: a0b1c2d3e4f5061728394a5b6c7d8e9f + 3g: Key: a0b1c2d3e4f5061728394a5b6c7d8e9f + 4g5g: Key: a0b1c2d3e4f5061728394a5b6c7d8e9f Done! sysmoISIM-SJA2 parameterization tool @@ -57,11 +62,14 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Writing KI value... +Writing Key value... * Initalizing... - * New KI setting: - KI: d7882eae7cd14f06108c55f8e5cffe93 + * New Key setting: + Key: d7882eae7cd14f06108c55f8e5cffe93 * Programming... + * 2g: Key programmed. + * 3g: Key programmed. + * 4g5g: Key programmed. Done! sysmoISIM-SJA2 parameterization tool @@ -79,10 +87,12 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Reading KI value... +Reading Key value... * Initalizing... * Reading... - * Current KI setting: - KI: d7882eae7cd14f06108c55f8e5cffe93 + * Current Key setting: + 2g: Key: d7882eae7cd14f06108c55f8e5cffe93 + 3g: Key: d7882eae7cd14f06108c55f8e5cffe93 + 4g5g: Key: d7882eae7cd14f06108c55f8e5cffe93 Done! diff --git a/tests/sja5/01_auth.out b/tests/sja5/01_auth.out new file mode 100644 index 0000000..afccdd5 --- /dev/null +++ b/tests/sja5/01_auth.out @@ -0,0 +1,16 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Done! diff --git a/tests/sja5/01_auth.sh b/tests/sja5/01_auth.sh new file mode 100755 index 0000000..d18b455 --- /dev/null +++ b/tests/sja5/01_auth.sh @@ -0,0 +1,4 @@ +#!/bin/sh +. ./test-data + +$TOOL -a $ADMPIN diff --git a/tests/sja5/02_algo.out b/tests/sja5/02_algo.out new file mode 100644 index 0000000..e16f006 --- /dev/null +++ b/tests/sja5/02_algo.out @@ -0,0 +1,1104 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 1=COMP128v1 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 1=COMP128v1 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 3=COMP128v3 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 3=COMP128v3 + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 4=MILENAGE + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 4=MILENAGE + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 5=SHA1-AKA + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 5=SHA1-AKA + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 15=XOR + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 15=XOR + 3g: 1=COMP128v1 + 4g5g: 1=COMP128v1 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 3=COMP128v3 + 3g: 15=XOR + 4g5g: 15=XOR + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 3=COMP128v3 + 3g: 15=XOR + 4g5g: 15=XOR + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 2=COMP128v2 + 3g: 2=COMP128v2 + 4g5g: 2=COMP128v2 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 2=COMP128v2 + 3g: 2=COMP128v2 + 4g5g: 2=COMP128v2 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 1=COMP128v1 + 3g: 3=COMP128v3 + 4g5g: 3=COMP128v3 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 1=COMP128v1 + 3g: 3=COMP128v3 + 4g5g: 3=COMP128v3 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 14=XOR-2G + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 14=XOR-2G + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 2=COMP128v2 + 3g: 6=TUAK + 4g5g: 6=TUAK + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 2=COMP128v2 + 3g: 6=TUAK + 4g5g: 6=TUAK + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 6=TUAK + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 6=TUAK + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 14=XOR-2G + 3g: 6=TUAK + 4g5g: 6=TUAK + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 14=XOR-2G + 3g: 6=TUAK + 4g5g: 6=TUAK + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 4=MILENAGE + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 4=MILENAGE + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 6=TUAK + 3g: 6=TUAK + 4g5g: 6=TUAK + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 6=TUAK + 3g: 6=TUAK + 4g5g: 6=TUAK + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 3=COMP128v3 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 3=COMP128v3 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 2=COMP128v2 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 2=COMP128v2 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 2=COMP128v2 + 3g: 6=TUAK + 4g5g: 6=TUAK + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 2=COMP128v2 + 3g: 6=TUAK + 4g5g: 6=TUAK + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 2=COMP128v2 + 3g: 14=XOR-2G + 4g5g: 14=XOR-2G + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 2=COMP128v2 + 3g: 14=XOR-2G + 4g5g: 14=XOR-2G + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 5=SHA1-AKA + 3g: 15=XOR + 4g5g: 15=XOR + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 5=SHA1-AKA + 3g: 15=XOR + 4g5g: 15=XOR + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 1=COMP128v1 + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 14=XOR-2G + 3g: 6=TUAK + 4g5g: 6=TUAK + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Authentication parameters... + * Initalizing... + * Reading... + * Current algorithm setting: + 2g: 14=XOR-2G + 3g: 6=TUAK + 4g5g: 6=TUAK + +Done! diff --git a/tests/sja5/02_algo.sh b/tests/sja5/02_algo.sh new file mode 100755 index 0000000..325ed9f --- /dev/null +++ b/tests/sja5/02_algo.sh @@ -0,0 +1,9 @@ +#!/bin/sh +. ./test-data + +ALGOS="1:1 3:1 4:1 5:1 15:1 1:4 3:15 2:2 1:3 14:4 2:6 6:4 14:6 " +ALGOS=$ALGOS"MILENAGE:MILENAGE TUAK:TUAK COMP128v1:MILENAGE COMP128v3:MILENAGE COMP128v2:MILENAGE COMP128v2:TUAK COMP128v2:XOR-2G SHA1-AKA:XOR COMP128v1:MILENAGE XOR-2G:TUAK" +for algo in $ALGOS; do + $TOOL -a $ADMPIN -T $algo + $TOOL -a $ADMPIN -t +done diff --git a/tests/sja5/03_milenage_par.out b/tests/sja5/03_milenage_par.out new file mode 100644 index 0000000..48d3de4 --- /dev/null +++ b/tests/sja5/03_milenage_par.out @@ -0,0 +1,124 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Milenage parameters... + * Initalizing... + * New Milenage Parameters for (EF.MILENAGE_CFG): + R1: 0xaa + R2: 0xbb + R3: 0xcc + R4: 0xdd + R5: 0xee + C1: 1234567890abcdef1234567890abcdef + C2: f1234567890abcdef1234567890abcde + C3: ef1234567890abcdef1234567890abcd + C4: def1234567890abcdef1234567890abc + C5: cdef1234567890abcdef1234567890ab + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Milenage parameters... + * Initalizing... + * Reading... + * Current Milenage Parameters: + R1: 0xaa + R2: 0xbb + R3: 0xcc + R4: 0xdd + R5: 0xee + C1: 1234567890abcdef1234567890abcdef + C2: f1234567890abcdef1234567890abcde + C3: ef1234567890abcdef1234567890abcd + C4: def1234567890abcdef1234567890abc + C5: cdef1234567890abcdef1234567890ab + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Milenage parameters... + * Initalizing... + * New Milenage Parameters for (EF.MILENAGE_CFG): + R1: 0x40 + R2: 0x0 + R3: 0x20 + R4: 0x40 + R5: 0x60 + C1: 00000000000000000000000000000000 + C2: 00000000000000000000000000000001 + C3: 00000000000000000000000000000002 + C4: 00000000000000000000000000000004 + C5: 00000000000000000000000000000008 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Milenage parameters... + * Initalizing... + * Reading... + * Current Milenage Parameters: + R1: 0x40 + R2: 0x0 + R3: 0x20 + R4: 0x40 + R5: 0x60 + C1: 00000000000000000000000000000000 + C2: 00000000000000000000000000000001 + C3: 00000000000000000000000000000002 + C4: 00000000000000000000000000000004 + C5: 00000000000000000000000000000008 + +Done! diff --git a/tests/sja5/03_milenage_par.sh b/tests/sja5/03_milenage_par.sh new file mode 100755 index 0000000..78c9a1a --- /dev/null +++ b/tests/sja5/03_milenage_par.sh @@ -0,0 +1,24 @@ +#!/bin/sh +. ./test-data + +# Write and reread with test data +C1="1234567890ABCDEF1234567890ABCDEF" +C2="F1234567890ABCDEF1234567890ABCDE" +C3="EF1234567890ABCDEF1234567890ABCD" +C4="DEF1234567890ABCDEF1234567890ABC" +C5="CDEF1234567890ABCDEF1234567890AB" +R12345="AA:BB:CC:DD:EE" +PARAMS=$C1$C2$C3$C4$C5$R12345 +$TOOL -a $ADMPIN -L $PARAMS +$TOOL -a $ADMPIN -l + +# Write and reread with factory defaults +C1="00000000000000000000000000000000" +C2="00000000000000000000000000000001" +C3="00000000000000000000000000000002" +C4="00000000000000000000000000000004" +C5="00000000000000000000000000000008" +R12345="40:00:20:40:60" +PARAMS=$C1$C2$C3$C4$C5$R12345 +$TOOL -a $ADMPIN -L $PARAMS +$TOOL -a $ADMPIN -l diff --git a/tests/sja5/04_op_opc.out b/tests/sja5/04_op_opc.out new file mode 100644 index 0000000..1c41868 --- /dev/null +++ b/tests/sja5/04_op_opc.out @@ -0,0 +1,122 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Programming Authentication parameters... + * Initalizing... + * New algorithm setting: + 2g: 4=MILENAGE + 3g: 4=MILENAGE + 4g5g: 4=MILENAGE + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing OPc value... + * Initalizing... + * New OPc setting: + OPc: 000102030405060708090a0b0c0d0e0f + * Programming... + 2g OPc programmed. + 3g OPc programmed. + 4g5g OPc programmed. + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading OP/c value... + * Initalizing... + * Reading... + * Current OP/OPc setting: + 2g: OPc: 000102030405060708090a0b0c0d0e0f + 3g: OPc: 000102030405060708090a0b0c0d0e0f + 4g5g: OPc: 000102030405060708090a0b0c0d0e0f + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing OP value... + * Initalizing... + * New OPc setting: + OP: 840337c3d45397ce8ea8609ffdc47224 + * Programming... + 2g OP programmed. + 3g OP programmed. + 4g5g OP programmed. + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading OP/c value... + * Initalizing... + * Reading... + * Current OP/OPc setting: + 2g: OP: 840337c3d45397ce8ea8609ffdc47224 + 3g: OP: 840337c3d45397ce8ea8609ffdc47224 + 4g5g: OP: 840337c3d45397ce8ea8609ffdc47224 + +Done! diff --git a/tests/sja5/04_op_opc.sh b/tests/sja5/04_op_opc.sh new file mode 100755 index 0000000..b7ca8c4 --- /dev/null +++ b/tests/sja5/04_op_opc.sh @@ -0,0 +1,11 @@ +#!/bin/sh +. ./test-data + +$TOOL -a $ADMPIN -T "MILENAGE:MILENAGE" + +$TOOL -a $ADMPIN -C 000102030405060708090a0b0c0d0e0f +$TOOL -a $ADMPIN -o + +$TOOL -a $ADMPIN -O 840337c3d45397ce8ea8609ffdc47224 +$TOOL -a $ADMPIN -o + diff --git a/tests/sja5/05_ki.out b/tests/sja5/05_ki.out new file mode 100644 index 0000000..bbc2404 --- /dev/null +++ b/tests/sja5/05_ki.out @@ -0,0 +1,98 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing Key value... + * Initalizing... + * New Key setting: + Key: a0b1c2d3e4f5061728394a5b6c7d8e9f + * Programming... + * 2g: Key programmed. + * 3g: Key programmed. + * 4g5g: Key programmed. + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Key value... + * Initalizing... + * Reading... + * Current Key setting: + 2g: Key: a0b1c2d3e4f5061728394a5b6c7d8e9f + 3g: Key: a0b1c2d3e4f5061728394a5b6c7d8e9f + 4g5g: Key: a0b1c2d3e4f5061728394a5b6c7d8e9f + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing Key value... + * Initalizing... + * New Key setting: + Key: d7882eae7cd14f06108c55f8e5cffe93 + * Programming... + * 2g: Key programmed. + * 3g: Key programmed. + * 4g5g: Key programmed. + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Key value... + * Initalizing... + * Reading... + * Current Key setting: + 2g: Key: d7882eae7cd14f06108c55f8e5cffe93 + 3g: Key: d7882eae7cd14f06108c55f8e5cffe93 + 4g5g: Key: d7882eae7cd14f06108c55f8e5cffe93 + +Done! diff --git a/tests/sja5/05_ki.sh b/tests/sja5/05_ki.sh new file mode 100755 index 0000000..93ee6a6 --- /dev/null +++ b/tests/sja5/05_ki.sh @@ -0,0 +1,11 @@ +#!/bin/sh +. ./test-data + +# set to arbitrary value + read back +$TOOL -a $ADMPIN -K a0b1c2d3e4f5061728394a5b6c7d8e9f +$TOOL -a $ADMPIN -k + +# set to original value + read back +$TOOL -a $ADMPIN -K $KI +$TOOL -a $ADMPIN -k + diff --git a/tests/sja5/06_seq.out b/tests/sja5/06_seq.out new file mode 100644 index 0000000..64f889e --- /dev/null +++ b/tests/sja5/06_seq.out @@ -0,0 +1,75 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading Milenage Sequence parameters... + * Initalizing... + * Current SQN Configuration for ADF_USIM: + IND (bits): 5 + SQN Check enabled + SQN Age Limit disabled + SQN Max Delta enabled + SQN Skip first enabled + SQN Conceal AUTN enabled + SQN Conceal AUTS enabled + SQN No AMF clear disabled + Max Delta: 8589934592 + Age Limit: 8589934592 + Freshness Data: + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000 + * Current SQN Configuration for ADF_ISIM: + IND (bits): 5 + SQN Check enabled + SQN Age Limit disabled + SQN Max Delta enabled + SQN Skip first enabled + SQN Conceal AUTN enabled + SQN Conceal AUTS enabled + SQN No AMF clear disabled + Max Delta: 8589934592 + Age Limit: 8589934592 + Freshness Data: + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + + * Resetting SQN Configuration to defaults... + * Initalizing... + * Resetting... + +Done! diff --git a/tests/sja5/06_seq.sh b/tests/sja5/06_seq.sh new file mode 100755 index 0000000..3dc715a --- /dev/null +++ b/tests/sja5/06_seq.sh @@ -0,0 +1,8 @@ +#!/bin/sh +. ./test-data + +# we can only read them for now, which will of course change once we perform auth against it +$TOOL -a $ADMPIN -s + +# test if resetting SQN parameters works +$TOOL -a $ADMPIN -S diff --git a/tests/sja5/07_mnclen.out b/tests/sja5/07_mnclen.out new file mode 100644 index 0000000..5499fbf --- /dev/null +++ b/tests/sja5/07_mnclen.out @@ -0,0 +1,132 @@ +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing MNCLEN value... + * Initalizing... + * New MNCLEN setting: + MNCLEN: 0x02 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading MNCLEN value... + * Initalizing... + * Reading... + * Current MNCLEN setting: + MNCLEN: 0x02 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing MNCLEN value... + * Initalizing... + * New MNCLEN setting: + MNCLEN: 0x03 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading MNCLEN value... + * Initalizing... + * Reading... + * Current MNCLEN setting: + MNCLEN: 0x03 + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Writing MNCLEN value... + * Initalizing... + * New MNCLEN setting: + MNCLEN: 0x02 + * Programming... + +Done! +sysmoISIM-SJA5 parameterization tool +Copyright (c) 2023 sysmocom - s.f.m.c. GmbH + +Trying to find card with ATR: 3B 9F 96 80 1F 87 80 31 E0 73 FE 21 1B 67 4A 35 75 30 35 02 59 C4 +Initializing smartcard terminal... + * Detected Card IMSI: 901700000046734 + ISIM Application installed + USIM Application installed + +Authenticating... + * Remaining attempts: 3 + * Authenticating... + * Authentication successful + * Remaining attempts: 3 + +Reading MNCLEN value... + * Initalizing... + * Reading... + * Current MNCLEN setting: + MNCLEN: 0x02 + +Done! diff --git a/tests/sja5/07_mnclen.sh b/tests/sja5/07_mnclen.sh new file mode 100755 index 0000000..19580d7 --- /dev/null +++ b/tests/sja5/07_mnclen.sh @@ -0,0 +1,15 @@ +#!/bin/sh +. ./test-data + +# set to 2 (default) + read back +$TOOL -a $ADMPIN -N 02 +$TOOL -a $ADMPIN -n + +# set to 3 + read back +$TOOL -a $ADMPIN -N 03 +$TOOL -a $ADMPIN -n + +# set to 2 (default) + read back +$TOOL -a $ADMPIN -N 02 +$TOOL -a $ADMPIN -n + diff --git a/tests/sja5/prepare b/tests/sja5/prepare new file mode 100755 index 0000000..9726f20 --- /dev/null +++ b/tests/sja5/prepare @@ -0,0 +1,9 @@ +#!/bin/sh + +. ./test-data + +echo "================ PREPARING TEST CARD ================" +$TOOL -a $ADMPIN -J $IMSI +$TOOL -a $ADMPIN -S +echo "================ TEST CARD PREPARED =================" +echo "" diff --git a/tests/sja5/regen b/tests/sja5/regen new file mode 100755 index 0000000..4cc2c8e --- /dev/null +++ b/tests/sja5/regen @@ -0,0 +1,14 @@ +#!/bin/sh + +echo "Regenerating test output..." +./prepare +./01_auth.sh > ./01_auth.out +./02_algo.sh > ./02_algo.out +./03_milenage_par.sh > ./03_milenage_par.out +./04_op_opc.sh > ./04_op_opc.out +./05_ki.sh > ./05_ki.out +./06_seq.sh > ./06_seq.out +./07_mnclen.sh > ./07_mnclen.out + +echo "Reference output regenerated!" +echo "" diff --git a/tests/sja5/run-tests b/tests/sja5/run-tests new file mode 100755 index 0000000..1eb6261 --- /dev/null +++ b/tests/sja5/run-tests @@ -0,0 +1,39 @@ +#!/bin/sh + +# default: execute all tests +TESTS="01_auth.sh 02_algo.sh 03_milenage_par.sh 04_op_opc.sh 05_ki.sh 06_seq.sh 07_mnclen.sh" + +# if command line specifies some specific tests, execute only those +if [ $# -ge 1 ]; then + TESTS=$* +fi + +TMP=`tempfile` +NUM_FAIL=0 + +# prepare test card +./prepare + +for T in $TESTS; do + echo "==> Executing Testcase $T" + EXPOUT=${T%%.sh}.out + rm $TMP + ./$T > $TMP + diff -u $EXPOUT $TMP + if [ $? -eq 0 ]; then + echo "Test $T passed" + else + echo "Test $T FAILED!" + NUM_FAIL=$((NUM_FAIL+1)) + fi +done + +echo +echo +echo "Summary: $NUM_FAIL Tests failed" + +if [ $NUM_FAIL -gt 0 ]; then + exit 1 +else + exit 0 +fi diff --git a/tests/sja5/test-data b/tests/sja5/test-data new file mode 100644 index 0000000..9121d00 --- /dev/null +++ b/tests/sja5/test-data @@ -0,0 +1,5 @@ +TOOL=../../sysmo-isim-tool.sja5.py +# data for the test scripts. The values have to match the SIM card inserted while executing the test +IMSI=901700000046734 +ADMPIN=11111111 # <==== CHANGE THIS TO THE ADM1 KEY OF YOUR TEST CARD! +KI=D7882EAE7CD14F06108C55F8E5CFFE93 diff --git a/utils.py b/utils.py index 1185a0f..99a6dc5 100644 --- a/utils.py +++ b/utils.py @@ -100,10 +100,13 @@ def id_to_str(table, nr): # Convert a string back to its ID by looking it up in a given table -def str_to_id(table, string): +def str_to_id(table, string, safe_default = None): dict_by_name = dict([(name.upper(), nr) for nr, name in table]) id = dict_by_name.get(string.upper()) if id is None: - raise ValueError('identifier (\"%s\") not in table %s' % (string, str(table))) + if safe_default != None: + return safe_default + else: + raise ValueError('identifier (\"%s\") not in table %s' % (string, str(table))) return id