aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-shell.py
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2023-11-29 13:04:09 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2023-11-29 15:24:10 +0100
commit1c207a24994a9125f80c015e78239f2cf63707ec (patch)
treeaf78f7a85e0972cc1787dcdff0a1c2d64c4af649 /pySim-shell.py
parenteb3b0dd3797ffa00afb1d500dd0ad5f8b5d6a146 (diff)
pySim-shell: Do not use self.lchan.scc when sending raw APDUs.
When sending raw APDUs, we access the scc (SimCardCommands) object via the scc member in the lchan object. Unfortunately self.lchan will not be populated when the rs (RuntimeState) object is missing. This is in particular the case when no profile could be detected for the card, which is a common situation when we boostrap an unprovisioned card. So let's access the scc object through the card object. This is also more logical since when we send raw APDUs we work below the level of logical channels. Change-Id: I6bbaebe7d7a2013f0ce558ca2da7d58f5e6d991a Related: OS#6278
Diffstat (limited to 'pySim-shell.py')
-rwxr-xr-xpySim-shell.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/pySim-shell.py b/pySim-shell.py
index 4e08eb7..3d8bd86 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -237,10 +237,15 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/
@cmd2.with_argparser(apdu_cmd_parser)
def do_apdu(self, opts):
"""Send a raw APDU to the card, and print SW + Response.
- DANGEROUS: pySim-shell will not know any card state changes, and
- not continue to work as expected if you e.g. select a different
- file."""
- data, sw = self.lchan.scc._tp.send_apdu(opts.APDU)
+ CAUTION: this command bypasses the logical channel handling of pySim-shell and card state changes are not
+ tracked. Dpending on the raw APDU sent, pySim-shell may not continue to work as expected if you e.g. select
+ a different file."""
+
+ # When sending raw APDUs we access the scc object through _scc member of the card object. It should also be
+ # noted that the apdu command plays an exceptional role since it is the only card accessing command that
+ # can be executed without the presence of a runtime state (self.rs) object. However, this also means that
+ # self.lchan is also not present (see method equip).
+ data, sw = self.card._scc._tp.send_apdu(opts.APDU)
if data:
self.poutput("SW: %s, RESP: %s" % (sw, data))
else: