aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpySim-prog.py4
-rw-r--r--pySim/cards.py22
2 files changed, 26 insertions, 0 deletions
diff --git a/pySim-prog.py b/pySim-prog.py
index f278015..3abd0bd 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -159,6 +159,9 @@ def parse_options():
parser.add_option("--ims-hdomain", dest="ims_hdomain",
help="Set IMS Home Network Domain Name in FQDN format",
)
+ parser.add_option("--impi", dest="impi",
+ help="Set IMS private user identity",
+ )
parser.add_option("--read-imsi", dest="read_imsi", action="store_true",
help="Read the IMSI from the CARD", default=False
)
@@ -468,6 +471,7 @@ def gen_parameters(opts):
'epdgSelection' : opts.epdgSelection,
'pcscf' : opts.pcscf,
'ims_hdomain': opts.ims_hdomain,
+ 'impi' : opts.impi
}
diff --git a/pySim/cards.py b/pySim/cards.py
index 56597b0..62163a1 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -385,6 +385,18 @@ class IsimCard(Card):
else:
return (None, sw)
+ def update_impi(self, impi=None):
+ hex_str = ""
+ if impi:
+ hex_str = s2h(impi)
+ # Build TLV
+ tlv = TLV(['80'])
+ content = tlv.build({'80': hex_str})
+
+ bin_size_bytes = self._scc.binary_size(EF_ISIM_ADF_map['IMPI'])
+ data, sw = self._scc.update_binary(EF_ISIM_ADF_map['IMPI'], rpad(content, bin_size_bytes*2))
+ return sw
+
def read_impu(self):
rec_cnt = self._scc.record_count(EF_ISIM_ADF_map['IMPU'])
impu_recs = ""
@@ -1301,6 +1313,16 @@ class SysmoISIMSJA2(UsimCard, IsimCard):
if sw != '9000':
print("Programming Home Network Domain Name failed with code %s"%sw)
+ # update EF.IMPI in ADF.ISIM
+ # TODO: Validate IMPI input
+ if self.file_exists(EF_ISIM_ADF_map['IMPI']):
+ if p.get('impi'):
+ sw = self.update_impi(p['impi'])
+ else:
+ sw = self.update_impi()
+ if sw != '9000':
+ print("Programming IMPI failed with code %s"%sw)
+
if '9000' == self.select_adf_by_aid():
# update EF-USIM_AUTH_KEY in ADF.USIM
if p.get('ki'):