pre-empt this from coming up in patch
I60ea8fd11fb438ec90ddb08b17b658cbb789c051:
E1135: Value 'self.permitted_len' doesn't support membership test (unsupported-membership-test) pickermitted_len
Change-Id: I0343f8dbbffefb4237a1cb4dd40b576f16111073
The implementations that inheret from the LinkBase class are expected to
implement a get_atr method. This method is mandatory, since it is one of
the most basic functionalities of pySim to display an ATR. Also the ATR
is sometimes needed to distinguish between different card models.
The modem_atcmd and calypso implementation completely lack the get_atr
method. Apparantly it is not possible to get an ATR in those
environments, so lets add a dummy method there.
Related: OS#6322
Change-Id: I4fc020ca45658af78e495a5c1b985213f83cbb50
type annotations claimed the return type was Hexstr, but in reality
it was a list of integers. Let's fix that.
Change-Id: I01b247dad40ec986cf199302f8e92d16848bd499
Closes: OS#6322
The ATR constants are the only hex string constants where the hex
bytes digits are separated with spaces. Also the hex digits are in
lowercase. Let's use a lowercase string without spaces here like
we do in many other code locations.
Related: OS#6322
Change-Id: I95118115b02523ed262a2fbe4369ace3996cd8f5
Installing JAVA-card applets from a CAP file is a multi step process, which is
difficult when done manually. Fortunately it is easy to automate the process,
so let's add a dedicated command for that.
Change-Id: I6cbd37f0fad5579b20e83c27349bd5acc129e6d0
Related: OS#6679
In this patch we add the commands "install_for_load" and "load".
Depends: pyosmocom.git I86df064fa41db85923eeb0d83cc399504fdd4488
Change-Id: I924aaeecbb3a72bdb65eefbff6135e4e9570579e
Related: OS#6679
The kvn parameter is used to select a keyset when establishin a secure channel.
At the moment this is a mandatory parameter and it must be within a certain
range.
However GPC_SPE_034 explicitly defines a reserved kvn value 0, that always
refers to the first available key. That effectively makes it an optional
parameter and the commandline interface should have the --key-ver parameter
as an optional parameter.
The ranges also have to be extended to allow 0 as kvn value. We also have to
put a range to support the sysmoUSIM-SJS1, which uses kvn value 1, which is
a non standard value.
Related: OS#6679
Change-Id: I42be2438c7f199b238f2ec7a9434cec5393210a7
Some old cards are classic SIM and not based on UICCs. Such cards
do not offer the capability of selecting applications. Let's avoid
running into an exception by providing dummy methods that simply fail
for each AID selection.
Change-Id: Ib3457496380c0c5096052ad7799970ee620dee33
Closes: OS#6691
To install JAVA-card applets we need to be able to extract the executeable
loadfile and the AIDs of the applet and the loadfile. This patch adds the
parser and related unittests.
Related: OS#6679
Change-Id: I581483ccb9d8a254fcecc995fec3c811c5cf38eb
The line with TAGS is longer than 120 columns and there is some
comment that should be moved to the python docstring.
Related: OS#6679
Change-Id: I1d02098320cfbe17a0eb1bfdcf3bc85034cc8e20
GPD_SPE_013 Table 6-3 defines two types of AID-REF-DO objects (both
are fully independed TLV IEs with the same name). The version with
tag '4F' identifies an SE application. It may contain an AID prefix
or even be of length 0 in case the rule should apply to all SE
applications. Then there is the version with tag 'C0', which must
always have length 0 and serves a flag to apply the rule to the
implicitly selected SE application. Technically both are completely
different things, so we must also treat them separately in the
pySim-shell code.
Related: OS#6681
Change-Id: I771d5e860b12215280e3d0a8c314ce843fe0d6a2
there are multiple references to a specification "SEID". As it seems this is
a reference to the GlobalPlatform "Secure Element Access Control" spec, which
has the document reference "GPD_SPE_013". Let's use "GPD_SPE_013" to referene
the spec.
Related: SYS#6681
Change-Id: I77895f1b84126563380ce89aa07a3b448d8784a3
Let's change the prompt from ">" to "#" when the user gains admin
privilegs using verify_adm.
Related: OS#6640
Change-Id: I957b9df7b5069b6fce5bf958c94e8ffda833c77f
the testcase EF_ePDGSelection has a wrong testvector in the plmn field.
This test vector is accepted because there is a complementary error in
pyosmocom. However, the root problem got fixed (see depends), which means
that the test vector of EF_ePDGSelection now needs to be updated.
Depends: pyosmocom.git: I3811b227d629bd4e051a480c9622967e31f8a376
Change-Id: I96fd4c13c8e58ef33ddf9e3124617b1b59b9b2c1
Related: OS#6598
In case the fileDescriptor of EF.IMSI is purely template based and only
the file content is given in the actual profile, we must pass a template
reference to the File() constructor before we can read the IMSI.
This fixes the following exception for some profiles:
ValueError: File(ef-imsi): No fileDescriptor found in tuple, and none set by template before
Change-Id: I14157a7b62ccd9b5b42de9b8060f2ebc5f91ebb3
So far we mainly created File() instances when parsing existing
profiles. However, sometimes we want to programmatically create Files
and we should offer a convenience helper to do so, rather than asking
API users to worry about low-level details.
Change-Id: I0817819af40f3d0dc0c3d2b91039c5748dd31ee2
The point of the SAIP template mechanism is to reduce the size of the
encoded profile. Therefore, our encoder in the to_fileDescriptor()
method should suppress generating attributes if their value is identical
to that of the template (if any).
Change-Id: I337ee6c7e882ec711bece17b7a0def9da36b0ad7
The encoding of the access rule reference is different in FileTemplate
vs File, let's make sure we properly convert it when instantiating a
File from a FileTemplate.
Change-Id: Ibb8afb85cc0006bc5c59230ebf28b2c0c1a8a8ed
If the API user modifies the size of the body, we need to check if we
need to re-compute the file_size attribute which is later encoded into
the fileDescriptor. The size obviously must be large enough to fit the
body. Let's do this implicitly by introducing a setter for File.body
Change-Id: I1a908504b845b7c90f31294faf2a6e988bdd8049
ProfileElements.insert_after_pe() is a convenience method to insert
a new PE after an existing one in the sequence. This is a frequent
task as there are strict ordering requirements in the SAIP format.
Change-Id: I4424926127b4867931c2157e9340bacd2682ff0c
When generating the file content (body), we need to proceed in the
following order:
1a) If FCP contains fillPattern/repeatPattern, compute file content from those
1b) If FCP doesn't contain fillPattern/repeatPattern but template
exists, compute file content from template
2) Apply any fillFileConten / fillFileOffset from the SAIP File on top
of the above
Change-Id: I822bb5fbec11a3be35910a496af7168458fd949c
Closes: OS#6642
If we know the efFileSize and record_len, but Fcp doesn't contain
the number of records, we can simply compute it.
Change-Id: I0cc8e7241e37ee23df00c2622422904e7ccdca77
There's a second flag hidden in the TS 102 222 "Special File
Information"; let's parse + re-encode it properly.
Change-Id: I7644d265f746c662b64f7156b3be08a01e3a97aa
Related: OS#6643
So far we only thought of default filling coming from a template.
However, filling can happen from the Fcp, and we need to properly parse
and [re-]encode that information.
Change-Id: Iff339cbe841112a01c9c617f43b0e69df2521b51
Related: OS#6643
ETSI TS 102 221, section 7.3 specifies that UICCs (and eUICCs) may support two
different transport protocols: T=0 or T=1 or both. The spec also says that the
terminal must support both protocols.
This patch adds the necessary functionality to support the T=1 protocol
alongside the T=0 protocol. However, this also means that we have to sharpen
the lines between APDUs and TPDUs.
As this patch also touches the low level interface to readers it was also
manually tested with a classic serial reader. Calypso and AT command readers
were not tested.
Change-Id: I8b56d7804a2b4c392f43f8540e0b6e70001a8970
Related: OS#6367
The _wrap_cmd_apdu methods for SCP02 and SCP03 are a bit hard to read. Let's
refactor them so that it is easier to understand what happens. In particular
that one can not have encryption (cenc) without signing (cmac)
Related: OS#6367
Change-Id: I4c5650337779a4bd1f98673650c6c3cb526d518b
by default pySim-shell does all kinds of probing and file selection
on startup. This is to determine the card type and to find a suitable
card profile. However, in case the card is non yet provisioned this
probing may cause a error messages and even might upset the cards
internal state. So let's have a commandline option thrugh which we
can instruct pySim-shell to skip any initialization and to give us
a prompt immediately, so that we can enter custom APDUs
Related: OS#6367
Change-Id: I1d8a57de201fe7ad7cbcbc6f72969ea8521e821d
when we sign and encrypt the APDU in _wrap_cmd_apdu (SCP03) we return an "mapdu"
at the end. However, in the (unlikely?) case where self.do_cencand
self.do_cmac are false, mapdu will be undeclared. In _wrap_cmd_apdu for SCP02
we just re-use the apdu variable and return it at the end, so when no
encryption and no signing is applied, the APDU falls just through without any
modifications. We should have the same mechanism for the SCP03 wrapping as
well.
Related: OS#6367
Change-Id: Ic7089a69dffd7313572c5b3e5953200be5925766
This adds a construct + pyosmocore.tlv based declarative encoder/decoder
for the EF.EARFCNList file used in the context of NB-IoT in later
release USIMs.
Change-Id: I16797ca58c3ad6ebaf588d04fec011a0cbcfcef3
When we use the argument parser with choices, we sometimes use a
list that we derive from a dictionary. However if we do that we
still must ensure that we really put a list and not a dict_values
or dict_keys class as parameter because this won't work any longer
with cmd2 version 2.5.0
Related: OS#6601
Change-Id: I165fefd8feb0d96cedc15d036fb32da381f711b3
We now have a construct based encoder/decoder for the record content
of EF.MSISDN. This means that we do not need the functions enc_msisdn
and dec_msisdn in the non-legacy code anymore. We can now move both
to legacy/utils.py.
Related: OS#5714
Change-Id: I19ec8ba14551ec282fc0cc12ae2f6d528bdfc527
The unittest for EF.DIR only runs with _test_decode, but it also runs with
_test_de_encode without any problems
Related: OS#5714
Change-Id: If459073c6ff927c1cc1790d506e3979243b1fb4c
The unittest for EF.CFIS only runs with _test_decode, but it also runs with
_test_de_encode without any problems
Related: OS#5714
Change-Id: Ib876fd799f871fe64ced2a7b64847ffd09e16ed9
The unittest for EF.ADN can run with _test_de_encode. However, the original
test vectors seem to be from a card with a slightly larger record size, so
they need a bit of re-alignment
Related: OS#5714
Change-Id: I241792e66ee6167be6ddc076453344b6307d6265
The encoding of EF.MSISDN is currently done with enc_msisdn and
dec_msisdn from utils.py. Let's replace this with a construct
based model, similar to the one we already use with EF.ADN
Related: OS#5714
Change-Id: I647f5c63f7f87902a86c0c5d8e92fdc7f4350a5a
Some methods sometimes have a **_kwargs parameter, let's be consistent
and use **kwargs only.
Related: OS#5714
Change-Id: I98857cc774185e55a604eb4fbfbf62ed4bd6ded7