the interpret_sw() method was moved from RuntimeState to RuntimeLchan
in Change-Id I7aa994b625467d4e46a2edd8123240b930305360 - but the code
in pySim/exceptions.py was not adjusted accordingly.
Change-Id: I0614436c99c6a6ebc22c4dc14fb361c5f5f16686
While in the pySim-shell, it's useful to filter the currently selected
file from the choice of available files for select, this doesn't apply
for the tracing case: It's perfectly valid for the UE to SELECT the
file that's already selected right now. The operation basically
becomes equivalent to a STATUS.
Change-Id: I1a20fb3ba70426333ac34448c6cb782c51363965
We need to pass the 'PARENT' flag to get_selectables() to be able
to track SELECT on any of the parent/ancestor DF FID.
Change-Id: Ia7ac627d5edccb97160c90688d720d887fad6ec7
I didn't check the specs, but at least experience with real-world cards
(and modems) shows that it's not just permitted to select the immediate
parent DF, but all ancestors of the currently selected file.
So adjust the get_selectables() method to not just return the immediate
parent, but to recurse all the way up and report the FID of any ancestor
DF.
Change-Id: Ic9037aa9a13af6fb0c2c22b673aa4afa78575b49
In order to be able to explicitly select the MF via 3f00,
we need to pass the 'MF' to get_selectables(), so the record
is included in the list of selectable files from the current
working directory.
Change-Id: I27085896142fe547a6e93e01e63e59bbc65c8b8a
All other get_selectables() understand a flag like 'FIDS' to request
only the hexadecimal FIDs and not the file names. However, the
CardEF.get_selectables() ignored those flags and unconditionally
returned the names.
Change-Id: Icdc37cae3eecd36d167da76c30224b9d48c844fd
The Tracer implemented those options and the argparser handled it,
but we didn't ever connect the two.
Change-Id: I7d7d5fc475a8d09efdb63d3d6f1cc1de1996687b
If the modem/UE doesn't ask for the FCP to be returned, a SELECT
can exit with 9000 and no response body. Don't crash in that case.
Change-Id: I66788717bec921bc54575e60f3f81adc80584dbc
Instead of a cryptic backtrace, we now return a meaningful error like this:
{"error": {"message": "Security Status not satisfied - Card PIN enabled?", "status_word": "6982"}
Change-Id: I6dafd37dfd9fa3d52ca2c2e5ec37a6d274ba651b
Closes: OS#5606
Let's make sure even error messages are returned in JSON format.
While at it, also reduce some code duplication between the 'auth'
and 'info' route handlers by using the klein handle_errors decorator
instead of manual exception catching.
Change-Id: I1e0364e28ba7ce7451993f57c8228f9a7ade6b0e
Closes: OS#5607
This introduces a new pySim.apdu module hierarchy, which contains
classes that represent TPDU/APDUs as exchanged between
SIM/UICC/USIM/ISIM card and UE.
It contains instruction level decoders for SELECT, READ BINARY and
friends, and then uses the pySim.filesystem.Runtime{Lchan,State} classes
to keep track of the currently selected EF/DF/ADF for each logical
channel, and uses the file-specific decoder classes of pySim to decode
the actual file content that is being read or written.
This provides a much more meaningful decode of protocol traces than
wireshark will ever be able to give us.
Furthermore, there's the new pySim.apdu_source set of classes which
provides "input plugins" for obtaining APDU traces in a variety of
formats. So far, GSMTAP UDP live capture and pyshark based RSPRO
live and pcap file reading are imlpemented.
Change-Id: I862d93163d495a294364168f7818641e47b18c0a
Closes: OS#5126
Fix a bug in the pySim.sysmocom_sja2 module, where we defined unnamed
bits in BitStruct without a default value causing exceptions like this:
EXCEPTION of type 'KeyError' occurred with message: 'None'
Change-Id: Ib2da5adda4fae374ab14bb8100f338691aef719a
Closes: OS#5575
We were invoking the constructor with the description as 4th positional
argument, but that was actually the 'size' argument in this case.
Let's swap the order to be aligned with other file constructors.
Change-Id: I9acee757f096fef0d8bacbec3b52f56267cd52f6
The size should be a *tuple*. In reality we so far passed a set. The
problem with the set is that ordering is not guaranteed, and hence we
cannot assume the first and second item have meaning (minimum vs.
default record length).
Change-Id: I470f4e69c83cb2761861b3350bf8d49e31f4d957
As the documentation strings say: The size should be a *tuple*. In
reality we so far passed a set. The problem with the set is that
ordering is not guaranteed, and hence we cannot assume the first and
second item have meaning (minimum vs. default size).
While at it, use a type annotation to catch such bugs easily.
Change-Id: I553616f8c6c4aaa8f635b3d7d94e8e8f49ed5a56
Reduce all the copy+pasted '/'.join(path_list) constructs with
a method returning the formatted path string.
Change-Id: I5e9bfb425c3a3fade13ca4ccd2b891a0c21ed56d
Otherwise we have binary/bytes as values inside the dict, rather than a
hexadecimal string. That's ugly when printing without json formatting.
Change-Id: Ia3e7c4791d11bd4e3719a43d58e11e05ec986d1f
Even while we don't yet have a proper decoder, let's at least represent
the network name as hex-string
Change-Id: I4ed626699d1e4e484d4ffd04349676dadff626a0
This file existed in earlier specs like Release 3.8.0, but was removed
in later revisions. Still, there are cards around implementing that
older spec, so let's add a decoder.
Change-Id: Ic7163b2a01f64ef1223cf15b8d0813d3edf5b61a
We want to use this class in an upcoming patch for DF_MCS support,
and in order to avoid cyclic imports, EF_UServiceTable must be moved.
Change-Id: I9cd6ab795bfd92f845eb943679a3d6302f1003ce
cards can have multiple logical channels; each logical channel
has its own state of what is the current selected file + application.
Let's split the RuntimeState class into the global RuntimeState and the
per-lchan-specific RuntimeLchan class.
This code doesn't actually introduce any code that uses lchans other
than the basic logical channel (0), but just modifies the data model
to accomodate those in the future.
Change-Id: I7aa994b625467d4e46a2edd8123240b930305360
When using __str__ for a CardDF we would get "DF(DF.TELECOM)"
but when using it on CardADF we would get ADF(a0000000871002)"
instead of "ADF(ADF.USIM)". Let's fix that.
Change-Id: I5801a08bcc28cb222734af6d9ee835227f4fee69
As it is possible to select files relative to the currently selected
ADF, we should keep track of that.
Change-Id: I83c93fdcd23b1d3877644ef0bf72d330343fbbc7
We should first see if any of the files in the tree actually
require a service mapping before raising
ValueError('TODO: implement recursive service -> file mapping')
Change-Id: I9c339f0cac020e7eec7f4f840748040e5f77923d
Service 126 relates to DF.5GS/EF.UAC_AIC. As we are deactivating that
file in the script, we should also disable the related EF.UST service.
Change-Id: Id35035aaf23b2163caed3197786288c87be03cfa
In class SimCard, we specify the key reference for ADM1 as 0x04. in the
UsimCard class, which inherits from SimCard nothing is specified, even
though ETSI TS 102 221 specifies 0x0A as key reference. Lets set the
member in UsimCard accordingly to be closer to the spec.
Note: For the moment this is a cosmetic fix, it does not change the
behaviour since all card classes derived from UsimCard set the key
reference properly.
Change-Id: I96af395b1832f4462a6043cca3bb3812fddac612
ETSI TS 102 221, Table 9.3 specifies 0x0A as default key reference for
ADM1. Lets make sure pySim-shell uses this key-reference if the card is
a generic UICC.
Change-Id: I8a96244269dc6619f39a5369502b15b83740ee45
The TLV IEs FILE SIZE and TOTAL FILE SIZE have a minimum length of 2
byte. Even when the length is in the single digit range two bytes must
be used. See also: ETSI TS 102 221, section 11.1.1.4.1 and 11.1.1.4.2
Change-Id: Ief113ce8fe3bcae2c9fb2ff4138df9ccf98d26ff
When updating files and records there are sometimes huge portions that
are just 0xff. Mostly this is at the end of a file or record that is not
completely used. Lets add a notation to tell PySim-shell how to fill
those sections.
Change-Id: Iedd7887bf7d706878f4a3beca8dbea456404610b
When we run the exporter we also get an error summary at the end.
However, if walk() throws an eception this stops the exporter
immediately and we won't get the summpary. Lets catch exceptions from
walk as well so that we are able to end gracefully.
Change-Id: I3edc250ef2a84550c5b821a72e207e4d685790a5
The walk() method that we use to traverse the whole file system tree is
currently only able to execute action callbacks on EFs. Lets add a
mechanism that allows us to have a second callback that is executed when
we hit a DF or ADF.
Change-Id: Iabcd78552a14a2d3f8f31273dda7731e1f640cdb
The apdu command is used to communicate with the card on the lowest
possible level. Lets make it available even before a card profile (rs)
is avalable. This is especially useful when the card has no files on it,
in this situation pySim-shell will not be able to assign a profile to
the card at all. We can then use the apdu command to equip the card with
the most basic files and start over.
Change-Id: I601b8f17bd6af41dcbf7bbb53c75903dd46beee7