mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-26 23:38:32 +03:00
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
This commit is contained in:
@@ -278,22 +278,35 @@ class SimCard(object):
|
|||||||
self._aids = []
|
self._aids = []
|
||||||
return 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"):
|
def select_adf_by_aid(self, adf="usim"):
|
||||||
"""Select ADF.U/ISIM in the Card using its full AID"""
|
"""Select ADF.U/ISIM in the Card using its full AID"""
|
||||||
# Find full AID by partial AID:
|
|
||||||
if is_hex(adf):
|
if is_hex(adf):
|
||||||
for aid in self._aids:
|
aid = adf
|
||||||
if len(aid) >= len(adf) and adf == aid[0:len(adf)]:
|
else:
|
||||||
return self._scc.select_adf(aid)
|
aid = self._get_aid(adf)
|
||||||
# Find full AID by application name:
|
if aid:
|
||||||
elif adf in ["usim", "isim"]:
|
aid_full = self._complete_aid(aid)
|
||||||
# First (known) halves of the U/ISIM AID
|
if aid_full:
|
||||||
aid_map = {}
|
return self._scc.select_adf(aid_full)
|
||||||
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)
|
return (None, None)
|
||||||
|
|
||||||
def erase_binary(self, ef):
|
def erase_binary(self, ef):
|
||||||
|
|||||||
Reference in New Issue
Block a user