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
The method send_apdu() first transmits the APDU in the cards direction.
The card may indicate that there is a response available by responding
with SW1=9F, where SW2 is the number of bytes. send_apdu() will then
craft a get-response APDU to pickup the response bytes. This mechanism
works fine for SIM, but USIM uses SW1=61 to indicate the availability
of a response, so lets also sense on SW1=61 to support USIMs as well.
- Also check on SW1=61 to see if a response is available
Change-Id: Ied7fb78873a7c4109de471c7a5e9c3701ba0c7d5
Related: SYS#4245
with Change I38f5d36d16b41b5d516a6a3e2ec1d09637883932, new constants
for file identifiers were introduced. When csv file input is used,
then pySim-prog.py uses one of these constans without importing
it from ts_51_011.py
- Add missing import
Change-Id: Ic5b067b16ec204c2ba2264b1ffb48d37be8d5eb3
The method send_apdu_checksw() is used to check the SW of the final
response against some pre defined value. However, in many cases the
last two digits of the SW are used to return varying information
(e.g. length information or a more specific status info). To cover
those cases it would be helfpul to define status words that contain
wildcards (e.g. 61**) in order to be able to accept all SWs from
6100 to 61ff.
- When the user supplies an expected SW with wildcards, mask out
those digits in the response before comparing
Change-Id: I5bfc0522b4228b5d9b3415f6e708abcf0da0a7b7
At the momemnt pysim takes the supplied ADM pin number and interprets
it as ascii string. This ascii string (max 8 digitis) is then padded
with 0xff bytes if necessary and sent to the card.
This limits the range of possible ADM keys and it is not possible
to deal with situataions where the ADM pin consists of arbitrary
bytes. At the momemnt pysim-prog forbis anything that is longer
than 8 digits. Lets also check if there are 16 digits and if yes
interpret them as raw bytes.
- when the adm pin is 16 digits long, interpret the string as raw
bytes (hex).
Change-Id: If0ac0d328c64b57bc4d45d985a4a516930053344
Related: SYS#4245
This reverts commit a51592e180, which
broke the use of ADM pins on sysmoUSIM-SJS1 (and possibly others?)
The ADM pins have so far always been specified as ASCII decimal digits,
i.e. something like "-a 53204025" gets translated to hex "3533323034303235"
After the above patch this is broken and gets instead translated to
"53204025ffffffff" in hex which obviously breaks. Let's revert back to
the old behavior to make it work again.
Change-Id: I3d68b7e09938a2fcb7a9a6a31048388cc3141f79
pySim has been using magic numbers to access various files which makes it hard
to read, maintain and extend. With this file in place we can start replacing all
those magic numbers with human readable names lile EF['IMSI'] instead of
['3F00', '7F20', '6F07'].
Change-Id: I38f5d36d16b41b5d516a6a3e2ec1d09637883932
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
Nowadays bin/python usually points to python3, and this script is written
in python2, which means if run directly from terminal it will fail with
some print syntax errors.
Change-Id: I6ab4e9edc44a8045915d4828c6de2fa98027fb7e
The programming procedure for sysmo-usim-sjs1 lacks
writing the ICCID. This commit adds the missing call
to update_binary()
Change-Id: Ief85aa07c562d8d7b2a6dec302d2f485d0b1e577
sysmo-usim-sjs1 requires P2 to be set to 0x0C (request FCI) when
using the USIM application commands. The FCI is not used by pysim
anyway and might even cause problems with other cards.
This commit adds a pair of get/set methods to the SimCardCommands
class in order to set a default for the selection control
parameters (P1, P2). (Similar to the set/get methods for the class
byte)
The SysmoUSIMSJS1 class now calls the setter method for the
selection control parameters inside of its constructuor and sets
the selection control parameter default to "000C". This way we
can be sure that we only change the behaviour for sysmo-usim-sjs1
and do not break support for any other cards.
Change-Id: I1993a267c952bf37d5de1cb4e1107f445614c17b
Rather than just having the capability of writing to CSV, it now
has the capability to (re)write a card based on data from the CSV:
./pySim-prog.py -S csv --read-csv /tmp/sim.csv -i 901701234567890
or in batch mode (from the first line onwards):
./pySim-prog.py -S csv --read-csv /tmp/sim.csv --batch -j 1