aboutsummaryrefslogtreecommitdiffstats
path: root/pySim/utils.py
diff options
context:
space:
mode:
authorSebastian Viviani <guilly@gmail.com>2020-06-03 08:57:00 +0100
committerSebastian Viviani <guilly@gmail.com>2020-06-09 10:10:28 +0100
commite61170c0eb85daa8ac5deabc8a62e00c9b33d800 (patch)
tree2892f7c3bbbaa5f98de1401d728656c90e8f6d18 /pySim/utils.py
parent0e9f93fdd613ec53b9123335bc6f1ed71b8a06b6 (diff)
utils.py add LOCI EFs decode functions
The LOCI, PSLOCI and EPSLOCI contain some info, including the PLMN, added helper functions to decode it Change-Id: Ibb513ff7d1dc6d33b354ae26cbd9c390ea3c8efc
Diffstat (limited to 'pySim/utils.py')
-rw-r--r--pySim/utils.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/pySim/utils.py b/pySim/utils.py
index 496b918..2ca6165 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -183,6 +183,36 @@ def format_xplmn_w_act(hexstr):
s += "\t%s # %s\n" % (rec_data, rec_str)
return s
+def dec_loci(hexstr):
+ res = {'tmsi': '', 'mcc': 0, 'mnc': 0, 'lac': '', 'status': 0}
+ res['tmsi'] = hexstr[:8]
+ res['mcc'] = dec_mcc_from_plmn(hexstr[8:14])
+ res['mnc'] = dec_mnc_from_plmn(hexstr[8:14])
+ res['lac'] = hexstr[14:18]
+ res['status'] = h2i(hexstr[20:22])
+ return res
+
+def dec_psloci(hexstr):
+ res = {'p-tmsi': '', 'p-tmsi-sig': '', 'mcc': 0, 'mnc': 0, 'lac': '', 'rac': '', 'status': 0}
+ res['p-tmsi'] = hexstr[:8]
+ res['p-tmsi-sig'] = hexstr[8:14]
+ res['mcc'] = dec_mcc_from_plmn(hexstr[14:20])
+ res['mnc'] = dec_mnc_from_plmn(hexstr[14:20])
+ res['lac'] = hexstr[20:24]
+ res['rac'] = hexstr[24:26]
+ res['status'] = h2i(hexstr[26:28])
+ return res
+
+def dec_epsloci(hexstr):
+ res = {'guti': '', 'mcc': 0, 'mnc': 0, 'tac': '', 'status': 0}
+ res['guti'] = hexstr[:24]
+ res['tai'] = hexstr[24:34]
+ res['mcc'] = dec_mcc_from_plmn(hexstr[24:30])
+ res['mnc'] = dec_mnc_from_plmn(hexstr[24:30])
+ res['tac'] = hexstr[30:34]
+ res['status'] = h2i(hexstr[34:36])
+ return res
+
def derive_milenage_opc(ki_hex, op_hex):
"""
Run the milenage algorithm to calculate OPC from Ki and OP