laforge has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/37937?usp=email
)
Change subject: commands: avoid double lchan patching, get rid of cla_byte getter+setter
methods
......................................................................
commands: avoid double lchan patching, get rid of cla_byte getter+setter methods
The SimCardCommands has a cla_byte @property method, which automatically
returns the lchan patched CLA byte. We use cla_byte property to build
the UICC command APDUs inside SimCardCommands and then we hand the APDU
over to the send_apdu* methods. The cla_byte @property method as well
as the send_apdu* methods perform the lchan patching. This means the CLA
byte gets patched twice, which is technically not an issue, but can be
confusing when trying to understand the code.
To fix this, let's remove the @property methods and turn cla_byte into
a normal property again. This is also more accurate since the cla_byte
property originally was introduced to switch between UICC and classic
SIM APDU commands, which have almost identcal APDUs.
Related: OS#6531
Change-Id: I420f8a5f7ff8d9e5ef94d6519fb3716d6c7caf64
---
M pySim/commands.py
1 file changed, 1 insertion(+), 12 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/commands.py b/pySim/commands.py
index 656f71a..f13e18b 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -66,7 +66,6 @@
byte by the respective instance. """
def __init__(self, transport: LinkBase, lchan_nr: int = 0):
self._tp = transport
- self._cla_byte = None
self.sel_ctrl = "0000"
self.lchan_nr = lchan_nr
# invokes the setter below
@@ -76,16 +75,11 @@
def fork_lchan(self, lchan_nr: int) -> 'SimCardCommands':
"""Fork a per-lchan specific SimCardCommands instance off the
current instance."""
ret = SimCardCommands(transport = self._tp, lchan_nr = lchan_nr)
- ret.cla_byte = self._cla_byte
+ ret.cla_byte = self.cla_byte
ret.sel_ctrl = self.sel_ctrl
return ret
@property
- def cla_byte(self) -> Hexstr:
- """Return the lchan patched default CLA value for this
card."""
- return cla_with_lchan(self._cla_byte, self.lchan_nr)
-
- @property
def max_cmd_len(self) -> int:
"""Maximum length of the command apdu data section. Depends on
secure channel protocol used."""
if self.scp:
@@ -93,11 +87,6 @@
else:
return 255
- @cla_byte.setter
- def cla_byte(self, new_val: Hexstr):
- """Set the (raw, without lchan) default CLA value for this
card."""
- self._cla_byte = new_val
-
def send_apdu(self, pdu: Hexstr, apply_lchan:bool = True) -> ResTuple:
"""Sends an APDU and auto fetch response data
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/37937?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I420f8a5f7ff8d9e5ef94d6519fb3716d6c7caf64
Gerrit-Change-Number: 37937
Gerrit-PatchSet: 4
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>