Change in pysim[master]: cards: move methods read_aids and select_adf_by_aid to class UsimCard

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 15:10:49 UTC 2021


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


Change subject: cards: move methods read_aids and select_adf_by_aid to class UsimCard
......................................................................

cards: move methods read_aids and select_adf_by_aid to class UsimCard

A SimCard does not have ISIM or USIM applications, nor does it have an
EF.DIR to look at. It is not logical to implement them in the SimCard
class. Lets move those methods to the UsimCard, which makes more sense.

Change-Id: I71667b7b38c930b4e0409fe2ba2786e1db9cf9a3
---
M pySim/cards.py
1 file changed, 35 insertions(+), 35 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/46/24146/1

diff --git a/pySim/cards.py b/pySim/cards.py
index 0fb7357..6e8b52a 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -238,41 +238,6 @@
 		else:
 			return (None, sw)
 
-	# Fetch all the AIDs present on UICC
-	def read_aids(self):
-		self._aids = []
-		try:
-			# Find out how many records the EF.DIR has
-			# and store all the AIDs in the UICC
-			rec_cnt = self._scc.record_count(EF['DIR'])
-			for i in range(0, rec_cnt):
-				rec = self._scc.read_record(EF['DIR'], i + 1)
-				if (rec[0][0:2], rec[0][4:6]) == ('61', '4f') and len(rec[0]) > 12 \
-				and rec[0][8:8 + int(rec[0][6:8], 16) * 2] not in self._aids:
-					self._aids.append(rec[0][8:8 + int(rec[0][6:8], 16) * 2])
-		except Exception as e:
-			print("Can't read AIDs from SIM -- %s" % (str(e),))
-			self._aids = []
-		return self._aids
-
-	# Select ADF.U/ISIM in the Card using its full AID
-	def select_adf_by_aid(self, adf="usim"):
-		# Find full AID by partial AID:
-		if is_hex(adf):
-			for aid in self._aids:
-				if len(aid) >= len(adf) and adf == aid[0:len(adf)]:
-					return self._scc.select_adf(aid)
-		# Find full AID by application name:
-		elif adf in ["usim", "isim"]:
-			# First (known) halves of the U/ISIM AID
-			aid_map = {}
-			aid_map["usim"] = "a0000000871002"
-			aid_map["isim"] = "a0000000871004"
-			for aid in self._aids:
-				if aid_map[adf] in aid:
-					return self._scc.select_adf(aid)
-		return (None, None)
-
 	# Erase the contents of a file
 	def erase_binary(self, ef):
 		len = self._scc.binary_size(ef)
@@ -356,6 +321,41 @@
 			(res, sw) = self._scc.update_binary(EF_USIM_ADF_map['UST'], content)
 		return sw
 
+	# Fetch all the AIDs present on UICC
+	def read_aids(self):
+		self._aids = []
+		try:
+			# Find out how many records the EF.DIR has
+			# and store all the AIDs in the UICC
+			rec_cnt = self._scc.record_count(EF['DIR'])
+			for i in range(0, rec_cnt):
+				rec = self._scc.read_record(EF['DIR'], i + 1)
+				if (rec[0][0:2], rec[0][4:6]) == ('61', '4f') and len(rec[0]) > 12 \
+				and rec[0][8:8 + int(rec[0][6:8], 16) * 2] not in self._aids:
+					self._aids.append(rec[0][8:8 + int(rec[0][6:8], 16) * 2])
+		except Exception as e:
+			print("Can't read AIDs from SIM -- %s" % (str(e),))
+			self._aids = []
+		return self._aids
+
+	# Select ADF.U/ISIM in the Card using its full AID
+	def select_adf_by_aid(self, adf="usim"):
+		# Find full AID by partial AID:
+		if is_hex(adf):
+			for aid in self._aids:
+				if len(aid) >= len(adf) and adf == aid[0:len(adf)]:
+					return self._scc.select_adf(aid)
+		# Find full AID by application name:
+		elif adf in ["usim", "isim"]:
+			# First (known) halves of the U/ISIM AID
+			aid_map = {}
+			aid_map["usim"] = "a0000000871002"
+			aid_map["isim"] = "a0000000871004"
+			for aid in self._aids:
+				if aid_map[adf] in aid:
+					return self._scc.select_adf(aid)
+		return (None, None)
+
 class IsimCard(UsimCard):
 
 	name = 'ISIM'

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I71667b7b38c930b4e0409fe2ba2786e1db9cf9a3
Gerrit-Change-Number: 24146
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/739a2b56/attachment.htm>


More information about the gerrit-log mailing list