the sim-rest-server is a minimal HTTP/RESTful API for performing
UMTS-AKA against a SIM card inserted in a locally reachable PC/SC
reader. Let's add s systemd service/unit file for people wanting to
run this service from systemd.
Change-Id: I84b390af09d33de2c740898ff3d7d5a90a300588
CardProfileSIM is currenty instantiated directly. However, it should be
implemented as class and then instaniated later like CardProfileUICC
Change-Id: I37d49b11a07ce5a80d1a703fab4620b7d1ecb25b
Currently we call the reset_card and get_atr methods directly at the
transport layer via the private _scc and _tp object of the card. This is
a violation. Fix and use the reset methods that are already in the
SimCard object.
Change-Id: I0e9d2a62a42a7387e7ca69d2ae830782a61aed89
There are situations where it is necessary to modify the class byte and
the selection control bytes of a card at runtime. This should not be
done by accessing the properties of the _scc object directly. The
modification of those properties should be done via a set method
instead.
Change-Id: Ifd8aa2660e44a18d28945d070419612eff443e78
A number of new commands were recently introduced without proper
coverage in the documentation (user manual). This includes equip,
bulk_script and others.
Change-Id: Ide7ba68ad90f6e5c2a41a2e3de22534258ebb7fd
We cannot simply skip anything that has 0xFF as first byte to detect
the padding after the end of a TLV object:
0xFF may very well be a valid first octet of a multi-octet TAG:
Tags of private class (11) with constructed (1) payload will have 0xFF
as first octet.
So let's expand the check to only detect padding in case of either only
a single byte FF being left, or two FF following each other [with
whatever suffix].
Change-Id: I5d64ce9ef1d973804daabae0b15c2e2349e6fab9
When calling from_dict() on a hierarchy of nested BER_TLV_IE,
only the first/outer layer of TLV_IE_Collection would get its
'decoded' initialized correctly from the dict. Subsequent layers
were not, as the 'decoded=' was passed as parameter during instance
initialization. If we first instantiate the class and then call the
from_dict() method, the recursive initialization down the full hierarchy
works as expected.
Change-Id: I795a33ed8dfa8454dc9079c189ab7b2ba64a3b72
There are instances where a TLV IE is used as just a flag, i.e.
length zero and no value part. In those situations, it would require
a lot of boilerplate code to require the TLV_IE class definitions to
have _to_bytes/_from_bytes methods that do nothing.
So instead, add a shortcut: If we want to encode 'None', then return
b'', and if we want to decode b'' return None.
Change-Id: Ie8eb2830e8eefa81e94b8b8b157062c085aeb777
GSM-R SIM cards have an additional directory (DF.EIRENE) with a number
of files. This is all specified in the following document:
UIC Reference P38 T 9001 5.0 "FFFIS for GSM-R SIM Cards"
Change-Id: I4034d09292a08d277d4abcbed9a0ec2808daaacb
There are scenarios where multiple cards need to get the same change.
Lets add a new command that takes a script as parameter and executes the
secript in a loop on multiple cards while prompting the user to change
the card before starting the next cycle.
Change-Id: I9e4926675c5a497a22fc6a4fefdd388fe18a2b2d
Related: SYS#5617
In change Id410489841bb9020ddbf74de9114d808b1d5adb6, the RuntimeState
class automatically adds additional files to the CardApplications for
ISIM and USIM. This works only once. The second time an exception will
be thrown because the added files are already in the CardApplication.
Currently there is no way generate new card applications during
initialization because the card applications are just objects that are
created once in ts_31_10x.py. Lets turn them into classes and create the
objects during initialization. This way we get fresh objects when we
re-initialize.
Change-Id: Ibb4f6242e7a92af84a905daa727b1b87016e7819
you can use this like that:
./pySim-shell.py -p0 --script ./scripts/sysmoISIM-SJA2/dump-auth-cfg.pysim
Change-Id: I5eac1af63d586f2371f519a160e1005fcbb27bfb
Similar to the fix in Ie1aeaab29701946233ed73db3331039690d695da
for update_binary(), read_binary() also contained a bug when treating
non-zero offsets.
Change-Id: Ic5c2f0ad1c1ec9c4e9c97e72895382f7b6fa9470
Related: OS#5254
Currently a card must be present in the reader until the user can enter
pySim-shell. Removing and plugging another card is in theory already
possible, but then the new card will operate on the old card and runtime
state object. It might also be useful to enter pySim-shell before the
card is plugged to execute some other commands for preperation before.
So lets allow to "equip" pySim-shell with a card and rs object at
runtime.
Related: SYS#5617
Change-Id: I9cf532d9da8203065463c7201e7064de6c7ab1b5
The select response decoder is using b2h() wrongly. b2h expects
a bytearray but we call it with an integer. In the following two
lines we try to convert an integer to an integer.
Change-Id: Ib6448d3bd7a0dc7f25e5ee82a42266b3313e2a95
In Icc240d5c8c04198640eb118565ea99f10ba27466 we introduced support for
writing files > 255 bytes by splitting the write into multiple chunks.
However, at the same time, that commit broke support for writing data at
non-zero offsets. Unfortunately, this is used extensively within
pySim-prog e.g. for writing K + OP/OPc data to sysmoISIM-SJA2 and sysmoUSIM-SJS1
cards.
This commit fixes the related problem.
Change-Id: Ie1aeaab29701946233ed73db3331039690d695da
Fixes: Icc240d5c8c04198640eb118565ea99f10ba27466
Closes: OS#5254
Before:
EXCEPTION of type 'NotImplementedError' occurred with message: ''
After:
EXCEPTION of type 'NotImplementedError' occurred with message: 'EF(EF.SST) encoder not yet implemented. Patches welcome.'
Change-Id: Ie8a10a8847f7c7c6a3332fb9f78de18c9f7f41d0
The card_detect function in cards.py allows to specify the card type or
use the hints "auto" and "auto_once" to trigger autodetection of the
card. However, "auto_once" has no effect and is not used by any caller,
so lets remove it.
Change-Id: Iea726f51e5ddb43d8a4da2672552fff38e29b006
* introduce type annotations
* introduce + derive implementations from base class
* move shared code to base class
Change-Id: I7168506cbebb1ebb67f47453419b860824912051
The code in __main__ which initalizes the reader and the card and
runtime state is not so well structured. Lets put the generation of the
card and rs (RuntimeState) object into a separate function. Also do not
wait indefinetly for a card. 3 seconds should be enough. If the card or
reader did not respond until then, then there will be a problem in any
case.
Change-Id: Id2a0f2012b84ce61f5c0c14404df559fca4ddfcd
Related: SYS#5617
The FairwavesSIM programming fails when the card is accessed with USIM
APDUs. To keep it working temporarly switch to SIM APDUs during
programming.
Change-Id: I8f02625d2b620ecdf4b2afc27a8750119b707152
When verify_adm is used with scripts, especially bulk provisioning, then
an exception is far more visible and allows us to spot problems with ADM
verification quicker.
Change-Id: I4162b43754efd061b6b9058b7ff8e1fc985e3538
Related: SYS#5617
The constructor gets an sl object on initalization. The card handler
will then carry out the reader operation wait_for_card().
In cases where an mechanically automated card reader is used it may
be useful to go without those operations and let the caller carry out
the appropriate reader operations. So Lets make the sl object
optional for the CardHandlerAuto class. If it is not present, simply
do not carry out the pre programmed reader operation.
Change-Id: I0f793aec51751b7c7b87d55b66326cce9970274e
Related: SYS#5617
Make sure that a reader is disconnected before connecting it. This will
efectively prevent resource leakage in the lower PCSC layers when the
reader is connected multiple times during bulk provisioning
Change-Id: I266e56f2330da25c680a76f4c0ca630a38e1f61b
There may be corner cases where an execption contains no error message.
In this case it might still be helpful to display the type of the
exeption calss to get at least an idea of what kind of error we are
dealing with.
Change-Id: I6e6b3acd17e40934050b9b088960a2f851120b26
The option and also the dest variable in the code are currently named
card_handler. This might be confusing since the variable actually refers
to a config file and therefore should be called "card_handler_config"
Change-Id: If93751e815cb46f9ff3f56b54e612d77fe1a6dfd
Almost all pySim-shell related commands are agrgated in PySimCommands.
There are a few exceptions, so there are some commands in PysimApp.
However, it makes sense to reserve PysimApp exclusively for very basic
commands that do not directly relate to card operations. So lets move
the command verify_adm and desc to PySimCommands.
Change-Id: I4a215c8a3907d69f702a70df9b85988be1ce3dbf
In OOP, we usually use capital letters for class names. The card handler
class should be no execption.
Change-Id: I4b2c06b1c607c993c9aaf0d57ad2352bb6b36e74
The variable card_handler is assigned in the following way:
card_handler = card_handler(sl)
This may cause problems since the class name and the variable name are
the same. Lets rename card_handler to avoid problems here.
Change-Id: I84dafc49862e373ae9f6a56bd2e8d1a02c27430a