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

Change subject: pySim-read.py: Enable reading of EF.IMPI from ISIM
......................................................................

pySim-read.py: Enable reading of EF.IMPI from ISIM

IMS private user identity (IMPI)
As per TS1.103 version 14.2.0, this EF contains the private user identity of 
the user.
EF.IMPI consist of NAI TLV Data object.The NAI shall be encoded to an octet 
string
according to UTF-8 encoding rules as specified in IETF RFC 3629.

Reading of EF.IMPI is achieved by first selecting the ISIM application using 
its AID.
This is followed by selecting EF.IMPI with File ID - 6f02 in ADF.ISIM

Change-Id: I8d8e76e3f6b9ca7a0be262fee99cd5a397edbefa
---
M pySim-read.py
M pySim/cards.py
M pysim-testdata/sysmoISIM-SJA2.ok
3 files changed, 22 insertions(+), 0 deletions(-)

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



diff --git a/pySim-read.py b/pySim-read.py
index f63205a..a7d9063 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -315,6 +315,17 @@
                except Exception as e:
                        print("Home Network Domain Name: Can't read file -- " + 
str(e))

+               # EF.IMPI - IMS private user identity
+               try:
+                       if card.file_exists(EF_ISIM_ADF_map['IMPI']):
+                               (res, sw) = card.read_impi()
+                               if sw == '9000':
+                                       print("IMS private user identity: %s" % 
(len(res) and res or 'Not available',))
+                               else:
+                                       print("IMS private user identity: Can't 
read, response code = %s" % (sw,))
+               except Exception as e:
+                       print("IMS private user identity: Can't read file -- " 
+ str(e))
+
        # Check whether we have th AID of ISIM, if so select it by its AID
        # EF.IST - File Id in ADF ISIM : 6f07
        if '9000' == card.select_adf_by_aid(adf="isim"):
diff --git a/pySim/cards.py b/pySim/cards.py
index 17da506..17b7bce 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -375,6 +375,16 @@
                data, sw = self._scc.update_binary(EF_ISIM_ADF_map['DOMAIN'], 
rpad(content, bin_size_bytes*2))
                return sw

+       def read_impi(self):
+               (res, sw) = self._scc.read_binary(EF_ISIM_ADF_map['IMPI'])
+               if sw == '9000':
+                       # Skip the inital tag value ('80') byte and get length 
of contents
+                       length = int(res[2:4], 16)
+                       content = h2s(res[4:4+(length*2)])
+                       return (content, sw)
+               else:
+                       return (None, sw)
+

 class _MagicSimBase(Card):
        """
diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok
index 4cdd9d5..335c886 100644
--- a/pysim-testdata/sysmoISIM-SJA2.ok
+++ b/pysim-testdata/sysmoISIM-SJA2.ok
@@ -183,6 +183,7 @@
        Not available

 Home Network Domain Name: Not available
+IMS private user identity: Not available
 ISIM Service Table: 190200
        Service 1 - P-CSCF address
        Service 4 - GBA-based Local Key Establishment Mechanism

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

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

Reply via email to