pysim/pySim
Vadim Yanitskiy c8458e2477 pySim/utils.py: fix 3-digit MNC encoding in enc_plmn()
The bug that was attempted to be fixed in [1] actually was in the
encoding API - pySim.utils.enc_plmn().  According to 3GPP TS 31.102,
which points to TS 24.008, the three-digit (E)HPLMN shall be encoded
as shown below (ASCII-art interpretation):

    0   1   2   3   4   5   6   7
  +---+---+---+---+---+---+---+---+
  |  MCC Digit 2  |  MCC Digit 1  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 3  |  MCC Digit 3  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 2  |  MNC Digit 1  |
  +---+---+---+---+---+---+---+---+

while pySim.utils.enc_plmn() would produce the following:

    0   1   2   3   4   5   6   7
  +---+---+---+---+---+---+---+---+
  |  MCC Digit 2  |  MCC Digit 1  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 1  |  MCC Digit 3  |
  +---+---+---+---+---+---+---+---+
  |  MNC Digit 3  |  MNC Digit 2  |
  +---+---+---+---+---+---+---+---+

Initially the _decoding_ API was correct, but then got changed in
[1] to follow buggy pySim's encoding API.  As a result, a (E)HPLMN
programmed with pySim-prog.py would look correct if verified by
pySim-read.py, but the actual file content would be wrong.

This situation shows that our 'program-read-match' build verification
approach alone is insignificant.  The lack of unit test coverage,
at least for the core parts of the project, makes it possible to have
symmetrical bugs in both encoding and decoding API parts unnoticed.

This problem was found while trying to enable dead unit tests in [3].
Change [1] that introduced a symmetrical bug is reverted in [2].

Change-Id: Ic7612502e1bb0d280133dabbcb5cb146fc6997e5
Related: [1] I799469206f87e930d8888367890babcb8ebe23a9
Related: [2] If6bf5383988ad442e275efc7c5a159327d104879
Related: [3] I4d4facfabc75187acd5238ff4d0f26022bd58f82
2021-03-12 01:00:32 +01:00
..
transport Get rid of Python 2 specific compatibility leftovers 2021-03-11 22:59:21 +01:00
__init__.py cosmetic: missing newlines on last line of 2 files 2017-03-21 13:07:57 +01:00
card_handler.py Remove Python shebang from files where it's not needed 2021-03-01 17:33:46 +01:00
cards.py start using python3 bytearray for our b2h/h2b types 2021-03-03 08:37:50 +01:00
commands.py commands.py: Introduce a real select_file() method 2021-03-02 14:26:32 +01:00
exceptions.py Get rid of Python 2 specific compatibility leftovers 2021-03-11 22:59:21 +01:00
filesystem.py Add a new pySim-shell program 2021-03-03 08:43:38 +01:00
ts_31_102.py Add a new pySim-shell program 2021-03-03 08:43:38 +01:00
ts_31_103.py Add a new pySim-shell program 2021-03-03 08:43:38 +01:00
ts_51_011.py ts_51_011: fix bitmask compositing in EF_xPLMNwAcT.enc_act() 2021-03-07 21:52:13 +01:00
ts_102_221.py Add a new pySim-shell program 2021-03-03 08:43:38 +01:00
utils.py pySim/utils.py: fix 3-digit MNC encoding in enc_plmn() 2021-03-12 01:00:32 +01:00