Commit Graph

11 Commits

Author SHA1 Message Date
Harald Welte d8e5309527 libosmogsm: Allow auth API caller to specify RES length
There are 3G algorithms which support different lengths of RES values
(4, 8, 16 byte).  For MILENAGE, we never really had to bother, as
the 4-byte RES is simply the first 4 bytes of the 8-byte RES.

However, for TUAK, the expected RES length is an input parameter to
the Keccak crypto functions, so the result of all parameters (including
CK, IK, ...) will be completely different for RES length 4 than RES
length 8.

So let's permit the caller of the osmocom auth API to specify the
requested RES length via the osmo_auth_vector.res_len parameter.

For backwards compatibility of callers of the old osmo_auth_gen_vec/
osmo_auth_gen_vec_auts API: Always force the res_len to 8 in this case,
which was the hard-coded length before this patch.

Change-Id: Ic662843fbe8b5c58e4af39ea630ad5ac13fd6bef
2023-06-02 08:29:55 +00:00
Harald Welte 53b4bbb955 osmo-auc-gen: Print RFC3310 IMS HTTP-AKA style base64 nonce/res
This is useful when debugging IMS Authentication which uses
RFC3310 representation of the nonce and expected result.

Change-Id: Ibfa72410d8ff8e5b42063f1a12bff69ad2bebbb8
2021-09-21 19:57:56 +00:00
Neels Hofmeyr 2066a42d5a umts aka: add sqn_ms out-param, print SQN.MS in osmo-auc-gen
When doing UMTS AKA with AUTS, it can be interesting to know the SQN.MS that
was encoded in the AUTS. The only way to know this is to provide it as a
separate out-parameter from milenage_gen_vec_auts(), because the SQN.MS from
AUTS stored in umts.sqn is immediately modified non-trivially by
milenage_gen_vec(). Add sqn_ms to struct osmo_sub_auth_data to retain SQN.MS
even after a vector was generated.

Use this to print out SQN.MS for 'osmo-auc-gen -3 -A'.

Adjust test suite expectations.

Related: OS#2464
Change-Id: I9fc05bbf169d06716f40b995154fd42a3f91bef3
2017-08-29 12:46:46 +00:00
Neels Hofmeyr e6e6446edf osmo-auc-gen: umts: print out the IND of the SQN used
Make ind_mask available in the main(){} scope, in order to print out
IND = SQN & ind_mask.

Adjust test suite expectations.

Related: OS#2465
Change-Id: I91eac53c4af66a58b9372d9baf5781fc9f29b1fc
2017-08-29 12:46:46 +00:00
Neels Hofmeyr b1af6ef164 osmo-auc-gen: umts: add --ind-len arg
osmo-auc-gen so far does not allow indicating the IND bit length of SQN. A
default of 5 serves most practical cases, nevertheless we should allow passing
arbitrary IND lengths.

Enhance the test suite to test --ind-len.

Related: OS#2465
Change-Id: Ia1d8b6a823ffc92290b3e39e4e4665aeff80ccc0
2017-08-29 12:46:45 +00:00
Neels Hofmeyr 3cb08277f1 osmo-auc-gen: umts: add --ind arg
During UMTS AKA, the caller typically indicates which IND slot the next used
SQN should belong to. Without this option, osmo-auc-gen will always produce SQN
from IND-slot 0. Add --ind option.

Enhance the osmo-auc-gen_test.sh to expect errors with useful printouts on
stderr, and add tests that verify valid --ind ranges.

Related: OS#2465
Change-Id: Ib60eec80d58ca9a0a01e7fbd2bcbbd4339b1a6d8
2017-08-29 12:46:45 +00:00
Neels Hofmeyr 4315e01f5a osmo-auc-gen: umts: use default of ind_bitlen = 5 instead of 0
Most USIM out there seem to use IND-length = 5 bits, so do sysmousim-sjs1.
Currently from initialization we are using an IND length of zero in
osmo-auc-gen, which produces confusing SQN results after AUTS:

Where want SQN to be incremented to the next IND array, usually +32, an IND-len
of 0 makes for only +1.

As result, the osmo-auc-gen_test.sh produces SQN 32 instead of 24 after
receiving SQN.MS = 23 from AUTS: adjust test expectations.

Related: OS#2465
Change-Id: I9fcc11fa2b5816302dcc6b72249b1ee40d5a61f5
2017-08-29 12:46:45 +00:00
Neels Hofmeyr 516910754e osmo-auc-gen: umts: remove erratic SQN.MS printout
osmo-auc-gen tries to be helpful by deriving the SQN.MS from the SQN that
resulted from AUTS + milenage_gen_vec(), but there is actually no way to derive
the actual AUTS SQN.MS from the resulting SQN.

Completely drop the printout to prevent confusion.

Adjust test suite expectations.

Related: OS#2464
Change-Id: Ie2432c6d6a23818f7b3a29b1295dcbb505e2be53
2017-08-29 12:46:44 +00:00
Neels Hofmeyr 9ca7d3e400 cosmetic: test for osmo-auc-gen: print error for missing binary
Change-Id: I98c23ae6378a16cf3b76c90d4ea0dfcf61ff3033
2017-08-29 12:46:44 +00:00
Neels Hofmeyr 5fe3d1b0f7 osmo-auc-gen: clarify SQN output, prepare for SQN changes
Upcoming patches will change the way SQN are incremented. Change the SQN
related output by osmo-auc-gen so that it also makes sense after these changes,
and so that its output is proven to remain unchanged for the same arguments:

Always show the SQN used for vector generation when a UMTS vector was generated.

Don't show the next SQN, it will not make sense anymore (see later patches).

The adjustments of expected output of osmo-auc-gen_test illustrates how the
output changes.

Related: OS#1968
Change-Id: I35d9c669002ff3e8570e07b444cca34ce57c3b0c
2017-03-15 12:46:08 +00:00
Neels Hofmeyr d3b58730d5 add osmo-auc-gen_test
Add test for osmo-auc-gen invocations to ensure stability across upcoming SQN
increment scheme changes.

The test comprises of a shell script that invokes the osmo-auc-gen binary with
various milenage parameters, of which the stdout/stderr are verified.

More osmo-auc-gen invocations could be added, but my main focus is on the SEQ
changes. Instead of manually testing that it still works for each SQN patch, I
want this test to do it for me.

To make sure that osmo-auc-gen is build before the tests are launched, place
'utils' before 'tests' in the root Makefile.am.

Related: OS#1968
Change-Id: Ib4af34201cd2e7d76037bcd31dd89ef18c1a9aec
2017-03-15 12:46:08 +00:00