cosmetic: rename Ki to Key

sysmo-isim-sja2 and sysmo-isim-sjs1 support multiple different
authentication algorithms. The commandline options and the log output
always speaks of "Ki", this is only correct when COMP128 is used. So
lets be more generic and call it "Key" rather then "Ki".

Related: OS#6473
This commit is contained in:
Philipp Maier 2023-06-22 15:43:38 +02:00
parent 7209731730
commit 4e196ceaf4
11 changed files with 50 additions and 48 deletions

View File

@ -28,8 +28,8 @@ import sys, getopt
COMMON_GETOPTS = "hfa:J:nN:lL:kK:tT:oO:C:sSip" COMMON_GETOPTS = "hfa:J:nN:lL:kK:tT:oO:C:sSip"
COMMON_GETOPTS_LONG = ["help", "force", "adm1=", "set-imsi=", "mnclen", COMMON_GETOPTS_LONG = ["help", "force", "adm1=", "set-imsi=", "mnclen",
"set-mnclen=", "milenage", "set-milenage=", "ki", "set-mnclen=", "milenage", "set-milenage=", "key",
"set-ki=", "auth", "set-auth=", "opc", "set-op=", "set-key=", "auth", "set-auth=", "opc", "set-op=",
"set-opc=", "seq-parameters", "reset-seq-parameters" "set-opc=", "seq-parameters", "reset-seq-parameters"
"iccid", "aid"] "iccid", "aid"]
@ -46,8 +46,8 @@ class Common():
show_mnclen = None show_mnclen = None
show_milenage = False show_milenage = False
write_milenage = None write_milenage = None
show_ki = None show_key = None
write_ki = None write_key = None
show_auth = False show_auth = False
write_auth = None write_auth = None
show_opc = False show_opc = False
@ -91,10 +91,10 @@ class Common():
self.show_milenage = True self.show_milenage = True
elif opt in ("-L", "--set-milenage"): elif opt in ("-L", "--set-milenage"):
self.write_milenage = asciihex_to_list(arg) self.write_milenage = asciihex_to_list(arg)
elif opt in ("-k", "--ki"): elif opt in ("-k", "--key"):
self.show_ki = True self.show_key = True
elif opt in ("-K", "--set-ki"): elif opt in ("-K", "--set-key"):
self.write_ki = asciihex_to_list(arg) self.write_key = asciihex_to_list(arg)
elif opt in ("-t", "--auth"): elif opt in ("-t", "--auth"):
self.show_auth = True self.show_auth = True
elif opt in ("-T", "--set-auth"): elif opt in ("-T", "--set-auth"):
@ -141,8 +141,8 @@ class Common():
print(" -N, --set-mnclen ............... Set MNC length value") print(" -N, --set-mnclen ............... Set MNC length value")
print(" -l, --milenage ................. Show milenage parameters") print(" -l, --milenage ................. Show milenage parameters")
print(" -L, --set-milenage HEXSTRING ... Set milenage parameters") print(" -L, --set-milenage HEXSTRING ... Set milenage parameters")
print(" -k, --ki ....................... Show KI value") print(" -k, --key ...................... Show auth key value")
print(" -K, --set-ki ................... Set KI value") print(" -K, --set-key .................. Set auth key value")
print(" -t, --auth ..................... Show Authentication algorithms") print(" -t, --auth ..................... Show Authentication algorithms")
print(" -T, --set-auth 2G:3G ........... Set 2G/3G Auth algo (e.g. COMP128v1:COMP128v1)") print(" -T, --set-auth 2G:3G ........... Set 2G/3G Auth algo (e.g. COMP128v1:COMP128v1)")
print(" -o, --opc ...................... Show OP/c configuration") print(" -o, --opc ...................... Show OP/c configuration")
@ -182,11 +182,11 @@ class Common():
if self.show_milenage: if self.show_milenage:
self.sim.show_milenage_params() self.sim.show_milenage_params()
if self.write_ki: if self.write_key:
self.sim.write_ki_params(self.write_ki) self.sim.write_key_params(self.write_key)
if self.show_ki: if self.show_key:
self.sim.show_ki_params() self.sim.show_key_params()
if self.show_auth: if self.show_auth:
self.sim.show_auth_params() self.sim.show_auth_params()

View File

@ -645,49 +645,51 @@ class Sysmo_isim_sja2(Sysmo_usim):
print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu)) print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu))
# Show current KI value def show_key_params(self):
def show_ki_params(self): """
print("Reading KI value...") Show current Key value
"""
print("Reading Key value...")
self._init() self._init()
# Note: The KI is expected to be the same in all eligible files # Note: The key is expected to be the same in all eligible files
print(" * Reading...") print(" * Reading...")
self.__select_xsim_auth_key(isim = False, _2G = True) self.__select_xsim_auth_key(isim = False, _2G = True)
res = self._read_binary(self.sim.filelen) res = self._read_binary(self.sim.filelen)
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)
print(" * Current KI setting:") print(" * Current Key setting:")
print(" KI: " + hexdump(ef.key)) print(" Key: " + hexdump(ef.key))
print("") print("")
# Program new KI value def write_key_params(self, key):
def write_ki_params(self, ki): """
print("Writing KI value...") Program new Key value
"""
print("Writing Key value...")
self._init() self._init()
print(" * New Key setting:")
print(" * New KI setting:") print(" Key: " + hexdump(key))
print(" KI: " + hexdump(ki))
print(" * Programming...") print(" * Programming...")
self.__select_xsim_auth_key(isim = False, _2G = True) self.__select_xsim_auth_key(isim = False, _2G = True)
res = self._read_binary(self.sim.filelen) res = self._read_binary(self.sim.filelen)
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu) ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY_2G(res.apdu)
ef.key = ki ef.key = key
self.sim.update_binary(ef.encode()) self.sim.update_binary(ef.encode())
self.__select_xsim_auth_key(isim = False, _2G = False) self.__select_xsim_auth_key(isim = False, _2G = False)
res = self._read_binary(self.sim.filelen) res = self._read_binary(self.sim.filelen)
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu)
ef.key = ki ef.key = key
self.sim.update_binary(ef.encode()) self.sim.update_binary(ef.encode())
if self.sim.has_isim: if self.sim.has_isim:
self.__select_xsim_auth_key(isim = True, _2G = False) self.__select_xsim_auth_key(isim = True, _2G = False)
res = self._read_binary(self.sim.filelen) res = self._read_binary(self.sim.filelen)
ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu) ef = SYSMO_ISIMSJA2_FILE_EF_USIM_AUTH_KEY(res.apdu)
ef.key = ki ef.key = key
self.sim.update_binary(ef.encode()) self.sim.update_binary(ef.encode())
print("") print("")

View File

@ -471,7 +471,7 @@ class Sysmo_usim_sjs1(Sysmo_usim):
# Show current KI value # Show current KI value
def show_ki_params(self): def show_key_params(self):
print("Reading KI value...") print("Reading KI value...")
print(" * Reading...") print(" * Reading...")
self.sim.select(GSM_SIM_DF_GSM) self.sim.select(GSM_SIM_DF_GSM)
@ -484,7 +484,7 @@ class Sysmo_usim_sjs1(Sysmo_usim):
# Program new KI value # Program new KI value
def write_ki_params(self, ki): def write_key_params(self, ki):
print("Writing KI value...") print("Writing KI value...")
self._init() self._init()

View File

@ -13,10 +13,10 @@ Authenticating...
* Authentication successful * Authentication successful
* Remaining attempts: 3 * Remaining attempts: 3
Writing KI value... Writing Key value...
* Initalizing... * Initalizing...
* New KI setting: * New Key setting:
KI: a0b1c2d3e4f5061728394a5b6c7d8e9f Key: a0b1c2d3e4f5061728394a5b6c7d8e9f
* Programming... * Programming...
Done! Done!
@ -35,11 +35,11 @@ Authenticating...
* Authentication successful * Authentication successful
* Remaining attempts: 3 * Remaining attempts: 3
Reading KI value... Reading Key value...
* Initalizing... * Initalizing...
* Reading... * Reading...
* Current KI setting: * Current Key setting:
KI: a0b1c2d3e4f5061728394a5b6c7d8e9f Key: a0b1c2d3e4f5061728394a5b6c7d8e9f
Done! Done!
sysmoISIM-SJA2 parameterization tool sysmoISIM-SJA2 parameterization tool
@ -57,10 +57,10 @@ Authenticating...
* Authentication successful * Authentication successful
* Remaining attempts: 3 * Remaining attempts: 3
Writing KI value... Writing Key value...
* Initalizing... * Initalizing...
* New KI setting: * New Key setting:
KI: d7882eae7cd14f06108c55f8e5cffe93 Key: d7882eae7cd14f06108c55f8e5cffe93
* Programming... * Programming...
Done! Done!
@ -79,10 +79,10 @@ Authenticating...
* Authentication successful * Authentication successful
* Remaining attempts: 3 * Remaining attempts: 3
Reading KI value... Reading Key value...
* Initalizing... * Initalizing...
* Reading... * Reading...
* Current KI setting: * Current Key setting:
KI: d7882eae7cd14f06108c55f8e5cffe93 Key: d7882eae7cd14f06108c55f8e5cffe93
Done! Done!

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# default: execute all tests # 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" TESTS="01_auth.sh 02_algo.sh 03_milenage_par.sh 04_op_opc.sh 05_key.sh 06_seq.sh 07_mnclen.sh"
# if command line specifies some specific tests, execute only those # if command line specifies some specific tests, execute only those
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then

View File

@ -1,5 +1,5 @@
TOOL=../../sysmo-isim-tool.sja2.py TOOL=../../sysmo-isim-tool.sja2.py
# data for the test scripts. The values have to match the SIM card inserted while executing the test # data for the test scripts. The values have to match the SIM card inserted while executing the test
IMSI=901700000046734 IMSI=901700000046734
ADMPIN=67225880 # <==== CHANGE THIS TO THE ADM1 KEY OF YOUR TEST CARD! ADMPIN=71365692 # <==== CHANGE THIS TO THE ADM1 KEY OF YOUR TEST CARD!
KI=D7882EAE7CD14F06108C55F8E5CFFE93 KI=D7882EAE7CD14F06108C55F8E5CFFE93

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# default: execute all tests # default: execute all tests
TESTS="01_auth.sh 02_mode_read.sh 03_mode_write.sh 04_algo.sh 05_milenage_par.sh 06_op_opc.sh 07_ki.sh 08_seq.sh 09_mnclen.sh" TESTS="01_auth.sh 02_mode_read.sh 03_mode_write.sh 04_algo.sh 05_milenage_par.sh 06_op_opc.sh 07_key.sh 08_seq.sh 09_mnclen.sh"
# if command line specifies some specific tests, execute only those # if command line specifies some specific tests, execute only those
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then

View File

@ -2,5 +2,5 @@ TOOL=../../sysmo-usim-tool.sjs1.py
# data for the test scripts. The values have to match the SIM card inserted while executing the test # data for the test scripts. The values have to match the SIM card inserted while executing the test
ICCID=8988211320300000028 ICCID=8988211320300000028
IMSI=262423203000002 IMSI=262423203000002
ADMPIN=55538407 # <==== CHANGE THIS TO THE ADM1 KEY OF YOUR TEST CARD! ADMPIN=05039324 # <==== CHANGE THIS TO THE ADM1 KEY OF YOUR TEST CARD!
KI=94c7f52c8c7337fad1af3a73b17b56ac KI=94c7f52c8c7337fad1af3a73b17b56ac