Change in pysim[master]: cards: Add support for Wavemobile SIM

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
Thu Jul 19 09:39:58 UTC 2018


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10047


Change subject: cards: Add support for Wavemobile SIM
......................................................................

cards: Add support for Wavemobile SIM

Add support to handle Wavemobile sim cards. The support excludes some
parameters. For example it is not possible to write own KI keys yet.

Support covers the following files:
EF.SMSP
EF.IMSI
EF.ACC
EF.PLMNsel
EF.PLMNwAcT
EF.OPLMNwAcT

Not yet supported are:
EF.ICCID
KI (propretary file)
OPc (propritary file)

Change-Id: Ida3f37bd6e3ac995812aeddc9770f1ccd54ecf3f
Related: SYS#4245
---
M pySim/cards.py
1 file changed, 112 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/47/10047/1

diff --git a/pySim/cards.py b/pySim/cards.py
index a72a52f..d729f07 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -83,6 +83,30 @@
 		data, sw = self._scc.update_binary(EF['HPLMNwAcT'], content + 'ffffff0000' * (size/5-1))
 		return sw
 
+	def update_oplmn_act(self, mcc, mnc, access_tech='FFFF'):
+		"""
+                See note in update_hplmn_act()
+		"""
+		# get size and write EF.OPLMNwAcT
+	        data = self._scc.read_binary(EF['OPLMNwAcT'], length=None, offset=0)
+                size = len(data[0])/2
+		hplmn = enc_plmn(mcc, mnc)
+		content = hplmn + access_tech
+		data, sw = self._scc.update_binary(EF['OPLMNwAcT'], content + 'ffffff0000' * (size/5-1))
+		return sw
+
+	def update_plmn_act(self, mcc, mnc, access_tech='FFFF'):
+		"""
+                See note in update_hplmn_act()
+		"""
+		# get size and write EF.PLMNwAcT
+	        data = self._scc.read_binary(EF['PLMNwAcT'], length=None, offset=0)
+                size = len(data[0])/2
+		hplmn = enc_plmn(mcc, mnc)
+		content = hplmn + access_tech
+		data, sw = self._scc.update_binary(EF['PLMNwAcT'], content + 'ffffff0000' * (size/5-1))
+		return sw
+
         def update_plmnsel(self, mcc, mnc):
 	        data = self._scc.read_binary(EF['PLMNsel'], length=None, offset=0)
                 size = len(data[0])/2
@@ -743,11 +767,98 @@
 		# write EF.IMSI
 		data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))
 
+class WavemobileSim(Card):
+	"""
+	WavemobileSim
+
+	"""
+
+	name = 'Wavemobile-SIM'
+
+	def __init__(self, ssc):
+		super(WavemobileSim, self).__init__(ssc)
+		self._adm_chv_num = 0x0A
+		self._scc.cla_byte = "00"
+		self._scc.sel_ctrl = "0004" #request an FCP
+
+	@classmethod
+	def autodetect(kls, scc):
+		try:
+			# Look for ATR
+			if scc.get_atr() == toBytes("3B 9F 95 80 1F C7 80 31 E0 73 F6 21 13 67 4D 45 16 00 43 01 00 8F"):
+				return kls(scc)
+		except:
+			return None
+		return None
+
+	def program(self, p):
+		if not p['pin_adm']:
+			raise ValueError("Please provide a PIN-ADM as there is no default one")
+		sw = self.verify_adm(h2b(p['pin_adm']))
+		if sw != '9000':
+			raise RuntimeError('Failed to authenticate with ADM key %s'%(p['pin_adm'],))
+
+                # EF.ICCID
+                # TODO: Add programming of the ICCID
+                if p.get('iccid'):
+			print("Warning: Programming of the ICCID is not implemented for this type of card.")
+
+                # KI (Presumably a propritary file)
+                # TODO: Add programming of KI
+                if p.get('ki'):
+			print("Warning: Programming of the KI is not implemented for this type of card.")
+
+                # OPc (Presumably a propritary file)
+                # TODO: Add programming of OPc
+                if p.get('opc'):
+			print("Warning: Programming of the OPc is not implemented for this type of card.")
+
+                # EF.SMSP
+		if p.get('smsp'):
+			sw = self.update_smsp(p['smsp'])
+			if sw != '9000':
+				print("Programming SMSP failed with code %s"%sw)
+
+                # EF.IMSI
+		if p.get('imsi'):
+			sw = self.update_imsi(p['imsi'])
+			if sw != '9000':
+				print("Programming IMSI failed with code %s"%sw)
+
+		# EF.ACC
+		if p.get('acc'):
+			sw = self.update_acc(p['acc'])
+			if sw != '9000':
+				print("Programming ACC failed with code %s"%sw)
+
+		# EF.PLMNsel
+                if p.get('mcc') and p.get('mnc'):
+                        sw = self.update_plmnsel(p['mcc'], p['mnc'])
+                        if sw != '9000':
+				print("Programming PLMNsel failed with code %s"%sw)
+
+                # EF.PLMNwAcT
+                if p.get('mcc') and p.get('mnc'):
+			sw = self.update_plmn_act(p['mcc'], p['mnc'])
+			if sw != '9000':
+				print("Programming PLMNwAcT failed with code %s"%sw)
+
+                # EF.OPLMNwAcT
+                if p.get('mcc') and p.get('mnc'):
+			sw = self.update_oplmn_act(p['mcc'], p['mnc'])
+			if sw != '9000':
+				print("Programming OPLMNwAcT failed with code %s"%sw)
+
+                return None
+
+	def erase(self):
+		return
+
 
 # In order for autodetection ...
 _cards_classes = [ FakeMagicSim, SuperSim, MagicSim, GrcardSim,
 		   SysmoSIMgr1, SysmoSIMgr2, SysmoUSIMgr1, SysmoUSIMSJS1,
-		   FairwavesSIM, OpenCellsSim ]
+		   FairwavesSIM, OpenCellsSim, WavemobileSim ]
 
 def card_autodetect(scc):
 	for kls in _cards_classes:

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

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


More information about the gerrit-log mailing list