Change in pysim[master]: pySim-read.py: Enable reading of EF.IMPU from ISIM

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

herlesupreeth gerrit-no-reply at lists.osmocom.org
Tue Jan 5 14:46:27 UTC 2021


herlesupreeth has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/21953 )


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

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

IMS public user identity (IMPU)
As per TS1.103, this EF contains one or more records, with each record able
to hold a public SIP Identity (SIP URI) of the user. EF.IMPI consist of URI TLV data
object values see IETF RFC 3261. The URI shall be encoded to an octet string according
to UTF-8 encoding rules as specified in IETF RFC 3629

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

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



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/53/21953/1

diff --git a/pySim-read.py b/pySim-read.py
index a7d9063..4047598 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -326,6 +326,14 @@
 		except Exception as e:
 			print("IMS private user identity: Can't read file -- " + str(e))
 
+		# EF.IMPU - IMS public user identity
+		try:
+			if card.file_exists(EF_ISIM_ADF_map['IMPU']):
+				res = card.read_impu()
+				print("IMS public user identity:\n%s" % (len(res) and res or '\tNot available\n',))
+		except Exception as e:
+			print("IMS public 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 17b7bce..56597b0 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -385,6 +385,20 @@
 		else:
 			return (None, sw)
 
+	def read_impu(self):
+		rec_cnt = self._scc.record_count(EF_ISIM_ADF_map['IMPU'])
+		impu_recs = ""
+		for i in range(0, rec_cnt):
+			(res, sw) = self._scc.read_record(EF_ISIM_ADF_map['IMPU'], i + 1)
+			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)])
+				impu_recs += "\t%s\n" % (len(content) and content or 'Not available')
+			else:
+				impu_recs += "IMS public user identity: Can't read, response code = %s\n" % (sw)
+		return impu_recs
+
 
 class _MagicSimBase(Card):
 	"""
diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok
index 335c886..26e20b0 100644
--- a/pysim-testdata/sysmoISIM-SJA2.ok
+++ b/pysim-testdata/sysmoISIM-SJA2.ok
@@ -184,6 +184,16 @@
 
 Home Network Domain Name: Not available
 IMS private user identity: Not available
+IMS public user identity:
+	Not available
+	Not available
+	Not available
+	Not available
+	Not available
+	Not available
+	Not available
+	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/+/21953
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icf78a564aeaf4254658d3b018ff57dfc4b987e6f
Gerrit-Change-Number: 21953
Gerrit-PatchSet: 1
Gerrit-Owner: herlesupreeth <herlesupreeth at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210105/856509bf/attachment.htm>


More information about the gerrit-log mailing list