Commit Graph

99 Commits

Author SHA1 Message Date
Philipp Maier e82fed7520 sysmo_isim_sja2: add full TUAK support and unit-tests
we do not have full TUAK support yet. All we can do so far is to set the
algorithm to TUAK, but we can not set configuration parameters and keys.
This patch adds features to modify the TUAK configuration byte. The key
and the TOP/TOPc is modified using the existing key and OP/OPC
commandline otions.

This patch also addes tests to verify sysmo-isim-tool.sja5.py. This also
includes TUAK. The tests are not activated for automatic testing yet
since the test fixture does not yet have a sysmo-isim-sja5 installed.

Related: SYS#6473
2023-06-23 14:05:44 +02:00
Philipp Maier 6702e0e5e8 sysmo_isim_sja2: fix OP/OPc display for 4g5g
When the OP/OPc for 4g5g should be displayed, then actually 3g key is displayed,
which is wrong.

Related: SYS#6473
2023-06-23 13:54:58 +02:00
Philipp Maier de8db1c189 sysmo_isim_sja2: improve class model
In the current form we assume that the files that store the key material
and the related configuration parameters have the same layout for all
algorithms. This assumption makes sense since for the currently
supported algorithms (not TUAK) this is indeed true.

(With the exception that there may be RFU bits still set to 1, even
though the spec clearly state those bits should be 0. However, this does
not matter in practice)

With the advent of TUAK longer keys were introduced. This made a new file
layout necessary. Unfortunately this also means that we can not rely on
the coincidence described above. This means we have to be more specific
when reading and writing the files.

This patch adds classes to model the file layout for each algorithm.

We also print the key (and OP/OPc) for each location individually
(2g,3g,4g5g). Even though the programmed key should be the same in all
locations, this allows better diagnosis. Also with the advent of TUAK we
may have different key material in 4g5g location.

Related: SYS#6473
2023-06-23 12:36:43 +02:00
Philipp Maier b8c465a72d sysmo-isim-tool: allow selection of 4g5g auth algo individually
At the moment we set the algorithm type for 4g5g to the same algorithm
type we use for 3g. There is no way to select the algorithm type for
4g5g individually.

With the Advent of TUAK users might need to set the 4g5g algorithm to
TUAK and the Algorithm used for 3g to something else (e.g. Milenage). So
let's allow to select the algorithm for 4g5g individually, but only if
the user explicitly defines it.

Related: SYS#6473
2023-06-23 11:28:43 +02:00
Philipp Maier fb9d5f7591 sysmo_isim_sja2: convert #comments to python comments where possible
Related: SYS#6473
2023-06-23 10:07:43 +02:00
Philipp Maier a97d2a2858 sysmo_isim_sja2: rename classes SYSMO_ISIMSJA2_ to SYSMO_ISIMSJAX_
The classes that model the file layout are applicable on both card
models, so lets replace the 2 with an X
2023-06-23 10:07:26 +02:00
Philipp Maier 12ce2512be sysmo_isim_sja2: Add comments to explain sysmo_isimsjax_algorithms
Related: OS#6473
2023-06-23 09:56:29 +02:00
Philipp Maier 0a2aa28f4e sysmo_isim_sja2: define return types for __str__ and encode methods
Related: OS#6473
2023-06-23 09:56:16 +02:00
Philipp Maier e3d250b805 sysmo_isim_sja2: fix file naming in comment
Related: SYS#6473
2023-06-23 09:55:52 +02:00
Philipp Maier 93facf5eda sysmo_isim_sja2: update copyright header
Related: SYS#6473
2023-06-23 09:55:35 +02:00
Philipp Maier 359d8ef645 sysmo_isim_sja2: cosmetic: remove unnecessary new lines
Related: SYS#6473
2023-06-23 09:55:24 +02:00
Philipp Maier 86a6bb6ea5 tests: restore incorrect ADM PIN
The test data, which was submitted with the previous patch also
contained incorrect ADM PIN data, which was not intended. This patch
fixes this.

Related: SYS#6473
2023-06-22 21:53:32 +02:00
Philipp Maier 4e196ceaf4 cosmetic: rename Ki to Key
sysmo-isim-sja2 and sysmo-isim-sjs1 support multiple different
authentication algorithms. The commandline options and the log output
always speaks of "Ki", this is only correct when COMP128 is used. So
lets be more generic and call it "Key" rather then "Ki".

Related: OS#6473
2023-06-22 21:46:24 +02:00
Philipp Maier 7209731730 utils: allow to use a safe default with str_to_id
The input to str_to_id may originate from user input. It may be that the
input is not found in the given table. In this case an exception is
raised. This may be impractical in some cases. Let's add an optional
safe default that is returned in case the string is not found, this can
be used to either select default settings or to detect an error.

Related: SYS#6473
2023-06-22 21:39:04 +02:00
Philipp Maier 513de41913 tests: Fixup test results ("XOR-2G" bacame "COMP128v3")
in 82a785d27f we correct the algorithm
name string for COMP128v2 from XOR-2G to COMP128v2. Since the wrong
naming also appears in the test scripts and the related .out files, we
need to fix those locations as well.
2023-06-05 15:00:48 +02:00
Harald Welte ba5a5ce6e7 tests: Fixup test results ('3' is COMP128v3, not XOR-2G) 2023-05-26 17:29:42 +02:00
Harald Welte 5af5ace55d test: update copyright statement after recent change 2023-05-26 16:43:14 +02:00
Harald Welte 9c73667324 initial support for sysmoISIM-SJA5
We inherit 99% of sysmoISIM-SJA2, but expand the algorithm definitions
2023-05-26 16:13:04 +02:00
Harald Welte caa06046be sja2: fix cosmetic copy+paste and copyright statement errors 2023-05-26 16:13:04 +02:00
Harald Welte 379a0fe771 sja2: Avoid mixed tab/space indentation
This file is tab-indented, but had very few lines that were space
indented.  This is bad python style, let's convert everything to tab
for consistency.
2023-05-26 16:11:17 +02:00
Harald Welte 82a785d27f sysmo_isim_sja2.py: Fix COMP128v3 support (copy+paste mistake) 2023-05-26 16:08:26 +02:00
Philipp Maier 7c6777d127 common: also accept single digit values for mnclen
when using the --mnclen option it is easy to get confused with the
parameter. The parameter has to be a two digit hex value. To make things
easier lets convert a single digit hex value to two digit one
automatically.
2023-01-19 12:22:16 +01:00
Philipp Maier 1b44d0e651 sysmo_usim: fix log output
When programming EF.AD an additional new-line is printed, which is not
as intended. This also upsets the unit-tests.
2023-01-19 11:50:10 +01:00
Philipp Maier 6d205d3a1a sysmo_usim: fix log output
When programming EF.AD the log now shows "Programming ..." instead
of "Programming...", which upsets the unit-tests
2023-01-19 11:41:35 +01:00
Philipp Maier 2c57f2a476 sysmo_usim: program EF.AD in DF.GSM and ADF.USIM
Since september 2021 EF.AD no longer exists as a single file that is
represented as a link in DF.GSM and ADF.USIM it is necessary to program
both locations individually.
2023-01-19 11:31:16 +01:00
Philipp Maier da4af9d9fa common: fix commandline options
some of the long command line options that take an argument lack the =
sign at the end, which means they won't work properly, lets fix this.
2023-01-19 11:12:49 +01:00
canghaiwuhen 0e73184c17 python3 support 2022-04-13 10:50:58 +02:00
Harald Welte b456b1bb68 update README.md with sysmoISIM-SJA2 information 2021-05-15 22:10:28 +02:00
Philipp Maier ee5c2d77b4 tests/sja2: change card in test rig
The sysmo-usim-sja2 which is currently used for testing somewhat old. In
order to have a defined state here lets exchange it with a new card.
This will also ensure that we have a card with the most recent card
profile in the tester.
2021-04-21 11:59:35 +02:00
Philipp Maier a767cec4d0 card: re-add capability to find USIM cards by ATR
de31d9f88b removes the ability to select
USIM cards by specifiying their ATR. This feature is needed to
properly distinguish symo-usim-sjs1 and sysmo-isim-sja2 from other
cards.
2020-09-10 22:45:39 +02:00
Philipp Maier fd95de36de sysmo-isim-sja2: change tests to match current card profile
The current card profile uses a different ATR, and ADM pin.
2020-09-10 21:37:37 +02:00
Philipp Maier 0e7ad7616f experiments.py: remove unused code
The code in this file was used for experiments while implementing the
support for sysmo-isim-sja2, it is not needed anymore
2020-09-10 21:35:01 +02:00
Harald Welte de31d9f88b Sync 'card' library with upstream
This reflects 2a81963790e27eb6b188359af169c45afb6d3aaf of
https://github.com/mitshell/card.git
2020-08-31 14:36:42 +02:00
Harald Welte 76c74c93d5 Fix many python3 compatibility problems
It's 2020, and I'm actually rather shocked to find that this code
was not python3 compatbile a long time ago...
2020-08-31 14:22:27 +02:00
Philipp Maier 77d68b84b3 sysmo_isim_sja2: reset SQN configuration to the current profile
The profile of sysmo_isim_sja2 has changed the content of the SQN
confugrantion file. Lets update the .out files of the tests and the
default values inside the program as well.
2020-03-17 14:26:57 +01:00
Philipp Maier 00241b4423 sysmoUSIM-SJA2: detect installed applications (ISIM/USIM)
Depending on the card profile the sysmoUSIM-SJA2 may come with an USIM
application or with an USIM and an ISIM application installed. If the
ISIM application is not present the related application must not get
selected and the related files must not accessed. At the moment the
presence of the ISIM application is detected by checking the ATR,
however the ATR only identifies a certain OS version or type, not an
application. Lets look at the EF.DIR first and dtermine the presence of
the applications by looking for the related AID.

Related: SYS#4817
2020-03-17 11:13:52 +01:00
Philipp Maier 5e9c6d2062 sysmo_usim: add functionality to show AID of installed apps
Modern SIM cards may come with multiple applications installed (e.g. an
additional ISIM application along with a regular USIM application). In
some debug cases it may be helpful to be able to list those
applications. Lets add some functionality for that.

Related: SYS#4817
2020-03-17 11:08:32 +01:00
Philipp Maier 625bc9d3f3 sysmoUSIM-SJS1: enable USIM mode before testing
sysmoUSIM-SJS1 features enableing/disableing its USIM application to
switch beween classic SIM and USIM mode. If the usim mode gets disabled
by excidant the testsuite would fail. Lets make sure that USIM mode is
always enabled before the testsuite is executed.
2020-03-11 14:10:48 +01:00
Philipp Maier 633d158eff sysmoUSIM-SJA2: remove abandonned 0 byte test output files
The directory with the test scripts for the SJA2 simcards contains
0-byte .out files which are unused. Presumably those files were
excidantly added to the repository, lets remove them.
2020-03-11 13:21:49 +01:00
Philipp Maier 7dde66efb3 sysmo-isim-sja2: reset SQN parameters completele
The commandline option -S states that the SQN parameters are reset to
default. Actually only the SQN counters are reset. Lets also reset the
related configuration parameters as well.

Change-Id: Ia1f298a00b0c4f0399afd60fefb8b3c8f3a514ba
2020-02-18 15:30:18 +01:00
Philipp Maier 59c1f0eab2 prepare: also reset SQN parameters
The SQN parameters may be changed by previous tests. Lets reset them
before running the testsuite.

Change-Id: I3caa0983a9494d1e22c0a9beae346bc0d7130ed2
2020-02-18 15:30:09 +01:00
Philipp Maier f745baa551 prepare: remove ICCID from prepare script and from test-data
The ICCID is not programmable on sysmo-usim-sja2 cards. Lets remove the
related parameters and variables from the test script

Change-Id: Ib22098b94dd2b8526e74b6d8b1cd7b2162f6307a
2020-02-18 15:29:59 +01:00
Philipp Maier 80653e791a tests: Make sure tests do not return with 0 on failure
The run-tests script that runs the two testsuites for the two different
supported card models returns 0, even when the tests fail. This tricks
jenkins into thinking everything were ok. Lets make sure the script is
stopped immediately and returns with 1 when the tests fail.
2020-02-18 13:34:54 +01:00
Harald Welte 149da081c1 sysmo_isim_sja2: Add support for sysmoTSIM-SJA2 variant
sysmoTSIM is a 3GPP Test SIM as per TS 34.108. It doesn't have an ISIM
application, and hence we must only program the SIM + USIM part of it.
2020-02-09 16:52:43 +01:00
Philipp Maier 8dd52e04ac sja2: Add support for new simcard model
Adding support for the new SJA2 simcard type requires comprensive
refactoring of sysmo-usim-tool. We resolve the commonalities of
both simcard models in a class based approach so that code duplication
is reduced to a minium.

- Refactor sysmo-usim-tool into a class based model
- Add support for SJA2 simcard models
- Add tests for SJA2 simcard models

Change-Id: I0feab71bdaab079b35737bb4e0e2a417c4a1f96b
Related: SYS#4466
2020-01-06 11:09:21 +01:00
Philipp Maier 08623baa4a utils.py: generate multiline hexdumps
At the moment we can only print single line hexdumps. This works fine
for short data. However, if data becomes longer we should be able to
display it over multiple lines.

Related: SYS#4466
Change-Id: Id553df7c579bd648cb724fb1bbf906d9b50a357e
2020-01-03 15:12:14 +01:00
Philipp Maier 214e103407 sysmo_usimsjs1.py: do not print OP/OPc twice
The method that shows the OP/OPc prints the OP/OPc value twice. Lets
remove the redundant output

Change-Id: I0c890b977b3a9dc80b5c328b0c859f0bc9c7ef8b
2020-01-03 15:09:58 +01:00
Philipp Maier 925b20e927 utils.py: cosmetic: add missing new line
Change-Id: I69c335c5ac4fc209daa7fcd7e9f8d509eec289b4
2019-11-11 11:39:33 +01:00
Philipp Maier 9fa8e47b4c sysmo-usimsjs1.py: refactor functions into class
The module sysmo-usimsjs1.py contains a lot of functions that could also
be methods of a class. Lets refactor those functions into class. This is
also an intermediate step towords support for different card models in
the future.

Related: SYS#4466
Change-Id: I2230f50b9d3c85a0d23b29ba5ed0af2471d22e8c
2019-11-11 11:32:21 +01:00
Philipp Maier 594bdd8248 utils.py: cosmetic: add comment to int_to_list()
It may not be immediately obvious what int_to_list() does, lets add a
comment to clarify

elated: SYS#4466
Change-Id: I82639a7333c3d805f6242aa58a3d42800a804820
2019-11-11 11:32:10 +01:00