laforge submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: laforge: Looks good to me, approved jolly: Looks good to me, but someone else must approve Jenkins Builder: Verified
ts_102_221: decode the termination state of the life cycle status

LifeCycleStatusInteger._from_bytes() tested the operational states
before the termination state and looked for termination in b8 b7
(mask 0xc0). The operational patterns leave b4 free, so '0C'..'0F'
decoded as operational, and the termination test could only match a
proprietary value.

Test the proprietary indicator (any of b8..b5 set) first, then the
termination state (b4 b3 = 1 1, mask 0x0c), then the operational
states, and add a termination vector to _test_de_encode.

The folder osmocom-pysim-lcsi-termination of
hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis
and a repro.

Change-Id: If9b0f1a42f854221ac71701f5d19a389b41671e0
---
M pySim/ts_102_221.py
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index 6a64f2b..5135b36 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -236,21 +236,28 @@
class LifeCycleStatusInteger(BER_TLV_IE, tag=0x8A):
_test_de_encode = [
( '8a0105', 'operational_activated' ),
+ ( '8a010c', 'termination' ),
]
def _from_bytes(self, do: bytes):
lcsi = int.from_bytes(do, 'big')
- if lcsi == 0x00:
+ # TS 102 221 table 11.7b: a value with any bit set in b8..b5 is
+ # proprietary, and none of the states below apply to it.
+ if lcsi & 0xf0:
+ ret = lcsi
+ elif lcsi == 0x00:
ret = 'no_information'
elif lcsi == 0x01:
ret = 'creation'
elif lcsi == 0x03:
ret = 'initialization'
+ elif lcsi & 0x0c == 0x0c:
+ # b4 b3 = 1 1 is the termination state. It has to be tested
+ # before the operational states, whose patterns leave b4 free.
+ ret = 'termination'
elif lcsi & 0x05 == 0x05:
ret = 'operational_activated'
elif lcsi & 0x05 == 0x04:
ret = 'operational_deactivated'
- elif lcsi & 0xc0 == 0xc0:
- ret = 'termination'
else:
ret = lcsi
self.decoded = ret

To view, visit change 43980. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: If9b0f1a42f854221ac71701f5d19a389b41671e0
Gerrit-Change-Number: 43980
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: jolly <andreas@eversberg.eu>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-CC: hampushellsberg <hampushellsberg@gmail.com>