Change in pysim[master]: Add API + shell command for sending TERMINAL PROFILE to card

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/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Oct 14 15:44:29 UTC 2021


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

Change subject: Add API + shell command for sending TERMINAL PROFILE to card
......................................................................

Add API + shell command for sending TERMINAL PROFILE to card

This allows a very first start to play with PROACTIVE SIM

Change-Id: Id8f23f7cebe0f9efce2c0ce4229509f35cd93d6a
---
M pySim/commands.py
M pySim/transport/__init__.py
M pySim/ts_31_102.py
3 files changed, 14 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/pySim/commands.py b/pySim/commands.py
index 9657162..eb8217d 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -441,3 +441,9 @@
 	def envelope(self, payload:str):
 		"""Send one ENVELOPE command to the SIM"""
 		return self._tp.send_apdu_checksw('80c20000%02x%s' % (len(payload)//2, payload))
+
+	def terminal_profile(self, payload:str):
+		"""Send TERMINAL PROFILE to card"""
+		data_length = len(payload) // 2
+		data, sw = self._tp.send_apdu(('80100000%02x' % data_length) + payload)
+		return (data, sw)
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 72a80a9..cb781b0 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -136,6 +136,10 @@
 		"""
 		rv = self.send_apdu(pdu)
 
+		if sw == '9000' and sw_match(rv[1], '91xx'):
+			# proactive sim as per TS 102 221 Setion 7.4.2
+			rv = self.send_apdu_checksw('80120000' + rv[1][2:], sw)
+			print("FETCH: %s", rv[0])
 		if not sw_match(rv[1], sw):
 			raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)
 		return rv
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index f3628ad..f347f67 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -1084,6 +1084,10 @@
             (data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn)
             self._cmd.poutput_json(data)
 
+        def do_terminal_profile(self, arg):
+            """Send a TERMINAL PROFILE command to the card."""
+            (data, sw) = self._cmd.card._scc.terminal_profile(arg)
+            self._cmd.poutput('SW: %s, data: %s' % (sw, data))
 
 
 # TS 31.102 Section 7.3

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id8f23f7cebe0f9efce2c0ce4229509f35cd93d6a
Gerrit-Change-Number: 25785
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211014/c0aa1d3a/attachment.htm>


More information about the gerrit-log mailing list