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
The normal description can be accessed with `python3 setup.py --description`. The long description can be accessed with `python3 setup.py --long-description`.
Change-Id: I1581a2b9ad7c2b5ed64b77e5e277df792b37990d
The T0 protocol (selected in transport/pcsc.py) does not support extended APDU, so 255 bytes is the maximum number of bytes that can be transmitted at a time. We can divide large data into 255 byte chunks. The read_binary function already has code to read more than 255 bytes, so we can just adapt it to the update_binary function.
Change-Id: Icc240d5c8c04198640eb118565ea99f10ba27466
There are the classes IsimCard and UsimCard, which inheret from Card,
which is the base class for a normal non ISIM/USIM simcard. Card also
has methods in it that are related to simcards, so it is not just any
"Card", it is a SimCard and should be called that way.
Change-Id: I2077ded44bc2297b8d478c5bd1895951b494efcc
The USIM EF.AD has quite some more bits, it should have a separate
implementation and not reuse te DF.GSM/EF.AD implementation.
Change-Id: Iaf195cb63d5d12fc906a7e7cd85e3fd44589a41e
This adds an easy way for files to make use of the pySim.tlv parser.
All a file has to do is to specify a _tlv member which points to
either a TLV_IE or a TLV_IE_Collection instance.
Change-Id: I59f456b4223ec88081e91cee168b654c69bcb5f4
This introduces a new TLV library that heavily builds upon python object
oriented concepts. Contrary to classic TLV parsers it doesn't focus on
the structure of Tag, Length and binary Value only, but it supports
actual decoding/interpretation of the value part into some kind of JSON
serializable dict. The latter can be achieved by imperative
encode/decode methods, or by using our existing declarative 'construct'
based approach.
The TLV library supports both BER-TLV and COMPREHENSION-TLV for both
nested and non-nested TLV definitions.
As an example we include TLV definitions for a number of CAT (Card
Application Toolkit) IEs.
Change-Id: I7fc1699443bc9d8a4e7cdd2687af9af7cc03c30e
If we want to use construct parse results to generate JSON serializable
dicts, we need to
* apply the filter_dict() operation recursively, and
* simplify the construct Container and ListContainer classes to
a simple dict and/or list.
We introduce a pySim.construct.parse_construct() helper which is
subsequently used from all pySim.filesystem caller sites.
Change-Id: I319414eb69808ef65895293832bb30519f45949d
The existing {comprehension,ber}tlv_parse_tag() functions are
decoding the tag to a high level of detail. However, all the 3GPP
specs seem to deal with the 'raw' version, i.e something like
0xD1 as a single-byte tag with the class + constructed fields already
shifted next to the actual tag value.
Let's accommodate that with new *_parse_tag_raw() functions.
Change-Id: Ib50946bfb3b3ecd7942c423ac0f98b6c07649224
We cannot re-activate a deactivated file after we have selected somethng
else, as SELECT will fail on the deactivated file. Hence, the
deactivate_file command needs to be used with a file name as argument.
Change-Id: Ief4d2bf8ea90497a8f25d1986aeea935c615f9bb
According to ETSI TS 102 221 Section 7.2.2.3.1 Table 7.1 the UICC
may respond with SW 6Cxx to tell us to re-issue the command with
a modified P3/Le.
Change-Id: Ia7e6202bbd0f61034a985ecf76d0542d959922ce
sim-rest-server.py can be used to provide a RESTful API to allow remote
clients to perform the authentication command against a SIM card in a
PC/SC reader.
sim-rest-client.py is an example client against sim-rest-server.py
which can be used to test the functionality of sim-rest-server.py.
Change-Id: I738ca3109ab038d4f5595cc1dab6a49087df5886
There's little point in having a getter+setter for a property if
all it does is assigning a value to an attribute of self. That
works without any property methods
Change-Id: Id214cc83a29e8aa88f4e1413e07b419285c1b7ff
The code uses self.sel_ctrl everywhere except in the two @property
methods, where the _sel_ctrl variable is used. Let's just abandon
those property methods and make sure all users directly use the
[public] sel_ctrl member variable.
Change-Id: I10362300c1cf7b493d89bf71bbd3a10c80ef9a49
The updated wording better reflects the actual meaning
of a set or unset flag, especially as OPLMN is inverted.
Change-Id: I65c6f0e9bc1a12a4a74c4274eebb8e612296888f
The encoder/decoder functions in class EF_PCSCF look rather unfinshed
because of problems with dec_addr_tlv(), since those problems are fixed
by a previous patch we can now finish the decoder function and fix the
decoder as well.
Change-Id: I7613b8b71624dc5802aca93163788a2a2d4ca345
Related: OS#4963