The REST megthd info uses deprecated methods to read the ICCID and the
IMSI from the card. However, we can replace those methods by selecting
the files we are interested in manually and then reading them.
Related: RT#67094
Change-Id: Ib0178823abb18187404249cfed71cfb3123d1d74
The class UsimCard is deprecated and only still used in very old
legacy applications. let's use the more modern UiccCardBase class
instead.
Related: RT#67094
Change-Id: I3676f033833665751c0d953176eafe175b20c14a
When the function connect_to_card is done, it selects ADF.USIM. This
might be contraproductive in case someone needs to access files on MF
level in one of the REST methods. Instead fo ADF.USIM, let's use MF as a
common ground to start from.
At the moment the only existing REST (info, auth) immediately select
ADF.USIM after calling connect_to_card already, so there are no further
modifications necessary.
Related: RT#67094
Change-Id: I16e7f3c991c83f81989ecc4e4764bb6cc799c01d
The method read_iccid in class CardBase should be put back to
legacy/cards.py. The reason for this is that it falls in the same
category like read_imsi, read_ki, etc. We should not use those old
methods in future programs since we have a more modern infrastructure
(lchan) now.
Also pySim-shell.py is the only caller of this method now. It is not
used in any other place.
Related: RT#67094
Change-Id: Ied3ae6fd107992abcc1b5ea3edb0eb4bdcd2f892
This dependency is currently only mentioned in requirements.txt, it
makes sense to also document it here.
Change-Id: I89760dd4008829c91fafbd442483d076c92a7ed4
The package providing the serial python module seems to be called
pyserial, which also matches what's written in requirements.txt.
Change-Id: I71ef6a19a487101e552219f10f2fa6215b966abd
When the command equip (do_equip) is executed, it accesses
self.rs.profile to see if there are any commands that need to be
unregistered before moving on with the card initialization.
However, it may be the case that no runtime state exists at this point.
This is in particular the case when the card is completely empty and
hence no profile is picked and no runtime state exists.
Change-Id: I0a8be66a69b630f1f2898b62dc752a8eb5275301
At the moment we only verify that no exceptions occurred but the output
is not yet verfied.
Related: OS#6094
Change-Id: I3aaa779b5bd8f30936c284a80dbdcb2b0e06985c
When we print the profile applications. which are not registered in
EF.DIR, we use python sets to subtract the applications which were part
of EF.DIR and hence already listed. Since we use sets the order may be
arbitrary. This is so far not a problem, since the output is meant to be
read by humans, but as soon as we try to use the output for unit-test
verifications we need a consistent order (sorted)
Related: OS#6094
Change-Id: Ie75613910aaba14c27420c52b6596ab080588273
We now have pySim-shell and pySim-trace. Let's give pysim-test.sh a more
distinctive name so that it is clear to which program it refers.
Related: OS#6094
Change-Id: I438f63f9580ebd3c7cc78cc5dab13c9937ac6e3a
pySim-trace has no test coverage yet. Let's use a script to run a
GSAMTAP pcacp through it and check that no exceptions are raised.
Related: OS#6094
Change-Id: Icfabfa7c59968021eef0399991bd05b92467d8d2
Card.update_ust() got replaced by the file operation ust_update().
In addition to Change-Id I7a6a77b872a6f5d8c478ca75dcff8ea067b8203e
Fixes: f8d2e2ba08 ("split pySim/legacy/{cards,utils} from pySim/{cards,utils}")
Change-Id: Ie6405cae37493a2101e5089a8d11766fbfed4518
When the trace file end is reaced, pyShark raises a StopIteration
exception. Let's catch this exception and exit gracefully.
Related: OS#6094
Change-Id: I6ab5689b909333531d08bf46e5dfea59b161a79e
The trace log currently does not contain any information about card
resets. This makes the trace difficult to follow. Let's use the
CardReset object to display the ATR in the trace.
Related: OS#6094
Change-Id: Ia550a8bd2f45d2ad622cb2ac2a2905397db76bce
TLV fields holding an address may still be uninitialized and hence
filled with 0xff bytes. Lets interpret those fields in the same way as
we interpret empty fields.
Related: OS#6094
Change-Id: Idc0a92ea88756266381c8da2ad62de061a8ea7a1
The trace log currently only shows the parsed APDU. However, depending
on the problem to investigate it may be required to see the raw APDU
string as well. Let's add an option for this.
Related: OS#6094
Change-Id: I1a3bc54c459e45ed3154479759ceecdc26db9d37
Uninitialized Files, File records or fields in a File record or File
usually contain a string of 0xff bytes. This becomes a problem when the
content is normally encoded/decoded as utf8 since by the construct
parser. The parser will throw an expection when it tries to decode the
0xff string as utf8. This is especially a serious problem in pySim-trace
where an execption stops the parser.
Let's fix this by interpreting a string of 0xff as an empty string.
Related: OS#6094
Change-Id: Id114096ccb8b7ff8fcc91e1ef3002526afa09cb7
When we perform a reset while multiple channels are open (this is in
particular the case when parsing real world traces with pySim-trace). To
delete those channels during the reset we iterate over the dictionary
using the keys and delete the channels one by one. However, this must
not be done using the keys as index directly. Python will then throw an
exception: "RuntimeError: dictionary changed size during iteration".
Instead using the keys directly we should cast them into a list and then
using that list for the iteration.
Related: OS#6094
Change-Id: I430ef216cf847ffbde2809f492ee9ed9030343b6
When the method del_lchan is called, closed_channel_nr still contains a dict
that contains the channel number under the key 'logical_channel_number'.
This will lead to an exception. We must extact the channel number from
the dict before we can use it with del_lchan. (See also
created_channel_nr)
Related: OS#6094
Change-Id: I399856bc227f17b66cdb4158a69a35d50ba222a7
The comman verify_adm does no longer work since the verify_adm method is
no longer available in the card base classes (cards.py). Let's use the
verify_chv method from SimCardCommands instead.
Change-Id: Ic87e1bff221b10d33d36da32b589e2737f6ca9cd
This adds a new operation mode for pySim-shell, where a single command
can be passed to pySim-shell, which then is executed before pySim-shell
terminates.
Example: ./pySim-shell.py -p0 export --json
Change-Id: I0ed379b23a4b1126006fd8f9e7ba2ba07fb01ada
Closes: OS#6088
Rather than having to know and explicitly list every CardApplication,
let's iterate over the __subclasses__ of the CardApplication base class.
Change-Id: Ia6918e49d73d80acfaf09506e604d4929d37f1b6
This profile has always been a hack/work-around for the situation that
a classic GSM SIM is not a UICC, and we didn't yet have the concept of
CardProfileAddons yet, so there was no way to probe and add something
to an UICC which was not an application with its own AID/ADF.
Since now we have CardProfileAddons (including one for GSM SIM),
and pySim-trace (the other user of CardProfileUICCSIM) has also switched
over to using CardProfileUICC + addons, we can remove this work-around.
Change-Id: I45cec68d72f2003123da4c3f86ed6a5a90988bd8
We have a strict "one CardProfile per card" rule. For a modern UICC
without legacy SIM support, that works great, as all applications
have AID and ADF and can hence be enumerated/detected that way.
However, in reality there are mostly UICC that have legacy SIM, GSM-R
or even CDMA support, all of which are not proper UICC applications
for historical reasons.
So instead of having hard-coded hacks in various places, let's introduce
the new concept of a CardProfileAddon. Every profile can have any
number of those. When building up the RuntimeState, we iterate over the
CardProfile addons, and probe which of those are actually on the card.
For those discovered, we add their files to the filesystem hierarchy.
Change-Id: I5866590b6d48f85eb889c9b1b8ab27936d2378b9
As pySim.cdma_ruim was not imported by test_files.py, the unit tests
were apparently never executed and hence didn't pass. Let's fix both
of those problems.
Change-Id: Icdf4621eb68d05a4948ae9efeb81a007d48e1bb7
Hence move this from the derived classes into the respective base
classes SimCardBase and UiccCardBase
Change-Id: Iad197c2b560c5ea05c54a122144361de5742aafd
Those old flat dicts indicating FID to string-name mapping have long
been obsoleted by the pySim.filsystem based classes.
Change-Id: I20ceea3fdb02ee70d8c8889c078b2e5a0f17c83b
There are some functions / classes which are only needed by the legacy
tools pySim-{read,prog}, bypassing our modern per-file transcoder
classes. Let's move this code to the pySim/legacy sub-directory,
rendering pySim.legacy.* module names.
The long-term goal is to get rid of those and have all code use the
modern pySim/filesystem classes for reading/decoding/encoding/writing
any kind of data on cards.
Change-Id: Ia8cf831929730c48f90679a83d69049475cc5077
This introduces an internal split between
* the code that is shared between pySim-shell and legacy tools, which is
now in the new class hierarchy {Card,SimCard,UiccCard}Base
* the code that is only used by legacy tools,
which is using the old class names inherited from the *Base above
All users still go through the legacy {Sim,Usim,Isim}Card classes, they
will be adjusted in subsequent patches.
Change-Id: Id36140675def5fc44eedce81fc7b09e0adc527e1
This was currently not handled in build_select_path_to(), resulting in
weird exceptions like 'Cannot determine path from MF(3f00) to MF(3f00)'
Change-Id: I41b9f047ee5dc6b91b487f370f011af994aaca04
The get_data shell command didn't have any interactive help / syntax,
and no meaningful error message in case an unknown data object name
was specified by the user. Let's fix that.
Change-Id: I09faaf5d45118635cf832c8c513033aede1427e5