aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-02-25 09:35:28 +0100
committerHarald Welte <laforge@osmocom.org>2022-02-25 09:37:40 +0100
commit5e9bd93bbd4213763ff1c7bbc340c1e0fcf55ed8 (patch)
tree52fee0a83d6ba1472e029211f9a64783604fc828
parentfa578bd6015853d05979e8a37220d1d33b2723e1 (diff)
ts_102_221: properly decode short file identifier
The SFI TLV contanins not the raw SFI, but it contains the SFI shifted to left by 3 bits (for some strange reason). So let's un-shift it. Change-Id: Ibc69b99010d2a25cbb69b6a3d1585d0cb63f1345
-rw-r--r--pySim/ts_102_221.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index ac2a60e..708b50b 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -186,7 +186,14 @@ class SecurityAttribReferenced(BER_TLV_IE, tag=0x8b):
# ETSI TS 102 221 11.1.1.4.8
class ShortFileIdentifier(BER_TLV_IE, tag=0x88):
- _construct = HexAdapter(COptional(Bytes(1)))
+ # If the length of the TLV is 1, the SFI value is indicated in the 5 most significant bits (bits b8 to b4)
+ # of the TLV value field. In this case, bits b3 to b1 shall be set to 0
+ class Shift3RAdapter(Adapter):
+ def _decode(self, obj, context, path):
+ return obj >> 3
+ def _encode(self, obj, context, path):
+ return obj << 3
+ _construct = COptional(Shift3RAdapter(Byte))
# ETSI TS 102 221 11.1.1.4.9
class LifeCycleStatusInteger(BER_TLV_IE, tag=0x8A):