Commit Graph

34 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 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 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 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
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 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 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 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 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
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 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 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 b15d23459b tests: add a script to regenerate .out files for tests
Currently all the .out files need to be regenerated by hand. Lets add a
script for this to make things easier
2019-11-07 11:57:15 +01:00
Philipp Maier 83760e2c22 Support programming of the MNC length value (EF.AD)
The file EF.AD contains the length of the MNC, this allows to phone to
distinguish where MCC/MNC end and where the MSIN number of the IMSI
begins. All cards are shipped with an MNC length of 2, which is fine for
the most situations, but when a MNC with 3 digits is needed the MNC
length value has to be updated. Otherwise the phone will recognize the
third digit of the MNC as part of the MSIN.

Related: OS#3850
2019-03-21 17:05:42 +01:00
Philipp Maier 3bd5054d56 sysmo_usimsjs1: use correct parameter for 3G auth
when programming the 3G authentication (EF_AUTH), the parameter for 2G
is used.

- make sure that parameter algo_3g_str is used to select the 3g
  authentication algorithem, do not use algo_2g_str here.

Change-Id: I6aaf49062f6faf36455dc48639dc58f3da8e804d
2018-10-24 17:37:24 +02:00
Philipp Maier 48c0993312 tests/test-data: Update ADM1 key
Updated the test-data to the ADM1 key of the test card we currently have
in use. Developers must change this ADM1 key to match theur own
testcards.

Change-Id: I68e7a739fa093d255006bf427c0a332610935800
Related: OS#3376
2018-08-08 12:30:13 +02:00
Philipp Maier 75342b86d1 tests/run-tests: Prepare test card before executing the tests
All tests need a physical card to be inserted in a reader. This card may
have a different IMSI and/or ICCID id set than the one that is expected
by the tests. Since sysmo-usim-tool.sjs1.py unconditionally displays
IMSI and ICCID we find those parameters in every .out file.

In order to run the unit-tests without changing the .out files very often
or having to manually prepare a test card we should write the expected
IMSI and ICCID before each testsuite is executed.

- Add a script to the testsuite that prepares the testcard, run this
  script from run-tests before the actual tests are executed.

Change-Id: I470f4f7d5facab277b6e78252bac7cc4d1fbc6bb
Related: OS#3376
2018-08-08 12:30:13 +02:00
Philipp Maier 12f0d25693 tests/08_seq: Test resetting of SEQ/SQN
the resetting of the SEQ/SQN parameters is currently not tested, we
currently only read out the parameters. Lets test resetting as well.

Change-Id: Ie3e386a79f69cd5e35782f593c3a30e1d2b50afb
Related: OS#3376
2018-08-08 12:30:13 +02:00
Philipp Maier 050231d86c tests/05_milenage_par: Extend unit test
At the moment we only read the milenage parameters but we do not write
them. Lets extend the unit test so that we test writing as well.

Change-Id: I81dd27b3e65510db931188171093f0e909cde16f
Related: OS#3376
2018-08-08 12:30:13 +02:00
Philipp Maier 6868ea7c26 tests/08_seq: Update .out file
The log output for writing the SQN parameters has changed. Update the
.out file accordingly

Change-Id: I58e7c44d3ff0a1c4fea7b8edaa4ca7326a4fd88a
Related: OS#3376
2018-08-08 12:29:50 +02:00
Philipp Maier 01d60a1f03 tests/04_algo: Update .out file
The output for the Algo setting has changed. Update the .out file
accordingly.

Change-Id: Ia9d175e0a8dbd02fd518f1735e42aa56296ea24d
Related: OS#3376
2018-08-08 12:29:26 +02:00
Philipp Maier 8c31a63f31 tests/run-tests: Replace == by -eq when comparing rc
The use of == with test seems to cause problems when comparing the
return code in line 20. Lets use -eq instead.

Change-Id: I92905770f3a96a632a51858952a82180303d6c05
Related: OS#3376
2018-08-08 12:28:22 +02:00
Philipp Maier 0868212cc8 tests/04_algo.sh: Fix string concatenation.
The concatenation

ALGOS=+"MILENAGE:...

seems to cause problems. Lets replace it with:

ALGOS=$ALGOS"MILENAGE:...

Change-Id: I8d946c47502305be77595cd45a64708d03441dd5
Related OS#3376
2018-08-08 12:28:22 +02:00
Harald Welte 5c15b238f5 Divide SQNms Offset by 6
The SQNms offset is a *byte* index into the SQNA file, let's divide
this by 6 before showing it to the user, so he can immediately
make the connection into the SQN array dumped below
2017-08-17 14:38:07 +02:00
Harald Welte 9b3c122329 Fix decoding of SQN values in SYSMO_USIMSJS1_FILE_EF_SQNC 2017-08-17 13:15:39 +02:00
Harald Welte 5140557f3b Add testsuite
The idea of the testsuite is to test all functions of the utility
against one known SIM card that is inserted at the time the test
is executed.

We could insert this card into a reader attached to a
permanently-running machine and then use that as a jenkins build
test slave.
2017-08-16 23:16:17 +02:00