Change in pysim[master]: cards:FairwavesSIM: force SIM APDUs during programming

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

dexter gerrit-no-reply at lists.osmocom.org
Wed May 5 12:22:42 UTC 2021


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


Change subject: cards:FairwavesSIM: force SIM APDUs during programming
......................................................................

cards:FairwavesSIM: force SIM APDUs during programming

The FairwavesSIM programming fails when the card is accessed with USIM
APDUs. To keep it working temporarly switch to SIM APDUs during
programming.

Change-Id: I8f02625d2b620ecdf4b2afc27a8750119b707152
---
M pySim/cards.py
1 file changed, 14 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/39/24139/1

diff --git a/pySim/cards.py b/pySim/cards.py
index fa22d4c..f06aa02 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -1011,7 +1011,6 @@
 		self._adm_chv_num = 0x11
 		self._adm2_chv_num = 0x12
 
-
 	@classmethod
 	def autodetect(kls, scc):
 		try:
@@ -1089,6 +1088,16 @@
 
 
 	def program(self, p):
+		# For some reason the card programming only works when the card
+		# is handled as a classic SIM, even though it is an USIM, so we
+		# reconfigure the class byte and the select control field on
+		# the fly. When the programming is done the original values are
+		# restored.
+		cla_byte_orig = self._scc.cla_byte
+		sel_ctrl_orig = self._scc.sel_ctrl
+		self._scc.cla_byte = "a0"
+		self._scc.sel_ctrl = "0000"
+
 		# authenticate as ADM1
 		if not p['pin_adm']:
 			raise ValueError("Please provide a PIN-ADM as there is no default one")
@@ -1121,6 +1130,10 @@
 			if sw != '9000':
 				print("Programming ACC failed with code %s"%sw)
 
+		# restore original cla byte and sel ctrl
+		self._scc.cla_byte = cla_byte_orig
+		self._scc.sel_ctrl = sel_ctrl_orig
+
 class OpenCellsSim(Card):
 	"""
 	OpenCellsSim

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I8f02625d2b620ecdf4b2afc27a8750119b707152
Gerrit-Change-Number: 24139
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210505/51708005/attachment.htm>


More information about the gerrit-log mailing list