Change in pysim[master]: pySim-shell: allow generic USIM/ISIM cards to be used

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
Fri Apr 9 20:24:00 UTC 2021


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


Change subject: pySim-shell: allow generic USIM/ISIM cards to be used
......................................................................

pySim-shell: allow generic USIM/ISIM cards to be used

At the moment the card is automatically detected. This means that
pySim-shell will only support the specific types of simcards we support
in pySim-prog. However pySim-shell is more generic and would in theory
work with any SIM/USIM/ISIM card as long as only the 3GPP specified
features are used.

Lets add a generic card that acts as a dummy in case we want to operate
a generic simcard.

Change-Id: Ie1fa42400d236928659a7e5d34225487161d4b83
Related: OS#4963
---
M pySim-shell.py
M pySim/cards.py
2 files changed, 34 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/89/23689/1

diff --git a/pySim-shell.py b/pySim-shell.py
index 29138cc..e7e3dc5 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -38,7 +38,7 @@
 from pySim.exceptions import *
 from pySim.commands import SimCardCommands
 from pySim.transport import init_reader
-from pySim.cards import card_detect, Card
+from pySim.cards import card_detect, Card, GenericUsimIsim
 from pySim.utils import h2b, swap_nibbles, rpad, h2s
 from pySim.utils import dec_st, sanitize_pin_adm, tabulate_str_list, is_hex
 from pySim.card_handler import card_handler
@@ -431,6 +431,9 @@
 	parser.add_option("-A", "--pin-adm-hex", dest="pin_adm_hex",
 			help="ADM PIN used for provisioning, as hex string (16 characters long",
 		)
+	parser.add_option("-U", "--generic-usim", dest="generic_usim", default=False, action='store_true',
+			help="Use a generic ISIM/USIM class instead of a specific (autodetected) card class",
+		)
 
 	(options, args) = parser.parse_args()
 
@@ -458,10 +461,13 @@
 
 	card_handler = card_handler(sl)
 
-	card = card_detect("auto", scc)
-	if card is None:
-		print("No card detected!")
-		sys.exit(2)
+	if opts.generic_usim:
+		card = GenericUsimIsim(scc)
+	else:
+		card = card_detect("auto", scc)
+		if card is None:
+			print("No card detected!")
+			sys.exit(2)
 
 	profile = CardProfileUICC()
 	profile.add_application(CardApplicationUSIM)
diff --git a/pySim/cards.py b/pySim/cards.py
index 8ac80bf..d193f08 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -1448,6 +1448,29 @@
 		return
 
 
+class GenericUsimIsim(UsimCard, IsimCard):
+	"""
+	GenericUsimIsim
+	"""
+
+	name = 'GenericUsimIsim'
+
+	def __init__(self, ssc):
+		super(GenericUsimIsim, self).__init__(ssc)
+		self._scc.cla_byte = "00"
+		self._scc.sel_ctrl = "0004" #request an FCP
+
+	@classmethod
+	def autodetect(kls, scc):
+		return kls(scc)
+
+	def verify_adm(self, key):
+		return "9000"
+
+	def program(self, p):
+		return
+
+
 # In order for autodetection ...
 _cards_classes = [ FakeMagicSim, SuperSim, MagicSim, GrcardSim,
 		   SysmoSIMgr1, SysmoSIMgr2, SysmoUSIMgr1, SysmoUSIMSJS1,

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie1fa42400d236928659a7e5d34225487161d4b83
Gerrit-Change-Number: 23689
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/20210409/f39535c1/attachment.htm>


More information about the gerrit-log mailing list