[PATCH] pysim[master]: add support for open cells SIM cards

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

Todd Neal gerrit-no-reply at lists.osmocom.org
Thu Apr 26 16:09:29 UTC 2018


Hello Vadim Yanitskiy, Harald Welte,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7932

to look at the new patch set (#3).

add support for open cells SIM cards

Change-Id: I4df5681952eefd7a67f5e2b0a96a9e01c9d960d2
---
M pySim/cards.py
1 file changed, 52 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/7932/3

diff --git a/pySim/cards.py b/pySim/cards.py
index e324857..0c9c2b8 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -687,10 +687,60 @@
 		return
 
 
-	# In order for autodetection ...
+class OpenCellsSim(Card):
+	"""
+	OpenCellsSim
+
+	"""
+
+	name = 'OpenCells SIM'
+
+	def __init__(self, ssc):
+		super(OpenCellsSim, self).__init__(ssc)
+		self._adm_chv_num = 0x0A
+
+
+	@classmethod
+	def autodetect(kls, scc):
+		try:
+			# Look for ATR
+			if scc.get_atr() == toBytes("3B 9F 95 80 1F C3 80 31 E0 73 FE 21 13 57 86 81 02 86 98 44 18 A8"):
+				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")
+		self._scc.verify_chv(0x0A, h2b(p['pin_adm']))
+
+		# select MF
+		r = self._scc.select_file(['3f00'])
+
+		# write EF.ICCID
+		data, sw = self._scc.update_binary('2fe2', enc_iccid(p['iccid']))
+
+		r = self._scc.select_file(['7ff0'])
+
+		# set Ki in proprietary file
+		data, sw = self._scc.update_binary('FF02', p['ki'])
+
+		# set OPC in proprietary file
+		data, sw = self._scc.update_binary('FF01', p['opc'])
+
+		# select DF_GSM
+		r = self._scc.select_file(['7f20'])
+
+		# write EF.IMSI
+		data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))
+
+
+# In order for autodetection ...
 _cards_classes = [ FakeMagicSim, SuperSim, MagicSim, GrcardSim,
 		   SysmoSIMgr1, SysmoSIMgr2, SysmoUSIMgr1, SysmoUSIMSJS1,
-		   FairwavesSIM ]
+		   FairwavesSIM, OpenCellsSim ]
 
 def card_autodetect(scc):
 	for kls in _cards_classes:

-- 
To view, visit https://gerrit.osmocom.org/7932
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4df5681952eefd7a67f5e2b0a96a9e01c9d960d2
Gerrit-PatchSet: 3
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Owner: Todd Neal <todd at tneal.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list