[PATCH] libosmocore[master]: milenage_test: cosmetic: verify AUTS in comments

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Mar 15 02:37:42 UTC 2017


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2051

to look at the new patch set (#3).

milenage_test: cosmetic: verify AUTS in comments

In a comment and by code #if'd away, illustrate that the AUTS used in the unit
test is accurate.

Related: OS#1968
Change-Id: Iefeaaf33570f8e40245fdf9b810390ec61cfc7e0
---
M tests/auth/milenage_test.c
1 file changed, 56 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/51/2051/3

diff --git a/tests/auth/milenage_test.c b/tests/auth/milenage_test.c
index 35d4889..abc4755 100644
--- a/tests/auth/milenage_test.c
+++ b/tests/auth/milenage_test.c
@@ -63,6 +63,15 @@
 	return rc;
 }
 
+#define RECALC_AUTS 0
+#if RECALC_AUTS
+typedef uint8_t u8;
+extern int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand,
+			  u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar);
+extern int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand,
+		       const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s);
+#endif
+
 int main(int argc, char **argv)
 {
 	struct osmo_auth_vector _vec;
@@ -92,6 +101,53 @@
 
 	dump_auth_vec(vec);
 
+	/* The USIM generates an AUTS to tell us it is at SQN == 31:
+	 *
+	 * SQN_MS = 00000000001f
+	 *
+	 * AUTS = Conc(SQN_MS) || MAC-S
+	 * Conc(SQN_MS) = SQN_MS ⊕ f5*[K](RAND)
+	 * MAC-S = f1*[K] (SQN MS || RAND || AMF)
+	 *
+	 *    K = 000102030405060708090a0b0c0d0e0f
+	 * RAND = 00000000000000000000000000000000
+	 *
+	 * f5*--> Conc(SQN_MS) = SQN_MS ^ f5*(K,RAND)
+	 *                     = 00000000001f ^ 8711a0ec9e09
+	 *                     = 8711a0ec9e16
+	 * AMF = 0000 (TS 33.102 v7.0.0, 6.3.3)
+	 * MAC-S = f1*[K] (SQN MS || RAND || AMF)
+	 *       = f1*[K] (00000000001f || 00000000000000000000000000000000 || 0000)
+	 *       = 37df17f80b384ee4
+	 *
+	 * AUTS = 8711a0ec9e16 || 37df17f80b384ee4
+	 */
+#if RECALC_AUTS
+	uint8_t ak[6];
+	uint8_t akstar[6];
+	uint8_t opc[16];
+	uint8_t k[16];
+	uint8_t rand[16];
+	osmo_hexparse("000102030405060708090a0b0c0d0e0f", k, sizeof(k));
+	osmo_hexparse("000102030405060708090a0b0c0d0e0f", opc, sizeof(opc));
+	osmo_hexparse("00000000000000000000000000000000", rand, sizeof(rand));
+	milenage_f2345(opc, k, rand, NULL, NULL, NULL, ak, akstar);
+	printf("ak = %s\n", osmo_hexdump_nospc(ak, sizeof(ak)));
+	printf("akstar = %s\n", osmo_hexdump_nospc(akstar, sizeof(akstar)));
+
+	uint8_t sqn_ms[6] = { 0, 0, 0, 0, 0, 31 };
+	uint8_t amf[2] = {};
+	uint8_t mac_s[8];
+	milenage_f1(opc, k, rand, sqn_ms, amf, NULL, mac_s);
+	printf("mac_s = %s\n", osmo_hexdump_nospc(mac_s, sizeof(mac_s)));
+	/* verify valid AUTS resulting in SQN 31 with:
+	   osmo-auc-gen -3 -a milenage -k 000102030405060708090a0b0c0d0e0f \
+	                -o 000102030405060708090a0b0c0d0e0f \
+	                -r 00000000000000000000000000000000 \
+	                -A 8711a0ec9e1637df17f80b384ee4
+	 */
+#endif
+
 	const uint8_t auts[14] = { 0x87, 0x11, 0xa0, 0xec, 0x9e, 0x16, 0x37, 0xdf,
 			     0x17, 0xf8, 0x0b, 0x38, 0x4e, 0xe4 };
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iefeaaf33570f8e40245fdf9b810390ec61cfc7e0
Gerrit-PatchSet: 3
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