diff options
author | Supreeth Herle <herlesupreeth@gmail.com> | 2020-03-18 11:33:14 +0100 |
---|---|---|
committer | Supreeth Herle <herlesupreeth@gmail.com> | 2020-03-19 10:27:48 +0100 |
commit | e4e98316a8bfabc9b1ce6952c1721d5c093cc9c1 (patch) | |
tree | 173ee14e767fd5e8663cddc1d64ba456fd2ed057 /pySim | |
parent | 0e90e6c3c6d182466900f5b94b9a856d345effd2 (diff) |
cards.py: Added parsing of all the AIDs in the UICC
Introduced a new member variable and a member function to Card class to fetch
and store the AIDs present in UICC. And, this variable (a list) is populated
by reading the EF 2f00 under MF 3f00 (function read_aids()).
Change-Id: I7ca77a73ebb42a8ba1381588d878040675d3019a
Diffstat (limited to 'pySim')
-rw-r--r-- | pySim/cards.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pySim/cards.py b/pySim/cards.py index a872ee0..fe7f0fd 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -32,6 +32,7 @@ class Card(object): def __init__(self, scc): self._scc = scc self._adm_chv_num = 4 + self._aids = [] def reset(self): self._scc.reset_card() @@ -168,6 +169,20 @@ class Card(object): return None + # Fetch all the AIDs present on UICC + def read_aids(self): + try: + # Find out how many records the EF.DIR has + # and store all the AIDs in the UICC + rec_cnt = self._scc.record_count(['3f00', '2f00']) + for i in range(0, rec_cnt): + rec = self._scc.read_record(['3f00', '2f00'], 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),)) + class _MagicSimBase(Card): """ |