aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-03-05 01:00:13 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2017-03-05 01:00:13 +0100
commit8b8ccfcba4a191205e4e3c5e3bfb599168a817f5 (patch)
tree698190b60fbb4cf12f8838bcb55f3bb9d45d2357
parent2c11efcdf64ee829e11b1b957f55443dcc8a9ff6 (diff)
downloadsysmo-usim-tool-8b8ccfcba4a191205e4e3c5e3bfb599168a817f5.tar.gz
sysmo-usim-tool-8b8ccfcba4a191205e4e3c5e3bfb599168a817f5.tar.bz2
sysmo-usim-tool-8b8ccfcba4a191205e4e3c5e3bfb599168a817f5.tar.xz
sysmo-usim-tool-8b8ccfcba4a191205e4e3c5e3bfb599168a817f5.zip
add cmds to read/write KI
-rwxr-xr-xsysmo-usim-tool.sjs1.py24
-rw-r--r--sysmo_usimsjs1.py29
2 files changed, 51 insertions, 2 deletions
diff --git a/sysmo-usim-tool.sjs1.py b/sysmo-usim-tool.sjs1.py
index afc7ecb..6c2c7ea 100755
--- a/sysmo-usim-tool.sjs1.py
+++ b/sysmo-usim-tool.sjs1.py
@@ -49,6 +49,8 @@ def helptext():
print " -o, --opc ...................... Show OP/c configuration"
print " -O, --set-op HEXSTRING ......... Set OP value"
print " -C, --set-opc HEXSTRING ........ Set OPc value"
+ print " -k, --ki ....................... Show KI value"
+ print " -K, --set-ki ................... Set KI value"
print ""
@@ -66,14 +68,17 @@ def main(argv):
getopt_show_opc = False
getopt_write_op = None
getopt_write_opc = None
+ getopt_show_ki = None
+ getopt_write_ki = None
# Analyze commandline options
try:
opts, args = getopt.getopt(argv,
- "hva:ucmtT:lL:oO:C:",
+ "hva:ucmtT:lL:oO:C:kK:",
["help","verbose","adm1=","usim","classic",
"mode","auth","set-auth=","milenage",
- "set-milenage","opc","set-op=","set-opc="])
+ "set-milenage","opc","set-op=","set-opc=",
+ "ki","set-ki="])
except getopt.GetoptError:
print " * Error: Invalid commandline options"
sys.exit(2)
@@ -106,6 +111,10 @@ def main(argv):
getopt_write_op = asciihex_to_list(arg)
elif opt in ("-C", "--set-opc"):
getopt_write_opc = asciihex_to_list(arg)
+ elif opt in ("-k", "--ki"):
+ getopt_show_ki = True
+ elif opt in ("-K", "--set-ki"):
+ getopt_write_ki = asciihex_to_list(arg)
if not getopt_adm1:
@@ -173,6 +182,17 @@ def main(argv):
sysmo_usim_show_opc_params(sim, getopt_adm1)
print("")
+ if getopt_write_ki:
+ print "Writing KI value..."
+ sysmo_usim_write_ki_params(sim,
+ getopt_adm1, getopt_write_ki)
+ print("")
+
+ if getopt_show_ki:
+ print "Reading KI value..."
+ sysmo_usim_show_ki_params(sim, getopt_adm1)
+ print("")
+
print "Done!"
diff --git a/sysmo_usimsjs1.py b/sysmo_usimsjs1.py
index 7c057c1..af7becb 100644
--- a/sysmo_usimsjs1.py
+++ b/sysmo_usimsjs1.py
@@ -269,6 +269,35 @@ def sysmo_usim_write_opc_params(sim, adm1, select, op):
sim.update_binary([select] + op)
+# Show current KI value
+def sysmo_usim_show_ki_params(sim, adm1):
+ sysmo_usim_init(sim)
+ sysmo_usim_admin_auth(sim, adm1)
+
+ print " * Reading..."
+ sim.select(GSM_SIM_DF_GSM)
+ sim.select(SYSMO_USIMSJS1_EF_KI)
+ res = sim.read_binary(16)
+
+ print " * Current KI setting:"
+ print " KI: " + hexdump(res.apdu)
+
+
+# Program new KI value
+def sysmo_usim_write_ki_params(sim, adm1, ki):
+ print " * New KI setting:"
+ print " KI: " + hexdump(ki)
+
+ sysmo_usim_init(sim)
+ sysmo_usim_admin_auth(sim, adm1)
+
+ sim.select(GSM_SIM_DF_GSM)
+ sim.select(SYSMO_USIMSJS1_EF_KI)
+
+ print " * Programming..."
+ sim.update_binary(ki)
+
+
# Show the enable status of the USIM application (app is enabled or disabled?)
def sysmo_usim_show_usim_status(sim, adm1):
sysmo_usim_init(sim)