[MERGED] libosmocore[master]: umts aka: add sqn_ms out-param, print SQN.MS in osmo-auc-gen

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Aug 29 12:46:49 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: umts aka: add sqn_ms out-param, print SQN.MS in osmo-auc-gen
......................................................................


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
---
M include/osmocom/crypt/auth.h
M src/gsm/auth_milenage.c
M tests/osmo-auc-gen/osmo-auc-gen_test.ok
M utils/osmo-auc-gen.c
4 files changed, 14 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h
index 059e734..6d2c783 100644
--- a/include/osmocom/crypt/auth.h
+++ b/include/osmocom/crypt/auth.h
@@ -39,6 +39,7 @@
 			int opc_is_op;	/*!< is the OPC field OPC (0) or OP (1) ? */
 			unsigned int ind_bitlen; /*!< nr of bits not in SEQ, only SQN */
 			unsigned int ind; /*!< which IND slot to use an SQN from */
+			uint64_t sqn_ms; /*!< sqn from AUTS (output value only) */
 		} umts;
 		struct {
 			uint8_t ki[16];	/*!< secret key */
diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c
index 6dd4f45..e1a1dfb 100644
--- a/src/gsm/auth_milenage.c
+++ b/src/gsm/auth_milenage.c
@@ -158,9 +158,10 @@
 	if (rc < 0)
 		return rc;
 
+	aud->u.umts.sqn_ms = osmo_load64be_ext(sqn_out, 6) >> 16;
 	/* Update our "largest used SQN" from the USIM -- milenage_gen_vec()
 	 * below will increment SQN. */
-	aud->u.umts.sqn = osmo_load64be_ext(sqn_out, 6) >> 16;
+	aud->u.umts.sqn = aud->u.umts.sqn_ms;
 
 	return milenage_gen_vec(vec, aud, _rand);
 }
diff --git a/tests/osmo-auc-gen/osmo-auc-gen_test.ok b/tests/osmo-auc-gen/osmo-auc-gen_test.ok
index 82923f1..2840783 100644
--- a/tests/osmo-auc-gen/osmo-auc-gen_test.ok
+++ b/tests/osmo-auc-gen/osmo-auc-gen_test.ok
@@ -103,6 +103,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	32
 IND:	0
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 5
@@ -118,6 +119,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	37
 IND:	5
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 23
@@ -133,6 +135,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	55
 IND:	23
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 31
@@ -148,6 +151,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	63
 IND:	31
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 0
@@ -163,6 +167,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	24
 IND:	0
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 1
@@ -178,6 +183,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	24
 IND:	0
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 1 --ind 1
@@ -193,6 +199,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	25
 IND:	1
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 8
@@ -208,6 +215,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	256
 IND:	0
+SQN.MS:	23
 
 
 > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 8 --ind 1
@@ -223,6 +231,7 @@
 Kc:	059a4f668f6fbe39
 SQN:	257
 IND:	1
+SQN.MS:	23
 
 
 expecting error:
diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c
index d4ae1b9..fee9767 100644
--- a/utils/osmo-auc-gen.c
+++ b/utils/osmo-auc-gen.c
@@ -317,6 +317,8 @@
 		if (test_aud.type == OSMO_AUTH_TYPE_UMTS) {
 			printf("SQN:\t%" PRIu64 "\n", test_aud.u.umts.sqn);
 			printf("IND:\t%u\n", (unsigned int)(test_aud.u.umts.sqn & ind_mask));
+			if (auts_is_set)
+				printf("SQN.MS:\t%" PRIu64 "\n", test_aud.u.umts.sqn_ms);
 		}
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/3704
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9fc05bbf169d06716f40b995154fd42a3f91bef3
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list