From f47433863e6218d4c55663a34ce0130e52ecbee0 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 25 May 2024 10:36:07 +0200 Subject: [PATCH] runtime: Introduce an 'identity' dict for things like ATR, ICCID, EID This patch introduces the dict, as well as its first use for ATR storage Change-Id: Ief5ceaf5afe82800e33da233573293527befd2f4 --- pySim-shell.py | 2 +- pySim/runtime.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pySim-shell.py b/pySim-shell.py index 127e366a..e238e6a8 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -761,7 +761,7 @@ Currently only ADM1 is supported.""" """Display information about the currently inserted card""" self._cmd.poutput("Card info:") self._cmd.poutput(" Name: %s" % self._cmd.card.name) - self._cmd.poutput(" ATR: %s" % b2h(self._cmd.lchan.scc.get_atr())) + self._cmd.poutput(" ATR: %s" % self._cmd.rs.identity['ATR']) self._cmd.poutput(" ICCID: %s" % self._cmd.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/runtime.py b/pySim/runtime.py index d873e203..3ef9b2dd 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -49,6 +49,9 @@ class RuntimeState: self.lchan = {} # the basic logical channel always exists self.lchan[0] = RuntimeLchan(0, self) + # this is a dict of card identities which different parts of the code might populate, + # typically with something like ICCID, EID, ATR, ... + self.identity = {} # make sure the class and selection control bytes, which are specified # by the card profile are used @@ -138,6 +141,8 @@ class RuntimeState: # select MF to reset internal state and to verify card really works self.lchan[0].select('MF', cmd_app) self.lchan[0].selected_adf = None + # store ATR as part of our card identies dict + self.identity['ATR'] = atr return atr def add_lchan(self, lchan_nr: int) -> 'RuntimeLchan':