Without that we have:
$ python3 pySim-read.py
Using serial reader (port=/dev/ttyUSB0, baudrate=9600) interface
Traceback (most recent call last):
File "pySim-read.py", line 91, in <module>
from pySim.transport.serial import SerialSimLink
File "/home/gnutoo/work/projects/osmocom/pysim/pySim/transport/serial.py", line 29, in <module>
from pySim.exceptions import NoCardError, ProtocolError
File "/home/gnutoo/work/projects/osmocom/pysim/pySim/exceptions.py", line 26, in <module>
import exceptions
ModuleNotFoundError: No module named 'exceptions'
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Change-Id: Ie45dc7ccd72fe077ba3b424f221ff4ed02db436c
Without that fix we have:
$ python3 pySim-read.py
File "pySim-read.py", line 135
try:
^
TabError: inconsistent use of tabs and spaces in indentation
The following command was used to do the conversion:
sed 's# #\t#g' -i $(find -name "*.py")
Then the remaining spaces spotted during the review were
addressed manually.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Change-Id: I83f76a8e9b6e36098f16552a0135a8c22dde545f
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
At the moment we do not chack if the CSV file exists at all. This may
lead into a crash while programming the card. Lets check the CSV file
before we start.
Change-Id: I2643996282d88e512c17901ab0e1181677d5dd6c
Related: SYS#4654
Inside of pySim all CSV headers are defined in lower case and are
evaluated case sensitive. This means that a CSV file that contains the
headers in uppercase for example will not parse. Lets make sure that the
CSV headers are evaluated case insensitive to increase compatibility
with slightly different formats.
Change-Id: I1a476e7fc521d1aad2956feec3db196156961d20
When the CSV file fails to read the error message is just "Error reading
parameters". Lets make clear that this error is related to a problem
with the CSV file
Change-Id: If285c1fbf7d285f512b573040f1b8983e4e3087e
When using the batch mode of pySim-prog, the user has to insert/remove
the cards from the cardreader manually. This is fine for small batches,
but for high volume batches this method is not applicable.
This patch adds support for the integration of an automatic card handler
machine. The user can freely configure a custom commandline that is
executed when a card should be inserted or moved to a good/bad
collection bin.
Change-Id: Icfed3cad7927b92816723d75603b78e1a4b87ef1
Related: SYS#4654
When reading CSV files we currently have no option to provide a
pin_adm_hex field like we already have it as commandline option.
Lets add an option pin_adm_hex for this.
Change-Id: I53e8d666d26a06f580725a8443a335643d10192c
This can be used to reprogram everything including IMSI on the card:
while true; do
./pySim-prog.py -p 0 -t sysmoUSIM-SJS1 --source=csv --read-csv=cards.csv --read-iccid &&
paplay complete.oga
sleep 2
done
Change-Id: Ib343a29141b5255f67a59ab76959b51e162b7916
pySim-prog would implicitly try to use the raw or hex-escaped format
depending on the length of the parameter, now there is the option "-A"
to explicitly specify the hex-escaped ADM1 key.
pysim-test.sh: Explicitly use the "-A" option to pass the hex adm1 key
for wavemobile cards
Change-Id: Id75a03482aa7f8cc3bdbb8d5967f1e8ab45c179a
This way we can have optional fields like pin_adm in the file
Also require iccid as identifier for the SIM card
Set defaults for optional card parameters.
Change-Id: I0d317ea51d0cf582b82157eec6cdec074001a236
Allow decoding and pretty printing of PLMNwAcT, HPLMNwAcT and OPLMNwAct.
Includes unit tests for the added functions.
Change-Id: I9b8ca6ffd98f665690b84239d9a228e2c72c6ff9
This test data is used by the jenkins build verification for pySim,
and it was previously located locally on the build slave.
By moving the testdata to this repository, any contributor can
modify both the code and the expected test results simultaneously.
Change-Id: I6714b091a114035d6aab8ba750c5f2b86e438467
The length field in wavemobile sim cards is not set, so that the field
stays at its initial value, which is 0xFF. Lets write the correct mnc
length here.
Change-Id: Ieda0ce864bf3e8c7b92f062eaa3a5482c98507e2
Related: OS#3850
At the moment EF.AD, which contains the length of the MNC is not
updated. For two digit MNC (the usual case) this is fine since the
length is set to 2 by default. However, when one wants to set an MNC
with 3 digit length the file must be updated, otherwise the third digit
of the MNC is recognized as part of the MSIN.
Change-Id: I827092b2c7f7952f54b2d9f8dbda419a0dbfaf65
Related: OS#3850
The files EF.PLMNsel, EF.PLMNwAcT and EF.OPLMNwAcT are currently not
programmed for sysmo-usim-sjs1, lets add them.
Change-Id: I0cac3041f1902383d98d6dc211cf31ae6e3a610b
Related: OS#3850
The hexadecimal tag defintions of pytlv are case sensitive strings. So
'A5' is something different than 'a5'. Pytlv uses lower case letters for
the upper hexadecimal digits. Lets correct this.
Change-Id: I41a9933707783f6b1b68ebd91a365405ac0892d0
Related: OS#3850
This interface allows to use a Calypso based phone (e.g. Motorola
C1XX) as a SIM card reader. It basically implements a few L1CTL
messages that are used to interact with the SIM card through
the OsmocomBB 'layer1' firmware.
Please note, that this is an experimental implementation, and
there is a risk that SIM programming would fail. Nevertheless,
I've managed to program and read one of my SIMs a few times.
Change-Id: Iec8101140581bf9e2cf7cf3a0b54bdf1875fc51b
The smsc no. programmed by pySim-prog would always be a national number
in the past. Check whether the first 'digit' is a + and indicate that it
is an international number.
Change-Id: Ia79913f5b0307e9786a5acea75c0811927be2eef
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
Add support to handle Wavemobile sim cards. The support excludes some
parameters. For example it is not possible to write own KI keys yet.
Support covers the following files:
EF.SMSP
EF.IMSI
EF.ACC
EF.PLMNsel
EF.PLMNwAcT
EF.OPLMNwAcT
Not yet supported are:
EF.ICCID
KI (propretary file)
OPc (propritary file)
Change-Id: Ida3f37bd6e3ac995812aeddc9770f1ccd54ecf3f
Related: SYS#4245
When sysmosom-gr1 is used with a custom ADM key, then the ADM string is
not fed through h2b() like we see it with sysmo-usim-sjs1 for example.
- feed the ADM to h2b() before use
Change-Id: I0b7cab380b89612ed3b8318e014161038335fe1b
Related: OS#3405
The sysmosim-gr1 lacks the auto detection feature because no autodetect
is yet programmed inside the related class.
- add autodetect for sysmosim-gr1
Change-Id: Iec1f1ab6824ff2328baedd731b08df997df4da01
Related: OS#3405
Some of the USIM-Card programming implementations do not need to look
at card responses, which means they also do not have to parse TLV
data. Lets depend on pytlv only in cases where TLV data has to be
parsed so that useser of cards that do not need at can go without
installing pytlv.
Change-Id: Ida841d74d9581e7f395751b0f74556a06a038de6
So far, the README.md file does not mention much about the
dependencies. This commt adds at lest the most important ones
Change-Id: I912bbf787e1408100183cade2113bf7617b86ffa
Pysim now supports quite a number of different cards. Estimating
if changes in pysim introce regressions becomes increasingly difficult
The script that is added with this patch is intended to run as
atomated testsuit on real cards attached to a test system. However,
it can also be used by developers locally to check for regressions.
Change-Id: I8c6f95998272333bc757b34e3ab6be004e8cd674
Related: OS#3376
The method update_plmnsel() does not return the status word yet, which
causes pysim-prog.py to print an error message that does not influence
the functionality but does not look nice.
- preserve the status word that is returned with update_binary() and
return it properly like the other methods do.
Change-Id: I54e8e165f87365e8162b36d24efc8f0db62b66da
Related: SYS#4245
The files EF.PLMNsel, EF.PLMNwAcT, EF.OPLMNwAcT, EF.HPLMNAcT are not
yet printed by pysim-read. Lets add support for those files.
Change-Id: Ice802033adfa6fc1bccc76da47495eb29c3aef6c
Related: SYS#4245
At the moment the exception is catched, but there is only a vague
error message printed. However, the exception string usually tells
us the status word, so it is very valuable to see it. Lets make
sure that the exception string is printed here.
Change-Id: Icb30470b1c0eee6a15fc028da820e92bf9ded27a
The Card class offers update methods for various EF, but for
PLMNsel there is no update method available yet. Lets add one.
Change-Id: I832f7bef70c92dc101b94ad871b6cafaa626e134
Related: SYS#4245
In some situations it may be helpful to know the card name (type)
we deal with in advance. So lets ad an to probe that only detects
the card and then exists.
- Add commandline option -T --probe
Change-Id: I57422d3819d52fd215ac8f13f890729aad2af76f
Related: OS#3376
Some of the methods SimCardCommands() have ways to determaine length
information from the card response. Regular sims use a format where
the length field is on a fixed position. USIMs use FCP templates
(format control parameters), which is a TLV encodecs string. So lets
distingish if we deal with an USIM (We can easily do this by looking
at the select control parameters) and extract the length info from
the FCP.
- If we deal with USIMs, use the FCP to determine length
information
Change-Id: I068cf8a532e1c79a2d208e9d275c155ddb72713c
Related: SYS#4245