[MERGED] osmo-hlr[master]: auc_3g_test: add AUTS test with N vectors, to show bug

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Feb 22 07:19:00 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: auc_3g_test: add AUTS test with N vectors, to show bug
......................................................................


auc_3g_test: add AUTS test with N vectors, to show bug

Add test that shows how passing AUTS to auc_compute_vectors performs an AUTS
sync on each vector and hence produces the same SQN each time. This will
generate one working vector as resync result, and then N-1 more with the wrong
SQN as far as the USIM is concerned. This causes a resync to be necessary on
every authentication.

Depends: libosmocore change-id If943731a78089f0aac3d55245de80596d01314a4
Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c
---
M tests/auc/auc_3g_test.c
M tests/auc/auc_3g_test.err
2 files changed, 198 insertions(+), 0 deletions(-)

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



diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c
index cb5e412..f8ff67a 100644
--- a/tests/auc/auc_3g_test.c
+++ b/tests/auc/auc_3g_test.c
@@ -239,11 +239,94 @@
 	comment_end();
 }
 
+void _test_gen_vectors_3g_only__expect_vecs__WRONG(struct osmo_auth_vector vecs[3])
+{
+	fprintf(stderr, "THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED\n");
+	fprintf(stderr, "The SQN should increment with each new vector.\n");
+	fprintf(stderr, "[0]: ");
+	VEC_IS(&vecs[0],
+	       "  rand: 897210a0f7de278f0b8213098e098a3f\n"
+	       "  autn: c6b9790dad4b00000cf322869ea6a481\n"
+	       "  ck: e9922bd036718ed9e40bd1d02c3b81a5\n"
+	       "  ik: f19c20ca863137f8892326d959ec5e01\n"
+	       "  res: 9af5a557902d2db80000000000000000\n"
+	       "  res_len: 08\n"
+	       "  kc: 7526fc13c5976685\n"
+	       "  sres: 0ad888ef\n"
+	       "  auth_types: 03000000\n"
+	      );
+	fprintf(stderr, "[1]: ");
+	VEC_IS(&vecs[1],
+	       "  rand: 9a8321b108ef38a01c93241a9f1a9b50\n"
+	       "  autn: 79a5113eb0900000f7e138537aa0962b\n"
+	       "  ck: 3686f05df057d1899c66ae4eb18cf941\n"
+	       "  ik: 79f21ed53bcb47787de57d136ff803a5\n"
+	       "  res: 43023475cb29292c0000000000000000\n"
+	       "  res_len: 08\n"
+	       "  kc: aef73dd515e86c15\n"
+	       "  sres: 882b1d59\n"
+	       "  auth_types: 03000000\n"
+	      );
+	fprintf(stderr, "[2]: ");
+	VEC_IS(&vecs[2],
+	       "  rand: ab9432c2190049b12da4352bb02bac61\n"
+	       "  autn: 24b018d46c390000d88e11730d0367ac\n"
+	       "  ck: d86c3191a36fc0602e48202ef2080964\n"
+	       "  ik: 648dab72016181406243420649e63dc9\n"
+	       "  res: 010cab11cc63a6e40000000000000000\n"
+	       "  res_len: 08\n"
+	       "  kc: f0eaf8cb19e0758d\n"
+	       "  sres: cd6f0df5\n"
+	       "  auth_types: 03000000\n"
+	      );
+}
+
+void _test_gen_vectors_3g_only__expect_vecs(struct osmo_auth_vector vecs[3])
+{
+	fprintf(stderr, "[0]: ");
+	VEC_IS(&vecs[0],
+	       "  rand: 897210a0f7de278f0b8213098e098a3f\n"
+	       "  autn: c6b9790dad4b00000cf322869ea6a481\n"
+	       "  ck: e9922bd036718ed9e40bd1d02c3b81a5\n"
+	       "  ik: f19c20ca863137f8892326d959ec5e01\n"
+	       "  res: 9af5a557902d2db80000000000000000\n"
+	       "  res_len: 08\n"
+	       "  kc: 7526fc13c5976685\n"
+	       "  sres: 0ad888ef\n"
+	       "  auth_types: 03000000\n"
+	      );
+	fprintf(stderr, "[1]: ");
+	VEC_IS(&vecs[1],
+	       "  rand: 9a8321b108ef38a01c93241a9f1a9b50\n"
+	       "  autn: 79a5113eb0910000be6020540503ffc5\n"
+	       "  ck: 3686f05df057d1899c66ae4eb18cf941\n"
+	       "  ik: 79f21ed53bcb47787de57d136ff803a5\n"
+	       "  res: 43023475cb29292c0000000000000000\n"
+	       "  res_len: 08\n"
+	       "  kc: aef73dd515e86c15\n"
+	       "  sres: 882b1d59\n"
+	       "  auth_types: 03000000\n"
+	      );
+	fprintf(stderr, "[2]: ");
+	VEC_IS(&vecs[2],
+	       "  rand: ab9432c2190049b12da4352bb02bac61\n"
+	       "  autn: 24b018d46c3b00009c7e1b47f3a19b2b\n"
+	       "  ck: d86c3191a36fc0602e48202ef2080964\n"
+	       "  ik: 648dab72016181406243420649e63dc9\n"
+	       "  res: 010cab11cc63a6e40000000000000000\n"
+	       "  res_len: 08\n"
+	       "  kc: f0eaf8cb19e0758d\n"
+	       "  sres: cd6f0df5\n"
+	       "  auth_types: 03000000\n"
+	      );
+}
+
 static void test_gen_vectors_3g_only(void)
 {
 	struct osmo_sub_auth_data aud2g;
 	struct osmo_sub_auth_data aud3g;
 	struct osmo_auth_vector vec;
+	struct osmo_auth_vector vecs[3];
 	uint8_t auts[14];
 	uint8_t rand_auts[16];
 	int rc;
@@ -379,6 +462,35 @@
 	       "  auth_types: 03000000\n"
 	      );
 
+
+	fprintf(stderr, "- verify N vectors with AUTS resync"
+		" == N vectors without AUTS\n"
+		"First just set rand and sqn = 24, and compute 3 vectors\n");
+	next_rand("897210a0f7de278f0b8213098e098a3f", false);
+	aud3g.u.umts.sqn = 24;
+	VERBOSE_ASSERT(aud3g.u.umts.sqn, == 24, "%"PRIu64);
+
+	memset(vecs, 0, sizeof(vecs));
+	rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, NULL, NULL);
+	VERBOSE_ASSERT(rc, == 3, "%d");
+	VERBOSE_ASSERT(aud3g.u.umts.sqn, == 27, "%"PRIu64);
+
+	_test_gen_vectors_3g_only__expect_vecs(vecs);
+
+	fprintf(stderr, "Now reach sqn = 24 with AUTS and expect the same\n");
+	/* AUTS response by USIM */
+	osmo_hexparse("979498b1f72d3e28c59fa2e72f9c",
+		      auts, sizeof(auts));
+	/* RAND sent to USIM, which AUTS was generated from */
+	osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d",
+		      rand_auts, sizeof(rand_auts));
+	next_rand("897210a0f7de278f0b8213098e098a3f", false);
+	rc = auc_compute_vectors(vecs, 3, &aud2g, &aud3g, rand_auts, auts);
+
+	/* THIS IS WRONG AND WILL BE FIXED IN A SUBSEQUENT COMMIT:
+	   should be _test_gen_vectors_3g_only__expect_vecs() instead */
+	_test_gen_vectors_3g_only__expect_vecs__WRONG(vecs);
+
 	comment_end();
 }
 
diff --git a/tests/auc/auc_3g_test.err b/tests/auc/auc_3g_test.err
index 5c3dd14..db076d7 100644
--- a/tests/auc/auc_3g_test.err
+++ b/tests/auc/auc_3g_test.err
@@ -119,6 +119,92 @@
   sres: 0ad888ef
   auth_types: 03000000
 
+- verify N vectors with AUTS resync == N vectors without AUTS
+First just set rand and sqn = 24, and compute 3 vectors
+aud3g.u.umts.sqn == 24
+DAUC rand 897210a0f7de278f0b8213098e098a3f
+DAUC compute vector [0]/3: 3G only
+DAUC rand 9a8321b108ef38a01c93241a9f1a9b50
+DAUC compute vector [1]/3: 3G only
+DAUC rand ab9432c2190049b12da4352bb02bac61
+DAUC compute vector [2]/3: 3G only
+rc == 3
+aud3g.u.umts.sqn == 27
+[0]: auth vector ==
+  rand: 897210a0f7de278f0b8213098e098a3f
+  autn: c6b9790dad4b00000cf322869ea6a481
+  ck: e9922bd036718ed9e40bd1d02c3b81a5
+  ik: f19c20ca863137f8892326d959ec5e01
+  res: 9af5a557902d2db80000000000000000
+  res_len: 08
+  kc: 7526fc13c5976685
+  sres: 0ad888ef
+  auth_types: 03000000
+
+[1]: auth vector ==
+  rand: 9a8321b108ef38a01c93241a9f1a9b50
+  autn: 79a5113eb0910000be6020540503ffc5
+  ck: 3686f05df057d1899c66ae4eb18cf941
+  ik: 79f21ed53bcb47787de57d136ff803a5
+  res: 43023475cb29292c0000000000000000
+  res_len: 08
+  kc: aef73dd515e86c15
+  sres: 882b1d59
+  auth_types: 03000000
+
+[2]: auth vector ==
+  rand: ab9432c2190049b12da4352bb02bac61
+  autn: 24b018d46c3b00009c7e1b47f3a19b2b
+  ck: d86c3191a36fc0602e48202ef2080964
+  ik: 648dab72016181406243420649e63dc9
+  res: 010cab11cc63a6e40000000000000000
+  res_len: 08
+  kc: f0eaf8cb19e0758d
+  sres: cd6f0df5
+  auth_types: 03000000
+
+Now reach sqn = 24 with AUTS and expect the same
+DAUC rand 897210a0f7de278f0b8213098e098a3f
+DAUC compute vector [0]/3: 3G only
+DAUC rand 9a8321b108ef38a01c93241a9f1a9b50
+DAUC compute vector [1]/3: 3G only
+DAUC rand ab9432c2190049b12da4352bb02bac61
+DAUC compute vector [2]/3: 3G only
+THERE IS A BUG AND THE TEST PASSES THE WRONG VECTORS UNTIL THAT IS FIXED
+The SQN should increment with each new vector.
+[0]: auth vector ==
+  rand: 897210a0f7de278f0b8213098e098a3f
+  autn: c6b9790dad4b00000cf322869ea6a481
+  ck: e9922bd036718ed9e40bd1d02c3b81a5
+  ik: f19c20ca863137f8892326d959ec5e01
+  res: 9af5a557902d2db80000000000000000
+  res_len: 08
+  kc: 7526fc13c5976685
+  sres: 0ad888ef
+  auth_types: 03000000
+
+[1]: auth vector ==
+  rand: 9a8321b108ef38a01c93241a9f1a9b50
+  autn: 79a5113eb0900000f7e138537aa0962b
+  ck: 3686f05df057d1899c66ae4eb18cf941
+  ik: 79f21ed53bcb47787de57d136ff803a5
+  res: 43023475cb29292c0000000000000000
+  res_len: 08
+  kc: aef73dd515e86c15
+  sres: 882b1d59
+  auth_types: 03000000
+
+[2]: auth vector ==
+  rand: ab9432c2190049b12da4352bb02bac61
+  autn: 24b018d46c390000d88e11730d0367ac
+  ck: d86c3191a36fc0602e48202ef2080964
+  ik: 648dab72016181406243420649e63dc9
+  res: 010cab11cc63a6e40000000000000000
+  res_len: 08
+  kc: f0eaf8cb19e0758d
+  sres: cd6f0df5
+  auth_types: 03000000
+
 ===== test_gen_vectors_3g_only: SUCCESS
 
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I246c9edfb009b593f834bb5b0577b65bfde7083c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-hlr
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