mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
pySim.app: Attempt to retrieve the EID of a SGP.22 / SGP.32 eUICC
... and populate the RuntimeState.identity['EID'] wit it, so other [future] parts of the system can use it. Let's also print the EID (if available) from the 'cardinfo' shell command. Change-Id: Idc2ea1d9263f39b3dff403e1535a5e6c4e88b26f
This commit is contained in:
@@ -760,6 +760,9 @@ Currently only ADM1 is supported."""
|
|||||||
self._cmd.poutput("Card info:")
|
self._cmd.poutput("Card info:")
|
||||||
self._cmd.poutput(" Name: %s" % self._cmd.card.name)
|
self._cmd.poutput(" Name: %s" % self._cmd.card.name)
|
||||||
self._cmd.poutput(" ATR: %s" % self._cmd.rs.identity['ATR'])
|
self._cmd.poutput(" ATR: %s" % self._cmd.rs.identity['ATR'])
|
||||||
|
eid = self._cmd.rs.identity.get('EID', None)
|
||||||
|
if eid:
|
||||||
|
self._cmd.poutput(" EID: %s" % eid)
|
||||||
self._cmd.poutput(" ICCID: %s" % self._cmd.rs.identity['ICCID'])
|
self._cmd.poutput(" ICCID: %s" % self._cmd.rs.identity['ICCID'])
|
||||||
self._cmd.poutput(" Class-Byte: %s" % self._cmd.lchan.scc.cla_byte)
|
self._cmd.poutput(" Class-Byte: %s" % self._cmd.lchan.scc.cla_byte)
|
||||||
self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.lchan.scc.sel_ctrl)
|
self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.lchan.scc.sel_ctrl)
|
||||||
|
|||||||
12
pySim/app.py
12
pySim/app.py
@@ -25,6 +25,7 @@ from pySim.profile import CardProfile
|
|||||||
from pySim.cdma_ruim import CardProfileRUIM
|
from pySim.cdma_ruim import CardProfileRUIM
|
||||||
from pySim.ts_102_221 import CardProfileUICC
|
from pySim.ts_102_221 import CardProfileUICC
|
||||||
from pySim.utils import all_subclasses
|
from pySim.utils import all_subclasses
|
||||||
|
from pySim.exceptions import SwMatchError
|
||||||
|
|
||||||
# we need to import this module so that the SysmocomSJA2 sub-class of
|
# we need to import this module so that the SysmocomSJA2 sub-class of
|
||||||
# CardModel is created, which will add the ATR-based matching and
|
# CardModel is created, which will add the ATR-based matching and
|
||||||
@@ -106,4 +107,15 @@ def init_card(sl: LinkBase) -> Tuple[RuntimeState, SimCardBase]:
|
|||||||
# inform the transport that we can do context-specific SW interpretation
|
# inform the transport that we can do context-specific SW interpretation
|
||||||
sl.set_sw_interpreter(rs)
|
sl.set_sw_interpreter(rs)
|
||||||
|
|
||||||
|
# try to obtain the EID, if any
|
||||||
|
isd_r = rs.mf.applications.get(pySim.euicc.AID_ISD_R.lower(), None)
|
||||||
|
if isd_r:
|
||||||
|
rs.lchan[0].select_file(isd_r)
|
||||||
|
try:
|
||||||
|
rs.identity['EID'] = pySim.euicc.CardApplicationISDR.get_eid(scc)
|
||||||
|
except SwMatchError:
|
||||||
|
# has ISD-R but not a SGP.22/SGP.32 eUICC - maybe SGP.02?
|
||||||
|
pass
|
||||||
|
card.reset()
|
||||||
|
|
||||||
return rs, card
|
return rs, card
|
||||||
|
|||||||
@@ -345,6 +345,13 @@ class CardApplicationISDR(pySim.global_platform.CardApplicationSD):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_eid(scc: SimCardCommands) -> str:
|
||||||
|
ged_cmd = GetEuiccData(children=[TagList(decoded=[0x5A])])
|
||||||
|
ged = CardApplicationISDR.store_data_tlv(scc, ged_cmd, GetEuiccData)
|
||||||
|
d = ged.to_dict()
|
||||||
|
return flatten_dict_lists(d['get_euicc_data'])['eid_value']
|
||||||
|
|
||||||
def decode_select_response(self, data_hex: Hexstr) -> object:
|
def decode_select_response(self, data_hex: Hexstr) -> object:
|
||||||
t = FciTemplate()
|
t = FciTemplate()
|
||||||
t.from_tlv(h2b(data_hex))
|
t.from_tlv(h2b(data_hex))
|
||||||
|
|||||||
Reference in New Issue
Block a user