From 4e196ceaf415564f99b9b742d4d458c7919deb49 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 22 Jun 2023 15:43:38 +0200 Subject: [PATCH] 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 --- common.py | 28 +++++++++++------------ sysmo_isim_sja2.py | 34 +++++++++++++++------------- sysmo_usim_sjs1.py | 4 ++-- tests/sja2/{05_ki.out => 05_key.out} | 24 ++++++++++---------- tests/sja2/{05_ki.sh => 05_key.sh} | 0 tests/sja2/run-tests | 2 +- tests/sja2/test-data | 2 +- tests/sjs1/{07_ki.out => 07_key.out} | 0 tests/sjs1/{07_ki.sh => 07_key.sh} | 0 tests/sjs1/run-tests | 2 +- tests/sjs1/test-data | 2 +- 11 files changed, 50 insertions(+), 48 deletions(-) rename tests/sja2/{05_ki.out => 05_key.out} (85%) rename tests/sja2/{05_ki.sh => 05_key.sh} (100%) rename tests/sjs1/{07_ki.out => 07_key.out} (100%) rename tests/sjs1/{07_ki.sh => 07_key.sh} (100%) diff --git a/common.py b/common.py index d718fce..479b76a 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,10 +91,10 @@ 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"): @@ -141,8 +141,8 @@ 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(" -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 ........... Set 2G/3G Auth algo (e.g. COMP128v1:COMP128v1)") print(" -o, --opc ...................... Show OP/c configuration") @@ -182,11 +182,11 @@ 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() diff --git a/sysmo_isim_sja2.py b/sysmo_isim_sja2.py index 606da78..5250f65 100644 --- a/sysmo_isim_sja2.py +++ b/sysmo_isim_sja2.py @@ -645,49 +645,51 @@ class Sysmo_isim_sja2(Sysmo_usim): print(SYSMO_ISIMSJA2_FILE_EF_USIM_SQN(res.apdu)) - # 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 + # Note: The key 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(" * Current Key setting:") + print(" Key: " + hexdump(ef.key)) print("") - # Program new KI value - def write_ki_params(self, ki): - print("Writing KI value...") + def write_key_params(self, key): + """ + Program new Key value + """ + print("Writing Key value...") self._init() - - print(" * New KI setting:") - print(" KI: " + hexdump(ki)) - + print(" * New Key setting:") + print(" Key: " + hexdump(key)) 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 + ef.key = key 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.key = ki + ef.key = key 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.key = ki + ef.key = key self.sim.update_binary(ef.encode()) print("") 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/sja2/05_ki.out b/tests/sja2/05_key.out similarity index 85% rename from tests/sja2/05_ki.out rename to tests/sja2/05_key.out index 0ac6fdd..73343e1 100644 --- a/tests/sja2/05_ki.out +++ b/tests/sja2/05_key.out @@ -13,10 +13,10 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Writing KI value... +Writing Key value... * Initalizing... - * New KI setting: - KI: a0b1c2d3e4f5061728394a5b6c7d8e9f + * New Key setting: + Key: a0b1c2d3e4f5061728394a5b6c7d8e9f * Programming... Done! @@ -35,11 +35,11 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Reading KI value... +Reading Key value... * Initalizing... * Reading... - * Current KI setting: - KI: a0b1c2d3e4f5061728394a5b6c7d8e9f + * Current Key setting: + Key: a0b1c2d3e4f5061728394a5b6c7d8e9f Done! sysmoISIM-SJA2 parameterization tool @@ -57,10 +57,10 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Writing KI value... +Writing Key value... * Initalizing... - * New KI setting: - KI: d7882eae7cd14f06108c55f8e5cffe93 + * New Key setting: + Key: d7882eae7cd14f06108c55f8e5cffe93 * Programming... Done! @@ -79,10 +79,10 @@ Authenticating... * Authentication successful * Remaining attempts: 3 -Reading KI value... +Reading Key value... * Initalizing... * Reading... - * Current KI setting: - KI: d7882eae7cd14f06108c55f8e5cffe93 + * Current Key setting: + Key: d7882eae7cd14f06108c55f8e5cffe93 Done! diff --git a/tests/sja2/05_ki.sh b/tests/sja2/05_key.sh similarity index 100% rename from tests/sja2/05_ki.sh rename to tests/sja2/05_key.sh diff --git a/tests/sja2/run-tests b/tests/sja2/run-tests index 1eb6261..98d33c2 100755 --- a/tests/sja2/run-tests +++ b/tests/sja2/run-tests @@ -1,7 +1,7 @@ #!/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" +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 [ $# -ge 1 ]; then diff --git a/tests/sja2/test-data b/tests/sja2/test-data index ffb36d2..b084ff3 100644 --- a/tests/sja2/test-data +++ b/tests/sja2/test-data @@ -1,5 +1,5 @@ TOOL=../../sysmo-isim-tool.sja2.py # data for the test scripts. The values have to match the SIM card inserted while executing the test 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 diff --git a/tests/sjs1/07_ki.out b/tests/sjs1/07_key.out similarity index 100% rename from tests/sjs1/07_ki.out rename to tests/sjs1/07_key.out diff --git a/tests/sjs1/07_ki.sh b/tests/sjs1/07_key.sh similarity index 100% rename from tests/sjs1/07_ki.sh rename to tests/sjs1/07_key.sh diff --git a/tests/sjs1/run-tests b/tests/sjs1/run-tests index d424093..e602201 100755 --- a/tests/sjs1/run-tests +++ b/tests/sjs1/run-tests @@ -1,7 +1,7 @@ #!/bin/sh # 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 [ $# -ge 1 ]; then diff --git a/tests/sjs1/test-data b/tests/sjs1/test-data index bb697eb..62a2b3b 100644 --- a/tests/sjs1/test-data +++ b/tests/sjs1/test-data @@ -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 ICCID=8988211320300000028 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