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.orgdexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/26280 )
Change subject: cards: select_adf_by_aid: split off aid completion
......................................................................
cards: select_adf_by_aid: split off aid completion
The function select_adf_by_aid first searches for the complete AID in
the set of AIDs that were read from EF.DIR. Lets put this task into a
separate helper method
Change-Id: I88447d47bc96d0d4ff5cea694b46e854232cdf86
---
M pySim/cards.py
1 file changed, 26 insertions(+), 13 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/pySim/cards.py b/pySim/cards.py
index 8f5004e..2319a56 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -278,22 +278,35 @@
self._aids = []
return self._aids
+ @staticmethod
+ def _get_aid(adf="usim") -> str:
+ aid_map = {}
+ # First (known) halves of the U/ISIM AID
+ aid_map["usim"] = "a0000000871002"
+ aid_map["isim"] = "a0000000871004"
+ if adf in aid_map:
+ return aid_map[adf]
+ return None
+
+ def _complete_aid(self, aid) -> str:
+ """find the complete version of an ADF.U/ISIM AID"""
+ # Find full AID by partial AID:
+ if is_hex(aid):
+ for aid_known in self._aids:
+ if len(aid_known) >= len(aid) and aid == aid_known[0:len(aid)]:
+ return aid_known
+ return None
+
def select_adf_by_aid(self, adf="usim"):
"""Select ADF.U/ISIM in the Card using its full AID"""
- # 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)
+ aid = adf
+ else:
+ aid = self._get_aid(adf)
+ if aid:
+ aid_full = self._complete_aid(aid)
+ if aid_full:
+ return self._scc.select_adf(aid_full)
return (None, None)
def erase_binary(self, ef):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/26280
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I88447d47bc96d0d4ff5cea694b46e854232cdf86
Gerrit-Change-Number: 26280
Gerrit-PatchSet: 5
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211118/e229fdc0/attachment.htm>