Add file specific command `update_imsi_plmn` to EF_IMSI to replace
the mcc and mnc part of the imsi for use in bulk_script(s)
Change-Id: I9662ff074acf9dc974ae4c78edac44db286e98fc
when encoding the AcT value bit 11 is correctly set
when NG-RAN is present in the string representation,
however the decoding of bit 11 was missing.
Adds tests for the decoder as well.
Change-Id: I910df28c4c59ec94cce9603377786325f6d8c1a3
When probing applications on a card by running select_adf_by_aid()
SwMatchError exceptions indicating the non exsistance of that
application on the card should be ignored.
Change-Id: I3aa7deaf46bdf352a201c3089b3714405a06f281
When printing applications found by probing for a specific AID, then the
wrong variable is used to print the AID.
Change-Id: I3d5ec28e46fe00c0d793a1d9ef0a0e0900649a4d
A profile can cover lots of different applications. Those applications
may not exist on all card models. To exclude applications that are not
installed on the particular card EF.DIR is evaluated. However, there may
be applications that are not registered in EF.DIR but supported by the
profile. To cover those as well, lets try to select the applications we
do not see in EF.DIR. If selecting works we know that the application
exists on the card and we can include them in the RuntimeState.
Change-Id: I3fa77a68664fe50d690a18adfb1ae1a88a189827
* serial is according to pypi: "A framework for serializing/deserializing
JSON/YAML/XML into python class instances and vice versa"
Change-Id: I154276fbadd70f6be94ba7d99e61f7e9eedbeb33
There is no need for us to expand a partial AID to the full AID before
selecting that ADF. The UICC specifications permit AID selection by
prefix only. So we could pass the prefix to the card, and the card would
do the prefix matching. In order to avoid problems with cards that fail
to do the prefix matching themselves we will still do the AID
completion, but in case we cannot complete the AID (AID not listed in
EF.DIR), we will try with the AID prefix anyway.
From the API user point of view, this allows us to select applications
not listed in EF.DIR
Change-Id: I0747b4e46ca7e30bd96d76053765080367ac1317
The method decode_select_response does not access any property of the
object. This means the method can be static.
Change-Id: Idd7aaebcf1ab0099cd40a88b8938604e84d8a88b
The select response of an UICC will always return the number of records
of a file. However, older SIM will not include the number of records in
the select response. In those cases, simply guess the number of records
by reading until the first invalid record is hit.
Change-Id: Ib480797d881b9ec607ec6a86b73d452449f8cf87
Related: OS#5274
At the moment the non checking send_apdu() method is used when records
are read. Lets use read_record_checksw so that we get an exception in
case there is a problem to read the specified record.
Change-Id: I9fc411e1b12e8d9fd89b9964209808c0706011bd
The method decode_select_response just calls the function
_decode_select_response. But the function _decode_select_response
is not called from any other location, so we can move it into the
profile class.
Change-Id: Icf0143f64ca7d1c1ebf60ba06585f7afc1ac0d11
UICC and old SIM cards can be difficult to tell apart without prior
knowledge of the card. The ATR won't tell if the card is UICC or not.
The only remaining option is to try out if the card is able to handle
UICC APDUs. The same is true for 2G SIM cards. It is not guranteed that
every UICC card will have 2G functionality.
Lets add functionality to match a profile to the currently plugged card
by actively probing it.
Lets also add another profile to distinguish between UICC-only cards and
UICC cards that include SIM functionality.
Change-Id: If090d32551145f75c644657b90085a3ef5bfa691
Related: OS#5274
Before reading EF.IST ADF.ISIM is selected again even though it was
selected before. Lets skip this step since it is unnecessary.
Change-Id: I75be18e3476cb1d093bc99775eeddd0c08b81d78
The function select_adf_by_aid first searches for the complete AID in
the set of AIDs that were read from EF.DIR. Lets put this task into a
separate helper method
Change-Id: I88447d47bc96d0d4ff5cea694b46e854232cdf86
This introduces support for talking to the ARA-M application on a card,
as specified in the GlobalPlatform "Secure Element Access Control"
specification v1.1.
Change-Id: Ia9107a4629c3d68320f32bbd4dd26e1f430717da
The table that holds the status word descriptions is initialized as an
empty list '[]'. This is not correct since the interpret_sw method
processes this data as dictionary, so lets initialize the sw member with
an empty dict '{}' when not status word description is given.
Change-Id: I3cae83f0f6ab274546991ecd14425f094b2816b2
Related: OS#5274
The class byte and the select control bytes are different for SIM cards
and UICC cards. Lets define those parameters in the card profile, so
that we always get the correct parameters depending on which profile we
use.
Change-Id: I2d175e28bd748a4871b1373273b3a9be9ae8c4d0
Related: OS#5274
When the runtime state is created there is already some interaction with
the card. Lets make sure that the card is in a defined state when we
leave the constructor of the RuntimeState.
Change-Id: I986204964903069bcce781afdbf3c5d26682b749
Related: OS#5274
When the profile does not define any ADFs, then do not try to read any
AIDs. This is the case for old non UICC SIMs for example.
Change-Id: I8cfbee1d23e9f99461fa5f4fbf92c1a0929c50bf
Related: OS#5274
There are some problems with the usage of decode_select_response. At the
moment the ADF files overload the related method to provide decoding of
the select responses as per 3gpp TS 102 221. However, this also means
that the decoder is only available under ADF.USIM and ADF.ISIM. DF.GSM
and DF.TELECOM also overload the decoder method, just like an ADF would
do. This decoding method is then implemented as per 3gpp TS 51 011.
Since this a a problem on UICCs, the method detects the magic byte 0x62
that can be found at the beginning on every select response of an UICC
to defer to the TS 102 221 decoding method. TS 51 011 defines the first
two bytes of the select response as RFU. This at least problematic.
To solve this there should be a default method for
decode_select_response in the profile, which can be used if no file
overloads it with a specific decoder. ADFs use specific decoders, but
everything else should use the default decoder. When we deal with an
UICC, we expect the select response to be consistantly conform to TS
102 221, if we deal with a clasic sim we expect responses as per TS 51
011 only.
Since it is still possible to replace the select response decoder we
still have the opportunity to have custom select response in cartain
DFs and ADFs should we need them.
Change-Id: I95e33ec1755727dc9bbbc6016ce2d99a9e66f214
Related: OS#5274
When pySim-shell is exited using CTRL+D it does not print a newline.
This means that the prompt of the OS shell shows up after the
pySim-shell prompt. This is irretating. Lets print a new line on exit
with CTRL+D so that everything looks straight.
Change-Id: I88e58094b9badeaabd8502006e5e16f35eaa683e
The computed length of the file may be negative, when the offset exceeds
the file length. When this is the case, return none
Change-Id: I2c017c620254fae188022851ef3b670730aab503
The transport layer provides a method send_apdu_checksw to send APDUs
and to be sure the SW is the expected one. Given that, there is no need
to verify the SW manually. The exception of send_apdu_checksw will catch
the problem and also display the SW in a human readable form.
Change-Id: I9ce556ac0b7bb21c5c5a27170c32af0152255b79
Related: OS#5275
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