In case try to decode the contents of an uninitalized EF.IMSI, the
function dec_imsi() would crash because it truncates all 0xFF from the
swapped version of the EF.IMSI contents and then accesses the first
element of the buffer. This always works for EF.IMSI contents that
contain valid IMSI data, but if all bytes are set to 0xFF, then no data
is left in the buffer after truncating, so lets check if we even have
bytes left before we move on with the decoding.
Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c
The lower part of gen_parameters() in pySim-prog.py contains some code
that checks whether the ADM pin supplied in its hexadecimal or in its
string form and generates a sanitised pin_adm from that. Lets separate
this part as it may become useful elsewhere too.
Change-Id: Ifead29724cc13a91de9e2e89314d7fb23c063d50
A MNC of 02 and 002 are *not* equal. The former is a two-digit MNC
and the latter is a three-digit MNC. Hence, we shouldn't treat
MNCs as integer values as we have no clue how many leading zeroes
(if any) the user entered.
Change-Id: I9d1d07a64888c76703c3e430bbdd822080c05819
Closes: OS#4523
pySim-prog and pySim-read currently echo back the pcsc reader id (or
baudrate/socket, depending on the interface used). This makes the output
unecessarly undeterministic, which becomes a problem when verifying the
putput in tests. Lets not echo those variable, user supplied parameters
back. Also lets move the code that does the initalization to utils, so
that it can be used from pySim-prog and from pySim-read (code dup).
Change-Id: I243cc332f075d007b1c111292effcc610e874eb3
Related: OS#4503
The hex string consists of contains zero or more ePDG identifier data objects.
Each ePDG Identifier TLV data object consists of tag value of '80', length, address type, identifier.
TS 31.102 version 13.4.0 Release 13. The same parsing method applies for both EF.ePDGId and EF.ePDGIdEm
Change-Id: I96fb129d178cfd7ec037989526da77899ae8d344
The functions are imported from the git commit 2a81963790e27eb6b188359af169c45afb6d3aaf from master branch
Change-Id: I5c7fdbd122e696d272f7480785d0c17ad2af138c
This method helps in printing Service Tables in EF.SST, EF.UST, EF.IST.
Takes hex string of Service table, parses it and prints available service along with its description.
Change-Id: Ie1e82e07ead2e28314a5794661e6b2ced0acd72a
This method helps in parsing Service Tables in EF.SST, EF.UST, EF.EST, EF.IST.
Takes hex string as input and output a list of available/enabled services.
Change-Id: I9b72efdb84ba7be4a40928a008a59c67f6fb71d4
This change implements programming of EF.MSISDN as per 3GPP TS 31.102,
sections 4.2.26 and 4.4.2.3, excluding the following fields:
- Alpha Identifier (currently 'FF'O * 20),
- Capability/Configuration1 Record Identifier ('FF'O),
- Extension1 Record Identifier ('FF'O).
This feature is introduced exclusively for sysmoUSIM-SJS1.
Othere SIM card types need to be tested.
Change-Id: Ie033a0ffc3697ae562eaa7a241a0f6af6c2b0594
This change implements parsing of EF.MSISDN (and thus EF.ADN)
as per 3GPP TS 31.102, sections 4.2.26 and 4.4.2.3.
Example (commercial SIM card from 401/02):
EF.MSISDN: ffffffffffffffffffffffffffff07917787028982f7ffffffffffff
Decoded (NPI=1 ToN=1): +77782098287
Note that sysmoUSIM-SJS1 in the test setup has malformed
EF.MSISDN, so that's why the test output is changed.
Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
In case the MCC/MNC are not supplied with a CSV file we cut out the
missing values from the IMSI string. Lets use a function to do this and
also check the input parameters.
Change-Id: I98e5bf8f9ff2a852efb190cc789edf42c5075bf8
At the moment MNC and MCC are represented as integer numbers inside the
parameter array while all other parameters are represented as strings.
Lets use strings for MNC/MCC as well to simplify the parameter handling.
We will also not loose the length information in case of leading zeros.
Change-Id: Ia2333921a4863f0f26ee923ca796e62ec5e2d59a
Allow decoding and pretty printing of PLMNwAcT, HPLMNwAcT and OPLMNwAct.
Includes unit tests for the added functions.
Change-Id: I9b8ca6ffd98f665690b84239d9a228e2c72c6ff9
When programming or reading a SIM with an IMSI shorter than 15, the IMSI
value is incorrectly encoded/decoded.
The code pads the the IMSI value with 0xF from the left but padding from
the right would be correct.
It also encodes the length as half the number of digits in the IMSI
(rounded up). This isn't correct for even length IMSIs. With even length
IMSIs, the odd/even parity bit bumps the last digit into an extra byte,
which should be counted as well.
- Fix endcoding of IMSI value
- Fix decoding of IMSI value
Change-Id: I9ae4ca4eb7c2965e601a7108843d052ff613beb9
Patch-by: Ben Foxmoore
Closes: SYS#3552
It should fix the following observed error:
~/pysim$ ./pySim-read.py -p0
Reading ...
ICCID:
Traceback (most recent call last):
File "./pySim-read.py", line 99, in <module>
print("IMSI: %s" % (dec_imsi(res),))
File "/home/lab434/pysim/pySim/utils.py", line 57, in dec_imsi
l = int(ef[0:2]) * 2 # Length of the IMSI string
ValueError: invalid literal for int() with base 10: 'ff'
Change-Id: I7d3ecbf9edd190d1941816796cee60e3957d5943