Age | Commit message (Collapse) | Author | Files | Lines |
|
pySim/cards.py:30:0: W0401: Wildcard import pySim.utils (wildcard-import)
pySim/cards.py:41:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
pySim/cards.py:55:4: R1711: Useless return at end of function or method (useless-return)
pySim/cards.py:78:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
pySim/cards.py:91:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
pySim/cards.py:159:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
pySim/cards.py:28:0: C0411: standard import "import abc" should be placed before "from pySim.ts_102_221 import EF_DIR" (wrong-import-order)
pySim/cards.py:25:0: W0611: Unused Dict imported from typing (unused-import)
pySim/cards.py:28:0: W0611: Unused import abc (unused-import)
Change-Id: I708da28caffb417ed2f8413f9611526b18b29cd4
|
|
Now that pySim-shell is aware of logical channels and issues almost
all of its APDUs on the currently selected channel, we must also make
sure that ADF selection by AID (implemented by the CardBase class)
issues the SELECT on the respective logical channel.
Before this patch, SELECT ADF by AID would always be issued on the
primary logical channel (0), irrespective of the currently active
RuntimeLchan.
Change-Id: Idf05c297e6a2e24ca539408b8912e348c0782bb4
Related: OS#6230
|
|
The CardBaes 'scc' member refers to a SimCardCommands instance,
not to a LinkBase.
Change-Id: If4c0dfbd8c9a03d1a0bc4129bb3c5d5fa492d4cb
|
|
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
|
|
The constant for _adm_chv_num is swapped. It should be 0x0A, rather than
0xA0
Change-Id: I5680d2deee855ef316a98058e8c8ff8cf4edbbb2
|
|
Hence move this from the derived classes into the respective base
classes SimCardBase and UiccCardBase
Change-Id: Iad197c2b560c5ea05c54a122144361de5742aafd
|
|
ssc = SimCardCommands
Change-Id: I9d690a0a5b9b49ea342728a29b7d4ed10ac31e4e
|
|
Change-Id: Id61b549f68410631529349ee62b08a102f609405
|
|
Change-Id: Id5752a64b59097584301c860ebf74d858ed3d240
|
|
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
|
|
Change-Id: I9ce8c1af691c28ea9ed69e7b5f03f0c02d1f029b
|
|
Change-Id: Icd2021aec630ac018f66ab565e03112047389e17
|
|
The cards are 99% software-compatible to the SJA2, so let's just
derive the SJA5 class from the SJA2
Change-Id: I706631baaf447c49904277886bc9a3f6ba3f5532
|
|
selecting it
sysmo-isim-sja2 may come in different configurations, so some may
intentionally lack ADF.USIM or ADF.ISIM. Since select_adf_by_aid() may
raise an exception when selecting a non existent file we should make
sure that the ADF we intend to select is indeed present. A reliable way
to do this is to check if the application is registered in EF.DIR.
Change-Id: Icf6f6b36f246398af408ec432d493fe3f22963dd
|
|
DF.GSM and ADF.USIM have an EF.AD with nearly the same contents. Usually
there is one file physically present and the other is just a link.
Apparantly this is not always the case for sysmo-ismi-sja2 cards, so
lets program EF.AD in both locations.
Change-Id: Ic9dd4acc8d9a72acbb7376ddf3e2128125d4a8f5
Related: OS#5830
|
|
Change-Id: I81a6074776bdf67b7bea359fe7a24f906936f46d
|
|
Since we now ensure that mnc always has a valid length lets make the
check in cards.py more strict.
Related: OS#5830
Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd
|
|
https://stackoverflow.com/questions/4015417/why-do-python-classes-inherit-object/45062077
Change-Id: I15003ba591510d68f3235f71526ad5d8a456088e
|
|
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
|
|
Change-Id: I5860179acd1cb330e91dbe5b57cd60cd520f2d9d
|
|
The existing code had the following serious problems:
* when trying to update EF.SST or EF.IST, it would write to EF.UST !
* shell commands were called ust_* even for the EST/IST files
Let's introduce the proper separation between what is shared and what
is file-specific.
Change-Id: Ie55669ca37a4762fac9f71b1db528ca67056e8dd
|
|
We had a mixture of tab and 4space based indenting, which is a bad
idea. 4space is the standard in python, so convert all our code to
that. The result unfortuantely still shoed even more inconsistencies,
so I've decided to run autopep8 on the entire code base.
Change-Id: I4a4b1b444a2f43fab05fc5d2c8a7dd6ddecb5f07
|
|
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
|
|
There is no need to be case sensitive when the xSIM application name is
given as AID.
Change-Id: I9944d9180bf1ba35f44f0be2b05bdb725b5b8da9
|
|
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
|
|
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
|
|
Change-Id: Iae862d8f0a191c7015a94f9516ef5804265f7a82
|
|
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
|
|
The function card_autodetect() is not used, lets remove it.
Change-Id: Ic188e1fffb4a40e89ad276941d20f94cf35e1538
|
|
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
|
|
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 function dec_addr_tlv() takes an encoded FQDN or IPv4 address and
fromats it into a human readable string that contains the human readable
form and the encoded hex form. Unfortunately this limits the usecase of
dec_addr_tlv. Lets split the string generation into a separate function
so that we can use dec_addr_tlv universally
Change-Id: Id017b0786089adac4d6c5be688742eaa9699e529
Related: OS#4963
|
|
Even though Card, UsimCard and IsimCard are abstract classes which are
normally only used to inherit from mit may make sense to pre-populate
the name property with some meaningful value.
Change-Id: Id643e1f83718aea073e7200aecbf2db2def8652f
|
|
This will replace the hand-crafted codec for EF_SPN
by a struct definition using the construct library.
Old encoders are updated and kept for API compatibility
but are not used internally anymore.
New data structures:
* Rpad(Adapter): Right-padded bytestring (0xff, adjustable)
* GsmStringAdapter(Adapter): Codec for "SMS default 7-bit
coded alphabet as defined int TS 23.038" using
the gsm0338 library.
* GsmString(n): Convenient wrapper of both above
Adjustments:
* utils: update+deprecate old dec_spn(), enc_spn()
* remove refs to deprecated functions
Change-Id: Ia1d3a3835933bac0002b7c52511481dd8094b994
|
|
Change-Id: Ie4ba72b725a56ba9cfe98cc7bd17dd3653194f36
|
|
Change-Id: I315c646d94a1d3282917f5abb0c93efb918b53d7
|
|
This method has been removed [1] in Python 3.0:
pySim/cards.py:581:14: E1101: Instance of 'dict' has no 'iteritems' member (no-member)
pySim/cards.py:591:24: E1101: Instance of 'dict' has no 'iteritems' member (no-member)
[1] https://wiki.python.org/moin/Python3.0#Built-In_Changes
Change-Id: Iba7ad9ed2a9b197ecedaaed1c6744fe1c721515a
|
|
Fixes the following pylint's warnings:
pySim/cards.py:494:18: E1101: Class '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:509:6: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:529:26: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:537:5: E1101: Instance of '_MagicSimBase' has no '_ki_file' member (no-member)
pySim/cards.py:547:5: E1101: Instance of '_MagicSimBase' has no '_ki_file' member (no-member)
pySim/cards.py:548:8: E1101: Instance of '_MagicSimBase' has no '_ki_file' member (no-member)
pySim/cards.py:559:26: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:560:11: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
pySim/cards.py:576:14: E1101: Instance of '_MagicSimBase' has no '_files' member (no-member)
Change-Id: I4db9d21258d6e04140962134c540e36631466322
|
|
The encoding of EF.MSISDN is a bit unstrutured. The encoder function
does not return a valid result since it lacks the parameters
Capability/Configuration2 Record Identifier and Extension5 Record
Identifier, which are mandatory but can be set to 0xFF. Also the
encoder gets its input from pySim-shell, so it should have some
more input validation, especially when the user encodes an empty
string. The encoder and decoder function also do not have unit-tests.
Since the encoder now adds the missing two bytes by isself this does
not have to be done manually anymore, so cards.py needs to be
re-aligned.
For pySim-shell.py the encoder is used from ts_51_011.py. Unfortunately
it is used wrongly there. The optional Alpha Identifier is required
here as well.
Related: OS#4963
Change-Id: Iee5369b3e3ba7fa1155facc8fa824bc60e33b55b
|
|
Also serves as example for RFU (reserved for future use) fields
which should not always be reset to zero in case they have been
set on the uSIM for some reason.
See pySim/ts_51_011.py, class EF_AD.
* Add definitions for RFU {Flag, Bits, Byte, Bytes}
* Use IntEnum for OP_MODE (convenient auto completion)
* Remove obsolete definitions and imports
* Update test results for all SIMs (opmode strings are shortened)
Change-Id: I65e0a426f80a619fec38856a30e590f0e726b554
|
|
Change-Id: Ic8392a951bf94f67b51e35bed95d0e856f7a9250
|
|
Use ``--opmode=OPMODE`` in cmdline mode or column ``OPMODE`` in csv mode
to specify OPMODE as listed below.
Details:
The ``EF_AD`` field contains administrative data (AD).
It consists of four bytes ``B1``, ``B2``, ``B3``, ``B4``,
and optionally further bytes for future use.
Previous implementation only sets the MNC field appropriately
(located in `B4`) and sets all other bits/bytes to 0.
However, `B1` also defines the *UE operation mode* (see below).
For type approval operations, such as testing with a test uSIM,
this value could be set to `0x80` rather than `0x00`(= normal operation).
This may unlock some UE capabilities that are restricted in
normal operation mode.
Excerpt from [ETSI TS 131 102, 4.2.18](https://www.etsi.org/deliver/etsi_ts/131100_131199/131102/04.15.00_60/ts_131102v041500p.pdf):
```
B1 - UE operation mode:
Coding:
Initial value
- '00' normal operation.
- '80' type approval operations.
- '01' normal operation + specific facilities.
- '81' type approval operations + specific facilities.
- '02' maintenance (off line).
- '04' cell test operation.
B2 - Additional information:
Coding:
Reserved for future use
B3 - Additional information:
Coding:
- B3.b1: OFM setting (Ciphering Indicator)
- B3.others: Reserved for future use
B4 - Length of MNC in the IMSI:
Coding:
- B4.b4..B4.b1: length: '0010' (= 2) or '0011' (=3)
- B4.others: Reserved for future use
```
**Legend:** Byte X, bit Y: BX.bY
Further reading: https://nickvsnetworking.com/usim-basics/
Change-Id: Ie9040c6b127c268878a0845ed73d0918ec6bbb08
|
|
The ``EF_ACC`` field defines the access control class (ACC)
for a subscriber.
Without this patch, the implementation adds padding 1 towards
the most significant bits if the input is shorter than 2 bytes.
However, it should be padded with 0, otherwise additional ACCs
are allocated to the subscriber. (Probably only a single bit
shall be set to 1)
Excerpt from [ETSI TS 131 102, 4.2.15](https://www.etsi.org/deliver/etsi_ts/131100_131199/131102/04.15.00_60/ts_131102v041500p.pdf):
```
EF_ACC: Two bytes: B1, B2
B1.b8...B1.b4: high priority users (class 15...11)
B1.b3: always 0
B1.b2...B1.b2 and B2.b7...B2.b0: normal priority users (class 9...0) - to be evenly distributed across subscribers
```
**Legend:** Byte X, bit Y: BX.bY
Change-Id: I1b8dc01a6c48adad1ed8158de59b12519ed688e9
|
|
Same implementation as for sysmoUSIM-SJS1
Change-Id: I3a9dd2fe85126584758ea4cfa127f9cd14ab0c7d
|
|
When the ADF is selected, then this is done by the AID. At the moment
only the first 7 bytes of the AID are used to select the ADF.
sysmo-isim-sja2 tolerates this, but sysmo-usim-sjs1 does not. The Cards
class already has methods to deal with this problem. The method
select_adf_by_aid takes an ADF name and completes the AID from an
internal list. This can be extended to support partial hexadecimal AIDs
as well.
Change-Id: If99b143ae5ff42a889c52e8023084692e709e1b1
Related: OS#4963
|
|
currently ADF.ISIM and ADF.USIM are always added regardless if there is
a matching application on the card or not. Lets check what applications
are actually installed and add ADF.ISIM and ADF.USIM dynamically.
Change-Id: I42ee23375f98e6322708c1c4db6d65e1425feecd
Related: OS#4963
|
|
The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.
Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963
|
|
The code was written long ago, when the python3 bytearray type
probably didn't exist yet, or was at least not known. Let's stop
using string types with binary bytes inside, and instead standardize
on two types:
* bytearray for binary data
* string for hexadecimal nibbles representing that binary data
Change-Id: I8aca84b6280f9702b0e2aba2c9759b4f312ab6a9
|