The option and also the dest variable in the code are currently named
card_handler. This might be confusing since the variable actually refers
to a config file and therefore should be called "card_handler_config"
Change-Id: If93751e815cb46f9ff3f56b54e612d77fe1a6dfd
In OOP, we usually use capital letters for class names. The card handler
class should be no execption.
Change-Id: I4b2c06b1c607c993c9aaf0d57ad2352bb6b36e74
The variable card_handler is assigned in the following way:
card_handler = card_handler(sl)
This may cause problems since the class name and the variable name are
the same. Lets rename card_handler to avoid problems here.
Change-Id: I84dafc49862e373ae9f6a56bd2e8d1a02c27430a
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
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
pySim has already been migrated to Python 3 in another change [1],
and the build verification has been migrated to Debian 10 with
Python 3.7. However, there is still some backwards compatibility
code left. Let's get rid of it.
[1] Ic78da9c03e99f59d142c93394051bbc2751f0205
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Tweaked-by: Vadim Yanitskiy <vyanitskiy@sysmocom.de>
Change-Id: I430d173535e0cd5bb895b9dfc9070cbc40cfc8ff
Failed reader initializations happen frome time to time, mostly because
of messed up commandline arguments. This results in ugly crashes very
often. Lets control this a bit by catching the exception string and
print it.
Change-Id: I313017355da01bbef7c3d3f1899555aadb509319
This EF contains one or more records, with each record able
to hold a public SIP Identity (SIP URI) of the user. EF.IMPU consist of URI TLV data
object values see IETF RFC 3261. The URI shall be encoded to an octet string according
to UTF-8 encoding rules as specified in IETF RFC 3629
./pySim-prog.py -p 0 -x 001 -y 01 -s 8988211900000000004 -i 001011234567895 -k 8baf473f2f8fd09487cccbd7097c6862 --op 11111111111111111111111111111111 -o 8E27B6AF0E692E750F32667A3B14605D -a 85524953 -n isim.test --msisdn 0598765432100 --epdgid epdg.epc.mnc001.mcc001.pub.3gppnetwork.org --pcscf pcscf.ims.testop.org --ims-hdomain ims.testop.org --impi 1234567895@ims.testop.org --impu sip:5987654321@ims.testop.org
Change-Id: If10bc2e50eca390b81755b5cc7211e695233612d
This EF contains the private user identity of the user. EF.IMPI consist of
NAI TLV data object values see IETF RFC 2486. The NAI shall be encoded to
an octet string according to UTF-8 encoding rules as specified in IETF RFC 3629
./pySim-prog.py -p 0 -x 001 -y 01 -s 8988211900000000004 -i 001011234567895 -k 8baf473f2f8fd09487cccbd7097c6862 --op 11111111111111111111111111111111 -o 8E27B6AF0E692E750F32667A3B14605D -a 85524953 -n isim.test --msisdn 0598765432100 --epdgid epdg.epc.mnc001.mcc001.pub.3gppnetwork.org --pcscf pcscf.ims.testop.org --ims-hdomain ims.testop.org --impi 1234567895@ims.testop.org
Change-Id: Ic1ccf99b5aa45297ef1e43a43373df603f756379
As per 3GPP TS 31.103, this EF (DOMAIN) can found under ADF.ISIM at File Id 6f03.
The Home Network Domain Name, i.e. FQDN shall be encoded to an octet string
according to UTF-8 encoding rules as specified in IETF RFC 3629 [27].
The tag value of the Home Network Domain Name TLV data object shall be '80'.
Example:
./pySim-prog.py -p 0 -x 001 -y 01 -s 8988211900000000004 -i 001011234567895 -k 8baf473f2f8fd09487cccbd7097c6862 --op 11111111111111111111111111111111 -o 8E27B6AF0E692E750F32667A3B14605D -a 85524953 -n isim.test --msisdn 0598765432100 --epdgid epdg.epc.mnc001.mcc001.pub.3gppnetwork.org --pcscf pcscf.testims.org --ims-hdomain testims.org
Change-Id: I3c823203aee88734ae423e4ad73da1027a4eaeed
If the EF.ePDGSelection is present, it is populated with a single entry with PLMN 1 set
to Home PLMN of USIM, ePDG FQDN format set to Operator Identifier FQDN and ePDG Priority value
set to 1.
Change-Id: I92f3f813afa41ae497ebc0dc2ca73da810f82364
Example:
./pySim-prog.py -p 0 -x 001 -y 01 -s 8988211900000000004 -i 001011234567895 \
-k 8baf473f2f8fd09487cccbd7097c6862 --op 11111111111111111111111111111111 \
-o 8E27B6AF0E692E750F32667A3B14605D -a 85524953 -n isim.test \
--msisdn 0598765432100 --epdgid epdg.epc.mnc001.mcc001.pub.3gppnetwork.org
Note:
1. For Operator Identifier based ePDG FQDN must be in the format
epdg.epc.mnc<MNC>.mcc<MCC>.pub.3gppnetwork.org
2. For Tracking/Location Area Identity based ePDG FQDN must be in format
lac<LAC>.epdg.epc.mnc<MNC>.mcc<MCC>.pub.3gppnetwork.org
and
tac-lb<TAC-low-byte>.tac-hb<TAC-high-byte>.tac.epdg.epc.mnc<MNC>.mcc<MCC>.pub.3gppnetwork.org
and
3. For 5GS Tracking Area Identity based ePDG FQDN using a 3 octet TAC
tac-lb<TAC-low-byte>.tac-mb<TAC-middle-byte>.tac-hb<TAC-high-byte>.5gstac. epdg.epc.mnc<MNC>.mcc<MCC>.pub.3gppnetwork.org
Change-Id: Ia00bfea36c50b6a38a5387d2f8147f25c81b1de4
According to 3GPP TS 27.007, sections 8.17 and 8.18, the modem
may *optionally* provide Generic and/or Restricted SIM Access
to the TE (Terminal Equipment) by means of the AT commands.
This basically means that a modem can act as a card reader.
Generic SIM Access allows the TE to send raw PDUs in the format
as described in 3GPP TS 51.011 directly to the SIM card, while
Restricted SIM Access is more limited, and thus is not really
interesting to us.
This change implements a new transport called ModemATCommandLink,
so using it a SIM card can be read and/or programmed without the
need to remove it from the modem's socket. A downside of this
approach is relatively slow I/O speed compared to PC/SC readers.
Tested with Quectel EC20:
$ ./pySim-read.py --modem-dev /dev/ttyUSB2
Change-Id: I20bc00315e2c7c298f46283852865c1416047bc6
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
The lower part of gen_parameters() in pySim-prog.py contains some code
that checks whether the ADM pin supplied in its hexadecimal or in its
string form and generates a sanitised pin_adm from that. Lets separate
this part as it may become useful elsewhere too.
Change-Id: Ifead29724cc13a91de9e2e89314d7fb23c063d50
A MNC of 02 and 002 are *not* equal. The former is a two-digit MNC
and the latter is a three-digit MNC. Hence, we shouldn't treat
MNCs as integer values as we have no clue how many leading zeroes
(if any) the user entered.
Change-Id: I9d1d07a64888c76703c3e430bbdd822080c05819
Closes: OS#4523
pySim-prog and pySim-read currently echo back the pcsc reader id (or
baudrate/socket, depending on the interface used). This makes the output
unecessarly undeterministic, which becomes a problem when verifying the
putput in tests. Lets not echo those variable, user supplied parameters
back. Also lets move the code that does the initalization to utils, so
that it can be used from pySim-prog and from pySim-read (code dup).
Change-Id: I243cc332f075d007b1c111292effcc610e874eb3
Related: OS#4503
This function is used to detect the card type and return Card class/Card subclasses object
if its a know card or else None. Also, an initial step towards refactoring of code.
Change-Id: I71f57c6403dc933bd9d54f90df3d3fe105b4f66f
This change implements programming of EF.MSISDN as per 3GPP TS 31.102,
sections 4.2.26 and 4.4.2.3, excluding the following fields:
- Alpha Identifier (currently 'FF'O * 20),
- Capability/Configuration1 Record Identifier ('FF'O),
- Extension1 Record Identifier ('FF'O).
This feature is introduced exclusively for sysmoUSIM-SJS1.
Othere SIM card types need to be tested.
Change-Id: Ie033a0ffc3697ae562eaa7a241a0f6af6c2b0594
Without that fix we have:
$ python3 pySim-read.py
File "pySim-read.py", line 135
try:
^
TabError: inconsistent use of tabs and spaces in indentation
The following command was used to do the conversion:
sed 's# #\t#g' -i $(find -name "*.py")
Then the remaining spaces spotted during the review were
addressed manually.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Change-Id: I83f76a8e9b6e36098f16552a0135a8c22dde545f
In case the MCC/MNC are not supplied with a CSV file we cut out the
missing values from the IMSI string. Lets use a function to do this and
also check the input parameters.
Change-Id: I98e5bf8f9ff2a852efb190cc789edf42c5075bf8
At the moment MNC and MCC are represented as integer numbers inside the
parameter array while all other parameters are represented as strings.
Lets use strings for MNC/MCC as well to simplify the parameter handling.
We will also not loose the length information in case of leading zeros.
Change-Id: Ia2333921a4863f0f26ee923ca796e62ec5e2d59a
At the moment we do not chack if the CSV file exists at all. This may
lead into a crash while programming the card. Lets check the CSV file
before we start.
Change-Id: I2643996282d88e512c17901ab0e1181677d5dd6c
Related: SYS#4654
Inside of pySim all CSV headers are defined in lower case and are
evaluated case sensitive. This means that a CSV file that contains the
headers in uppercase for example will not parse. Lets make sure that the
CSV headers are evaluated case insensitive to increase compatibility
with slightly different formats.
Change-Id: I1a476e7fc521d1aad2956feec3db196156961d20
When the CSV file fails to read the error message is just "Error reading
parameters". Lets make clear that this error is related to a problem
with the CSV file
Change-Id: If285c1fbf7d285f512b573040f1b8983e4e3087e
When using the batch mode of pySim-prog, the user has to insert/remove
the cards from the cardreader manually. This is fine for small batches,
but for high volume batches this method is not applicable.
This patch adds support for the integration of an automatic card handler
machine. The user can freely configure a custom commandline that is
executed when a card should be inserted or moved to a good/bad
collection bin.
Change-Id: Icfed3cad7927b92816723d75603b78e1a4b87ef1
Related: SYS#4654
When reading CSV files we currently have no option to provide a
pin_adm_hex field like we already have it as commandline option.
Lets add an option pin_adm_hex for this.
Change-Id: I53e8d666d26a06f580725a8443a335643d10192c
This can be used to reprogram everything including IMSI on the card:
while true; do
./pySim-prog.py -p 0 -t sysmoUSIM-SJS1 --source=csv --read-csv=cards.csv --read-iccid &&
paplay complete.oga
sleep 2
done
Change-Id: Ib343a29141b5255f67a59ab76959b51e162b7916
pySim-prog would implicitly try to use the raw or hex-escaped format
depending on the length of the parameter, now there is the option "-A"
to explicitly specify the hex-escaped ADM1 key.
pysim-test.sh: Explicitly use the "-A" option to pass the hex adm1 key
for wavemobile cards
Change-Id: Id75a03482aa7f8cc3bdbb8d5967f1e8ab45c179a
This way we can have optional fields like pin_adm in the file
Also require iccid as identifier for the SIM card
Set defaults for optional card parameters.
Change-Id: I0d317ea51d0cf582b82157eec6cdec074001a236
The smsc no. programmed by pySim-prog would always be a national number
in the past. Check whether the first 'digit' is a + and indicate that it
is an international number.
Change-Id: Ia79913f5b0307e9786a5acea75c0811927be2eef
In some situations it may be helpful to know the card name (type)
we deal with in advance. So lets ad an to probe that only detects
the card and then exists.
- Add commandline option -T --probe
Change-Id: I57422d3819d52fd215ac8f13f890729aad2af76f
Related: OS#3376
with Change I38f5d36d16b41b5d516a6a3e2ec1d09637883932, new constants
for file identifiers were introduced. When csv file input is used,
then pySim-prog.py uses one of these constans without importing
it from ts_51_011.py
- Add missing import
Change-Id: Ic5b067b16ec204c2ba2264b1ffb48d37be8d5eb3
At the momemnt pysim takes the supplied ADM pin number and interprets
it as ascii string. This ascii string (max 8 digitis) is then padded
with 0xff bytes if necessary and sent to the card.
This limits the range of possible ADM keys and it is not possible
to deal with situataions where the ADM pin consists of arbitrary
bytes. At the momemnt pysim-prog forbis anything that is longer
than 8 digits. Lets also check if there are 16 digits and if yes
interpret them as raw bytes.
- when the adm pin is 16 digits long, interpret the string as raw
bytes (hex).
Change-Id: If0ac0d328c64b57bc4d45d985a4a516930053344
Related: SYS#4245
This reverts commit a51592e180, which
broke the use of ADM pins on sysmoUSIM-SJS1 (and possibly others?)
The ADM pins have so far always been specified as ASCII decimal digits,
i.e. something like "-a 53204025" gets translated to hex "3533323034303235"
After the above patch this is broken and gets instead translated to
"53204025ffffffff" in hex which obviously breaks. Let's revert back to
the old behavior to make it work again.
Change-Id: I3d68b7e09938a2fcb7a9a6a31048388cc3141f79