laforge has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/36929?usp=email
)
Change subject: pySim.app: Attempt to retrieve the EID of a SGP.22 / SGP.32 eUICC
......................................................................
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
---
M pySim-shell.py
M pySim/app.py
M pySim/euicc.py
3 files changed, 37 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/pySim-shell.py b/pySim-shell.py
index c7539be..26f3d9b 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -760,6 +760,9 @@
self._cmd.poutput("Card info:")
self._cmd.poutput(" Name: %s" % self._cmd.card.name)
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(" Class-Byte: %s" % self._cmd.lchan.scc.cla_byte)
self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.lchan.scc.sel_ctrl)
diff --git a/pySim/app.py b/pySim/app.py
index e3878b8..5525cd1 100644
--- a/pySim/app.py
+++ b/pySim/app.py
@@ -25,6 +25,7 @@
from pySim.cdma_ruim import CardProfileRUIM
from pySim.ts_102_221 import CardProfileUICC
from pySim.utils import all_subclasses
+from pySim.exceptions import SwMatchError
# we need to import this module so that the SysmocomSJA2 sub-class of
# CardModel is created, which will add the ATR-based matching and
@@ -106,4 +107,15 @@
# inform the transport that we can do context-specific SW interpretation
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
diff --git a/pySim/euicc.py b/pySim/euicc.py
index e32fa4d..a771a22 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -345,6 +345,13 @@
else:
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:
t = FciTemplate()
t.from_tlv(h2b(data_hex))
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/36929?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Idc2ea1d9263f39b3dff403e1535a5e6c4e88b26f
Gerrit-Change-Number: 36929
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged