mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-17 02:48:34 +03:00
utils: fix encoding of EF.MSISDN
The encoding of EF.MSISDN is a bit unstrutured. The encoder function does not return a valid result since it lacks the parameters Capability/Configuration2 Record Identifier and Extension5 Record Identifier, which are mandatory but can be set to 0xFF. Also the encoder gets its input from pySim-shell, so it should have some more input validation, especially when the user encodes an empty string. The encoder and decoder function also do not have unit-tests. Since the encoder now adds the missing two bytes by isself this does not have to be done manually anymore, so cards.py needs to be re-aligned. For pySim-shell.py the encoder is used from ts_51_011.py. Unfortunately it is used wrongly there. The optional Alpha Identifier is required here as well. Related: OS#4963 Change-Id: Iee5369b3e3ba7fa1155facc8fa824bc60e33b55b
This commit is contained in:
@@ -377,11 +377,13 @@ class EF_SMS(LinFixedEF):
|
||||
# TS 51.011 Section 10.5.5
|
||||
class EF_MSISDN(LinFixedEF):
|
||||
def __init__(self, fid='6f40', sfid=None, name='EF.MSISDN', desc='MSISDN'):
|
||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len={15, None})
|
||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len={15, 34})
|
||||
def _decode_record_hex(self, raw_hex_data):
|
||||
return {'msisdn': dec_msisdn(raw_hex_data)}
|
||||
def _encode_record_hex(self, abstract):
|
||||
return enc_msisdn(abstract['msisdn'])
|
||||
encoded_msisdn = enc_msisdn(abstract['msisdn'])
|
||||
alpha_identifier = (list(self.rec_len)[0] - len(encoded_msisdn) // 2) * "ff"
|
||||
return alpha_identifier + encoded_msisdn
|
||||
|
||||
# TS 51.011 Section 10.5.6
|
||||
class EF_SMSP(LinFixedEF):
|
||||
|
||||
Reference in New Issue
Block a user