From 321973ad202a897faa61f7b35f62f3d9237b928e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 1 Feb 2024 18:43:48 +0100 Subject: [PATCH] pySim-shell: Make 'apdu' command use logical (and secure) channel The 'apdu' command so far bypassed the logical channel and also the recently-introduced support for secure channels. Let's change that, at least by default. If somebody wants a raw APDU without secure / logical channel processing, they may use the --raw option. Change-Id: Id0c364f772c31e11e8dfa21624d8685d253220d0 --- pySim-shell.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pySim-shell.py b/pySim-shell.py index abe0b5fa..89fdf6ed 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -237,6 +237,7 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/ apdu_cmd_parser = argparse.ArgumentParser() apdu_cmd_parser.add_argument('APDU', type=is_hexstr, help='APDU as hex string') apdu_cmd_parser.add_argument('--expect-sw', help='expect a specified status word', type=str, default=None) + apdu_cmd_parser.add_argument('--raw', help='Bypass the logical channel (and secure channel)', action='store_true') @cmd2.with_argparser(apdu_cmd_parser) def do_apdu(self, opts): @@ -249,7 +250,10 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/ # 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.send_apdu(opts.APDU) + if opts.raw: + data, sw = self.card._scc.send_apdu(opts.APDU) + else: + data, sw = self.lchan.scc.send_apdu(opts.APDU) if data: self.poutput("SW: %s, RESP: %s" % (sw, data)) else: