laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/21954 
)

Change subject: sysmoISIM-SJA2: Add support for programming IMS private user 
identity
......................................................................

sysmoISIM-SJA2: Add support for programming IMS private user identity

This EF contains the private user identity of the user. EF.IMPI consist of
NAI TLV data object values see IETF RFC 2486. The NAI shall be encoded to
an octet string according to UTF-8 encoding rules as specified in IETF RFC 3629

./pySim-prog.py -p 0 -x 001 -y 01 -s 8988211900000000004 -i 001011234567895 -k 
8baf473f2f8fd09487cccbd7097c6862 --op 11111111111111111111111111111111 -o 
8E27B6AF0E692E750F32667A3B14605D -a 85524953 -n isim.test --msisdn 
0598765432100 --epdgid epdg.epc.mnc001.mcc001.pub.3gppnetwork.org --pcscf 
pcscf.ims.testop.org --ims-hdomain ims.testop.org --impi 
[email protected]

Change-Id: Ic1ccf99b5aa45297ef1e43a43373df603f756379
---
M pySim-prog.py
M pySim/cards.py
2 files changed, 26 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



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 @@
        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 @@
                '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 @@
                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 @@
                                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'):

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/21954
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic1ccf99b5aa45297ef1e43a43373df603f756379
Gerrit-Change-Number: 21954
Gerrit-PatchSet: 1
Gerrit-Owner: herlesupreeth <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to